rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.42k stars 12.73k forks source link

ICE: `assertion failed: matches!(diagnostic.level, Error | Warning | Allow)` #126751

Open matthiaskrgr opened 4 months ago

matthiaskrgr commented 4 months ago

code:

#![feature(lint_reasons)]
macro_rules! foo {
    ($val:ident) => {
        (5_i32.overflowing_sub(3));
    };
}

fn main() {
    #[expect(semicolon_in_expressions_from_macros)]
    let _ = foo!(x);
}

Version information

rustc 1.81.0-nightly (1ca578e68 2024-06-20)
binary: rustc
commit-hash: 1ca578e68eb715e772fc0c1b9e6ca7c5b122765a
commit-date: 2024-06-20
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command: /home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(lint_reasons)

Program output

``` thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:1462:13: assertion failed: matches!(diagnostic.level, Error | Warning | Allow) stack backtrace: 0: 0x74a1ae426915 - std::backtrace_rs::backtrace::libunwind::trace::h796e75e96c439f3e at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x74a1ae426915 - std::backtrace_rs::backtrace::trace_unsynchronized::h57b5b13bb46e11ba at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x74a1ae426915 - std::sys::backtrace::_print_fmt::h11ce45f986076e87 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:68:5 3: 0x74a1ae426915 - ::fmt::hcd09ba6a4fc236f1 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:44:22 4: 0x74a1ae4774bb - core::fmt::rt::Argument::fmt::h914f09f4a1c58d59 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/fmt/rt.rs:165:63 5: 0x74a1ae4774bb - core::fmt::write::hc590b91d463e6a2c at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/fmt/mod.rs:1168:21 6: 0x74a1ae41b5af - std::io::Write::write_fmt::hc69b1d0ded026622 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/io/mod.rs:1835:15 7: 0x74a1ae4266ee - std::sys::backtrace::_print::hc852e4497da27a95 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:47:5 8: 0x74a1ae4266ee - std::sys::backtrace::print::hc624de700d5fe576 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:34:9 9: 0x74a1ae429129 - std::panicking::default_hook::{{closure}}::hf8d8481f1d9702fb 10: 0x74a1ae428ecc - std::panicking::default_hook::he469b58de751f8ee at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:292:9 11: 0x74a1aab47870 - std[eca1b30e63fdea7a]::panicking::update_hook::>::{closure#0} 12: 0x74a1ae429a4f - as core::ops::function::Fn>::call::h7fb9108d23a6d563 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/alloc/src/boxed.rs:2076:9 13: 0x74a1ae429a4f - std::panicking::rust_panic_with_hook::h738066c73a52890f at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:804:13 14: 0x74a1ae429643 - std::panicking::begin_panic_handler::{{closure}}::h8534a2aac695431b at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:663:13 15: 0x74a1ae426dd9 - std::sys::backtrace::__rust_end_short_backtrace::h3420ee35d28bf807 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:171:18 16: 0x74a1ae429304 - rust_begin_unwind at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:661:5 17: 0x74a1ae473a73 - core::panicking::panic_fmt::h51cb44e3a97167f8 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/panicking.rs:74:14 18: 0x74a1ae473afc - core::panicking::panic::h01e4b12779f48d55 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/panicking.rs:148:5 19: 0x74a1acd3c4e9 - ::emit_diagnostic 20: 0x74a1aab8f43b - ::update_unstable_expectation_id 21: 0x74a1ab001df2 - rustc_lint[d375b8f4745d3144]::levels::lint_expectations 22: 0x74a1ab4cbf6e - rustc_query_impl[da2d3b64247f93f0]::plumbing::__rust_begin_short_backtrace::> 23: 0x74a1ace329d2 - rustc_query_system[5e65d9b3abdd3162]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[da2d3b64247f93f0]::plumbing::QueryCtxt, false> 24: 0x74a1ab4cfe06 - rustc_query_impl[da2d3b64247f93f0]::query_impl::lint_expectations::get_query_non_incr::__rust_end_short_backtrace 25: 0x74a1ad0c3598 - rustc_lint[d375b8f4745d3144]::expect::check_expectations 26: 0x74a1ad0c353b - rustc_query_impl[da2d3b64247f93f0]::plumbing::__rust_begin_short_backtrace::> 27: 0x74a1ad0c309a - rustc_query_system[5e65d9b3abdd3162]::query::plumbing::try_execute_query::, rustc_middle[a7abdaade2c6424c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[da2d3b64247f93f0]::plumbing::QueryCtxt, false> 28: 0x74a1ad0c2e25 - rustc_query_impl[da2d3b64247f93f0]::query_impl::check_expectations::get_query_non_incr::__rust_end_short_backtrace 29: 0x74a1ac7f5818 - rustc_interface[7fb7dc76513cf959]::passes::analysis 30: 0x74a1ac7f4ac7 - rustc_query_impl[da2d3b64247f93f0]::plumbing::__rust_begin_short_backtrace::> 31: 0x74a1ace33ea5 - rustc_query_system[5e65d9b3abdd3162]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[da2d3b64247f93f0]::plumbing::QueryCtxt, false> 32: 0x74a1ace33c0f - rustc_query_impl[da2d3b64247f93f0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 33: 0x74a1accdd252 - rustc_interface[7fb7dc76513cf959]::interface::run_compiler::, rustc_driver_impl[93e75e0175b92285]::run_compiler::{closure#0}>::{closure#1} 34: 0x74a1acc9dac9 - std[eca1b30e63fdea7a]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[93e75e0175b92285]::run_compiler::{closure#0}>::{closure#1}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>> 35: 0x74a1acc9d880 - <::spawn_unchecked_, rustc_driver_impl[93e75e0175b92285]::run_compiler::{closure#0}>::{closure#1}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#2} as core[daaba097f859fa28]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 36: 0x74a1ae4338cb - as core::ops::function::FnOnce>::call_once::ha1ad2417ff4e2c89 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/alloc/src/boxed.rs:2062:9 37: 0x74a1ae4338cb - as core::ops::function::FnOnce>::call_once::ha5ab2243447620ef at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/alloc/src/boxed.rs:2062:9 38: 0x74a1ae4338cb - std::sys::pal::unix::thread::Thread::new::thread_start::he00df2d38aeed7a5 at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/pal/unix/thread.rs:108:17 39: 0x74a1a76a6ded - 40: 0x74a1a772a0dc - 41: 0x0 - error: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: please make sure that you have updated to the latest nightly note: rustc 1.81.0-nightly (1ca578e68 2024-06-20) running on x86_64-unknown-linux-gnu note: compiler flags: -Z crate-attr=feature(lint_reasons) -Z dump-mir-dir=dir query stack during panic: #0 [lint_expectations] computing `#[expect]`ed lints in this crate #1 [check_expectations] checking lint expectations (RFC 2383) end of query stack ```

@rustbot label +F-lint_reasons

compiler-errors commented 4 months ago

fixed by https://github.com/rust-lang/rust/pull/126719?

matthiaskrgr commented 4 months ago

no?

compiler-errors commented 4 months ago

actually probably broken by #126719 cc @nnethercote

nnethercote commented 4 months ago

actually probably broken by #126719 cc @nnethercote

Not broken by #126719. Like #126521, #120699 is the regressing PR.

Has the fuzzer been updated recently to use more expected lints with future breakage? That would be my guess as to why these two crashes appeared close to each other.

matthiaskrgr commented 4 months ago

I've been using several batches of flags like all lints, mir optimisations, debuginfo, etc since mostly forever, however, I also automatically reduce to try to find a minimal set of required RUSTFLAGS for each ICE. The first ice did not require any special flags but this one did which is why it showed up in my reports again, but now with the flag ^^'

nnethercote commented 1 month ago

This is no longer crashing. I'm not sure which PR fixed it.