@@ -523,11 +523,17 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
523523 // have to instantiate all methods of the trait being cast to, so we
524524 // can build the appropriate vtable.
525525 mir:: Rvalue :: Cast ( mir:: CastKind :: Unsize , ref operand, target_ty) => {
526- let target_ty = self . tcx . trans_apply_param_substs ( self . param_substs ,
527- & target_ty) ;
526+ let target_ty = self . tcx . subst_and_normalize_erasing_regions (
527+ self . param_substs ,
528+ ty:: ParamEnv :: reveal_all ( ) ,
529+ & target_ty,
530+ ) ;
528531 let source_ty = operand. ty ( self . mir , self . tcx ) ;
529- let source_ty = self . tcx . trans_apply_param_substs ( self . param_substs ,
530- & source_ty) ;
532+ let source_ty = self . tcx . subst_and_normalize_erasing_regions (
533+ self . param_substs ,
534+ ty:: ParamEnv :: reveal_all ( ) ,
535+ & source_ty,
536+ ) ;
531537 let ( source_ty, target_ty) = find_vtable_types_for_unsizing ( self . tcx ,
532538 source_ty,
533539 target_ty) ;
@@ -543,14 +549,20 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
543549 }
544550 mir:: Rvalue :: Cast ( mir:: CastKind :: ReifyFnPointer , ref operand, _) => {
545551 let fn_ty = operand. ty ( self . mir , self . tcx ) ;
546- let fn_ty = self . tcx . trans_apply_param_substs ( self . param_substs ,
547- & fn_ty) ;
552+ let fn_ty = self . tcx . subst_and_normalize_erasing_regions (
553+ self . param_substs ,
554+ ty:: ParamEnv :: reveal_all ( ) ,
555+ & fn_ty,
556+ ) ;
548557 visit_fn_use ( self . tcx , fn_ty, false , & mut self . output ) ;
549558 }
550559 mir:: Rvalue :: Cast ( mir:: CastKind :: ClosureFnPointer , ref operand, _) => {
551560 let source_ty = operand. ty ( self . mir , self . tcx ) ;
552- let source_ty = self . tcx . trans_apply_param_substs ( self . param_substs ,
553- & source_ty) ;
561+ let source_ty = self . tcx . subst_and_normalize_erasing_regions (
562+ self . param_substs ,
563+ ty:: ParamEnv :: reveal_all ( ) ,
564+ & source_ty,
565+ ) ;
554566 match source_ty. sty {
555567 ty:: TyClosure ( def_id, substs) => {
556568 let instance = monomorphize:: resolve_closure (
@@ -595,14 +607,22 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
595607 match * kind {
596608 mir:: TerminatorKind :: Call { ref func, .. } => {
597609 let callee_ty = func. ty ( self . mir , tcx) ;
598- let callee_ty = tcx. trans_apply_param_substs ( self . param_substs , & callee_ty) ;
610+ let callee_ty = tcx. subst_and_normalize_erasing_regions (
611+ self . param_substs ,
612+ ty:: ParamEnv :: reveal_all ( ) ,
613+ & callee_ty,
614+ ) ;
599615 visit_fn_use ( self . tcx , callee_ty, true , & mut self . output ) ;
600616 }
601617 mir:: TerminatorKind :: Drop { ref location, .. } |
602618 mir:: TerminatorKind :: DropAndReplace { ref location, .. } => {
603619 let ty = location. ty ( self . mir , self . tcx )
604620 . to_ty ( self . tcx ) ;
605- let ty = tcx. trans_apply_param_substs ( self . param_substs , & ty) ;
621+ let ty = tcx. subst_and_normalize_erasing_regions (
622+ self . param_substs ,
623+ ty:: ParamEnv :: reveal_all ( ) ,
624+ & ty,
625+ ) ;
606626 visit_drop_use ( self . tcx , ty, true , self . output ) ;
607627 }
608628 mir:: TerminatorKind :: Goto { .. } |
@@ -1155,8 +1175,11 @@ fn collect_const<'a, 'tcx>(
11551175 let val = match constant. val {
11561176 ConstVal :: Unevaluated ( def_id, substs) => {
11571177 let param_env = ty:: ParamEnv :: reveal_all ( ) ;
1158- let substs = tcx. trans_apply_param_substs ( param_substs,
1159- & substs) ;
1178+ let substs = tcx. subst_and_normalize_erasing_regions (
1179+ param_substs,
1180+ param_env,
1181+ & substs,
1182+ ) ;
11601183 let instance = ty:: Instance :: resolve ( tcx,
11611184 param_env,
11621185 def_id,
0 commit comments