Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --Found an ICE with when trying to use it in the standard library (). cc . <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
I can hit an additional ICE by using an unknown attribute instead of a valid one: <details<summary<strongBacktrace</strong</summary<p</p</detailsI don't really think it's useful for this issue though, since it's a delayed error.
Fixed in

Discussion:
} fn visit_item_kind(&mut self, item: &mut ast::ItemKind) { <del> match item { ast::ItemKind::MacroDef(..) => {} _ => { self.cfg.configure_item_kind(item); noop_visit_item_kind(item, self); } } </del> <ins> self.cfg.configure_item_kind(item); noop_visit_item_kind(item, self); </ins> } fn flat_map_generic_param(

fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> { match item.kind { <del> ast::ItemKind::MacCall(_) => return self.remove(item.id).make_items(), ast::ItemKind::MacroDef(_) => return smallvec![item], _ => {} </del> <ins> ast::ItemKind::MacCall(_) => self.remove(item.id).make_items(), _ => noop_flat_map_item(item, self), </ins> } <del> noop_flat_map_item(item, self) </del> } fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {

method!(visit_ty: ast::Ty, ast::TyKind::MacCall, walk_ty); fn visit_item(&mut self, item: &'b Item) { <del> let macro_use = match item.kind { </del> <ins> let orig_module_scope = self.parent_scope.module; self.parent_scope.macro_rules = match item.kind { </ins> ItemKind::MacroDef(..) => { <del> self.parent_scope.macro_rules = self.define_macro(item); return; </del> <ins> let macro_rules_scope = self.define_macro(item); visit::walk_item(self, item); macro_rules_scope </ins> } ItemKind::MacCall(..) => { <del> self.parent_scope.macro_rules = self.visit_invoc_in_module(item.id); return; </del> <ins> let macro_rules_scope = self.visit_invoc_in_module(item.id); visit::walk_item(self, item); macro_rules_scope } _ => { let orig_macro_rules_scope = self.parent_scope.macro_rules; self.build_reduced_graph_for_item(item); visit::walk_item(self, item); match item.kind { ItemKind::Mod(..) if self.contains_macro_use(&item.attrs) => { self.parent_scope.macro_rules } _ => orig_macro_rules_scope, } </ins> } <del> ItemKind::Mod(..) => self.contains_macro_use(&item.attrs), _ => false, </del> }; <del> let orig_current_module = self.parent_scope.module; let orig_current_macro_rules_scope = self.parent_scope.macro_rules; self.build_reduced_graph_for_item(item); visit::walk_item(self, item); self.parent_scope.module = orig_current_module; if !macro_use { self.parent_scope.macro_rules = orig_current_macro_rules_scope; } </del> <ins> self.parent_scope.module = orig_module_scope; </ins> } fn visit_stmt(&mut self, stmt: &'b ast::Stmt) {

DefPathData::ValueNs(i.ident.name) } ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.name), <del> ItemKind::MacCall(..) => return self.visit_macro_invoc(i.id), </del> <ins> ItemKind::MacCall(..) => { visit::walk_item(self, i); return self.visit_macro_invoc(i.id); } </ins> ItemKind::GlobalAsm(..) => DefPathData::Misc, ItemKind::Use(..) => { return visit::walk_item(self, i);

<ins> #![feature(extended_key_value_attributes)] #![feature(rustc_attrs)] #[rustc_dummy = stringify!(a)] // OK macro_rules! bar { () => {}; } // FIXME?: `bar` here expands before `stringify` has a chance to expand. // `#[rustc_dummy = ...]` is validated and dropped during expansion of `bar`, // the "unexpected token" errors comes from the validation. #[rustc_dummy = stringify!(b)] //~ ERROR unexpected token: `stringify!(b)` bar!(); fn main() {} </ins>

<ins> error: unexpected token: `stringify!(b)` --> $DIR/key-value-expansion-on-mac.rs:12:17 | LL | #[rustc_dummy = stringify!(b)] |                 ^^^^^^^^^^^^^ error: aborting due to previous error </ins>

|            ^^^^^ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` <del> --> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` </del> --> $DIR/issue-43106-gating-of-builtin-attrs.rs:441:17 | LL |     mod inner { #![macro_escape] }

| = help: try an outer attribute: `#[macro_use]` <ins> warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ </ins> warning: use of deprecated attribute `plugin_registrar`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:228:17 |

error: arguments to `macro_use` are not allowed here <del> --> $DIR/issue-43106-gating-of-macro_use.rs:6:1 </del> <ins> --> $DIR/issue-43106-gating-of-macro_use.rs:12:17 </ins> | <del> LL | #![macro_use(my_macro)] | ^^^^^^^^^^^^^^^^^^^^^^^ </del> <ins> LL |     mod inner { #![macro_use(my_macro)] } |                 ^^^^^^^^^^^^^^^^^^^^^^^ </ins> error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:9:1

| ^^^^^^^^^^^^^^^^^^^^^^ error: arguments to `macro_use` are not allowed here <del> --> $DIR/issue-43106-gating-of-macro_use.rs:12:17 </del> <ins> --> $DIR/issue-43106-gating-of-macro_use.rs:6:1 </ins> | <del> LL |     mod inner { #![macro_use(my_macro)] } |                 ^^^^^^^^^^^^^^^^^^^^^^^ </del> <ins> LL | #![macro_use(my_macro)] | ^^^^^^^^^^^^^^^^^^^^^^^ </ins> error: malformed `macro_use` attribute input --> $DIR/issue-43106-gating-of-macro_use.rs:15:5