File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -167,9 +167,19 @@ impl<'a> Extractor<'a> {
167
167
let Some ( id) = path_to_file_id ( file, vfs) else {
168
168
return Err ( "not included in files loaded from manifest" . to_string ( ) ) ;
169
169
} ;
170
- if semantics. file_to_module_def ( id) . is_none ( ) {
171
- return Err ( "not included as a module" . to_string ( ) ) ;
172
- }
170
+ match semantics. file_to_module_def ( id) {
171
+ None => return Err ( "not included as a module" . to_string ( ) ) ,
172
+ Some ( module)
173
+ if module
174
+ . as_source_file_id ( semantics. db )
175
+ . is_none_or ( |mod_file_id| mod_file_id. file_id ( semantics. db ) != id) =>
176
+ {
177
+ return Err (
178
+ "not loaded as its own module, probably included by `!include`" . to_string ( ) ,
179
+ ) ;
180
+ }
181
+ _ => { }
182
+ } ;
173
183
self . steps . push ( ExtractionStep :: load_source ( before, file) ) ;
174
184
Ok ( ( ) )
175
185
}
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ macro_rules! pre_emit {
29
29
return Some ( label) ;
30
30
}
31
31
} ;
32
+ ( Meta , $self: ident, $node: ident) => {
33
+ // rust-analyzer doesn't expand macros in this context
34
+ $self. macro_context_depth += 1 ;
35
+ } ;
32
36
( $( $_: tt) * ) => { } ;
33
37
}
34
38
@@ -122,7 +126,7 @@ pub struct Translator<'a> {
122
126
pub semantics : Option < & ' a Semantics < ' a , RootDatabase > > ,
123
127
resolve_paths : bool ,
124
128
source_kind : SourceKind ,
125
- macro_context_depth : usize ,
129
+ pub ( crate ) macro_context_depth : usize ,
126
130
}
127
131
128
132
const UNKNOWN_LOCATION : ( LineCol , LineCol ) =
You can’t perform that action at this time.
0 commit comments