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 {
202202 None => Some ( first) ,
203203 }
204204 }
205+
205206 pub ( crate ) fn is_cfg_enabled ( & self , cfg_options : & CfgOptions ) -> bool {
206207 match self . cfg ( ) {
207208 None => true ,
Original file line number Diff line number Diff line change @@ -290,16 +290,16 @@ impl DefCollector<'_> {
290290 let module_id = self . def_map . root ;
291291
292292 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- }
298293
299294 self . inject_prelude ( & attrs) ;
300295
301296 // Process other crate-level attributes.
302297 for attr in & * attrs {
298+ if let Some ( cfg) = attr. cfg ( ) {
299+ if self . cfg_options . check ( & cfg) == Some ( false ) {
300+ return ;
301+ }
302+ }
303303 let attr_name = match attr. path . as_ident ( ) {
304304 Some ( name) => name,
305305 None => continue ,
Original file line number Diff line number Diff line change @@ -309,6 +309,14 @@ impl Attr {
309309
310310 Some ( paths)
311311 }
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+ }
312320}
313321
314322pub fn collect_attrs (
You can’t perform that action at this time.
0 commit comments