@@ -397,7 +397,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
397
397
}
398
398
TransItem :: Fn ( instance) => {
399
399
// Keep track of the monomorphization recursion depth
400
- recursion_depth_reset = Some ( check_recursion_limit ( ccx,
400
+ recursion_depth_reset = Some ( check_recursion_limit ( ccx. tcx ( ) ,
401
401
instance,
402
402
recursion_depths) ) ;
403
403
@@ -420,7 +420,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
420
420
}
421
421
}
422
422
423
- record_references ( ccx, starting_point, & neighbors[ ..] , reference_map) ;
423
+ record_references ( ccx. tcx ( ) , starting_point, & neighbors[ ..] , reference_map) ;
424
424
425
425
for neighbour in neighbors {
426
426
collect_items_rec ( ccx, neighbour, visited, recursion_depths, reference_map) ;
@@ -433,23 +433,23 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
433
433
debug ! ( "END collect_items_rec({})" , starting_point. to_string( ccx. tcx( ) ) ) ;
434
434
}
435
435
436
- fn record_references < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
437
- caller : TransItem < ' tcx > ,
438
- callees : & [ TransItem < ' tcx > ] ,
439
- reference_map : & mut ReferenceMap < ' tcx > ) {
436
+ fn record_references < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
437
+ caller : TransItem < ' tcx > ,
438
+ callees : & [ TransItem < ' tcx > ] ,
439
+ reference_map : & mut ReferenceMap < ' tcx > ) {
440
440
let iter = callees. into_iter ( )
441
441
. map ( |callee| {
442
442
let is_inlining_candidate = callee. is_from_extern_crate ( ) ||
443
- callee. requests_inline ( ccx . tcx ( ) ) ;
443
+ callee. requests_inline ( tcx) ;
444
444
( * callee, is_inlining_candidate)
445
445
} ) ;
446
446
reference_map. record_references ( caller, iter) ;
447
447
}
448
448
449
- fn check_recursion_limit < ' a , ' tcx : ' a > ( ccx : & CrateContext < ' a , ' tcx > ,
450
- instance : Instance < ' tcx > ,
451
- recursion_depths : & mut DefIdMap < usize > )
452
- -> ( DefId , usize ) {
449
+ fn check_recursion_limit < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
450
+ instance : Instance < ' tcx > ,
451
+ recursion_depths : & mut DefIdMap < usize > )
452
+ -> ( DefId , usize ) {
453
453
let recursion_depth = recursion_depths. get ( & instance. def )
454
454
. map ( |x| * x)
455
455
. unwrap_or ( 0 ) ;
@@ -458,13 +458,13 @@ fn check_recursion_limit<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
458
458
// Code that needs to instantiate the same function recursively
459
459
// more than the recursion limit is assumed to be causing an
460
460
// infinite expansion.
461
- if recursion_depth > ccx . sess ( ) . recursion_limit . get ( ) {
461
+ if recursion_depth > tcx . sess . recursion_limit . get ( ) {
462
462
let error = format ! ( "reached the recursion limit while instantiating `{}`" ,
463
463
instance) ;
464
- if let Some ( node_id) = ccx . tcx ( ) . map . as_local_node_id ( instance. def ) {
465
- ccx . sess ( ) . span_fatal ( ccx . tcx ( ) . map . span ( node_id) , & error) ;
464
+ if let Some ( node_id) = tcx. map . as_local_node_id ( instance. def ) {
465
+ tcx . sess . span_fatal ( tcx. map . span ( node_id) , & error) ;
466
466
} else {
467
- ccx . sess ( ) . fatal ( & error) ;
467
+ tcx . sess . fatal ( & error) ;
468
468
}
469
469
}
470
470
@@ -488,8 +488,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
488
488
match * rvalue {
489
489
mir:: Rvalue :: Aggregate ( mir:: AggregateKind :: Closure ( def_id,
490
490
ref substs) , _) => {
491
- assert ! ( can_have_local_instance( self . ccx, def_id) ) ;
492
- let trans_item = create_fn_trans_item ( self . ccx ,
491
+ assert ! ( can_have_local_instance( self . ccx. tcx ( ) , def_id) ) ;
492
+ let trans_item = create_fn_trans_item ( self . ccx . tcx ( ) ,
493
493
def_id,
494
494
substs. func_substs ,
495
495
self . param_substs ) ;
@@ -527,9 +527,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
527
527
. require ( ExchangeMallocFnLangItem )
528
528
. unwrap_or_else ( |e| self . ccx . sess ( ) . fatal ( & e) ) ;
529
529
530
- assert ! ( can_have_local_instance( self . ccx, exchange_malloc_fn_def_id) ) ;
530
+ assert ! ( can_have_local_instance( self . ccx. tcx ( ) , exchange_malloc_fn_def_id) ) ;
531
531
let exchange_malloc_fn_trans_item =
532
- create_fn_trans_item ( self . ccx ,
532
+ create_fn_trans_item ( self . ccx . tcx ( ) ,
533
533
exchange_malloc_fn_def_id,
534
534
& Substs :: empty ( ) ,
535
535
self . param_substs ) ;
@@ -596,7 +596,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
596
596
// result in a translation item ...
597
597
if can_result_in_trans_item ( self . ccx , callee_def_id) {
598
598
// ... and create one if it does.
599
- let trans_item = create_fn_trans_item ( self . ccx ,
599
+ let trans_item = create_fn_trans_item ( self . ccx . tcx ( ) ,
600
600
callee_def_id,
601
601
callee_substs,
602
602
self . param_substs ) ;
@@ -631,18 +631,18 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
631
631
return false ;
632
632
}
633
633
634
- can_have_local_instance ( ccx, def_id)
634
+ can_have_local_instance ( ccx. tcx ( ) , def_id)
635
635
}
636
636
}
637
637
}
638
638
639
- fn can_have_local_instance < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
640
- def_id : DefId )
641
- -> bool {
639
+ fn can_have_local_instance < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
640
+ def_id : DefId )
641
+ -> bool {
642
642
// Take a look if we have the definition available. If not, we
643
643
// will not emit code for this item in the local crate, and thus
644
644
// don't create a translation item for it.
645
- def_id. is_local ( ) || ccx . sess ( ) . cstore . is_item_mir_available ( def_id)
645
+ def_id. is_local ( ) || tcx . sess . cstore . is_item_mir_available ( def_id)
646
646
}
647
647
648
648
fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
@@ -667,9 +667,9 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
667
667
. require ( ExchangeFreeFnLangItem )
668
668
. unwrap_or_else ( |e| ccx. sess ( ) . fatal ( & e) ) ;
669
669
670
- assert ! ( can_have_local_instance( ccx, exchange_free_fn_def_id) ) ;
670
+ assert ! ( can_have_local_instance( ccx. tcx ( ) , exchange_free_fn_def_id) ) ;
671
671
let exchange_free_fn_trans_item =
672
- create_fn_trans_item ( ccx,
672
+ create_fn_trans_item ( ccx. tcx ( ) ,
673
673
exchange_free_fn_def_id,
674
674
& Substs :: empty ( ) ,
675
675
& Substs :: empty ( ) ) ;
@@ -706,8 +706,8 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
706
706
_ => bug ! ( )
707
707
} ;
708
708
709
- if can_have_local_instance ( ccx, destructor_did) {
710
- let trans_item = create_fn_trans_item ( ccx,
709
+ if can_have_local_instance ( ccx. tcx ( ) , destructor_did) {
710
+ let trans_item = create_fn_trans_item ( ccx. tcx ( ) ,
711
711
destructor_did,
712
712
substs,
713
713
& Substs :: empty ( ) ) ;
@@ -961,29 +961,27 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
961
961
}
962
962
}
963
963
964
- fn create_fn_trans_item < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
965
- def_id : DefId ,
966
- fn_substs : & Substs < ' tcx > ,
967
- param_substs : & Substs < ' tcx > )
968
- -> TransItem < ' tcx >
969
- {
964
+ fn create_fn_trans_item < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
965
+ def_id : DefId ,
966
+ fn_substs : & Substs < ' tcx > ,
967
+ param_substs : & Substs < ' tcx > )
968
+ -> TransItem < ' tcx > {
970
969
debug ! ( "create_fn_trans_item(def_id={}, fn_substs={:?}, param_substs={:?})" ,
971
- def_id_to_string( ccx . tcx( ) , def_id) ,
970
+ def_id_to_string( tcx, def_id) ,
972
971
fn_substs,
973
972
param_substs) ;
974
973
975
974
// We only get here, if fn_def_id either designates a local item or
976
975
// an inlineable external item. Non-inlineable external items are
977
976
// ignored because we don't want to generate any code for them.
978
- let concrete_substs = monomorphize:: apply_param_substs ( ccx . tcx ( ) ,
977
+ let concrete_substs = monomorphize:: apply_param_substs ( tcx,
979
978
param_substs,
980
979
fn_substs) ;
981
- let concrete_substs = ccx . tcx ( ) . erase_regions ( & concrete_substs) ;
980
+ let concrete_substs = tcx. erase_regions ( & concrete_substs) ;
982
981
983
982
let trans_item =
984
983
TransItem :: Fn ( Instance :: new ( def_id,
985
- & ccx. tcx ( ) . mk_substs ( concrete_substs) ) ) ;
986
-
984
+ & tcx. mk_substs ( concrete_substs) ) ) ;
987
985
return trans_item;
988
986
}
989
987
@@ -1014,8 +1012,8 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1014
1012
. filter_map ( |opt_impl_method| opt_impl_method)
1015
1013
// create translation items
1016
1014
. filter_map ( |impl_method| {
1017
- if can_have_local_instance ( ccx, impl_method. method . def_id ) {
1018
- Some ( create_fn_trans_item ( ccx,
1015
+ if can_have_local_instance ( ccx. tcx ( ) , impl_method. method . def_id ) {
1016
+ Some ( create_fn_trans_item ( ccx. tcx ( ) ,
1019
1017
impl_method. method . def_id ,
1020
1018
& impl_method. substs ,
1021
1019
& Substs :: empty ( ) ) )
@@ -1063,7 +1061,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1063
1061
1064
1062
hir:: ItemImpl ( ..) => {
1065
1063
if self . mode == TransItemCollectionMode :: Eager {
1066
- create_trans_items_for_default_impls ( self . ccx ,
1064
+ create_trans_items_for_default_impls ( self . ccx . tcx ( ) ,
1067
1065
item,
1068
1066
self . output ) ;
1069
1067
}
@@ -1149,9 +1147,9 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1149
1147
}
1150
1148
}
1151
1149
1152
- fn create_trans_items_for_default_impls < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1153
- item : & ' tcx hir:: Item ,
1154
- output : & mut Vec < TransItem < ' tcx > > ) {
1150
+ fn create_trans_items_for_default_impls < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1151
+ item : & ' tcx hir:: Item ,
1152
+ output : & mut Vec < TransItem < ' tcx > > ) {
1155
1153
match item. node {
1156
1154
hir:: ItemImpl ( _,
1157
1155
_,
@@ -1163,11 +1161,10 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1163
1161
return
1164
1162
}
1165
1163
1166
- let tcx = ccx. tcx ( ) ;
1167
1164
let impl_def_id = tcx. map . local_def_id ( item. id ) ;
1168
1165
1169
1166
debug ! ( "create_trans_items_for_default_impls(item={})" ,
1170
- def_id_to_string( ccx . tcx( ) , impl_def_id) ) ;
1167
+ def_id_to_string( tcx, impl_def_id) ) ;
1171
1168
1172
1169
if let Some ( trait_ref) = tcx. impl_trait_ref ( impl_def_id) {
1173
1170
let default_impls = tcx. provided_trait_methods ( trait_ref. def_id ) ;
@@ -1194,13 +1191,13 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1194
1191
assert ! ( mth. is_provided) ;
1195
1192
1196
1193
let predicates = mth. method . predicates . predicates . subst ( tcx, & mth. substs ) ;
1197
- if !normalize_and_test_predicates ( ccx . tcx ( ) , predicates. into_vec ( ) ) {
1194
+ if !normalize_and_test_predicates ( tcx, predicates. into_vec ( ) ) {
1198
1195
continue ;
1199
1196
}
1200
1197
1201
- if can_have_local_instance ( ccx , default_impl. def_id ) {
1202
- let empty_substs = ccx . tcx ( ) . mk_substs ( ccx . tcx ( ) . erase_regions ( mth. substs ) ) ;
1203
- let item = create_fn_trans_item ( ccx ,
1198
+ if can_have_local_instance ( tcx , default_impl. def_id ) {
1199
+ let empty_substs = tcx. mk_substs ( tcx. erase_regions ( mth. substs ) ) ;
1200
+ let item = create_fn_trans_item ( tcx ,
1204
1201
default_impl. def_id ,
1205
1202
callee_substs,
1206
1203
empty_substs) ;
0 commit comments