@@ -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
@@ -417,7 +417,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
417
417
}
418
418
}
419
419
420
- record_references ( ccx, starting_point, & neighbors[ ..] , reference_map) ;
420
+ record_references ( ccx. tcx ( ) , starting_point, & neighbors[ ..] , reference_map) ;
421
421
422
422
for neighbour in neighbors {
423
423
collect_items_rec ( ccx, neighbour, visited, recursion_depths, reference_map) ;
@@ -430,23 +430,23 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
430
430
debug ! ( "END collect_items_rec({})" , starting_point. to_string( ccx. tcx( ) ) ) ;
431
431
}
432
432
433
- fn record_references < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
434
- caller : TransItem < ' tcx > ,
435
- callees : & [ TransItem < ' tcx > ] ,
436
- reference_map : & mut ReferenceMap < ' tcx > ) {
433
+ fn record_references < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
434
+ caller : TransItem < ' tcx > ,
435
+ callees : & [ TransItem < ' tcx > ] ,
436
+ reference_map : & mut ReferenceMap < ' tcx > ) {
437
437
let iter = callees. into_iter ( )
438
438
. map ( |callee| {
439
439
let is_inlining_candidate = callee. is_from_extern_crate ( ) ||
440
- callee. requests_inline ( ccx . tcx ( ) ) ;
440
+ callee. requests_inline ( tcx) ;
441
441
( * callee, is_inlining_candidate)
442
442
} ) ;
443
443
reference_map. record_references ( caller, iter) ;
444
444
}
445
445
446
- fn check_recursion_limit < ' a , ' tcx : ' a > ( ccx : & CrateContext < ' a , ' tcx > ,
447
- instance : Instance < ' tcx > ,
448
- recursion_depths : & mut DefIdMap < usize > )
449
- -> ( DefId , usize ) {
446
+ fn check_recursion_limit < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
447
+ instance : Instance < ' tcx > ,
448
+ recursion_depths : & mut DefIdMap < usize > )
449
+ -> ( DefId , usize ) {
450
450
let recursion_depth = recursion_depths. get ( & instance. def )
451
451
. map ( |x| * x)
452
452
. unwrap_or ( 0 ) ;
@@ -455,13 +455,13 @@ fn check_recursion_limit<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
455
455
// Code that needs to instantiate the same function recursively
456
456
// more than the recursion limit is assumed to be causing an
457
457
// infinite expansion.
458
- if recursion_depth > ccx . sess ( ) . recursion_limit . get ( ) {
458
+ if recursion_depth > tcx . sess . recursion_limit . get ( ) {
459
459
let error = format ! ( "reached the recursion limit while instantiating `{}`" ,
460
460
instance) ;
461
- if let Some ( node_id) = ccx . tcx ( ) . map . as_local_node_id ( instance. def ) {
462
- ccx . sess ( ) . span_fatal ( ccx . tcx ( ) . map . span ( node_id) , & error) ;
461
+ if let Some ( node_id) = tcx. map . as_local_node_id ( instance. def ) {
462
+ tcx . sess . span_fatal ( tcx. map . span ( node_id) , & error) ;
463
463
} else {
464
- ccx . sess ( ) . fatal ( & error) ;
464
+ tcx . sess . fatal ( & error) ;
465
465
}
466
466
}
467
467
@@ -485,8 +485,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
485
485
match * rvalue {
486
486
mir:: Rvalue :: Aggregate ( mir:: AggregateKind :: Closure ( def_id,
487
487
ref substs) , _) => {
488
- assert ! ( can_have_local_instance( self . ccx, def_id) ) ;
489
- let trans_item = create_fn_trans_item ( self . ccx ,
488
+ assert ! ( can_have_local_instance( self . ccx. tcx ( ) , def_id) ) ;
489
+ let trans_item = create_fn_trans_item ( self . ccx . tcx ( ) ,
490
490
def_id,
491
491
substs. func_substs ,
492
492
self . param_substs ) ;
@@ -524,9 +524,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
524
524
. require ( ExchangeMallocFnLangItem )
525
525
. unwrap_or_else ( |e| self . ccx . sess ( ) . fatal ( & e) ) ;
526
526
527
- assert ! ( can_have_local_instance( self . ccx, exchange_malloc_fn_def_id) ) ;
527
+ assert ! ( can_have_local_instance( self . ccx. tcx ( ) , exchange_malloc_fn_def_id) ) ;
528
528
let exchange_malloc_fn_trans_item =
529
- create_fn_trans_item ( self . ccx ,
529
+ create_fn_trans_item ( self . ccx . tcx ( ) ,
530
530
exchange_malloc_fn_def_id,
531
531
& Substs :: empty ( ) ,
532
532
self . param_substs ) ;
@@ -593,7 +593,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
593
593
// result in a translation item ...
594
594
if can_result_in_trans_item ( self . ccx , callee_def_id) {
595
595
// ... and create one if it does.
596
- let trans_item = create_fn_trans_item ( self . ccx ,
596
+ let trans_item = create_fn_trans_item ( self . ccx . tcx ( ) ,
597
597
callee_def_id,
598
598
callee_substs,
599
599
self . param_substs ) ;
@@ -628,18 +628,18 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
628
628
return false ;
629
629
}
630
630
631
- can_have_local_instance ( ccx, def_id)
631
+ can_have_local_instance ( ccx. tcx ( ) , def_id)
632
632
}
633
633
}
634
634
}
635
635
636
- fn can_have_local_instance < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
637
- def_id : DefId )
638
- -> bool {
636
+ fn can_have_local_instance < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
637
+ def_id : DefId )
638
+ -> bool {
639
639
// Take a look if we have the definition available. If not, we
640
640
// will not emit code for this item in the local crate, and thus
641
641
// don't create a translation item for it.
642
- def_id. is_local ( ) || ccx . sess ( ) . cstore . is_item_mir_available ( def_id)
642
+ def_id. is_local ( ) || tcx . sess . cstore . is_item_mir_available ( def_id)
643
643
}
644
644
645
645
fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
@@ -664,9 +664,9 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
664
664
. require ( ExchangeFreeFnLangItem )
665
665
. unwrap_or_else ( |e| ccx. sess ( ) . fatal ( & e) ) ;
666
666
667
- assert ! ( can_have_local_instance( ccx, exchange_free_fn_def_id) ) ;
667
+ assert ! ( can_have_local_instance( ccx. tcx ( ) , exchange_free_fn_def_id) ) ;
668
668
let exchange_free_fn_trans_item =
669
- create_fn_trans_item ( ccx,
669
+ create_fn_trans_item ( ccx. tcx ( ) ,
670
670
exchange_free_fn_def_id,
671
671
& Substs :: empty ( ) ,
672
672
& Substs :: empty ( ) ) ;
@@ -703,8 +703,8 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
703
703
_ => bug ! ( )
704
704
} ;
705
705
706
- if can_have_local_instance ( ccx, destructor_did) {
707
- let trans_item = create_fn_trans_item ( ccx,
706
+ if can_have_local_instance ( ccx. tcx ( ) , destructor_did) {
707
+ let trans_item = create_fn_trans_item ( ccx. tcx ( ) ,
708
708
destructor_did,
709
709
substs,
710
710
& Substs :: empty ( ) ) ;
@@ -958,29 +958,27 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
958
958
}
959
959
}
960
960
961
- fn create_fn_trans_item < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
962
- def_id : DefId ,
963
- fn_substs : & Substs < ' tcx > ,
964
- param_substs : & Substs < ' tcx > )
965
- -> TransItem < ' tcx >
966
- {
961
+ fn create_fn_trans_item < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
962
+ def_id : DefId ,
963
+ fn_substs : & Substs < ' tcx > ,
964
+ param_substs : & Substs < ' tcx > )
965
+ -> TransItem < ' tcx > {
967
966
debug ! ( "create_fn_trans_item(def_id={}, fn_substs={:?}, param_substs={:?})" ,
968
- def_id_to_string( ccx . tcx( ) , def_id) ,
967
+ def_id_to_string( tcx, def_id) ,
969
968
fn_substs,
970
969
param_substs) ;
971
970
972
971
// We only get here, if fn_def_id either designates a local item or
973
972
// an inlineable external item. Non-inlineable external items are
974
973
// ignored because we don't want to generate any code for them.
975
- let concrete_substs = monomorphize:: apply_param_substs ( ccx . tcx ( ) ,
974
+ let concrete_substs = monomorphize:: apply_param_substs ( tcx,
976
975
param_substs,
977
976
fn_substs) ;
978
- let concrete_substs = ccx . tcx ( ) . erase_regions ( & concrete_substs) ;
977
+ let concrete_substs = tcx. erase_regions ( & concrete_substs) ;
979
978
980
979
let trans_item =
981
980
TransItem :: Fn ( Instance :: new ( def_id,
982
- & ccx. tcx ( ) . mk_substs ( concrete_substs) ) ) ;
983
-
981
+ & tcx. mk_substs ( concrete_substs) ) ) ;
984
982
return trans_item;
985
983
}
986
984
@@ -1011,8 +1009,8 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1011
1009
. filter_map ( |opt_impl_method| opt_impl_method)
1012
1010
// create translation items
1013
1011
. filter_map ( |impl_method| {
1014
- if can_have_local_instance ( ccx, impl_method. method . def_id ) {
1015
- Some ( create_fn_trans_item ( ccx,
1012
+ if can_have_local_instance ( ccx. tcx ( ) , impl_method. method . def_id ) {
1013
+ Some ( create_fn_trans_item ( ccx. tcx ( ) ,
1016
1014
impl_method. method . def_id ,
1017
1015
& impl_method. substs ,
1018
1016
& Substs :: empty ( ) ) )
@@ -1060,7 +1058,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1060
1058
1061
1059
hir:: ItemImpl ( ..) => {
1062
1060
if self . mode == TransItemCollectionMode :: Eager {
1063
- create_trans_items_for_default_impls ( self . ccx ,
1061
+ create_trans_items_for_default_impls ( self . ccx . tcx ( ) ,
1064
1062
item,
1065
1063
self . output ) ;
1066
1064
}
@@ -1146,9 +1144,9 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1146
1144
}
1147
1145
}
1148
1146
1149
- fn create_trans_items_for_default_impls < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1150
- item : & ' tcx hir:: Item ,
1151
- output : & mut Vec < TransItem < ' tcx > > ) {
1147
+ fn create_trans_items_for_default_impls < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1148
+ item : & ' tcx hir:: Item ,
1149
+ output : & mut Vec < TransItem < ' tcx > > ) {
1152
1150
match item. node {
1153
1151
hir:: ItemImpl ( _,
1154
1152
_,
@@ -1160,11 +1158,10 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1160
1158
return
1161
1159
}
1162
1160
1163
- let tcx = ccx. tcx ( ) ;
1164
1161
let impl_def_id = tcx. map . local_def_id ( item. id ) ;
1165
1162
1166
1163
debug ! ( "create_trans_items_for_default_impls(item={})" ,
1167
- def_id_to_string( ccx . tcx( ) , impl_def_id) ) ;
1164
+ def_id_to_string( tcx, impl_def_id) ) ;
1168
1165
1169
1166
if let Some ( trait_ref) = tcx. impl_trait_ref ( impl_def_id) {
1170
1167
let default_impls = tcx. provided_trait_methods ( trait_ref. def_id ) ;
@@ -1191,13 +1188,13 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1191
1188
assert ! ( mth. is_provided) ;
1192
1189
1193
1190
let predicates = mth. method . predicates . predicates . subst ( tcx, & mth. substs ) ;
1194
- if !normalize_and_test_predicates ( ccx . tcx ( ) , predicates. into_vec ( ) ) {
1191
+ if !normalize_and_test_predicates ( tcx, predicates. into_vec ( ) ) {
1195
1192
continue ;
1196
1193
}
1197
1194
1198
- if can_have_local_instance ( ccx , default_impl. def_id ) {
1199
- let empty_substs = ccx . tcx ( ) . mk_substs ( ccx . tcx ( ) . erase_regions ( mth. substs ) ) ;
1200
- let item = create_fn_trans_item ( ccx ,
1195
+ if can_have_local_instance ( tcx , default_impl. def_id ) {
1196
+ let empty_substs = tcx. mk_substs ( tcx. erase_regions ( mth. substs ) ) ;
1197
+ let item = create_fn_trans_item ( tcx ,
1201
1198
default_impl. def_id ,
1202
1199
callee_substs,
1203
1200
empty_substs) ;
0 commit comments