Skip to content

Commit 7ca089c

Browse files
committed
Only use assign_id! for ast nodes that support attributes
1 parent d6e3c11 commit 7ca089c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/rustc_expand/src/base.rs

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ use std::rc::Rc;
2929

3030
crate use rustc_span::hygiene::MacroKind;
3131

32+
// When adding new variants, make sure to
33+
// adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector`
34+
// to use `assign_id!`
3235
#[derive(Debug, Clone)]
3336
pub enum Annotatable {
3437
Item(P<ast::Item>),

compiler/rustc_expand/src/expand.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10991099
}
11001100

11011101
/// Wraps a call to `noop_visit_*` / `noop_flat_map_*`
1102+
/// for an AST node that supports attributes
1103+
/// (see the `Annotatable` enum)
11021104
/// This method assigns a `NodeId`, and sets that `NodeId`
11031105
/// as our current 'lint node id'. If a macro call is found
11041106
/// inside this AST node, we will use this AST node's `NodeId`
@@ -1269,9 +1271,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
12691271
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
12701272
match pat.kind {
12711273
PatKind::MacCall(_) => {}
1272-
_ => {
1273-
return assign_id!(self, &mut pat.id, || noop_visit_pat(pat, self));
1274-
}
1274+
_ => return noop_visit_pat(pat, self),
12751275
}
12761276

12771277
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> {
13261326
&mut self.cx.current_expansion.dir_ownership,
13271327
DirOwnership::UnownedViaBlock,
13281328
);
1329-
assign_id!(self, &mut block.id, || noop_visit_block(block, self));
1329+
noop_visit_block(block, self);
13301330
self.cx.current_expansion.dir_ownership = orig_dir_ownership;
13311331
}
13321332

@@ -1498,7 +1498,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14981498
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
14991499
match ty.kind {
15001500
ast::TyKind::MacCall(_) => {}
1501-
_ => return assign_id!(self, &mut ty.id, || noop_visit_ty(ty, self)),
1501+
_ => return noop_visit_ty(ty, self),
15021502
};
15031503

15041504
visit_clobber(ty, |mut ty| match mem::replace(&mut ty.kind, ast::TyKind::Err) {

0 commit comments

Comments
 (0)