@@ -14,6 +14,7 @@ use crate::{
14
14
db:: DefDatabase ,
15
15
expander:: { Expander , Mark } ,
16
16
item_tree:: { self , AssocItem , FnFlags , ItemTree , ItemTreeId , ModItem , Param , TreeId } ,
17
+ macro_call_as_call_id, macro_id_to_def_id,
17
18
nameres:: {
18
19
attr_resolution:: ResolvedAttr ,
19
20
diagnostics:: DefDiagnostic ,
@@ -639,18 +640,15 @@ impl<'a> AssocItemCollector<'a> {
639
640
}
640
641
AssocItem :: MacroCall ( call) => {
641
642
let file_id = self . expander . current_file_id ( ) ;
642
- let root = self . db . parse_or_expand ( file_id) ;
643
643
let call = & item_tree[ call] ;
644
-
645
- let ast_id_map = self . db . ast_id_map ( file_id) ;
646
- let macro_call = ast_id_map. get ( call. ast_id ) . to_node ( & root) ;
647
- let _cx = stdx:: panic_context:: enter ( format ! (
648
- "collect_items MacroCall: {macro_call}"
649
- ) ) ;
650
644
let module = self . expander . module . local_id ;
651
645
652
- if let Ok ( res) =
653
- self . expander . enter_expand :: < ast:: MacroItems > ( self . db , macro_call, |path| {
646
+ if let Ok ( Some ( call_id) ) = macro_call_as_call_id (
647
+ self . db . upcast ( ) ,
648
+ & AstIdWithPath :: new ( file_id, call. ast_id , Clone :: clone ( & call. path ) ) ,
649
+ call. expand_to ,
650
+ self . expander . module . krate ( ) ,
651
+ |path| {
654
652
self . def_map
655
653
. resolve_path (
656
654
self . db ,
@@ -660,8 +658,11 @@ impl<'a> AssocItemCollector<'a> {
660
658
)
661
659
. 0
662
660
. take_macros ( )
663
- } )
664
- {
661
+ . map ( |it| macro_id_to_def_id ( self . db , it) )
662
+ } ,
663
+ ) {
664
+ let res =
665
+ self . expander . enter_expand_id :: < ast:: MacroItems > ( self . db , call_id) ;
665
666
self . collect_macro_items ( res, & || hir_expand:: MacroCallKind :: FnLike {
666
667
ast_id : InFile :: new ( file_id, call. ast_id ) ,
667
668
expand_to : hir_expand:: ExpandTo :: Items ,
0 commit comments