@@ -291,8 +291,6 @@ impl DefCollector<'_> {
291
291
292
292
let attrs = item_tree. top_level_attrs ( self . db , self . def_map . krate ) ;
293
293
294
- self . inject_prelude ( & attrs) ;
295
-
296
294
// Process other crate-level attributes.
297
295
for attr in & * attrs {
298
296
if let Some ( cfg) = attr. cfg ( ) {
@@ -321,6 +319,16 @@ impl DefCollector<'_> {
321
319
continue ;
322
320
}
323
321
322
+ if * attr_name == hir_expand:: name![ no_core] {
323
+ self . def_map . no_core = true ;
324
+ continue ;
325
+ }
326
+
327
+ if * attr_name == hir_expand:: name![ no_std] {
328
+ self . def_map . no_std = true ;
329
+ continue ;
330
+ }
331
+
324
332
if attr_name. as_text ( ) . as_deref ( ) == Some ( "rustc_coherence_is_core" ) {
325
333
self . def_map . rustc_coherence_is_core = true ;
326
334
continue ;
@@ -359,6 +367,8 @@ impl DefCollector<'_> {
359
367
}
360
368
}
361
369
370
+ self . inject_prelude ( ) ;
371
+
362
372
ModCollector {
363
373
def_collector : self ,
364
374
macro_depth : 0 ,
@@ -517,15 +527,15 @@ impl DefCollector<'_> {
517
527
}
518
528
}
519
529
520
- fn inject_prelude ( & mut self , crate_attrs : & Attrs ) {
530
+ fn inject_prelude ( & mut self ) {
521
531
// See compiler/rustc_builtin_macros/src/standard_library_imports.rs
522
532
523
- if crate_attrs . by_key ( "no_core" ) . exists ( ) {
533
+ if self . def_map . no_core {
524
534
// libcore does not get a prelude.
525
535
return ;
526
536
}
527
537
528
- let krate = if crate_attrs . by_key ( "no_std" ) . exists ( ) {
538
+ let krate = if self . def_map . no_std {
529
539
name ! [ core]
530
540
} else {
531
541
let std = name ! [ std] ;
0 commit comments