Skip to content

Commit af03b49

Browse files
committed
Handle MacCall items directly in the def collector
instead of entangling it with the brg logic
1 parent 209a2a6 commit af03b49

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,6 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
13771377
visit::walk_item(self, item);
13781378
macro_rules_scope
13791379
}
1380-
ItemKind::MacCall(..) => self.visit_invoc_in_module(item.id),
13811380
_ => {
13821381
let orig_macro_rules_scope = self.parent_scope.macro_rules;
13831382
self.build_reduced_graph_for_item(item);
@@ -1402,8 +1401,10 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
14021401
self.parent_scope.module = orig_module_scope;
14031402
}
14041403

1405-
pub(crate) fn brg_visit_stmt_mac_call(&mut self, stmt: &'a ast::Stmt) {
1406-
self.parent_scope.macro_rules = self.visit_invoc_in_module(stmt.id);
1404+
/// Handle a macro call that itself can produce new `macro_rules` items
1405+
/// in the current module.
1406+
pub(crate) fn brg_visit_mac_call_in_module(&mut self, id: NodeId) {
1407+
self.parent_scope.macro_rules = self.visit_invoc_in_module(id);
14071408
}
14081409

14091410
pub(crate) fn brg_visit_block(&mut self, block: &'a Block) {

compiler/rustc_resolve/src/def_collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
179179
}
180180
ItemKind::MacCall(..) => {
181181
self.visit_macro_invoc(i.id);
182-
self.brg_visit_item(i);
182+
self.brg_visit_mac_call_in_module(i.id);
183183
return;
184184
}
185185
ItemKind::DelegationMac(..) => unreachable!(),
@@ -497,7 +497,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
497497
fn visit_stmt(&mut self, stmt: &'a Stmt) {
498498
match stmt.kind {
499499
StmtKind::MacCall(..) => {
500-
self.brg_visit_stmt_mac_call(stmt);
500+
self.brg_visit_mac_call_in_module(stmt.id);
501501
self.visit_macro_invoc(stmt.id)
502502
}
503503
// FIXME(impl_trait_in_bindings): We don't really have a good way of

0 commit comments

Comments
 (0)