Code change:
<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>

Related discussion:
text: <!-- [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.