Skip to content

Commit f74e7ab

Browse files
authored
Rollup merge of #124341 - petrochenkov:nomacvisit, r=compiler-errors
resolve: Remove two cases of misleading macro call visiting Macro calls are ephemeral, they should not add anything to the definition tree, even if their AST could contains something with identity. Thankfully, macro call AST cannot contain anything like that, so these walks are just noops. In majority of other places in def_collector / build_reduced_graph they are already not visited. (Also, a minor match reformatting is included.)
2 parents 1b3a329 + 0c0833d commit f74e7ab

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,11 +1304,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
13041304
visit::walk_item(self, item);
13051305
macro_rules_scope
13061306
}
1307-
ItemKind::MacCall(..) => {
1308-
let macro_rules_scope = self.visit_invoc_in_module(item.id);
1309-
visit::walk_item(self, item);
1310-
macro_rules_scope
1311-
}
1307+
ItemKind::MacCall(..) => self.visit_invoc_in_module(item.id),
13121308
_ => {
13131309
let orig_macro_rules_scope = self.parent_scope.macro_rules;
13141310
self.build_reduced_graph_for_item(item);

compiler/rustc_resolve/src/def_collector.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
136136
opt_macro_data = Some(macro_data);
137137
DefKind::Macro(macro_kind)
138138
}
139-
ItemKind::MacCall(..) => {
140-
visit::walk_item(self, i);
141-
return self.visit_macro_invoc(i.id);
142-
}
143139
ItemKind::GlobalAsm(..) => DefKind::GlobalAsm,
144-
ItemKind::Use(..) => {
145-
return visit::walk_item(self, i);
146-
}
140+
ItemKind::Use(..) => return visit::walk_item(self, i),
141+
ItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
147142
};
148143
let def_id = self.create_def(i.id, i.ident.name, def_kind, i.span);
149144

0 commit comments

Comments
 (0)