@@ -1229,6 +1229,7 @@ impl DefCollector<'_> {
12291229 No ,
12301230 }
12311231
1232+ let mut eager_callback_buffer = vec ! [ ] ;
12321233 let mut res = ReachedFixedPoint :: Yes ;
12331234 // Retain unresolved macros after this round of resolution.
12341235 let mut retain = |directive : & MacroDirective | {
@@ -1261,11 +1262,8 @@ impl DefCollector<'_> {
12611262 * expand_to,
12621263 self . def_map . krate ,
12631264 resolver_def_id,
1264- & mut |_ptr, _call_id| {
1265- // FIXME:
1266- // self.def_map.modules[directive.module_id]
1267- // .scope
1268- // .add_macro_invoc(ptr.map(|(_, it)| it), call_id);
1265+ & mut |ptr, call_id| {
1266+ eager_callback_buffer. push ( ( directive. module_id , ptr, call_id) ) ;
12691267 } ,
12701268 ) ;
12711269 if let Ok ( Some ( call_id) ) = call_id {
@@ -1492,6 +1490,10 @@ impl DefCollector<'_> {
14921490 macros. extend ( mem:: take ( & mut self . unresolved_macros ) ) ;
14931491 self . unresolved_macros = macros;
14941492
1493+ for ( module_id, ptr, call_id) in eager_callback_buffer {
1494+ self . def_map . modules [ module_id] . scope . add_macro_invoc ( ptr. map ( |( _, it) | it) , call_id) ;
1495+ }
1496+
14951497 for ( module_id, depth, container, macro_call_id) in resolved {
14961498 self . collect_macro_expansion ( module_id, macro_call_id, depth, container) ;
14971499 }
@@ -2419,6 +2421,7 @@ impl ModCollector<'_, '_> {
24192421 // new legacy macros that create textual scopes. We need a way to resolve names in textual
24202422 // scopes without eager expansion.
24212423
2424+ let mut eager_callback_buffer = vec ! [ ] ;
24222425 // Case 1: try to resolve macro calls with single-segment name and expand macro_rules
24232426 if let Ok ( res) = macro_call_as_call_id_with_eager (
24242427 db. upcast ( ) ,
@@ -2460,13 +2463,13 @@ impl ModCollector<'_, '_> {
24602463 ) ;
24612464 resolved_res. resolved_def . take_macros ( ) . map ( |it| db. macro_def ( it) )
24622465 } ,
2463- & mut |_ptr, _call_id| {
2464- // FIXME:
2465- // self.def_collector.def_map.modules[self.module_id]
2466- // .scope
2467- // .add_macro_invoc(ptr.map(|(_, it)| it), call_id);
2468- } ,
2466+ & mut |ptr, call_id| eager_callback_buffer. push ( ( ptr, call_id) ) ,
24692467 ) {
2468+ for ( ptr, call_id) in eager_callback_buffer {
2469+ self . def_collector . def_map . modules [ self . module_id ]
2470+ . scope
2471+ . add_macro_invoc ( ptr. map ( |( _, it) | it) , call_id) ;
2472+ }
24702473 // FIXME: if there were errors, this might've been in the eager expansion from an
24712474 // unresolved macro, so we need to push this into late macro resolution. see fixme above
24722475 if res. err . is_none ( ) {
@@ -2629,7 +2632,7 @@ foo!(KABOOM);
26292632 // the release mode. That's why the argument is not an ra_fixture --
26302633 // otherwise injection highlighting gets stuck.
26312634 //
2632- // We need to find a way to fail this faster.
2635+ // We need to find a way to fail this faster!
26332636 do_resolve (
26342637 r#"
26352638macro_rules! foo {
0 commit comments