Skip to content

Commit

Permalink
Auto merge of #110107 - cjgillot:const-prop-lint-junk, r=oli-obk
Browse files Browse the repository at this point in the history
Ensure mir_drops_elaborated_and_const_checked when requiring codegen.

mir_drops_elaborated_and_const_checked may emit errors while codegen has started, and the compiler would exit leaving object code files around.

Found by `@cuviper` in rust-lang/rust#109731
  • Loading branch information
bors committed Apr 21, 2023
2 parents 5ba1b78 + 9746b51 commit 707e6d7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 6 additions & 0 deletions tests/fail/const-ub-checks.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ error[E0080]: evaluation of constant value failed
LL | ptr.read();
| ^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required

note: erroneous constant used
--> $DIR/const-ub-checks.rs:LL:CC
|
LL | let _x = UNALIGNED_READ;
| ^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
14 changes: 14 additions & 0 deletions tests/fail/erroneous_const2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ error[E0080]: evaluation of constant value failed
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow

note: erroneous constant used
--> $DIR/erroneous_const2.rs:LL:CC
|
LL | println!("{}", FOO);
| ^^^

note: erroneous constant used
--> $DIR/erroneous_const2.rs:LL:CC
|
LL | println!("{}", FOO);
| ^^^
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
6 changes: 0 additions & 6 deletions tests/pass/track-alloc-1.rs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/pass/track-alloc-1.stderr

This file was deleted.

0 comments on commit 707e6d7

Please sign in to comment.