@@ -528,7 +528,7 @@ impl<'db> SemanticsImpl<'db> {
528
528
if first == last {
529
529
self . descend_into_macros_impl (
530
530
first,
531
- |InFile { value, .. } | {
531
+ & mut |InFile { value, .. } | {
532
532
if let Some ( node) = value. ancestors ( ) . find_map ( N :: cast) {
533
533
res. push ( node)
534
534
}
@@ -540,7 +540,7 @@ impl<'db> SemanticsImpl<'db> {
540
540
let mut scratch: SmallVec < [ _ ; 1 ] > = smallvec ! [ ] ;
541
541
self . descend_into_macros_impl (
542
542
first,
543
- |token| {
543
+ & mut |token| {
544
544
scratch. push ( token) ;
545
545
} ,
546
546
false ,
@@ -549,7 +549,7 @@ impl<'db> SemanticsImpl<'db> {
549
549
let mut scratch = scratch. into_iter ( ) ;
550
550
self . descend_into_macros_impl (
551
551
last,
552
- |InFile { value : last, file_id : last_fid } | {
552
+ & mut |InFile { value : last, file_id : last_fid } | {
553
553
if let Some ( InFile { value : first, file_id : first_fid } ) = scratch. next ( ) {
554
554
if first_fid == last_fid {
555
555
if let Some ( p) = first. parent ( ) {
@@ -574,28 +574,28 @@ impl<'db> SemanticsImpl<'db> {
574
574
575
575
fn descend_into_macros ( & self , token : SyntaxToken ) -> SmallVec < [ SyntaxToken ; 1 ] > {
576
576
let mut res = smallvec ! [ ] ;
577
- self . descend_into_macros_impl ( token, |InFile { value, .. } | res. push ( value) , false ) ;
577
+ self . descend_into_macros_impl ( token, & mut |InFile { value, .. } | res. push ( value) , false ) ;
578
578
res
579
579
}
580
580
581
581
fn descend_into_macros_single ( & self , token : SyntaxToken ) -> SyntaxToken {
582
582
let mut res = token. clone ( ) ;
583
- self . descend_into_macros_impl ( token, |InFile { value, .. } | res = value, true ) ;
583
+ self . descend_into_macros_impl ( token, & mut |InFile { value, .. } | res = value, true ) ;
584
584
res
585
585
}
586
586
587
587
fn descend_into_macros_impl (
588
588
& self ,
589
589
token : SyntaxToken ,
590
- mut f : impl FnMut ( InFile < SyntaxToken > ) ,
590
+ f : & mut dyn FnMut ( InFile < SyntaxToken > ) ,
591
591
single : bool ,
592
592
) {
593
593
let _p = profile:: span ( "descend_into_macros" ) ;
594
594
let parent = match token. parent ( ) {
595
595
Some ( it) => it,
596
596
None => return ,
597
597
} ;
598
- let sa = self . analyze ( & parent) ;
598
+ let sa = self . analyze_no_infer ( & parent) ;
599
599
let mut stack: SmallVec < [ _ ; 4 ] > = smallvec ! [ InFile :: new( sa. file_id, token) ] ;
600
600
let mut cache = self . expansion_info_cache . borrow_mut ( ) ;
601
601
let mut mcache = self . macro_call_cache . borrow_mut ( ) ;
@@ -927,14 +927,23 @@ impl<'db> SemanticsImpl<'db> {
927
927
}
928
928
929
929
fn analyze ( & self , node : & SyntaxNode ) -> SourceAnalyzer {
930
- self . analyze_impl ( node, None )
930
+ self . analyze_impl ( node, None , true )
931
931
}
932
932
933
933
fn analyze_with_offset ( & self , node : & SyntaxNode , offset : TextSize ) -> SourceAnalyzer {
934
- self . analyze_impl ( node, Some ( offset) )
934
+ self . analyze_impl ( node, Some ( offset) , true )
935
935
}
936
936
937
- fn analyze_impl ( & self , node : & SyntaxNode , offset : Option < TextSize > ) -> SourceAnalyzer {
937
+ fn analyze_no_infer ( & self , node : & SyntaxNode ) -> SourceAnalyzer {
938
+ self . analyze_impl ( node, None , false )
939
+ }
940
+
941
+ fn analyze_impl (
942
+ & self ,
943
+ node : & SyntaxNode ,
944
+ offset : Option < TextSize > ,
945
+ infer_body : bool ,
946
+ ) -> SourceAnalyzer {
938
947
let _p = profile:: span ( "Semantics::analyze_impl" ) ;
939
948
let node = self . find_file ( node. clone ( ) ) ;
940
949
let node = node. as_ref ( ) ;
@@ -946,7 +955,11 @@ impl<'db> SemanticsImpl<'db> {
946
955
947
956
let resolver = match container {
948
957
ChildContainer :: DefWithBodyId ( def) => {
949
- return SourceAnalyzer :: new_for_body ( self . db , def, node, offset)
958
+ return if infer_body {
959
+ SourceAnalyzer :: new_for_body ( self . db , def, node, offset)
960
+ } else {
961
+ SourceAnalyzer :: new_for_body_no_infer ( self . db , def, node, offset)
962
+ }
950
963
}
951
964
ChildContainer :: TraitId ( it) => it. resolver ( self . db . upcast ( ) ) ,
952
965
ChildContainer :: ImplId ( it) => it. resolver ( self . db . upcast ( ) ) ,
0 commit comments