@@ -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 ! (
@@ -1097,16 +1090,7 @@ impl<'db> SemanticsImpl<'db> {
10971090 let file_id = match m_cache. get ( & mcall) {
10981091 Some ( & it) => it,
10991092 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 ( ) ) ?;
1093+ let it = ast:: MacroCall :: to_def ( self , mcall. as_ref ( ) ) ?;
11101094 m_cache. insert ( mcall, it) ;
11111095 it
11121096 }
@@ -1562,14 +1546,8 @@ impl<'db> SemanticsImpl<'db> {
15621546 }
15631547
15641548 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
1549+ let file_id = self . to_def ( macro_call) ?;
1550+ self . db . parse_macro_expansion ( file_id) . value . 1 . matched_arm
15731551 }
15741552
15751553 pub fn get_unsafe_ops ( & self , def : DefWithBody ) -> FxHashSet < ExprOrPatSource > {
0 commit comments