Skip to content

Commit 707e6d7

Browse files
committed
Auto merge of #110107 - cjgillot:const-prop-lint-junk, r=oli-obk
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
2 parents 5ba1b78 + 9746b51 commit 707e6d7

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

tests/fail/const-ub-checks.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error[E0080]: evaluation of constant value failed
44
LL | ptr.read();
55
| ^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
66

7+
note: erroneous constant used
8+
--> $DIR/const-ub-checks.rs:LL:CC
9+
|
10+
LL | let _x = UNALIGNED_READ;
11+
| ^^^^^^^^^^^^^^
12+
713
error: aborting due to previous error
814

915
For more information about this error, try `rustc --explain E0080`.

tests/fail/erroneous_const2.stderr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ error[E0080]: evaluation of constant value failed
44
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
55
| ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow
66

7+
note: erroneous constant used
8+
--> $DIR/erroneous_const2.rs:LL:CC
9+
|
10+
LL | println!("{}", FOO);
11+
| ^^^
12+
13+
note: erroneous constant used
14+
--> $DIR/erroneous_const2.rs:LL:CC
15+
|
16+
LL | println!("{}", FOO);
17+
| ^^^
18+
|
19+
= 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)
20+
721
error: aborting due to previous error
822

923
For more information about this error, try `rustc --explain E0080`.

tests/pass/track-alloc-1.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/pass/track-alloc-1.stderr

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)