@@ -33,8 +33,7 @@ use std::ops::Deref;
33
33
use std:: path:: PathBuf ;
34
34
use std:: { cmp, fs} ;
35
35
36
- use syntax:: ast;
37
- use syntax:: attr;
36
+ use syntax:: { ast, attr} ;
38
37
use syntax:: ext:: base:: SyntaxExtension ;
39
38
use syntax:: symbol:: Symbol ;
40
39
use syntax:: visit;
@@ -57,9 +56,9 @@ pub struct CrateLoader<'a> {
57
56
fn dump_crates ( cstore : & CStore ) {
58
57
info ! ( "resolved crates:" ) ;
59
58
cstore. iter_crate_data ( |_, data| {
60
- info ! ( " name: {}" , data. name( ) ) ;
59
+ info ! ( " name: {}" , data. root . name) ;
61
60
info ! ( " cnum: {}" , data. cnum) ;
62
- info ! ( " hash: {}" , data. hash( ) ) ;
61
+ info ! ( " hash: {}" , data. root . hash) ;
63
62
info ! ( " reqd: {:?}" , * data. dep_kind. lock( ) ) ;
64
63
let CrateSource { dylib, rlib, rmeta } = data. source . clone ( ) ;
65
64
dylib. map ( |dl| info ! ( " dylib: {}" , dl. 0 . display( ) ) ) ;
@@ -112,7 +111,7 @@ impl<'a> CrateLoader<'a> {
112
111
if data. name != name { return }
113
112
114
113
match hash {
115
- Some ( hash) if * hash == data. hash ( ) => { ret = Some ( cnum) ; return }
114
+ Some ( hash) if * hash == data. root . hash => { ret = Some ( cnum) ; return }
116
115
Some ( ..) => return ,
117
116
None => { }
118
117
}
@@ -171,9 +170,9 @@ impl<'a> CrateLoader<'a> {
171
170
172
171
// Check for conflicts with any crate loaded so far
173
172
self . cstore . iter_crate_data ( |_, other| {
174
- if other. name ( ) == root. name && // same crate-name
175
- other. disambiguator ( ) == root. disambiguator && // same crate-disambiguator
176
- other. hash ( ) != root. hash { // but different SVH
173
+ if other. root . name == root. name && // same crate-name
174
+ other. root . disambiguator == root. disambiguator && // same crate-disambiguator
175
+ other. root . hash != root. hash { // but different SVH
177
176
span_fatal ! ( self . sess, span, E0523 ,
178
177
"found two different crates with name `{}` that are \
179
178
not distinguished by differing `-C metadata`. This \
@@ -213,7 +212,6 @@ impl<'a> CrateLoader<'a> {
213
212
let root = if root. is_some ( ) { root } else { & crate_paths } ;
214
213
215
214
let Library { dylib, rlib, rmeta, metadata } = lib;
216
-
217
215
let cnum_map = self . resolve_crate_deps ( root, & crate_root, & metadata, cnum, span, dep_kind) ;
218
216
219
217
let dependencies: Vec < CrateNum > = cnum_map. iter ( ) . cloned ( ) . collect ( ) ;
@@ -242,13 +240,12 @@ impl<'a> CrateLoader<'a> {
242
240
cnum,
243
241
dependencies : Lock :: new ( dependencies) ,
244
242
codemap_import_info : RwLock :: new ( vec ! [ ] ) ,
245
- attribute_cache : Lock :: new ( [ Vec :: new ( ) , Vec :: new ( ) ] ) ,
246
243
dep_kind : Lock :: new ( dep_kind) ,
247
244
source : cstore:: CrateSource {
248
245
dylib,
249
246
rlib,
250
247
rmeta,
251
- } ,
248
+ }
252
249
} ;
253
250
254
251
let cmeta = Lrc :: new ( cmeta) ;
@@ -344,7 +341,7 @@ impl<'a> CrateLoader<'a> {
344
341
if locate_ctxt. triple == & self . sess . opts . target_triple {
345
342
let mut result = LoadResult :: Loaded ( library) ;
346
343
self . cstore . iter_crate_data ( |cnum, data| {
347
- if data. name ( ) == root. name && root. hash == data. hash ( ) {
344
+ if data. root . name == root. name && root. hash == data. root . hash {
348
345
assert ! ( locate_ctxt. hash. is_none( ) ) ;
349
346
info ! ( "load success, going to previous cnum: {}" , cnum) ;
350
347
result = LoadResult :: Previous ( cnum) ;
@@ -636,15 +633,14 @@ impl<'a> CrateLoader<'a> {
636
633
let mut needs_panic_runtime = attr:: contains_name ( & krate. attrs ,
637
634
"needs_panic_runtime" ) ;
638
635
639
- let sess = self . sess ;
640
636
self . cstore . iter_crate_data ( |cnum, data| {
641
637
needs_panic_runtime = needs_panic_runtime ||
642
- data. needs_panic_runtime ( sess ) ;
643
- if data. is_panic_runtime ( sess ) {
638
+ data. root . needs_panic_runtime ;
639
+ if data. root . panic_runtime {
644
640
// Inject a dependency from all #![needs_panic_runtime] to this
645
641
// #![panic_runtime] crate.
646
642
self . inject_dependency_if ( cnum, "a panic runtime" ,
647
- & |data| data. needs_panic_runtime ( sess ) ) ;
643
+ & |data| data. root . needs_panic_runtime ) ;
648
644
runtime_found = runtime_found || * data. dep_kind . lock ( ) == DepKind :: Explicit ;
649
645
}
650
646
} ) ;
@@ -681,19 +677,19 @@ impl<'a> CrateLoader<'a> {
681
677
682
678
// Sanity check the loaded crate to ensure it is indeed a panic runtime
683
679
// and the panic strategy is indeed what we thought it was.
684
- if !data. is_panic_runtime ( self . sess ) {
680
+ if !data. root . panic_runtime {
685
681
self . sess . err ( & format ! ( "the crate `{}` is not a panic runtime" ,
686
682
name) ) ;
687
683
}
688
- if data. panic_strategy ( ) != desired_strategy {
684
+ if data. root . panic_strategy != desired_strategy {
689
685
self . sess . err ( & format ! ( "the crate `{}` does not have the panic \
690
686
strategy `{}`",
691
687
name, desired_strategy. desc( ) ) ) ;
692
688
}
693
689
694
690
self . sess . injected_panic_runtime . set ( Some ( cnum) ) ;
695
691
self . inject_dependency_if ( cnum, "a panic runtime" ,
696
- & |data| data. needs_panic_runtime ( self . sess ) ) ;
692
+ & |data| data. root . needs_panic_runtime ) ;
697
693
}
698
694
699
695
fn inject_sanitizer_runtime ( & mut self ) {
@@ -788,7 +784,7 @@ impl<'a> CrateLoader<'a> {
788
784
PathKind :: Crate , dep_kind) ;
789
785
790
786
// Sanity check the loaded crate to ensure it is indeed a sanitizer runtime
791
- if !data. is_sanitizer_runtime ( self . sess ) {
787
+ if !data. root . sanitizer_runtime {
792
788
self . sess . err ( & format ! ( "the crate `{}` is not a sanitizer runtime" ,
793
789
name) ) ;
794
790
}
@@ -811,7 +807,7 @@ impl<'a> CrateLoader<'a> {
811
807
PathKind :: Crate , dep_kind) ;
812
808
813
809
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
814
- if !data. is_profiler_runtime ( self . sess ) {
810
+ if !data. root . profiler_runtime {
815
811
self . sess . err ( & format ! ( "the crate `profiler_builtins` is not \
816
812
a profiler runtime") ) ;
817
813
}
@@ -828,7 +824,7 @@ impl<'a> CrateLoader<'a> {
828
824
let mut needs_allocator = attr:: contains_name ( & krate. attrs ,
829
825
"needs_allocator" ) ;
830
826
self . cstore . iter_crate_data ( |_, data| {
831
- needs_allocator = needs_allocator || data. needs_allocator ( self . sess ) ;
827
+ needs_allocator = needs_allocator || data. root . needs_allocator ;
832
828
} ) ;
833
829
if !needs_allocator {
834
830
self . sess . injected_allocator . set ( None ) ;
@@ -870,7 +866,7 @@ impl<'a> CrateLoader<'a> {
870
866
None
871
867
} ;
872
868
self . cstore . iter_crate_data ( |_, data| {
873
- if !data. has_global_allocator ( ) {
869
+ if !data. root . has_global_allocator {
874
870
return
875
871
}
876
872
match global_allocator {
@@ -879,14 +875,14 @@ impl<'a> CrateLoader<'a> {
879
875
conflicts with this global \
880
876
allocator in: {}",
881
877
other_crate,
882
- data. name( ) ) ) ;
878
+ data. root . name) ) ;
883
879
}
884
880
Some ( None ) => {
885
881
self . sess . err ( & format ! ( "the #[global_allocator] in this \
886
882
crate conflicts with global \
887
- allocator in: {}", data. name( ) ) ) ;
883
+ allocator in: {}", data. root . name) ) ;
888
884
}
889
- None => global_allocator = Some ( Some ( data. name ( ) ) ) ,
885
+ None => global_allocator = Some ( Some ( data. root . name ) ) ,
890
886
}
891
887
} ) ;
892
888
if global_allocator. is_some ( ) {
@@ -948,7 +944,7 @@ impl<'a> CrateLoader<'a> {
948
944
// error.
949
945
let mut allocator = None ;
950
946
self . cstore . iter_crate_data ( |_, data| {
951
- if allocator. is_none ( ) && data. has_default_lib_allocator ( ) {
947
+ if allocator. is_none ( ) && data. root . has_default_lib_allocator {
952
948
allocator = Some ( data. clone ( ) ) ;
953
949
}
954
950
} ) ;
@@ -1024,9 +1020,9 @@ impl<'a> CrateLoader<'a> {
1024
1020
self . sess . err ( & format ! ( "the crate `{}` cannot depend \
1025
1021
on a crate that needs {}, but \
1026
1022
it depends on `{}`",
1027
- self . cstore. get_crate_data( krate) . name( ) ,
1023
+ self . cstore. get_crate_data( krate) . root . name,
1028
1024
what,
1029
- data. name( ) ) ) ;
1025
+ data. root . name) ) ;
1030
1026
}
1031
1027
}
1032
1028
0 commit comments