Change:
<!-- [31mICE[0m: Rustc '' 'error: internal compiler error: builtin attribute "shouldpanic" not handled by ', 'error: internal compiler error: builtin attribute "shouldpanic" not handled by ' File: --auto-reduced (treereduce-rust): original: Version information ` Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details<!-- query stack: [checkmodattrs] checking attributes in top-level module [analysis] running analysis passes on this crate --
there are a bunch more which probably all follow the pattern... 2 "errorreason": "error: internal compiler error: builtin attribute "allow" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "cfgattr" not handled by ", 4 "errorreason": "error: internal compiler error: builtin attribute "cfg" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "cmsenonsecureentry" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "collapsedebuginfo" not handled by ", 6 "errorreason": "error: internal compiler error: builtin attribute "deny" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "doc" not handled by ", 4 "errorreason": "error: internal compiler error: builtin attribute "inline" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "macroexport" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "optimize" not handled by ", 4 "errorreason": "error: internal compiler error: builtin attribute "procmacroderive" not handled by ", 14 "errorreason": "error: internal compiler error: builtin attribute "procmacro" not handled by ", 2 "errorreason": "error: internal compiler error: builtin attribute "shouldpanic" not handled by ",
cc
Taking a look
Problem is the previous match falls through to the fallback case for etc. because it has 1 segments ... and then since et al. is a attribute, it triggers the ICE.
I have a candidate fix locally, doing some more testing
Opened as a candidate fix.

Discussion:
let attrs = self.tcx.hir().attrs(hir_id); for attr in attrs { match attr.path().as_slice() { <del> [sym::diagnostic, sym::do_not_recommend] => { </del> <ins> [sym::diagnostic, sym::do_not_recommend, ..] => { </ins> self.check_do_not_recommend(attr.span, hir_id, target) } <del> [sym::diagnostic, sym::on_unimplemented] => { </del> <ins> [sym::diagnostic, sym::on_unimplemented, ..] => { </ins> self.check_diagnostic_on_unimplemented(attr.span, hir_id, target) } <del> [sym::inline] => self.check_inline(hir_id, attr, span, target), [sym::coverage] => self.check_coverage(attr, span, target), [sym::optimize] => self.check_optimize(hir_id, attr, target), [sym::non_exhaustive] => self.check_non_exhaustive(hir_id, attr, span, target), [sym::marker] => self.check_marker(hir_id, attr, span, target), [sym::target_feature] => { </del> <ins> [sym::inline, ..] => self.check_inline(hir_id, attr, span, target), [sym::coverage, ..] => self.check_coverage(attr, span, target), [sym::optimize, ..] => self.check_optimize(hir_id, attr, target), [sym::non_exhaustive, ..] => self.check_non_exhaustive(hir_id, attr, span, target), [sym::marker, ..] => self.check_marker(hir_id, attr, span, target), [sym::target_feature, ..] => { </ins> self.check_target_feature(hir_id, attr, span, target, attrs) } <del> [sym::thread_local] => self.check_thread_local(attr, span, target), [sym::track_caller] => { </del> <ins> [sym::thread_local, ..] => self.check_thread_local(attr, span, target), [sym::track_caller, ..] => { </ins> self.check_track_caller(hir_id, attr.span, attrs, span, target) } <del> [sym::doc] => self.check_doc_attrs( </del> <ins> [sym::doc, ..] => self.check_doc_attrs( </ins> attr, hir_id, target, &mut specified_inline, &mut doc_aliases, ), <del> [sym::no_link] => self.check_no_link(hir_id, attr, span, target), [sym::export_name] => self.check_export_name(hir_id, attr, span, target), [sym::rustc_layout_scalar_valid_range_start] | [sym::rustc_layout_scalar_valid_range_end] => { </del> <ins> [sym::no_link, ..] => self.check_no_link(hir_id, attr, span, target), [sym::export_name, ..] => self.check_export_name(hir_id, attr, span, target), [sym::rustc_layout_scalar_valid_range_start, ..] | [sym::rustc_layout_scalar_valid_range_end, ..] => { </ins> self.check_rustc_layout_scalar_valid_range(attr, span, target) } <del> [sym::allow_internal_unstable] => { </del> <ins> [sym::allow_internal_unstable, ..] => { </ins> self.check_allow_internal_unstable(hir_id, attr, span, target, attrs) } <del> [sym::debugger_visualizer] => self.check_debugger_visualizer(attr, target), [sym::rustc_allow_const_fn_unstable] => { </del> <ins> [sym::debugger_visualizer, ..] => self.check_debugger_visualizer(attr, target), [sym::rustc_allow_const_fn_unstable, ..] => { </ins> self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target) } <del> [sym::rustc_std_internal_symbol] => { </del> <ins> [sym::rustc_std_internal_symbol, ..] => { </ins> self.check_rustc_std_internal_symbol(attr, span, target) } <del> [sym::naked] => self.check_naked(hir_id, attr, span, target, attrs), [sym::rustc_never_returns_null_ptr] => { </del> <ins> [sym::naked, ..] => self.check_naked(hir_id, attr, span, target, attrs), [sym::rustc_never_returns_null_ptr, ..] => { </ins> self.check_applied_to_fn_or_method(hir_id, attr, span, target) } <del> [sym::rustc_legacy_const_generics] => { </del> <ins> [sym::rustc_legacy_const_generics, ..] => { </ins> self.check_rustc_legacy_const_generics(hir_id, attr, span, target, item) } <del> [sym::rustc_lint_query_instability] => { </del> <ins> [sym::rustc_lint_query_instability, ..] => { </ins> self.check_rustc_lint_query_instability(hir_id, attr, span, target) } <del> [sym::rustc_lint_diagnostics] => { </del> <ins> [sym::rustc_lint_diagnostics, ..] => { </ins> self.check_rustc_lint_diagnostics(hir_id, attr, span, target) } <del> [sym::rustc_lint_opt_ty] => self.check_rustc_lint_opt_ty(attr, span, target), [sym::rustc_lint_opt_deny_field_access] => { </del> <ins> [sym::rustc_lint_opt_ty, ..] => self.check_rustc_lint_opt_ty(attr, span, target), [sym::rustc_lint_opt_deny_field_access, ..] => { </ins> self.check_rustc_lint_opt_deny_field_access(attr, span, target) } <del> [sym::rustc_clean] | [sym::rustc_dirty] | [sym::rustc_if_this_changed] | [sym::rustc_then_this_would_need] => self.check_rustc_dirty_clean(attr), [sym::rustc_coinductive] | [sym::rustc_must_implement_one_of] | [sym::rustc_deny_explicit_impl] | [sym::const_trait] => self.check_must_be_applied_to_trait(attr, span, target), [sym::cmse_nonsecure_entry] => { </del> <ins> [sym::rustc_clean, ..] | [sym::rustc_dirty, ..] | [sym::rustc_if_this_changed, ..] | [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr), [sym::rustc_coinductive, ..] | [sym::rustc_must_implement_one_of, ..] | [sym::rustc_deny_explicit_impl, ..] | [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr, span, target), [sym::cmse_nonsecure_entry, ..] => { </ins> self.check_cmse_nonsecure_entry(hir_id, attr, span, target) } <del> [sym::collapse_debuginfo] => self.check_collapse_debuginfo(attr, span, target), [sym::must_not_suspend] => self.check_must_not_suspend(attr, span, target), [sym::must_use] => self.check_must_use(hir_id, attr, target), [sym::rustc_pass_by_value] => self.check_pass_by_value(attr, span, target), [sym::rustc_allow_incoherent_impl] => { </del> <ins> [sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target), [sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target), [sym::must_use, ..] => self.check_must_use(hir_id, attr, target), [sym::rustc_pass_by_value, ..] => self.check_pass_by_value(attr, span, target), [sym::rustc_allow_incoherent_impl, ..] => { </ins> self.check_allow_incoherent_impl(attr, span, target) } <del> [sym::rustc_has_incoherent_inherent_impls] => { </del> <ins> [sym::rustc_has_incoherent_inherent_impls, ..] => { </ins> self.check_has_incoherent_inherent_impls(attr, span, target) } <del> [sym::ffi_pure] => self.check_ffi_pure(attr.span, attrs, target), [sym::ffi_const] => self.check_ffi_const(attr.span, target), [sym::rustc_const_unstable] | [sym::rustc_const_stable] | [sym::unstable] | [sym::stable] | [sym::rustc_allowed_through_unstable_modules] | [sym::rustc_promotable] => self.check_stability_promotable(attr, target), [sym::link_ordinal] => self.check_link_ordinal(attr, span, target), [sym::rustc_confusables] => self.check_confusables(attr, target), [sym::rustc_safe_intrinsic] => { </del> <ins> [sym::ffi_pure, ..] => self.check_ffi_pure(attr.span, attrs, target), [sym::ffi_const, ..] => self.check_ffi_const(attr.span, target), [sym::rustc_const_unstable, ..] | [sym::rustc_const_stable, ..] | [sym::unstable, ..] | [sym::stable, ..] | [sym::rustc_allowed_through_unstable_modules, ..] | [sym::rustc_promotable, ..] => self.check_stability_promotable(attr, target), [sym::link_ordinal, ..] => self.check_link_ordinal(attr, span, target), [sym::rustc_confusables, ..] => self.check_confusables(attr, target), [sym::rustc_safe_intrinsic, ..] => { </ins> self.check_rustc_safe_intrinsic(hir_id, attr, span, target) } <del> [sym::cold] => self.check_cold(hir_id, attr, span, target), [sym::link] => self.check_link(hir_id, attr, span, target), [sym::link_name] => self.check_link_name(hir_id, attr, span, target), [sym::link_section] => self.check_link_section(hir_id, attr, span, target), [sym::no_mangle] => self.check_no_mangle(hir_id, attr, span, target), [sym::deprecated] => self.check_deprecated(hir_id, attr, span, target), [sym::macro_use] | [sym::macro_escape] => { </del> <ins> [sym::cold, ..] => self.check_cold(hir_id, attr, span, target), [sym::link, ..] => self.check_link(hir_id, attr, span, target), [sym::link_name, ..] => self.check_link_name(hir_id, attr, span, target), [sym::link_section, ..] => self.check_link_section(hir_id, attr, span, target), [sym::no_mangle, ..] => self.check_no_mangle(hir_id, attr, span, target), [sym::deprecated, ..] => self.check_deprecated(hir_id, attr, span, target), [sym::macro_use, ..] | [sym::macro_escape, ..] => { </ins> self.check_macro_use(hir_id, attr, target) } <del> [sym::path] => self.check_generic_attr(hir_id, attr, target, Target::Mod), [sym::macro_export] => self.check_macro_export(hir_id, attr, target), [sym::ignore] | [sym::should_panic] => { </del> <ins> [sym::path, ..] => self.check_generic_attr(hir_id, attr, target, Target::Mod), [sym::macro_export, ..] => self.check_macro_export(hir_id, attr, target), [sym::ignore, ..] | [sym::should_panic, ..] => { </ins> self.check_generic_attr(hir_id, attr, target, Target::Fn) } <del> [sym::automatically_derived] => { </del> <ins> [sym::automatically_derived, ..] => { </ins> self.check_generic_attr(hir_id, attr, target, Target::Impl) } <del> [sym::no_implicit_prelude] => { </del> <ins> [sym::no_implicit_prelude, ..] => { </ins> self.check_generic_attr(hir_id, attr, target, Target::Mod) } <del> [sym::rustc_object_lifetime_default] => self.check_object_lifetime_default(hir_id), [sym::proc_macro] => { </del> <ins> [sym::rustc_object_lifetime_default, ..] => self.check_object_lifetime_default(hir_id), [sym::proc_macro, ..] => { </ins> self.check_proc_macro(hir_id, target, ProcMacroKind::FunctionLike) } <del> [sym::proc_macro_attribute] => { </del> <ins> [sym::proc_macro_attribute, ..] => { </ins> self.check_proc_macro(hir_id, target, ProcMacroKind::Attribute); } <del> [sym::proc_macro_derive] => { </del> <ins> [sym::proc_macro_derive, ..] => { </ins> self.check_generic_attr(hir_id, attr, target, Target::Fn); self.check_proc_macro(hir_id, target, ProcMacroKind::Derive) } <del> [sym::coroutine] => { </del> <ins> [sym::coroutine, ..] => { </ins> self.check_coroutine(attr, target); } [

| sym::default_lib_allocator | sym::start | sym::custom_mir, <ins> .. </ins> ] => {} [name, ..] => { match BUILTIN_ATTRIBUTE_MAP.get(name) { // checked below Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {} Some(_) => { <del> // 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. </del> <ins> // 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. </ins> if !name.as_str().starts_with("rustc_") { span_bug!( attr.span,

<ins> //! Regression test for #128622. //! //! PR #128581 introduced an assertion that all builtin attributes are actually checked via //! `CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes. //! Unfortunately, the check had correctness problems. //! //! The match on attribute path segments looked like //! //! ```rs,ignore //! [sym::should_panic] => /* check is implemented */ //! match BUILTIN_ATTRIBUTE_MAP.get(name) { //!     // checked below //!     Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {} //!     Some(_) => { //!         if !name.as_str().starts_with("rustc_") { //!             span_bug!( //!                 attr.span, //!                 "builtin attribute {name:?} not handled by `CheckAttrVisitor`" //!             ) //!         } //!     } //!     None => (), //! } //! ``` //! //! However, it failed to account for edge cases such as an attribute whose: //! //! 1. path segments *starts* with a builtin attribute such as `should_panic` //! 2. which does not start with `rustc_`, and //! 3. is also an `AttributeType::Normal` attribute upon registration with the builtin attribute map //! //! These conditions when all satisfied cause the span bug to be issued for e.g. //! `#[should_panic::skip]` because the `[sym::should_panic]` arm is not matched (since it's //! `[sym::should_panic, sym::skip]`). //! //! This test checks that the span bug is not fired for such cases. //! //! issue: rust-lang/rust#128622 // Notably, `should_panic` is a `AttributeType::Normal` attribute that is checked separately. struct Foo { #[should_panic::skip] //~^ ERROR failed to resolve pub field: u8, #[should_panic::a::b::c] //~^ ERROR failed to resolve pub field2: u8, } fn foo() {} fn main() { #[deny::skip] //~^ ERROR failed to resolve foo(); } </ins>

<ins> error[E0433]: failed to resolve: use of undeclared crate or module `should_panic` --> $DIR/check-builtin-attr-ice.rs:43:7 | LL |     #[should_panic::skip] |       ^^^^^^^^^^^^ use of undeclared crate or module `should_panic` error[E0433]: failed to resolve: use of undeclared crate or module `should_panic` --> $DIR/check-builtin-attr-ice.rs:47:7 | LL |     #[should_panic::a::b::c] |       ^^^^^^^^^^^^ use of undeclared crate or module `should_panic` error[E0433]: failed to resolve: use of undeclared crate or module `deny` --> $DIR/check-builtin-attr-ice.rs:55:7 | LL |     #[deny::skip] |       ^^^^ use of undeclared crate or module `deny` error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0433`. </ins>