Skip to content

Commit

Permalink
Unrolled build for rust-lang#124341
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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.)
  • Loading branch information
rust-timer authored Apr 27, 2024
2 parents aa6a8ee + 0c0833d commit 0eaced3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
6 changes: 1 addition & 5 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,11 +1304,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
visit::walk_item(self, item);
macro_rules_scope
}
ItemKind::MacCall(..) => {
let macro_rules_scope = self.visit_invoc_in_module(item.id);
visit::walk_item(self, item);
macro_rules_scope
}
ItemKind::MacCall(..) => self.visit_invoc_in_module(item.id),
_ => {
let orig_macro_rules_scope = self.parent_scope.macro_rules;
self.build_reduced_graph_for_item(item);
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
opt_macro_data = Some(macro_data);
DefKind::Macro(macro_kind)
}
ItemKind::MacCall(..) => {
visit::walk_item(self, i);
return self.visit_macro_invoc(i.id);
}
ItemKind::GlobalAsm(..) => DefKind::GlobalAsm,
ItemKind::Use(..) => {
return visit::walk_item(self, i);
}
ItemKind::Use(..) => return visit::walk_item(self, i),
ItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
};
let def_id = self.create_def(i.id, i.ident.name, def_kind, i.span);

Expand Down

0 comments on commit 0eaced3

Please sign in to comment.