@@ -936,16 +936,7 @@ impl<'db> SemanticsImpl<'db> {
936936 }
937937 }
938938
939- let ( file_id, tokens) = stack. first ( ) ?;
940- // make sure we pick the token in the expanded include if we encountered an include,
941- // otherwise we'll get the wrong semantics
942- let sa =
943- tokens. first ( ) ?. 0 . parent ( ) . and_then ( |parent| {
944- self . analyze_impl ( InFile :: new ( * file_id, & parent) , None , false )
945- } ) ?;
946-
947939 let mut m_cache = self . macro_call_cache . borrow_mut ( ) ;
948- let def_map = sa. resolver . def_map ( ) ;
949940
950941 // Filters out all tokens that contain the given range (usually the macro call), any such
951942 // token is redundant as the corresponding macro call has already been processed
@@ -1024,8 +1015,16 @@ impl<'db> SemanticsImpl<'db> {
10241015 ) {
10251016 call. as_macro_file ( )
10261017 } else {
1027- // FIXME: This is wrong, the SourceAnalyzer might be invalid here
1028- sa. expand ( self . db , mcall. as_ref ( ) ) ?
1018+ token
1019+ . parent ( )
1020+ . and_then ( |parent| {
1021+ self . analyze_impl (
1022+ InFile :: new ( expansion, & parent) ,
1023+ None ,
1024+ false ,
1025+ )
1026+ } ) ?
1027+ . expand ( self . db , mcall. as_ref ( ) ) ?
10291028 } ;
10301029 m_cache. insert ( mcall, it) ;
10311030 it
@@ -1095,9 +1094,16 @@ impl<'db> SemanticsImpl<'db> {
10951094 attr. path ( ) . and_then ( |it| it. as_single_name_ref ( ) ) ?. as_name ( ) ;
10961095 // Not an attribute, nor a derive, so it's either an intert attribute or a derive helper
10971096 // Try to resolve to a derive helper and downmap
1097+ let resolver = & token
1098+ . parent ( )
1099+ . and_then ( |parent| {
1100+ self . analyze_impl ( InFile :: new ( expansion, & parent) , None , false )
1101+ } ) ?
1102+ . resolver ;
10981103 let id = self . db . ast_id_map ( expansion) . ast_id ( & adt) ;
1099- let helpers =
1100- def_map. derive_helpers_in_scope ( InFile :: new ( expansion, id) ) ?;
1104+ let helpers = resolver
1105+ . def_map ( )
1106+ . derive_helpers_in_scope ( InFile :: new ( expansion, id) ) ?;
11011107
11021108 if !helpers. is_empty ( ) {
11031109 let text_range = attr. syntax ( ) . text_range ( ) ;
0 commit comments