@@ -10,7 +10,7 @@ use rustc_infer::infer::TyCtxtInferExt;
1010use rustc_middle:: mir:: interpret:: { read_target_uint, write_target_uint} ;
1111use rustc_middle:: mir:: { self , BinOp , ConstValue , NonDivergingIntrinsic } ;
1212use rustc_middle:: ty:: layout:: TyAndLayout ;
13- use rustc_middle:: ty:: { Ty , TyCtxt , Upcast } ;
13+ use rustc_middle:: ty:: { Ty , TyCtxt } ;
1414use rustc_middle:: { bug, span_bug, ty} ;
1515use rustc_span:: { Symbol , sym} ;
1616use rustc_trait_selection:: traits:: { Obligation , ObligationCause , ObligationCtxt } ;
@@ -166,18 +166,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
166166 let ( infcx, param_env) =
167167 self . tcx . infer_ctxt ( ) . build_with_typing_env ( self . typing_env ) ;
168168
169- let type_impls_trait = preds. iter ( ) . all ( |pred| {
170- let trait_ref = ty:: TraitRef :: new ( tcx, pred. def_id ( ) , [ tp_ty] ) ;
171-
172- let ocx = ObligationCtxt :: new ( & infcx) ;
173- ocx. register_obligation ( Obligation :: new (
174- tcx,
175- ObligationCause :: dummy ( ) ,
176- param_env,
177- pred,
178- ) ) ;
179- ocx. select_all_or_error ( ) . is_empty ( )
180- } ) ;
169+ let ocx = ObligationCtxt :: new ( & infcx) ;
170+ ocx. register_obligations ( preds. iter ( ) . map ( |pred| {
171+ let pred = pred. with_self_ty ( tcx, tp_ty) ;
172+ let pred = tcx. erase_regions ( pred) ;
173+ Obligation :: new ( tcx, ObligationCause :: dummy ( ) , param_env, pred)
174+ } ) ) ;
175+ let type_impls_trait = ocx. select_all_or_error ( ) . is_empty ( ) ;
181176
182177 if type_impls_trait {
183178 let vtable_ptr = self . get_vtable_ptr ( tp_ty, preds) ?;
0 commit comments