Skip to content

ICE: parse: builtin attribute "stable" not handled by CheckAttrVisitor #137590

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct S(#[stable::skip] u8, u16, u32);

original:

//@ check-pass

struct S(
    #[stable::skip] u8,
    u16,
    #[tokyo::main] u32,
);

fn main() { println!("{} landed on hir feet" , self . name); }

Version information

rustc 1.87.0-nightly (f5729cfed 2025-02-25)
binary: rustc
commit-hash: f5729cfed3c45e061e8a443677fc1d5ef9277df7
commit-date: 2025-02-25
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {}
Some(_) => {
// FIXME: differentiate between unstable and internal attributes just
// like we do with features instead of just accepting `rustc_`
// attributes by name. That should allow trimming the above list, too.
if !name.as_str().starts_with("rustc_") {
span_bug!(
attr.span(),
"builtin attribute {name:?} not handled by `CheckAttrVisitor`"
)
}
}
None => (),

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

Program output

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `stable`
 --> /tmp/icemaker_global_tempdir.Pu0CoxkwO27L/rustc_testrunner_tmpdir_reporting.RPLa6XCrNAt2/mvce.rs:1:12
  |
1 | struct S(#[stable::skip] u8, u16, u32);
  |            ^^^^^^ use of unresolved module or unlinked crate `stable`

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.Pu0CoxkwO27L/rustc_testrunner_tmpdir_reporting.RPLa6XCrNAt2/mvce.rs:1:40
  |
1 | struct S(#[stable::skip] u8, u16, u32);
  |                                        ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Pu0CoxkwO27L/rustc_testrunner_tmpdir_reporting.RPLa6XCrNAt2/mvce.rs`

error: internal compiler error: compiler/rustc_passes/src/check_attr.rs:301:41: builtin attribute "stable" not handled by `CheckAttrVisitor`
 --> /tmp/icemaker_global_tempdir.Pu0CoxkwO27L/rustc_testrunner_tmpdir_reporting.RPLa6XCrNAt2/mvce.rs:1:10
  |
1 | struct S(#[stable::skip] u8, u16, u32);
  |          ^^^^^^^^^^^^^^^


thread 'rustc' panicked at compiler/rustc_passes/src/check_attr.rs:301:41:
Box<dyn Any>
stack backtrace:
   0:     0x7751857b0f34 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hca18af6381e1367c
   1:     0x77518601622c - core::fmt::write::h5592619a5f30a24e
   2:     0x7751870dcbd1 - std::io::Write::write_fmt::hc543125416d93a55
   3:     0x7751857b0d92 - std::sys::backtrace::BacktraceLock::print::h2507b83f5fdb3698
   4:     0x7751857b359e - std::panicking::default_hook::{{closure}}::h25029c6d53322486
   5:     0x7751857b3174 - std::panicking::default_hook::hded85171c110cc3b
   6:     0x77518491a827 - std[581eff941795a880]::panicking::update_hook::<alloc[44b1b4d4d47dda6c]::boxed::Box<rustc_driver_impl[dcc8af57e0e84081]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7751857b3e13 - std::panicking::rust_panic_with_hook::hbe0a3b6f34c80380
   8:     0x775184956cd1 - std[581eff941795a880]::panicking::begin_panic::<rustc_errors[c0f9bdb3918293e2]::ExplicitBug>::{closure#0}
   9:     0x77518494b0e6 - std[581eff941795a880]::sys::backtrace::__rust_end_short_backtrace::<std[581eff941795a880]::panicking::begin_panic<rustc_errors[c0f9bdb3918293e2]::ExplicitBug>::{closure#0}, !>
  10:     0x77518494b0cb - std[581eff941795a880]::panicking::begin_panic::<rustc_errors[c0f9bdb3918293e2]::ExplicitBug>
  11:     0x7751849606c1 - <rustc_errors[c0f9bdb3918293e2]::diagnostic::BugAbort as rustc_errors[c0f9bdb3918293e2]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x775184ea5f4c - <rustc_errors[c0f9bdb3918293e2]::DiagCtxtHandle>::span_bug::<rustc_span[159dd1552b739661]::span_encoding::Span, alloc[44b1b4d4d47dda6c]::string::String>
  13:     0x775184f27e1a - rustc_middle[e6f8bc74c8fc856c]::util::bug::opt_span_bug_fmt::<rustc_span[159dd1552b739661]::span_encoding::Span>::{closure#0}
  14:     0x775184f113aa - rustc_middle[e6f8bc74c8fc856c]::ty::context::tls::with_opt::<rustc_middle[e6f8bc74c8fc856c]::util::bug::opt_span_bug_fmt<rustc_span[159dd1552b739661]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x775184f1121b - rustc_middle[e6f8bc74c8fc856c]::ty::context::tls::with_context_opt::<rustc_middle[e6f8bc74c8fc856c]::ty::context::tls::with_opt<rustc_middle[e6f8bc74c8fc856c]::util::bug::opt_span_bug_fmt<rustc_span[159dd1552b739661]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x77518373ac07 - rustc_middle[e6f8bc74c8fc856c]::util::bug::span_bug_fmt::<rustc_span[159dd1552b739661]::span_encoding::Span>
  17:     0x7751863f8f9d - <rustc_passes[6ccbb36aefae929c]::check_attr::CheckAttrVisitor>::check_attributes
  18:     0x7751863f5d74 - <rustc_passes[6ccbb36aefae929c]::check_attr::CheckAttrVisitor as rustc_hir[2b60df8069066663]::intravisit::Visitor>::visit_item
  19:     0x77518640ba41 - rustc_passes[6ccbb36aefae929c]::check_attr::check_mod_attrs
  20:     0x77518640b9cb - rustc_query_impl[c32460660d187a22]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c32460660d187a22]::query_impl::check_mod_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e6f8bc74c8fc856c]::query::erase::Erased<[u8; 0usize]>>
  21:     0x7751870743c1 - rustc_query_system[e93ee9904dcaa7d1]::query::plumbing::try_execute_query::<rustc_query_impl[c32460660d187a22]::DynamicConfig<rustc_query_system[e93ee9904dcaa7d1]::query::caches::DefaultCache<rustc_span[159dd1552b739661]::def_id::LocalModDefId, rustc_middle[e6f8bc74c8fc856c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c32460660d187a22]::plumbing::QueryCtxt, false>
  22:     0x7751870740bf - rustc_query_impl[c32460660d187a22]::query_impl::check_mod_attrs::get_query_non_incr::__rust_end_short_backtrace
  23:     0x775187073c5c - <rustc_middle[e6f8bc74c8fc856c]::ty::context::TyCtxt>::par_hir_for_each_module::<rustc_interface[5317c0be442ff202]::passes::run_required_analyses::{closure#0}::{closure#0}::{closure#1}::{closure#0}>::{closure#0}
  24:     0x7751863b4f56 - rustc_interface[5317c0be442ff202]::passes::run_required_analyses
  25:     0x77518707633a - rustc_interface[5317c0be442ff202]::passes::analysis
  26:     0x775187076319 - rustc_query_impl[c32460660d187a22]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c32460660d187a22]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e6f8bc74c8fc856c]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7751870d5e8b - rustc_query_system[e93ee9904dcaa7d1]::query::plumbing::try_execute_query::<rustc_query_impl[c32460660d187a22]::DynamicConfig<rustc_query_system[e93ee9904dcaa7d1]::query::caches::SingleCache<rustc_middle[e6f8bc74c8fc856c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c32460660d187a22]::plumbing::QueryCtxt, false>
  28:     0x7751870d5b79 - rustc_query_impl[c32460660d187a22]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x77518715903c - rustc_interface[5317c0be442ff202]::passes::create_and_enter_global_ctxt::<core[f5b0be8ed3a1b4e]::option::Option<rustc_interface[5317c0be442ff202]::queries::Linker>, rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  30:     0x7751870e7ee0 - rustc_interface[5317c0be442ff202]::interface::run_compiler::<(), rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}>::{closure#1}
  31:     0x775186fa1ac8 - std[581eff941795a880]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5317c0be442ff202]::util::run_in_thread_with_globals<rustc_interface[5317c0be442ff202]::util::run_in_thread_pool_with_globals<rustc_interface[5317c0be442ff202]::interface::run_compiler<(), rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x775186fa2274 - <<std[581eff941795a880]::thread::Builder>::spawn_unchecked_<rustc_interface[5317c0be442ff202]::util::run_in_thread_with_globals<rustc_interface[5317c0be442ff202]::util::run_in_thread_pool_with_globals<rustc_interface[5317c0be442ff202]::interface::run_compiler<(), rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f5b0be8ed3a1b4e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x775186fa376f - std::sys::pal::unix::thread::Thread::new::thread_start::h717201ab54b439ec
  34:     0x7751810a370a - <unknown>
  35:     0x775181127aac - <unknown>
  36:                0x0 - <unknown>

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.87.0-nightly (f5729cfed 2025-02-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0433, E0601.
For more information about an error, try `rustc --explain E0433`.

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions