@@ -459,7 +459,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
459
459
format ! ( "Could not find MIR for closure: {:?}" , def_id)
460
460
} ) ;
461
461
462
- let concrete_substs = monomorphize:: apply_param_substs ( self . scx . tcx ( ) ,
462
+ let concrete_substs = monomorphize:: apply_param_substs ( self . scx ,
463
463
self . param_substs ,
464
464
& substs. func_substs ) ;
465
465
let concrete_substs = self . scx . tcx ( ) . erase_regions ( & concrete_substs) ;
@@ -477,11 +477,11 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
477
477
// have to instantiate all methods of the trait being cast to, so we
478
478
// can build the appropriate vtable.
479
479
mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref operand, target_ty) => {
480
- let target_ty = monomorphize:: apply_param_substs ( self . scx . tcx ( ) ,
480
+ let target_ty = monomorphize:: apply_param_substs ( self . scx ,
481
481
self . param_substs ,
482
482
& target_ty) ;
483
483
let source_ty = operand. ty ( self . mir , self . scx . tcx ( ) ) ;
484
- let source_ty = monomorphize:: apply_param_substs ( self . scx . tcx ( ) ,
484
+ let source_ty = monomorphize:: apply_param_substs ( self . scx ,
485
485
self . param_substs ,
486
486
& source_ty) ;
487
487
let ( source_ty, target_ty) = find_vtable_types_for_unsizing ( self . scx ,
@@ -508,7 +508,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
508
508
assert ! ( can_have_local_instance( self . scx. tcx( ) , exchange_malloc_fn_def_id) ) ;
509
509
let empty_substs = self . scx . empty_substs_for_def_id ( exchange_malloc_fn_def_id) ;
510
510
let exchange_malloc_fn_trans_item =
511
- create_fn_trans_item ( self . scx . tcx ( ) ,
511
+ create_fn_trans_item ( self . scx ,
512
512
exchange_malloc_fn_def_id,
513
513
empty_substs,
514
514
self . param_substs ) ;
@@ -531,7 +531,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
531
531
let ty = lvalue. ty ( self . mir , self . scx . tcx ( ) )
532
532
. to_ty ( self . scx . tcx ( ) ) ;
533
533
534
- let ty = monomorphize:: apply_param_substs ( self . scx . tcx ( ) ,
534
+ let ty = monomorphize:: apply_param_substs ( self . scx ,
535
535
self . param_substs ,
536
536
& ty) ;
537
537
assert ! ( ty. is_normalized_for_trans( ) ) ;
@@ -555,7 +555,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
555
555
// references to `const` items
556
556
if let mir:: Literal :: Item { def_id, substs } = constant. literal {
557
557
let tcx = self . scx . tcx ( ) ;
558
- let substs = monomorphize:: apply_param_substs ( tcx ,
558
+ let substs = monomorphize:: apply_param_substs ( self . scx ,
559
559
self . param_substs ,
560
560
& substs) ;
561
561
@@ -613,7 +613,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
613
613
// result in a translation item ...
614
614
if can_result_in_trans_item ( self . scx . tcx ( ) , callee_def_id) {
615
615
// ... and create one if it does.
616
- let trans_item = create_fn_trans_item ( self . scx . tcx ( ) ,
616
+ let trans_item = create_fn_trans_item ( self . scx ,
617
617
callee_def_id,
618
618
callee_substs,
619
619
self . param_substs ) ;
@@ -670,7 +670,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
670
670
if is_drop_in_place_intrinsic ( tcx, def_id, bare_fn_ty) => {
671
671
let operand_ty = args[ 0 ] . ty ( self . mir , tcx) ;
672
672
if let ty:: TyRawPtr ( mt) = operand_ty. sty {
673
- let operand_ty = monomorphize:: apply_param_substs ( tcx ,
673
+ let operand_ty = monomorphize:: apply_param_substs ( self . scx ,
674
674
self . param_substs ,
675
675
& mt. ty ) ;
676
676
let ty = glue:: get_drop_glue_type ( tcx, operand_ty) ;
@@ -732,7 +732,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
732
732
assert ! ( can_have_local_instance( scx. tcx( ) , exchange_free_fn_def_id) ) ;
733
733
let fn_substs = scx. empty_substs_for_def_id ( exchange_free_fn_def_id) ;
734
734
let exchange_free_fn_trans_item =
735
- create_fn_trans_item ( scx. tcx ( ) ,
735
+ create_fn_trans_item ( scx,
736
736
exchange_free_fn_def_id,
737
737
fn_substs,
738
738
Substs :: empty ( scx. tcx ( ) ) ) ;
@@ -769,7 +769,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
769
769
} ;
770
770
771
771
if can_have_local_instance ( scx. tcx ( ) , destructor_did) {
772
- let trans_item = create_fn_trans_item ( scx. tcx ( ) ,
772
+ let trans_item = create_fn_trans_item ( scx,
773
773
destructor_did,
774
774
substs,
775
775
Substs :: empty ( scx. tcx ( ) ) ) ;
@@ -800,7 +800,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
800
800
ty:: TyStruct ( ref adt_def, substs) |
801
801
ty:: TyEnum ( ref adt_def, substs) => {
802
802
for field in adt_def. all_fields ( ) {
803
- let field_type = monomorphize:: apply_param_substs ( scx. tcx ( ) ,
803
+ let field_type = monomorphize:: apply_param_substs ( scx,
804
804
substs,
805
805
& field. unsubst_ty ( ) ) ;
806
806
let field_type = glue:: get_drop_glue_type ( scx. tcx ( ) , field_type) ;
@@ -894,8 +894,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
894
894
callee_substs,
895
895
param_substs) ;
896
896
897
-
898
- let rcvr_substs = monomorphize:: apply_param_substs ( tcx,
897
+ let rcvr_substs = monomorphize:: apply_param_substs ( scx,
899
898
param_substs,
900
899
& callee_substs) ;
901
900
let trait_ref = ty:: TraitRef :: from_method ( tcx, trait_id, rcvr_substs) ;
@@ -1016,11 +1015,13 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
1016
1015
}
1017
1016
}
1018
1017
1019
- fn create_fn_trans_item < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1018
+ fn create_fn_trans_item < ' a , ' tcx > ( scx : & SharedCrateContext < ' a , ' tcx > ,
1020
1019
def_id : DefId ,
1021
1020
fn_substs : & ' tcx Substs < ' tcx > ,
1022
1021
param_substs : & ' tcx Substs < ' tcx > )
1023
1022
-> TransItem < ' tcx > {
1023
+ let tcx = scx. tcx ( ) ;
1024
+
1024
1025
debug ! ( "create_fn_trans_item(def_id={}, fn_substs={:?}, param_substs={:?})" ,
1025
1026
def_id_to_string( tcx, def_id) ,
1026
1027
fn_substs,
@@ -1029,7 +1030,7 @@ fn create_fn_trans_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1029
1030
// We only get here, if fn_def_id either designates a local item or
1030
1031
// an inlineable external item. Non-inlineable external items are
1031
1032
// ignored because we don't want to generate any code for them.
1032
- let concrete_substs = monomorphize:: apply_param_substs ( tcx ,
1033
+ let concrete_substs = monomorphize:: apply_param_substs ( scx ,
1033
1034
param_substs,
1034
1035
& fn_substs) ;
1035
1036
assert ! ( concrete_substs. is_normalized_for_trans( ) ) ;
@@ -1063,7 +1064,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(scx: &SharedCrateContext<'a,
1063
1064
// create translation items
1064
1065
. filter_map ( |impl_method| {
1065
1066
if can_have_local_instance ( scx. tcx ( ) , impl_method. method . def_id ) {
1066
- Some ( create_fn_trans_item ( scx. tcx ( ) ,
1067
+ Some ( create_fn_trans_item ( scx,
1067
1068
impl_method. method . def_id ,
1068
1069
impl_method. substs ,
1069
1070
Substs :: empty ( scx. tcx ( ) ) ) )
@@ -1114,7 +1115,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1114
1115
1115
1116
hir:: ItemImpl ( ..) => {
1116
1117
if self . mode == TransItemCollectionMode :: Eager {
1117
- create_trans_items_for_default_impls ( self . scx . tcx ( ) ,
1118
+ create_trans_items_for_default_impls ( self . scx ,
1118
1119
item,
1119
1120
self . output ) ;
1120
1121
}
@@ -1202,9 +1203,10 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1202
1203
}
1203
1204
}
1204
1205
1205
- fn create_trans_items_for_default_impls < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1206
+ fn create_trans_items_for_default_impls < ' a , ' tcx > ( scx : & SharedCrateContext < ' a , ' tcx > ,
1206
1207
item : & ' tcx hir:: Item ,
1207
1208
output : & mut Vec < TransItem < ' tcx > > ) {
1209
+ let tcx = scx. tcx ( ) ;
1208
1210
match item. node {
1209
1211
hir:: ItemImpl ( _,
1210
1212
_,
@@ -1255,7 +1257,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1255
1257
1256
1258
if can_have_local_instance ( tcx, method. def_id ) {
1257
1259
let empty_substs = tcx. erase_regions ( & mth. substs ) ;
1258
- let item = create_fn_trans_item ( tcx ,
1260
+ let item = create_fn_trans_item ( scx ,
1259
1261
method. def_id ,
1260
1262
callee_substs,
1261
1263
empty_substs) ;
0 commit comments