@@ -28,7 +28,7 @@ use hir_expand::{
28
28
use itertools:: Itertools ;
29
29
use rustc_hash:: { FxHashMap , FxHashSet } ;
30
30
use smallvec:: { smallvec, SmallVec } ;
31
- use span:: { EditionedFileId , FileId , Span , SyntaxContextId , ROOT_ERASED_FILE_AST_ID } ;
31
+ use span:: { EditionedFileId , FileId } ;
32
32
use stdx:: TupleExt ;
33
33
use syntax:: {
34
34
algo:: skip_trivia_token,
@@ -757,84 +757,9 @@ impl<'db> SemanticsImpl<'db> {
757
757
res
758
758
}
759
759
760
- // return:
761
- // SourceAnalyzer(file_id that original call include!)
762
- // macro file id
763
- // token in include! macro mapped from token in params
764
- // span for the mapped token
765
- fn is_from_include_file (
766
- & self ,
767
- token : SyntaxToken ,
768
- ) -> Option < ( SourceAnalyzer , HirFileId , SyntaxToken , Span ) > {
769
- let parent = token. parent ( ) ?;
770
- let file_id = self . find_file ( & parent) . file_id . file_id ( ) ?;
771
-
772
- // iterate related crates and find all include! invocations that include_file_id matches
773
- for iter in self
774
- . db
775
- . relevant_crates ( file_id. file_id ( ) )
776
- . iter ( )
777
- . map ( |krate| self . db . include_macro_invoc ( * krate) )
778
- {
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 ( ) ) ;
790
-
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 ( ) ) ;
796
-
797
- exp_info
798
- } )
799
- . clone ( )
800
- } )
801
- } ;
802
-
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
- } ;
812
-
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
- } ;
824
-
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
- }
829
- }
830
- }
831
-
832
- None
833
- }
834
-
835
760
fn descend_into_macros_impl (
836
761
& self ,
837
- mut token : SyntaxToken ,
762
+ token : SyntaxToken ,
838
763
f : & mut dyn FnMut ( InFile < SyntaxToken > ) -> ControlFlow < ( ) > ,
839
764
) {
840
765
let _p = tracing:: info_span!( "descend_into_macros_impl" ) . entered ( ) ;
@@ -851,17 +776,7 @@ impl<'db> SemanticsImpl<'db> {
851
776
return ;
852
777
}
853
778
} ,
854
- None => {
855
- // if we cannot find a source analyzer for this token, then we try to find out
856
- // whether this file is an included file and treat that as the include input
857
- let Some ( ( it, macro_file_id, mapped_token, s) ) =
858
- self . is_from_include_file ( token)
859
- else {
860
- return ;
861
- } ;
862
- token = mapped_token;
863
- ( it, s, macro_file_id)
864
- }
779
+ None => return ,
865
780
} ;
866
781
867
782
let mut m_cache = self . macro_call_cache . borrow_mut ( ) ;
0 commit comments