diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 03ded6465d0..8c6aef80635 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -29,6 +29,9 @@ use std::rc::Rc; crate use rustc_span::hygiene::MacroKind; +// When adding new variants, make sure to +// adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector` +// to use `assign_id!` #[derive(Debug, Clone)] pub enum Annotatable { Item(P), diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 208894c3791..dcd871c9d20 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1099,6 +1099,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { } /// Wraps a call to `noop_visit_*` / `noop_flat_map_*` +/// for an AST node that supports attributes +/// (see the `Annotatable` enum) /// This method assigns a `NodeId`, and sets that `NodeId` /// as our current 'lint node id'. If a macro call is found /// inside this AST node, we will use this AST node's `NodeId` @@ -1269,9 +1271,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_pat(&mut self, pat: &mut P) { match pat.kind { PatKind::MacCall(_) => {} - _ => { - return assign_id!(self, &mut pat.id, || noop_visit_pat(pat, self)); - } + _ => return noop_visit_pat(pat, self), } visit_clobber(pat, |mut pat| match mem::replace(&mut pat.kind, PatKind::Wild) { @@ -1326,7 +1326,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { &mut self.cx.current_expansion.dir_ownership, DirOwnership::UnownedViaBlock, ); - assign_id!(self, &mut block.id, || noop_visit_block(block, self)); + noop_visit_block(block, self); self.cx.current_expansion.dir_ownership = orig_dir_ownership; } @@ -1498,7 +1498,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_ty(&mut self, ty: &mut P) { match ty.kind { ast::TyKind::MacCall(_) => {} - _ => return assign_id!(self, &mut ty.id, || noop_visit_ty(ty, self)), + _ => return noop_visit_ty(ty, self), }; visit_clobber(ty, |mut ty| match mem::replace(&mut ty.kind, ast::TyKind::Err) {