rust-lang / rust

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

ICE: `None` in `rustc_hir_typeck` due to malformed attribute #124352

Open matthiaskrgr opened 4 months ago

matthiaskrgr commented 4 months ago

auto-reduced (treereduce-rust):

#![rustc_never_type_options(: Unsize<U> = "hi")]

fn main() {}

original:

//
// issue: rust-lang/rust#120600

#![allow(internal_features)]
#![feature("{}", <Foo as T>::Assoc::cake())]
#![rustc_never_type_options(: Unsize<U> = "hi")]

fn ice(a: !) {
    2_usize + (loop {});
}

fn main() {}

Version information

rustc 1.79.0-nightly (7bb4f0889 2024-04-24)
binary: rustc
commit-hash: 7bb4f0889e8b133c5b03c46f31f2ae6432c00219
commit-date: 2024-04-24
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4

Command: /home/matthias/.rustup/toolchains/master/bin/rustc

Program output

``` error: expected unsuffixed literal or identifier, found `:` --> /tmp/icemaker_global_tempdir.EufKbBnTYnxL/rustc_testrunner_tmpdir_reporting.QmhD5w5eupoC/mvce.rs:3:29 | 3 | #![rustc_never_type_options(: Unsize = "hi")] | ^ error[E0658]: `rustc_never_type_options` is used to experiment with never type fallback and work on never type stabilization, and will never be stable --> /tmp/icemaker_global_tempdir.EufKbBnTYnxL/rustc_testrunner_tmpdir_reporting.QmhD5w5eupoC/mvce.rs:3:1 | 3 | #![rustc_never_type_options(: Unsize = "hi")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable = note: this compiler was built on 2024-04-24; consider upgrading it if it is out of date thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs:395:43: called `Option::unwrap()` on a `None` value stack backtrace: 0: 0x70c3e25da145 - std::backtrace_rs::backtrace::libunwind::trace::h86d426b17d4e2e3d at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x70c3e25da145 - std::backtrace_rs::backtrace::trace_unsynchronized::h8c0ef1d148b9d940 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x70c3e25da145 - std::sys_common::backtrace::_print_fmt::he2abce7aa62cdc3a at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:68:5 3: 0x70c3e25da145 - ::fmt::h0c9241533158777f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:44:22 4: 0x70c3e262921b - core::fmt::rt::Argument::fmt::h733dbde17a4a7d04 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/fmt/rt.rs:165:63 5: 0x70c3e262921b - core::fmt::write::h03896a7fdcd4b82f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/fmt/mod.rs:1157:21 6: 0x70c3e25ced4f - std::io::Write::write_fmt::hd74e7c0305df2660 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/io/mod.rs:1832:15 7: 0x70c3e25d9f1e - std::sys_common::backtrace::_print::hea8c9c28ab87b1b7 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:47:5 8: 0x70c3e25d9f1e - std::sys_common::backtrace::print::hd4bb5623fa4b8de6 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:34:9 9: 0x70c3e25dc889 - std::panicking::default_hook::{{closure}}::h4623b55631f16943 10: 0x70c3e25dc5cd - std::panicking::default_hook::he5d3fa1d7e671103 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:298:9 11: 0x70c3dee456ab - std[73cef507c0358b10]::panicking::update_hook::>::{closure#0} 12: 0x70c3e25dcf86 - as core::ops::function::Fn>::call::h8ef97572a456b9c7 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2036:9 13: 0x70c3e25dcf86 - std::panicking::rust_panic_with_hook::h1e2384e63ce90283 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:799:13 14: 0x70c3e25dccfb - std::panicking::begin_panic_handler::{{closure}}::h8399fde27d16fbcc at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:656:13 15: 0x70c3e25da609 - std::sys_common::backtrace::__rust_end_short_backtrace::hbc2e58d3e2bbc56f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:171:18 16: 0x70c3e25dca67 - rust_begin_unwind at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:652:5 17: 0x70c3e26256e3 - core::panicking::panic_fmt::h1b24b925c3ff40f0 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/panicking.rs:72:14 18: 0x70c3e262578c - core::panicking::panic::hc98b4908cef81389 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/panicking.rs:146:5 19: 0x70c3e2625469 - core::option::unwrap_failed::h547512c5c65004d9 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/option.rs:1984:5 20: 0x70c3e0528691 - ::new 21: 0x70c3e05290ef - rustc_hir_typeck[3cef36dd3b13bfec]::typeck 22: 0x70c3e0528dbd - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::> 23: 0x70c3e05e8531 - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false> 24: 0x70c3e05e725c - rustc_query_impl[e8a6f5b0469e51af]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 25: 0x70c3e05e6e94 - ::par_body_owners::::{closure#0} 26: 0x70c3e05e5b8d - rustc_hir_analysis[4525919e9da128a7]::check_crate 27: 0x70c3e05ef507 - rustc_interface[b73225351c325ab5]::passes::analysis 28: 0x70c3e05ef055 - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::> 29: 0x70c3e0fbe665 - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false> 30: 0x70c3e0fbe3c9 - rustc_query_impl[e8a6f5b0469e51af]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 31: 0x70c3e0e45993 - rustc_interface[b73225351c325ab5]::interface::run_compiler::, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1} 32: 0x70c3e0e2f8e7 - std[73cef507c0358b10]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>> 33: 0x70c3e0e2f6aa - <::spawn_unchecked_, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#2} as core[dad89120088e7e02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 34: 0x70c3e25e6e1b - as core::ops::function::FnOnce>::call_once::h3679caeb60ab03c2 at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2022:9 35: 0x70c3e25e6e1b - as core::ops::function::FnOnce>::call_once::h7e27b57c37e0ef1f at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2022:9 36: 0x70c3e25e6e1b - std::sys::pal::unix::thread::Thread::new::thread_start::he8797429d1c20e6e at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys/pal/unix/thread.rs:108:17 37: 0x70c3e238555a - 38: 0x70c3e2402a3c - 39: 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.79.0-nightly (7bb4f0889 2024-04-24) running on x86_64-unknown-linux-gnu query stack during panic: #0 [typeck] type-checking `main` #1 [analysis] running analysis passes on this crate end of query stack error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. ```

@rustbot label +F-"{}" +F-::Assoc::cake

rustbot commented 4 months ago

Error: Parsing relabel command in comment failed: ...' label +F-' | error: quote in word at >| '"{}" +F-<F'...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

matthiaskrgr commented 4 months ago

this bisects to #122843 fyi @WaffleLapkin :waffle:

fmease commented 4 months ago

At the risk of you removing a requires-*-features again (:P) I've added https://github.com/rust-lang/rust/labels/requires-internal-features, not throwing shade.

fmease commented 4 months ago

We really ought to push the idea of exiting fatally when encountering experimental and internal features that were not enabled as @compiler-errors has suggested.

fmease commented 4 months ago

I understand your POV: If it ICEs on stable or nightly without any #![feature(...)] or -Zcrate-attr=feature(...) physically present, it's buggy.

fmease commented 4 months ago

Imma open an issue / PR / MCP for that.