File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ impl Attrs {
202
202
None => Some ( first) ,
203
203
}
204
204
}
205
+
205
206
pub ( crate ) fn is_cfg_enabled ( & self , cfg_options : & CfgOptions ) -> bool {
206
207
match self . cfg ( ) {
207
208
None => true ,
Original file line number Diff line number Diff line change @@ -290,16 +290,16 @@ impl DefCollector<'_> {
290
290
let module_id = self . def_map . root ;
291
291
292
292
let attrs = item_tree. top_level_attrs ( self . db , self . def_map . krate ) ;
293
- if let Some ( cfg) = attrs. cfg ( ) {
294
- if self . cfg_options . check ( & cfg) == Some ( false ) {
295
- return ;
296
- }
297
- }
298
293
299
294
self . inject_prelude ( & attrs) ;
300
295
301
296
// Process other crate-level attributes.
302
297
for attr in & * attrs {
298
+ if let Some ( cfg) = attr. cfg ( ) {
299
+ if self . cfg_options . check ( & cfg) == Some ( false ) {
300
+ return ;
301
+ }
302
+ }
303
303
let attr_name = match attr. path . as_ident ( ) {
304
304
Some ( name) => name,
305
305
None => continue ,
Original file line number Diff line number Diff line change @@ -309,6 +309,14 @@ impl Attr {
309
309
310
310
Some ( paths)
311
311
}
312
+
313
+ pub fn cfg ( & self ) -> Option < CfgExpr > {
314
+ if * self . path . as_ident ( ) ? == crate :: name![ cfg] {
315
+ self . token_tree_value ( ) . map ( CfgExpr :: parse)
316
+ } else {
317
+ None
318
+ }
319
+ }
312
320
}
313
321
314
322
pub fn collect_attrs (
You can’t perform that action at this time.
0 commit comments