@@ -289,80 +289,84 @@ impl DefCollector<'_> {
289
289
let module_id = self . def_map . root ;
290
290
291
291
let attrs = item_tree. top_level_attrs ( self . db , self . def_map . krate ) ;
292
- if attrs. cfg ( ) . map_or ( true , |cfg| self . cfg_options . check ( & cfg) != Some ( false ) ) {
293
- self . inject_prelude ( & attrs) ;
294
-
295
- // Process other crate-level attributes.
296
- for attr in & * attrs {
297
- let attr_name = match attr. path . as_ident ( ) {
298
- Some ( name) => name,
299
- None => continue ,
300
- } ;
292
+ if let Some ( cfg) = attrs. cfg ( ) {
293
+ if self . cfg_options . check ( & cfg) == Some ( false ) {
294
+ return ;
295
+ }
296
+ }
301
297
302
- if * attr_name == hir_expand:: name![ recursion_limit] {
303
- if let Some ( limit) = attr. string_value ( ) {
304
- if let Ok ( limit) = limit. parse ( ) {
305
- self . def_map . recursion_limit = Some ( limit) ;
306
- }
307
- }
308
- continue ;
309
- }
298
+ self . inject_prelude ( & attrs) ;
310
299
311
- if * attr_name == hir_expand :: name! [ crate_type ] {
312
- if let Some ( "proc-macro" ) = attr . string_value ( ) . map ( SmolStr :: as_str ) {
313
- self . is_proc_macro = true ;
314
- }
315
- continue ;
316
- }
300
+ // Process other crate-level attributes.
301
+ for attr in & * attrs {
302
+ let attr_name = match attr . path . as_ident ( ) {
303
+ Some ( name ) => name ,
304
+ None => continue ,
305
+ } ;
317
306
318
- if attr_name. as_text ( ) . as_deref ( ) == Some ( "rustc_coherence_is_core" ) {
319
- self . def_map . rustc_coherence_is_core = true ;
320
- continue ;
307
+ if * attr_name == hir_expand:: name![ recursion_limit] {
308
+ if let Some ( limit) = attr. string_value ( ) {
309
+ if let Ok ( limit) = limit. parse ( ) {
310
+ self . def_map . recursion_limit = Some ( limit) ;
311
+ }
321
312
}
313
+ continue ;
314
+ }
322
315
323
- if * attr_name == hir_expand:: name![ feature] {
324
- let hygiene = & Hygiene :: new_unhygienic ( ) ;
325
- let features = attr
326
- . parse_path_comma_token_tree ( self . db . upcast ( ) , hygiene)
327
- . into_iter ( )
328
- . flatten ( )
329
- . filter_map ( |feat| match feat. segments ( ) {
330
- [ name] => Some ( name. to_smol_str ( ) ) ,
331
- _ => None ,
332
- } ) ;
333
- self . def_map . unstable_features . extend ( features) ;
316
+ if * attr_name == hir_expand:: name![ crate_type] {
317
+ if let Some ( "proc-macro" ) = attr. string_value ( ) . map ( SmolStr :: as_str) {
318
+ self . is_proc_macro = true ;
334
319
}
320
+ continue ;
321
+ }
335
322
336
- let attr_is_register_like = * attr_name == hir_expand:: name![ register_attr]
337
- || * attr_name == hir_expand:: name![ register_tool] ;
338
- if !attr_is_register_like {
339
- continue ;
340
- }
323
+ if attr_name. as_text ( ) . as_deref ( ) == Some ( "rustc_coherence_is_core" ) {
324
+ self . def_map . rustc_coherence_is_core = true ;
325
+ continue ;
326
+ }
341
327
342
- let registered_name = match attr. single_ident_value ( ) {
343
- Some ( ident) => ident. as_name ( ) ,
344
- _ => continue ,
345
- } ;
328
+ if * attr_name == hir_expand:: name![ feature] {
329
+ let hygiene = & Hygiene :: new_unhygienic ( ) ;
330
+ let features = attr
331
+ . parse_path_comma_token_tree ( self . db . upcast ( ) , hygiene)
332
+ . into_iter ( )
333
+ . flatten ( )
334
+ . filter_map ( |feat| match feat. segments ( ) {
335
+ [ name] => Some ( name. to_smol_str ( ) ) ,
336
+ _ => None ,
337
+ } ) ;
338
+ self . def_map . unstable_features . extend ( features) ;
339
+ }
346
340
347
- if * attr_name == hir_expand:: name![ register_attr] {
348
- self . def_map . registered_attrs . push ( registered_name. to_smol_str ( ) ) ;
349
- cov_mark:: hit!( register_attr) ;
350
- } else {
351
- self . def_map . registered_tools . push ( registered_name. to_smol_str ( ) ) ;
352
- cov_mark:: hit!( register_tool) ;
353
- }
341
+ let attr_is_register_like = * attr_name == hir_expand:: name![ register_attr]
342
+ || * attr_name == hir_expand:: name![ register_tool] ;
343
+ if !attr_is_register_like {
344
+ continue ;
354
345
}
355
346
356
- ModCollector {
357
- def_collector : self ,
358
- macro_depth : 0 ,
359
- module_id,
360
- tree_id : TreeId :: new ( file_id. into ( ) , None ) ,
361
- item_tree : & item_tree,
362
- mod_dir : ModDir :: root ( ) ,
347
+ let registered_name = match attr. single_ident_value ( ) {
348
+ Some ( ident) => ident. as_name ( ) ,
349
+ _ => continue ,
350
+ } ;
351
+
352
+ if * attr_name == hir_expand:: name![ register_attr] {
353
+ self . def_map . registered_attrs . push ( registered_name. to_smol_str ( ) ) ;
354
+ cov_mark:: hit!( register_attr) ;
355
+ } else {
356
+ self . def_map . registered_tools . push ( registered_name. to_smol_str ( ) ) ;
357
+ cov_mark:: hit!( register_tool) ;
363
358
}
364
- . collect_in_top_module ( item_tree. top_level_items ( ) ) ;
365
359
}
360
+
361
+ ModCollector {
362
+ def_collector : self ,
363
+ macro_depth : 0 ,
364
+ module_id,
365
+ tree_id : TreeId :: new ( file_id. into ( ) , None ) ,
366
+ item_tree : & item_tree,
367
+ mod_dir : ModDir :: root ( ) ,
368
+ }
369
+ . collect_in_top_module ( item_tree. top_level_items ( ) ) ;
366
370
}
367
371
368
372
fn seed_with_inner ( & mut self , tree_id : TreeId ) {
0 commit comments