@@ -936,16 +936,7 @@ impl<'db> SemanticsImpl<'db> {
936
936
}
937
937
}
938
938
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
-
947
939
let mut m_cache = self . macro_call_cache . borrow_mut ( ) ;
948
- let def_map = sa. resolver . def_map ( ) ;
949
940
950
941
// Filters out all tokens that contain the given range (usually the macro call), any such
951
942
// token is redundant as the corresponding macro call has already been processed
@@ -1024,8 +1015,16 @@ impl<'db> SemanticsImpl<'db> {
1024
1015
) {
1025
1016
call. as_macro_file ( )
1026
1017
} 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 ( ) ) ?
1029
1028
} ;
1030
1029
m_cache. insert ( mcall, it) ;
1031
1030
it
@@ -1095,9 +1094,16 @@ impl<'db> SemanticsImpl<'db> {
1095
1094
attr. path ( ) . and_then ( |it| it. as_single_name_ref ( ) ) ?. as_name ( ) ;
1096
1095
// Not an attribute, nor a derive, so it's either an intert attribute or a derive helper
1097
1096
// 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 ;
1098
1103
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) ) ?;
1101
1107
1102
1108
if !helpers. is_empty ( ) {
1103
1109
let text_range = attr. syntax ( ) . text_range ( ) ;
0 commit comments