@@ -408,11 +408,7 @@ impl<'db> SemanticsImpl<'db> {
408
408
}
409
409
410
410
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) ?;
416
412
let node = self . parse_or_expand ( file_id. into ( ) ) ;
417
413
Some ( InFile :: new ( file_id. into ( ) , node) )
418
414
}
@@ -434,10 +430,7 @@ impl<'db> SemanticsImpl<'db> {
434
430
& self ,
435
431
macro_call : & ast:: MacroCall ,
436
432
) -> 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) ?;
441
434
let macro_call = self . db . lookup_intern_macro_call ( file_id) ;
442
435
443
436
let skip = matches ! (
@@ -1097,16 +1090,7 @@ impl<'db> SemanticsImpl<'db> {
1097
1090
let file_id = match m_cache. get ( & mcall) {
1098
1091
Some ( & it) => it,
1099
1092
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 ( ) ) ?;
1110
1094
m_cache. insert ( mcall, it) ;
1111
1095
it
1112
1096
}
@@ -1562,14 +1546,8 @@ impl<'db> SemanticsImpl<'db> {
1562
1546
}
1563
1547
1564
1548
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
1573
1551
}
1574
1552
1575
1553
pub fn get_unsafe_ops ( & self , def : DefWithBody ) -> FxHashSet < ExprOrPatSource > {
0 commit comments