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 } ;
@@ -223,17 +222,6 @@ impl<'a> CrateLoader<'a> {
223
222
crate_root. def_path_table . decode ( ( & metadata, self . sess ) )
224
223
} ) ;
225
224
226
- let crate_entry = crate_root
227
- . index
228
- . lookup ( metadata. raw_bytes ( ) , CRATE_DEF_INDEX )
229
- . unwrap ( )
230
- . decode ( & metadata) ;
231
-
232
- let crate_attrs: Vec < ast:: Attribute > = crate_entry
233
- . attributes
234
- . decode ( ( & metadata, self . sess ) )
235
- . collect ( ) ;
236
-
237
225
let trait_impls = crate_root
238
226
. impls
239
227
. decode ( ( & metadata, self . sess ) )
@@ -259,14 +247,7 @@ impl<'a> CrateLoader<'a> {
259
247
dylib,
260
248
rlib,
261
249
rmeta,
262
- } ,
263
- compiler_builtins : attr:: contains_name ( & crate_attrs, "compiler_builtins" ) ,
264
- needs_allocator : attr:: contains_name ( & crate_attrs, "needs_allocator" ) ,
265
- needs_panic_runtime : attr:: contains_name ( & crate_attrs, "needs_panic_runtime" ) ,
266
- no_builtins : attr:: contains_name ( & crate_attrs, "no_builtins" ) ,
267
- panic_runtime : attr:: contains_name ( & crate_attrs, "panic_runtime" ) ,
268
- profiler_runtime : attr:: contains_name ( & crate_attrs, "profiler_runtime" ) ,
269
- sanitizer_runtime : attr:: contains_name ( & crate_attrs, "sanitizer_runtime" ) ,
250
+ }
270
251
} ;
271
252
272
253
let cmeta = Lrc :: new ( cmeta) ;
@@ -661,12 +642,12 @@ impl<'a> CrateLoader<'a> {
661
642
662
643
self . cstore . iter_crate_data ( |cnum, data| {
663
644
needs_panic_runtime = needs_panic_runtime ||
664
- data. needs_panic_runtime ;
665
- if data. panic_runtime {
645
+ data. needs_panic_runtime ( ) ;
646
+ if data. is_panic_runtime ( ) {
666
647
// Inject a dependency from all #![needs_panic_runtime] to this
667
648
// #![panic_runtime] crate.
668
649
self . inject_dependency_if ( cnum, "a panic runtime" ,
669
- & |data| data. needs_panic_runtime ) ;
650
+ & |data| data. needs_panic_runtime ( ) ) ;
670
651
runtime_found = runtime_found || * data. dep_kind . lock ( ) == DepKind :: Explicit ;
671
652
}
672
653
} ) ;
@@ -703,7 +684,7 @@ impl<'a> CrateLoader<'a> {
703
684
704
685
// Sanity check the loaded crate to ensure it is indeed a panic runtime
705
686
// and the panic strategy is indeed what we thought it was.
706
- if !data. panic_runtime {
687
+ if !data. is_panic_runtime ( ) {
707
688
self . sess . err ( & format ! ( "the crate `{}` is not a panic runtime" ,
708
689
name) ) ;
709
690
}
@@ -715,7 +696,7 @@ impl<'a> CrateLoader<'a> {
715
696
716
697
self . sess . injected_panic_runtime . set ( Some ( cnum) ) ;
717
698
self . inject_dependency_if ( cnum, "a panic runtime" ,
718
- & |data| data. needs_panic_runtime ) ;
699
+ & |data| data. needs_panic_runtime ( ) ) ;
719
700
}
720
701
721
702
fn inject_sanitizer_runtime ( & mut self ) {
@@ -810,7 +791,7 @@ impl<'a> CrateLoader<'a> {
810
791
PathKind :: Crate , dep_kind) ;
811
792
812
793
// Sanity check the loaded crate to ensure it is indeed a sanitizer runtime
813
- if !data. sanitizer_runtime {
794
+ if !data. is_sanitizer_runtime ( ) {
814
795
self . sess . err ( & format ! ( "the crate `{}` is not a sanitizer runtime" ,
815
796
name) ) ;
816
797
}
@@ -833,7 +814,7 @@ impl<'a> CrateLoader<'a> {
833
814
PathKind :: Crate , dep_kind) ;
834
815
835
816
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
836
- if !data. profiler_runtime {
817
+ if !data. is_profiler_runtime ( ) {
837
818
self . sess . err ( & format ! ( "the crate `profiler_builtins` is not \
838
819
a profiler runtime") ) ;
839
820
}
@@ -850,7 +831,7 @@ impl<'a> CrateLoader<'a> {
850
831
let mut needs_allocator = attr:: contains_name ( & krate. attrs ,
851
832
"needs_allocator" ) ;
852
833
self . cstore . iter_crate_data ( |_, data| {
853
- needs_allocator = needs_allocator || data. needs_allocator ;
834
+ needs_allocator = needs_allocator || data. needs_allocator ( ) ;
854
835
} ) ;
855
836
if !needs_allocator {
856
837
self . sess . injected_allocator . set ( None ) ;
0 commit comments