11
11
//! Validates all used crates and extern libraries and loads their metadata
12
12
13
13
use cstore:: { self , CStore , CrateSource , MetadataBlob } ;
14
- use decoder:: Metadata ;
15
14
use locator:: { self , CratePaths } ;
16
15
use schema:: CrateRoot ;
17
16
use rustc_data_structures:: sync:: { Lrc , RwLock , Lock } ;
@@ -221,17 +220,6 @@ impl<'a> CrateLoader<'a> {
221
220
crate_root. def_path_table . decode ( ( & metadata, self . sess ) )
222
221
} ) ;
223
222
224
- let crate_entry = crate_root
225
- . index
226
- . lookup ( metadata. raw_bytes ( ) , CRATE_DEF_INDEX )
227
- . unwrap ( )
228
- . decode ( & metadata) ;
229
-
230
- let crate_attrs: Vec < ast:: Attribute > = crate_entry
231
- . attributes
232
- . decode ( ( & metadata, self . sess ) )
233
- . collect ( ) ;
234
-
235
223
let trait_impls = crate_root
236
224
. impls
237
225
. decode ( ( & metadata, self . sess ) )
@@ -257,14 +245,7 @@ impl<'a> CrateLoader<'a> {
257
245
dylib,
258
246
rlib,
259
247
rmeta,
260
- } ,
261
- compiler_builtins : attr:: contains_name ( & crate_attrs, "compiler_builtins" ) ,
262
- needs_allocator : attr:: contains_name ( & crate_attrs, "needs_allocator" ) ,
263
- needs_panic_runtime : attr:: contains_name ( & crate_attrs, "needs_panic_runtime" ) ,
264
- no_builtins : attr:: contains_name ( & crate_attrs, "no_builtins" ) ,
265
- panic_runtime : attr:: contains_name ( & crate_attrs, "panic_runtime" ) ,
266
- profiler_runtime : attr:: contains_name ( & crate_attrs, "profiler_runtime" ) ,
267
- sanitizer_runtime : attr:: contains_name ( & crate_attrs, "sanitizer_runtime" ) ,
248
+ }
268
249
} ;
269
250
270
251
let cmeta = Lrc :: new ( cmeta) ;
@@ -654,12 +635,12 @@ impl<'a> CrateLoader<'a> {
654
635
655
636
self . cstore . iter_crate_data ( |cnum, data| {
656
637
needs_panic_runtime = needs_panic_runtime ||
657
- data. needs_panic_runtime ;
658
- if data. panic_runtime {
638
+ data. needs_panic_runtime ( ) ;
639
+ if data. is_panic_runtime ( ) {
659
640
// Inject a dependency from all #![needs_panic_runtime] to this
660
641
// #![panic_runtime] crate.
661
642
self . inject_dependency_if ( cnum, "a panic runtime" ,
662
- & |data| data. needs_panic_runtime ) ;
643
+ & |data| data. needs_panic_runtime ( ) ) ;
663
644
runtime_found = runtime_found || * data. dep_kind . lock ( ) == DepKind :: Explicit ;
664
645
}
665
646
} ) ;
@@ -696,7 +677,7 @@ impl<'a> CrateLoader<'a> {
696
677
697
678
// Sanity check the loaded crate to ensure it is indeed a panic runtime
698
679
// and the panic strategy is indeed what we thought it was.
699
- if !data. panic_runtime {
680
+ if !data. is_panic_runtime ( ) {
700
681
self . sess . err ( & format ! ( "the crate `{}` is not a panic runtime" ,
701
682
name) ) ;
702
683
}
@@ -708,7 +689,7 @@ impl<'a> CrateLoader<'a> {
708
689
709
690
self . sess . injected_panic_runtime . set ( Some ( cnum) ) ;
710
691
self . inject_dependency_if ( cnum, "a panic runtime" ,
711
- & |data| data. needs_panic_runtime ) ;
692
+ & |data| data. needs_panic_runtime ( ) ) ;
712
693
}
713
694
714
695
fn inject_sanitizer_runtime ( & mut self ) {
@@ -803,7 +784,7 @@ impl<'a> CrateLoader<'a> {
803
784
PathKind :: Crate , dep_kind) ;
804
785
805
786
// Sanity check the loaded crate to ensure it is indeed a sanitizer runtime
806
- if !data. sanitizer_runtime {
787
+ if !data. is_sanitizer_runtime ( ) {
807
788
self . sess . err ( & format ! ( "the crate `{}` is not a sanitizer runtime" ,
808
789
name) ) ;
809
790
}
@@ -826,7 +807,7 @@ impl<'a> CrateLoader<'a> {
826
807
PathKind :: Crate , dep_kind) ;
827
808
828
809
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
829
- if !data. profiler_runtime {
810
+ if !data. is_profiler_runtime ( ) {
830
811
self . sess . err ( & format ! ( "the crate `profiler_builtins` is not \
831
812
a profiler runtime") ) ;
832
813
}
@@ -843,7 +824,7 @@ impl<'a> CrateLoader<'a> {
843
824
let mut needs_allocator = attr:: contains_name ( & krate. attrs ,
844
825
"needs_allocator" ) ;
845
826
self . cstore . iter_crate_data ( |_, data| {
846
- needs_allocator = needs_allocator || data. needs_allocator ;
827
+ needs_allocator = needs_allocator || data. needs_allocator ( ) ;
847
828
} ) ;
848
829
if !needs_allocator {
849
830
self . sess . injected_allocator . set ( None ) ;
0 commit comments