@@ -14,6 +14,7 @@ use crate::{
1414 db:: DefDatabase ,
1515 expander:: { Expander , Mark } ,
1616 item_tree:: { self , AssocItem , FnFlags , ItemTree , ItemTreeId , ModItem , Param , TreeId } ,
17+ macro_call_as_call_id, macro_id_to_def_id,
1718 nameres:: {
1819 attr_resolution:: ResolvedAttr ,
1920 diagnostics:: DefDiagnostic ,
@@ -639,18 +640,15 @@ impl<'a> AssocItemCollector<'a> {
639640 }
640641 AssocItem :: MacroCall ( call) => {
641642 let file_id = self . expander . current_file_id ( ) ;
642- let root = self . db . parse_or_expand ( file_id) ;
643643 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- ) ) ;
650644 let module = self . expander . module . local_id ;
651645
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| {
654652 self . def_map
655653 . resolve_path (
656654 self . db ,
@@ -660,8 +658,11 @@ impl<'a> AssocItemCollector<'a> {
660658 )
661659 . 0
662660 . 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) ;
665666 self . collect_macro_items ( res, & || hir_expand:: MacroCallKind :: FnLike {
666667 ast_id : InFile :: new ( file_id, call. ast_id ) ,
667668 expand_to : hir_expand:: ExpandTo :: Items ,
0 commit comments