about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2021-07-17 08:22:09 -0500
committerAaron Hill <aa1ronham@gmail.com>2021-07-17 23:03:58 -0500
commit7ca089c6d2e834ea007d7a62b8bbbe0c880de4a2 (patch)
tree9979b2b2b07c2c5eccd6334b8054510746db2a40
parentd6e3c111011f6a270d56fdaf5222b484c4f38d65 (diff)
downloadrust-7ca089c6d2e834ea007d7a62b8bbbe0c880de4a2.tar.gz
rust-7ca089c6d2e834ea007d7a62b8bbbe0c880de4a2.zip
Only use `assign_id!` for ast nodes that support attributes
-rw-r--r--compiler/rustc_expand/src/base.rs3
-rw-r--r--compiler/rustc_expand/src/expand.rs10
2 files changed, 8 insertions, 5 deletions
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<ast::Item>),
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<ast::Pat>) {
         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<ast::Ty>) {
         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) {