@@ -408,11 +408,7 @@ impl<'db> SemanticsImpl<'db> {
408408 }
409409
410410 pub fn expand_macro_call ( & self , macro_call : & ast:: MacroCall ) -> Option < InFile < SyntaxNode > > {
411- let sa = self . analyze_no_infer ( macro_call. syntax ( ) ) ?;
412-
413- let macro_call = InFile :: new ( sa. file_id , macro_call) ;
414- let file_id = sa. expansion ( self . db , macro_call) ?;
415-
411+ let file_id = self . to_def ( macro_call) ?;
416412 let node = self . parse_or_expand ( file_id. into ( ) ) ;
417413 Some ( InFile :: new ( file_id. into ( ) , node) )
418414 }
@@ -434,10 +430,7 @@ impl<'db> SemanticsImpl<'db> {
434430 & self ,
435431 macro_call : & ast:: MacroCall ,
436432 ) -> Option < ExpandResult < SyntaxNode > > {
437- let sa = self . analyze_no_infer ( macro_call. syntax ( ) ) ?;
438-
439- let macro_call = InFile :: new ( sa. file_id , macro_call) ;
440- let file_id = sa. expansion ( self . db , macro_call) ?;
433+ let file_id = self . to_def ( macro_call) ?;
441434 let macro_call = self . db . lookup_intern_macro_call ( file_id) ;
442435
443436 let skip = matches ! (
@@ -574,9 +567,7 @@ impl<'db> SemanticsImpl<'db> {
574567 speculative_args : & ast:: TokenTree ,
575568 token_to_map : SyntaxToken ,
576569 ) -> Option < ( SyntaxNode , Vec < ( SyntaxToken , u8 ) > ) > {
577- let analyzer = self . analyze_no_infer ( actual_macro_call. syntax ( ) ) ?;
578- let macro_call = InFile :: new ( analyzer. file_id , actual_macro_call) ;
579- let macro_file = analyzer. expansion ( self . db , macro_call) ?;
570+ let macro_file = self . to_def ( actual_macro_call) ?;
580571 hir_expand:: db:: expand_speculative (
581572 self . db ,
582573 macro_file,
@@ -1097,16 +1088,7 @@ impl<'db> SemanticsImpl<'db> {
10971088 let file_id = match m_cache. get ( & mcall) {
10981089 Some ( & it) => it,
10991090 None => {
1100- let it = token
1101- . parent ( )
1102- . and_then ( |parent| {
1103- self . analyze_impl (
1104- InFile :: new ( expansion, & parent) ,
1105- None ,
1106- false ,
1107- )
1108- } ) ?
1109- . expansion ( self . db , mcall. as_ref ( ) ) ?;
1091+ let it = ast:: MacroCall :: to_def ( self , mcall. as_ref ( ) ) ?;
11101092 m_cache. insert ( mcall, it) ;
11111093 it
11121094 }
@@ -1551,9 +1533,6 @@ impl<'db> SemanticsImpl<'db> {
15511533 . and_then ( |call| macro_call_to_macro_id ( ctx, call) )
15521534 . map ( Into :: into)
15531535 } )
1554- . or_else ( || {
1555- self . analyze ( macro_call. value . syntax ( ) ) ?. resolve_macro_call ( self . db , macro_call)
1556- } )
15571536 }
15581537
15591538 pub fn is_proc_macro_call ( & self , macro_call : InFile < & ast:: MacroCall > ) -> bool {
@@ -1562,14 +1541,8 @@ impl<'db> SemanticsImpl<'db> {
15621541 }
15631542
15641543 pub fn resolve_macro_call_arm ( & self , macro_call : & ast:: MacroCall ) -> Option < u32 > {
1565- let sa = self . analyze ( macro_call. syntax ( ) ) ?;
1566- self . db
1567- . parse_macro_expansion (
1568- sa. expansion ( self . db , self . wrap_node_infile ( macro_call. clone ( ) ) . as_ref ( ) ) ?,
1569- )
1570- . value
1571- . 1
1572- . matched_arm
1544+ let file_id = self . to_def ( macro_call) ?;
1545+ self . db . parse_macro_expansion ( file_id) . value . 1 . matched_arm
15731546 }
15741547
15751548 pub fn get_unsafe_ops ( & self , def : DefWithBody ) -> FxHashSet < ExprOrPatSource > {
0 commit comments