Open matthiaskrgr opened 1 month ago
```
warning: denote infinite loops with `loop { ... }`
--> /tmp/icemaker_global_tempdir.aFoZ42mi4yBx/rustc_testrunner_tmpdir_reporting.rWKlJmu4GRYT/mvce.rs:2:5
|
2 | while true {}
| ^^^^^^^^^^ help: use `loop`
|
= note: `#[warn(while_true)]` on by default
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.aFoZ42mi4yBx/rustc_testrunner_tmpdir_reporting.rWKlJmu4GRYT/mvce.rs:5:2
|
5 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.aFoZ42mi4yBx/rustc_testrunner_tmpdir_reporting.rWKlJmu4GRYT/mvce.rs`
thread 'rustc' panicked at compiler/rustc_mir_transform/src/jump_threading.rs:741:9:
assertion `left == right` failed
left: 2
right: 1
stack backtrace:
0: 0x7f56c56fd921 - std::backtrace_rs::backtrace::libunwind::trace::h639a5cad6c57f7ee
at /home/gh-matthiaskrgr/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
1: 0x7f56c56fd921 - std::backtrace_rs::backtrace::trace_unsynchronized::hf8c45b3224ec87e3
at /home/gh-matthiaskrgr/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f56c56fd921 - std::sys::backtrace::_print_fmt::h387df6ff1b4891d7
at /home/gh-matthiaskrgr/vcs/github/rust_debug_assertions/library/std/src/sys/backtrace.rs:66:9
3: 0x7f56c56fd921 -
The MIR pre-opt is:
fn check_multiple_lints_3(_1: bool) -> () {
debug terminate => _1;
let mut _0: ();
bb0: {
goto -> bb1;
}
bb1: {
goto -> bb1;
}
bb2: {
switchInt(copy _1) -> [0: bb2, otherwise: bb3];
}
bb3: {
return;
}
}
In apply_once
, the debug assertion fails because op.chain
contains [bb2, bb2]
This doesn't reproduce if loop {}
is used instead as the unreachable second loop is removed from the MIR
auto-reduced (treereduce-rust):
original code
original: ````rust //@ check-pass #![warn(unused)] // This expect attribute should catch all lint triggers #[expect(unused_variables)] fn check_multiple_lints_1() { let value_i = 0xff00ff; let value_ii = 0xff00ff; let value_iii = 0xff00ff; let value_iiii = 0xff00ff; let value_iiiii = 0xff00ff; } // This expect attribute should catch all lint triggers #[expect(unused_mut)] fn check_multiple_lints_2() { let mut a = 0xa; let mut b = 0xb; let mut c = 0xc; println!( unused_mut, //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations] //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default //~| NOTE this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered reason = "this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered" ); } // This expect attribute should catch all lint triggers #[warn( unused_mut, //~^ NOTE the lint level is defined here reason = "this overrides the previous `expect` lint level and warns about the `unused_mut` lint here" )] fn check_multiple_lints_3(terminate: bool) { // `while_true` is an early lint while true {} while true {} while true { println!("I never stop") } while !terminate { println!("Do you know what a spin lock is?") } while true {} } fn main() { check_multiple_lints_1(); check_multiple_lints_2(); check_multiple_lints_3(); } ````
Version information
Command:
/home/gh-matthiaskrgr/.rustup/toolchains/local-debug-assertions/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir