@@ -206,8 +206,8 @@ impl CStore {
206
206
207
207
fn intern_stable_crate_id < ' tcx > (
208
208
& mut self ,
209
- root : & CrateRoot ,
210
209
tcx : TyCtxt < ' tcx > ,
210
+ root : & CrateRoot ,
211
211
) -> Result < TyCtxtFeed < ' tcx , CrateNum > , CrateError > {
212
212
assert_eq ! ( self . metas. len( ) , tcx. untracked( ) . stable_crate_ids. read( ) . len( ) ) ;
213
213
let num = tcx. create_crate_num ( root. stable_crate_id ( ) ) . map_err ( |existing| {
@@ -480,10 +480,10 @@ impl CStore {
480
480
481
481
fn existing_match (
482
482
& self ,
483
+ tcx : TyCtxt < ' _ > ,
483
484
name : Symbol ,
484
485
hash : Option < Svh > ,
485
486
kind : PathKind ,
486
- tcx : TyCtxt < ' _ > ,
487
487
) -> Option < CrateNum > {
488
488
for ( cnum, data) in self . iter_crate_data ( ) {
489
489
if data. name ( ) != name {
@@ -563,10 +563,10 @@ impl CStore {
563
563
/// command parameter is set to `public-dependency`
564
564
fn is_private_dep < ' tcx > (
565
565
& self ,
566
+ tcx : TyCtxt < ' tcx > ,
566
567
name : Symbol ,
567
568
private_dep : Option < bool > ,
568
569
origin : CrateOrigin < ' _ > ,
569
- tcx : TyCtxt < ' tcx > ,
570
570
) -> bool {
571
571
if matches ! ( origin, CrateOrigin :: Injected ) {
572
572
return true ;
@@ -584,24 +584,24 @@ impl CStore {
584
584
585
585
fn register_crate < ' tcx > (
586
586
& mut self ,
587
+ tcx : TyCtxt < ' tcx > ,
587
588
host_lib : Option < Library > ,
588
589
origin : CrateOrigin < ' _ > ,
589
590
lib : Library ,
590
591
dep_kind : CrateDepKind ,
591
592
name : Symbol ,
592
593
private_dep : Option < bool > ,
593
- tcx : TyCtxt < ' tcx > ,
594
594
) -> Result < CrateNum , CrateError > {
595
595
let _prof_timer =
596
596
tcx. sess . prof . generic_activity_with_arg ( "metadata_register_crate" , name. as_str ( ) ) ;
597
597
598
598
let Library { source, metadata } = lib;
599
599
let crate_root = metadata. get_root ( ) ;
600
600
let host_hash = host_lib. as_ref ( ) . map ( |lib| lib. metadata . get_root ( ) . hash ( ) ) ;
601
- let private_dep = self . is_private_dep ( name, private_dep, origin, tcx ) ;
601
+ let private_dep = self . is_private_dep ( tcx , name, private_dep, origin) ;
602
602
603
603
// Claim this crate number and cache it
604
- let feed = self . intern_stable_crate_id ( & crate_root , tcx ) ?;
604
+ let feed = self . intern_stable_crate_id ( tcx , & crate_root ) ?;
605
605
let cnum = feed. key ( ) ;
606
606
607
607
info ! (
@@ -622,13 +622,13 @@ impl CStore {
622
622
} ;
623
623
624
624
let cnum_map = self . resolve_crate_deps (
625
+ tcx,
625
626
dep_root,
626
627
& crate_root,
627
628
& metadata,
628
629
cnum,
629
630
dep_kind,
630
631
private_dep,
631
- tcx,
632
632
) ?;
633
633
634
634
let raw_proc_macros = if crate_root. is_proc_macro_crate ( ) {
@@ -641,7 +641,7 @@ impl CStore {
641
641
None => ( & source, & crate_root) ,
642
642
} ;
643
643
let dlsym_dylib = dlsym_source. dylib . as_ref ( ) . expect ( "no dylib for a proc-macro crate" ) ;
644
- Some ( self . dlsym_proc_macros ( & dlsym_dylib. 0 , dlsym_root. stable_crate_id ( ) , tcx ) ?)
644
+ Some ( self . dlsym_proc_macros ( tcx , & dlsym_dylib. 0 , dlsym_root. stable_crate_id ( ) ) ?)
645
645
} else {
646
646
None
647
647
} ;
@@ -667,11 +667,11 @@ impl CStore {
667
667
668
668
fn load_proc_macro < ' b , ' tcx > (
669
669
& self ,
670
+ tcx : TyCtxt < ' tcx > ,
670
671
locator : & mut CrateLocator < ' b > ,
671
672
crate_rejections : & mut CrateRejections ,
672
673
path_kind : PathKind ,
673
674
host_hash : Option < Svh > ,
674
- tcx : TyCtxt < ' tcx > ,
675
675
) -> Result < Option < ( LoadResult , Option < Library > ) > , CrateError >
676
676
where
677
677
' tcx : ' b ,
@@ -734,14 +734,14 @@ impl CStore {
734
734
735
735
fn resolve_crate < ' tcx > (
736
736
& mut self ,
737
+ tcx : TyCtxt < ' tcx > ,
737
738
name : Symbol ,
738
739
span : Span ,
739
740
dep_kind : CrateDepKind ,
740
741
origin : CrateOrigin < ' _ > ,
741
- tcx : TyCtxt < ' tcx > ,
742
742
) -> Option < CrateNum > {
743
743
self . used_extern_options . insert ( name) ;
744
- match self . maybe_resolve_crate ( name, dep_kind, origin, tcx ) {
744
+ match self . maybe_resolve_crate ( tcx , name, dep_kind, origin) {
745
745
Ok ( cnum) => {
746
746
self . set_used_recursively ( cnum) ;
747
747
Some ( cnum)
@@ -750,10 +750,10 @@ impl CStore {
750
750
debug ! ( "failed to resolve crate {} {:?}" , name, dep_kind) ;
751
751
let missing_core = self
752
752
. maybe_resolve_crate (
753
+ tcx,
753
754
sym:: core,
754
755
CrateDepKind :: Explicit ,
755
756
CrateOrigin :: Extern ,
756
- tcx,
757
757
)
758
758
. is_err ( ) ;
759
759
err. report ( tcx. sess , span, missing_core) ;
@@ -764,10 +764,10 @@ impl CStore {
764
764
765
765
fn maybe_resolve_crate < ' b , ' tcx > (
766
766
& ' b mut self ,
767
+ tcx : TyCtxt < ' tcx > ,
767
768
name : Symbol ,
768
769
mut dep_kind : CrateDepKind ,
769
770
origin : CrateOrigin < ' b > ,
770
- tcx : TyCtxt < ' tcx > ,
771
771
) -> Result < CrateNum , CrateError > {
772
772
info ! ( "resolving crate `{}`" , name) ;
773
773
if !name. as_str ( ) . is_ascii ( ) {
@@ -782,7 +782,7 @@ impl CStore {
782
782
let path_kind = if dep. is_some ( ) { PathKind :: Dependency } else { PathKind :: Crate } ;
783
783
let private_dep = origin. private_dep ( ) ;
784
784
785
- let result = if let Some ( cnum) = self . existing_match ( name, hash, path_kind, tcx ) {
785
+ let result = if let Some ( cnum) = self . existing_match ( tcx , name, hash, path_kind) {
786
786
( LoadResult :: Previous ( cnum) , None )
787
787
} else {
788
788
info ! ( "falling back to a load" ) ;
@@ -805,11 +805,11 @@ impl CStore {
805
805
info ! ( "falling back to loading proc_macro" ) ;
806
806
dep_kind = CrateDepKind :: MacrosOnly ;
807
807
match self . load_proc_macro (
808
+ tcx,
808
809
& mut locator,
809
810
& mut crate_rejections,
810
811
path_kind,
811
812
host_hash,
812
- tcx,
813
813
) ? {
814
814
Some ( res) => res,
815
815
None => return Err ( locator. into_error ( crate_rejections, dep_root. cloned ( ) ) ) ,
@@ -825,7 +825,7 @@ impl CStore {
825
825
// not specified by `--extern` on command line parameters, it may be
826
826
// `private-dependency` when `register_crate` is called for the first time. Then it must be updated to
827
827
// `public-dependency` here.
828
- let private_dep = self . is_private_dep ( name, private_dep, origin, tcx ) ;
828
+ let private_dep = self . is_private_dep ( tcx , name, private_dep, origin) ;
829
829
let data = self . get_crate_data_mut ( cnum) ;
830
830
if data. is_proc_macro_crate ( ) {
831
831
dep_kind = CrateDepKind :: MacrosOnly ;
@@ -836,7 +836,7 @@ impl CStore {
836
836
}
837
837
( LoadResult :: Loaded ( library) , host_library) => {
838
838
info ! ( "register newly loaded library for `{}`" , name) ;
839
- self . register_crate ( host_library, origin, library, dep_kind, name, private_dep, tcx )
839
+ self . register_crate ( tcx , host_library, origin, library, dep_kind, name, private_dep)
840
840
}
841
841
_ => panic ! ( ) ,
842
842
}
@@ -871,13 +871,13 @@ impl CStore {
871
871
/// Go through the crate metadata and load any crates that it references.
872
872
fn resolve_crate_deps (
873
873
& mut self ,
874
+ tcx : TyCtxt < ' _ > ,
874
875
dep_root : & CratePaths ,
875
876
crate_root : & CrateRoot ,
876
877
metadata : & MetadataBlob ,
877
878
krate : CrateNum ,
878
879
dep_kind : CrateDepKind ,
879
880
parent_is_private : bool ,
880
- tcx : TyCtxt < ' _ > ,
881
881
) -> Result < CrateNumMap , CrateError > {
882
882
debug ! (
883
883
"resolving deps of external crate `{}` with dep root `{}`" ,
@@ -908,14 +908,14 @@ impl CStore {
908
908
_ => dep. kind ,
909
909
} ;
910
910
let cnum = self . maybe_resolve_crate (
911
+ tcx,
911
912
dep. name ,
912
913
dep_kind,
913
914
CrateOrigin :: IndirectDependency {
914
915
dep_root,
915
916
parent_private : parent_is_private,
916
917
dep : & dep,
917
918
} ,
918
- tcx,
919
919
) ?;
920
920
crate_num_map. push ( cnum) ;
921
921
}
@@ -926,9 +926,9 @@ impl CStore {
926
926
927
927
fn dlsym_proc_macros < ' tcx > (
928
928
& self ,
929
+ tcx : TyCtxt < ' tcx > ,
929
930
path : & Path ,
930
931
stable_crate_id : StableCrateId ,
931
- tcx : TyCtxt < ' tcx > ,
932
932
) -> Result < & ' static [ ProcMacro ] , CrateError > {
933
933
let sym_name = tcx. sess . generate_proc_macro_decls_symbol ( stable_crate_id) ;
934
934
debug ! ( "trying to dlsym proc_macros {} for symbol `{}`" , path. display( ) , sym_name) ;
@@ -952,7 +952,7 @@ impl CStore {
952
952
}
953
953
}
954
954
955
- fn inject_panic_runtime ( & mut self , krate : & ast :: Crate , tcx : TyCtxt < ' _ > ) {
955
+ fn inject_panic_runtime ( & mut self , tcx : TyCtxt < ' _ > , krate : & ast :: Crate ) {
956
956
// If we're only compiling an rlib, then there's no need to select a
957
957
// panic runtime, so we just skip this section entirely.
958
958
let only_rlib = tcx. crate_types ( ) . iter ( ) . all ( |ct| * ct == CrateType :: Rlib ) ;
@@ -992,7 +992,7 @@ impl CStore {
992
992
info ! ( "panic runtime not found -- loading {}" , name) ;
993
993
994
994
let Some ( cnum) =
995
- self . resolve_crate ( name, DUMMY_SP , CrateDepKind :: Implicit , CrateOrigin :: Injected , tcx )
995
+ self . resolve_crate ( tcx , name, DUMMY_SP , CrateDepKind :: Implicit , CrateOrigin :: Injected )
996
996
else {
997
997
return ;
998
998
} ;
@@ -1022,7 +1022,7 @@ impl CStore {
1022
1022
1023
1023
let name = Symbol :: intern ( & tcx. sess . opts . unstable_opts . profiler_runtime ) ;
1024
1024
let Some ( cnum) =
1025
- self . resolve_crate ( name, DUMMY_SP , CrateDepKind :: Implicit , CrateOrigin :: Injected , tcx )
1025
+ self . resolve_crate ( tcx , name, DUMMY_SP , CrateDepKind :: Implicit , CrateOrigin :: Injected )
1026
1026
else {
1027
1027
return ;
1028
1028
} ;
@@ -1034,7 +1034,7 @@ impl CStore {
1034
1034
}
1035
1035
}
1036
1036
1037
- fn inject_allocator_crate ( & mut self , krate : & ast :: Crate , tcx : TyCtxt < ' _ > ) {
1037
+ fn inject_allocator_crate ( & mut self , tcx : TyCtxt < ' _ > , krate : & ast :: Crate ) {
1038
1038
self . has_global_allocator =
1039
1039
match & * fn_spans ( krate, Symbol :: intern ( & global_fn_name ( sym:: alloc) ) ) {
1040
1040
[ span1, span2, ..] => {
@@ -1142,19 +1142,19 @@ impl CStore {
1142
1142
let name_interned = Symbol :: intern ( name) ;
1143
1143
if !self . used_extern_options . contains ( & name_interned) {
1144
1144
self . resolve_crate (
1145
+ tcx,
1145
1146
name_interned,
1146
1147
DUMMY_SP ,
1147
1148
CrateDepKind :: Explicit ,
1148
1149
CrateOrigin :: Extern ,
1149
- tcx,
1150
1150
) ;
1151
1151
}
1152
1152
}
1153
1153
}
1154
1154
}
1155
1155
1156
1156
/// Inject the `compiler_builtins` crate if it is not already in the graph.
1157
- fn inject_compiler_builtins ( & mut self , krate : & ast :: Crate , tcx : TyCtxt < ' _ > ) {
1157
+ fn inject_compiler_builtins ( & mut self , tcx : TyCtxt < ' _ > , krate : & ast :: Crate ) {
1158
1158
// `compiler_builtins` does not get extern builtins, nor do `#![no_core]` crates
1159
1159
if attr:: contains_name ( & krate. attrs , sym:: compiler_builtins)
1160
1160
|| attr:: contains_name ( & krate. attrs , sym:: no_core)
@@ -1174,11 +1174,11 @@ impl CStore {
1174
1174
1175
1175
// `compiler_builtins` is not yet in the graph; inject it. Error on resolution failure.
1176
1176
let Some ( cnum) = self . resolve_crate (
1177
+ tcx,
1177
1178
sym:: compiler_builtins,
1178
1179
krate. spans . inner_span . shrink_to_lo ( ) ,
1179
1180
CrateDepKind :: Explicit ,
1180
1181
CrateOrigin :: Injected ,
1181
- tcx,
1182
1182
) else {
1183
1183
info ! ( "`compiler_builtins` not resolved" ) ;
1184
1184
return ;
@@ -1191,7 +1191,7 @@ impl CStore {
1191
1191
}
1192
1192
}
1193
1193
1194
- fn report_unused_deps_in_crate ( & mut self , krate : & ast :: Crate , tcx : TyCtxt < ' _ > ) {
1194
+ fn report_unused_deps_in_crate ( & mut self , tcx : TyCtxt < ' _ > , krate : & ast :: Crate ) {
1195
1195
// Make a point span rather than covering the whole file
1196
1196
let span = krate. spans . inner_span . shrink_to_lo ( ) ;
1197
1197
// Complain about anything left over
@@ -1227,7 +1227,7 @@ impl CStore {
1227
1227
}
1228
1228
}
1229
1229
1230
- fn report_future_incompatible_deps ( & self , krate : & ast :: Crate , tcx : TyCtxt < ' _ > ) {
1230
+ fn report_future_incompatible_deps ( & self , tcx : TyCtxt < ' _ > , krate : & ast :: Crate ) {
1231
1231
let name = tcx. crate_name ( LOCAL_CRATE ) ;
1232
1232
1233
1233
if name. as_str ( ) == "wasm_bindgen" {
@@ -1260,26 +1260,26 @@ impl CStore {
1260
1260
}
1261
1261
}
1262
1262
1263
- pub fn postprocess ( & mut self , krate : & ast :: Crate , tcx : TyCtxt < ' _ > ) {
1264
- self . inject_compiler_builtins ( krate , tcx ) ;
1263
+ pub fn postprocess ( & mut self , tcx : TyCtxt < ' _ > , krate : & ast :: Crate ) {
1264
+ self . inject_compiler_builtins ( tcx , krate ) ;
1265
1265
self . inject_forced_externs ( tcx) ;
1266
1266
self . inject_profiler_runtime ( tcx) ;
1267
- self . inject_allocator_crate ( krate , tcx ) ;
1268
- self . inject_panic_runtime ( krate , tcx ) ;
1267
+ self . inject_allocator_crate ( tcx , krate ) ;
1268
+ self . inject_panic_runtime ( tcx , krate ) ;
1269
1269
1270
- self . report_unused_deps_in_crate ( krate , tcx ) ;
1271
- self . report_future_incompatible_deps ( krate , tcx ) ;
1270
+ self . report_unused_deps_in_crate ( tcx , krate ) ;
1271
+ self . report_future_incompatible_deps ( tcx , krate ) ;
1272
1272
1273
1273
info ! ( "{:?}" , CrateDump ( self ) ) ;
1274
1274
}
1275
1275
1276
1276
/// Process an `extern crate foo` AST node.
1277
1277
pub fn process_extern_crate (
1278
1278
& mut self ,
1279
+ tcx : TyCtxt < ' _ > ,
1279
1280
item : & ast:: Item ,
1280
1281
def_id : LocalDefId ,
1281
1282
definitions : & Definitions ,
1282
- tcx : TyCtxt < ' _ > ,
1283
1283
) -> Option < CrateNum > {
1284
1284
match item. kind {
1285
1285
ast:: ItemKind :: ExternCrate ( orig_name, ident) => {
@@ -1298,7 +1298,7 @@ impl CStore {
1298
1298
} ;
1299
1299
1300
1300
let cnum =
1301
- self . resolve_crate ( name, item. span , dep_kind, CrateOrigin :: Extern , tcx ) ?;
1301
+ self . resolve_crate ( tcx , name, item. span , dep_kind, CrateOrigin :: Extern ) ?;
1302
1302
1303
1303
let path_len = definitions. def_path ( def_id) . data . len ( ) ;
1304
1304
self . update_extern_crate (
@@ -1318,12 +1318,12 @@ impl CStore {
1318
1318
1319
1319
pub fn process_path_extern (
1320
1320
& mut self ,
1321
+ tcx : TyCtxt < ' _ > ,
1321
1322
name : Symbol ,
1322
1323
span : Span ,
1323
- tcx : TyCtxt < ' _ > ,
1324
1324
) -> Option < CrateNum > {
1325
1325
let cnum =
1326
- self . resolve_crate ( name, span, CrateDepKind :: Explicit , CrateOrigin :: Extern , tcx ) ?;
1326
+ self . resolve_crate ( tcx , name, span, CrateDepKind :: Explicit , CrateOrigin :: Extern ) ?;
1327
1327
1328
1328
self . update_extern_crate (
1329
1329
cnum,
@@ -1339,8 +1339,8 @@ impl CStore {
1339
1339
Some ( cnum)
1340
1340
}
1341
1341
1342
- pub fn maybe_process_path_extern ( & mut self , name : Symbol , tcx : TyCtxt < ' _ > ) -> Option < CrateNum > {
1343
- self . maybe_resolve_crate ( name, CrateDepKind :: Explicit , CrateOrigin :: Extern , tcx ) . ok ( )
1342
+ pub fn maybe_process_path_extern ( & mut self , tcx : TyCtxt < ' _ > , name : Symbol ) -> Option < CrateNum > {
1343
+ self . maybe_resolve_crate ( tcx , name, CrateDepKind :: Explicit , CrateOrigin :: Extern ) . ok ( )
1344
1344
}
1345
1345
}
1346
1346
0 commit comments