1111//! Validates all used crates and extern libraries and loads their metadata
1212
1313use cstore:: { self , CStore , CrateSource , MetadataBlob } ;
14- use decoder:: Metadata ;
1514use locator:: { self , CratePaths } ;
1615use schema:: CrateRoot ;
1716use rustc_data_structures:: sync:: { Lrc , RwLock , Lock } ;
@@ -223,17 +222,6 @@ impl<'a> CrateLoader<'a> {
223222 crate_root. def_path_table . decode ( ( & metadata, self . sess ) )
224223 } ) ;
225224
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-
237225 let trait_impls = crate_root
238226 . impls
239227 . decode ( ( & metadata, self . sess ) )
@@ -259,14 +247,7 @@ impl<'a> CrateLoader<'a> {
259247 dylib,
260248 rlib,
261249 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+ }
270251 } ;
271252
272253 let cmeta = Lrc :: new ( cmeta) ;
@@ -661,12 +642,12 @@ impl<'a> CrateLoader<'a> {
661642
662643 self . cstore . iter_crate_data ( |cnum, data| {
663644 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 ( ) {
666647 // Inject a dependency from all #![needs_panic_runtime] to this
667648 // #![panic_runtime] crate.
668649 self . inject_dependency_if ( cnum, "a panic runtime" ,
669- & |data| data. needs_panic_runtime ) ;
650+ & |data| data. needs_panic_runtime ( ) ) ;
670651 runtime_found = runtime_found || * data. dep_kind . lock ( ) == DepKind :: Explicit ;
671652 }
672653 } ) ;
@@ -703,7 +684,7 @@ impl<'a> CrateLoader<'a> {
703684
704685 // Sanity check the loaded crate to ensure it is indeed a panic runtime
705686 // and the panic strategy is indeed what we thought it was.
706- if !data. panic_runtime {
687+ if !data. is_panic_runtime ( ) {
707688 self . sess . err ( & format ! ( "the crate `{}` is not a panic runtime" ,
708689 name) ) ;
709690 }
@@ -715,7 +696,7 @@ impl<'a> CrateLoader<'a> {
715696
716697 self . sess . injected_panic_runtime . set ( Some ( cnum) ) ;
717698 self . inject_dependency_if ( cnum, "a panic runtime" ,
718- & |data| data. needs_panic_runtime ) ;
699+ & |data| data. needs_panic_runtime ( ) ) ;
719700 }
720701
721702 fn inject_sanitizer_runtime ( & mut self ) {
@@ -810,7 +791,7 @@ impl<'a> CrateLoader<'a> {
810791 PathKind :: Crate , dep_kind) ;
811792
812793 // Sanity check the loaded crate to ensure it is indeed a sanitizer runtime
813- if !data. sanitizer_runtime {
794+ if !data. is_sanitizer_runtime ( ) {
814795 self . sess . err ( & format ! ( "the crate `{}` is not a sanitizer runtime" ,
815796 name) ) ;
816797 }
@@ -833,7 +814,7 @@ impl<'a> CrateLoader<'a> {
833814 PathKind :: Crate , dep_kind) ;
834815
835816 // Sanity check the loaded crate to ensure it is indeed a profiler runtime
836- if !data. profiler_runtime {
817+ if !data. is_profiler_runtime ( ) {
837818 self . sess . err ( & format ! ( "the crate `profiler_builtins` is not \
838819 a profiler runtime") ) ;
839820 }
@@ -850,7 +831,7 @@ impl<'a> CrateLoader<'a> {
850831 let mut needs_allocator = attr:: contains_name ( & krate. attrs ,
851832 "needs_allocator" ) ;
852833 self . cstore . iter_crate_data ( |_, data| {
853- needs_allocator = needs_allocator || data. needs_allocator ;
834+ needs_allocator = needs_allocator || data. needs_allocator ( ) ;
854835 } ) ;
855836 if !needs_allocator {
856837 self . sess . injected_allocator . set ( None ) ;
0 commit comments