Handle MacCall items directly in the def collector

instead of entangling it with the brg logic
This commit is contained in:
Oli Scherer
2026-04-20 15:20:16 +02:00
parent 209a2a6e33
commit af03b49b25
2 changed files with 6 additions and 5 deletions
@@ -1377,7 +1377,6 @@ pub(crate) fn brg_visit_item(&mut self, item: &'a Item) {
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);
@@ -1402,8 +1401,10 @@ pub(crate) fn brg_visit_item(&mut self, item: &'a Item) {
self.parent_scope.module = orig_module_scope;
}
pub(crate) fn brg_visit_stmt_mac_call(&mut self, stmt: &'a ast::Stmt) {
self.parent_scope.macro_rules = self.visit_invoc_in_module(stmt.id);
/// Handle a macro call that itself can produce new `macro_rules` items
/// in the current module.
pub(crate) fn brg_visit_mac_call_in_module(&mut self, id: NodeId) {
self.parent_scope.macro_rules = self.visit_invoc_in_module(id);
}
pub(crate) fn brg_visit_block(&mut self, block: &'a Block) {
+2 -2
View File
@@ -179,7 +179,7 @@ fn visit_item(&mut self, i: &'a Item) {
}
ItemKind::MacCall(..) => {
self.visit_macro_invoc(i.id);
self.brg_visit_item(i);
self.brg_visit_mac_call_in_module(i.id);
return;
}
ItemKind::DelegationMac(..) => unreachable!(),
@@ -497,7 +497,7 @@ fn visit_ty(&mut self, ty: &'a Ty) {
fn visit_stmt(&mut self, stmt: &'a Stmt) {
match stmt.kind {
StmtKind::MacCall(..) => {
self.brg_visit_stmt_mac_call(stmt);
self.brg_visit_mac_call_in_module(stmt.id);
self.visit_macro_invoc(stmt.id)
}
// FIXME(impl_trait_in_bindings): We don't really have a good way of