@@ -770,59 +770,62 @@ impl<'db> SemanticsImpl<'db> {
770
770
let file_id = self . find_file ( & parent) . file_id . file_id ( ) ?;
771
771
772
772
// iterate related crates and find all include! invocations that include_file_id matches
773
- for ( invoc , _ ) in self
773
+ for iter in self
774
774
. db
775
775
. relevant_crates ( file_id. file_id ( ) )
776
776
. iter ( )
777
- . flat_map ( |krate| self . db . include_macro_invoc ( * krate) )
778
- . filter ( |& ( _, include_file_id) | include_file_id == file_id)
777
+ . map ( |krate| self . db . include_macro_invoc ( * krate) )
779
778
{
780
- let macro_file = invoc. as_macro_file ( ) ;
781
- let expansion_info = {
782
- self . with_ctx ( |ctx| {
783
- ctx. cache
784
- . expansion_info_cache
785
- . entry ( macro_file)
786
- . or_insert_with ( || {
787
- let exp_info = macro_file. expansion_info ( self . db . upcast ( ) ) ;
779
+ for ( invoc, _) in
780
+ iter. iter ( ) . filter ( |& & ( _, include_file_id) | include_file_id == file_id)
781
+ {
782
+ let macro_file = invoc. as_macro_file ( ) ;
783
+ let expansion_info = {
784
+ self . with_ctx ( |ctx| {
785
+ ctx. cache
786
+ . expansion_info_cache
787
+ . entry ( macro_file)
788
+ . or_insert_with ( || {
789
+ let exp_info = macro_file. expansion_info ( self . db . upcast ( ) ) ;
788
790
789
- let InMacroFile { file_id, value } = exp_info. expanded ( ) ;
790
- if let InFile { file_id, value : Some ( value) } = exp_info. arg ( ) {
791
- self . cache ( value. ancestors ( ) . last ( ) . unwrap ( ) , file_id) ;
792
- }
793
- self . cache ( value, file_id. into ( ) ) ;
791
+ let InMacroFile { file_id, value } = exp_info. expanded ( ) ;
792
+ if let InFile { file_id, value : Some ( value) } = exp_info. arg ( ) {
793
+ self . cache ( value. ancestors ( ) . last ( ) . unwrap ( ) , file_id) ;
794
+ }
795
+ self . cache ( value, file_id. into ( ) ) ;
794
796
795
- exp_info
796
- } )
797
- . clone ( )
798
- } )
799
- } ;
797
+ exp_info
798
+ } )
799
+ . clone ( )
800
+ } )
801
+ } ;
800
802
801
- // FIXME: uncached parse
802
- // Create the source analyzer for the macro call scope
803
- let Some ( sa) = expansion_info
804
- . arg ( )
805
- . value
806
- . and_then ( |it| self . analyze_no_infer ( & it. ancestors ( ) . last ( ) . unwrap ( ) ) )
807
- else {
808
- continue ;
809
- } ;
803
+ // FIXME: uncached parse
804
+ // Create the source analyzer for the macro call scope
805
+ let Some ( sa) = expansion_info
806
+ . arg ( )
807
+ . value
808
+ . and_then ( |it| self . analyze_no_infer ( & it. ancestors ( ) . last ( ) . unwrap ( ) ) )
809
+ else {
810
+ continue ;
811
+ } ;
810
812
811
- // get mapped token in the include! macro file
812
- let span = span:: Span {
813
- range : token. text_range ( ) ,
814
- anchor : span:: SpanAnchor { file_id, ast_id : ROOT_ERASED_FILE_AST_ID } ,
815
- ctx : SyntaxContextId :: ROOT ,
816
- } ;
817
- let Some ( InMacroFile { file_id, value : mut mapped_tokens } ) =
818
- expansion_info. map_range_down_exact ( span)
819
- else {
820
- continue ;
821
- } ;
813
+ // get mapped token in the include! macro file
814
+ let span = span:: Span {
815
+ range : token. text_range ( ) ,
816
+ anchor : span:: SpanAnchor { file_id, ast_id : ROOT_ERASED_FILE_AST_ID } ,
817
+ ctx : SyntaxContextId :: ROOT ,
818
+ } ;
819
+ let Some ( InMacroFile { file_id, value : mut mapped_tokens } ) =
820
+ expansion_info. map_range_down_exact ( span)
821
+ else {
822
+ continue ;
823
+ } ;
822
824
823
- // if we find one, then return
824
- if let Some ( t) = mapped_tokens. next ( ) {
825
- return Some ( ( sa, file_id. into ( ) , t, span) ) ;
825
+ // if we find one, then return
826
+ if let Some ( t) = mapped_tokens. next ( ) {
827
+ return Some ( ( sa, file_id. into ( ) , t, span) ) ;
828
+ }
826
829
}
827
830
}
828
831
0 commit comments