@@ -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 ! (
@@ -574,9 +567,7 @@ impl<'db> SemanticsImpl<'db> {
574
567
speculative_args : & ast:: TokenTree ,
575
568
token_to_map : SyntaxToken ,
576
569
) -> 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) ?;
580
571
hir_expand:: db:: expand_speculative (
581
572
self . db ,
582
573
macro_file,
@@ -1097,16 +1088,7 @@ impl<'db> SemanticsImpl<'db> {
1097
1088
let file_id = match m_cache. get ( & mcall) {
1098
1089
Some ( & it) => it,
1099
1090
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 ( ) ) ?;
1110
1092
m_cache. insert ( mcall, it) ;
1111
1093
it
1112
1094
}
@@ -1551,9 +1533,6 @@ impl<'db> SemanticsImpl<'db> {
1551
1533
. and_then ( |call| macro_call_to_macro_id ( ctx, call) )
1552
1534
. map ( Into :: into)
1553
1535
} )
1554
- . or_else ( || {
1555
- self . analyze ( macro_call. value . syntax ( ) ) ?. resolve_macro_call ( self . db , macro_call)
1556
- } )
1557
1536
}
1558
1537
1559
1538
pub fn is_proc_macro_call ( & self , macro_call : InFile < & ast:: MacroCall > ) -> bool {
@@ -1562,14 +1541,8 @@ impl<'db> SemanticsImpl<'db> {
1562
1541
}
1563
1542
1564
1543
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
1573
1546
}
1574
1547
1575
1548
pub fn get_unsafe_ops ( & self , def : DefWithBody ) -> FxHashSet < ExprOrPatSource > {
0 commit comments