Skip to content

Commit f6b6930

Browse files
ivarflakstadizagawd
authored andcommitted
Improve type impls trait check
1 parent b002d72 commit f6b6930

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
237237
let (infcx, param_env) =
238238
self.tcx.infer_ctxt().build_with_typing_env(self.typing_env);
239239

240-
let type_impls_trait = preds.iter().all(|pred| {
241-
let trait_ref = ty::TraitRef::new(tcx, pred.def_id(), [tp_ty]);
242-
243-
let ocx = ObligationCtxt::new(&infcx);
244-
ocx.register_obligation(Obligation::new(
245-
tcx,
246-
ObligationCause::dummy(),
247-
param_env,
248-
pred,
249-
));
250-
ocx.select_all_or_error().is_empty()
251-
});
240+
let ocx = ObligationCtxt::new(&infcx);
241+
ocx.register_obligations(preds.iter().map(|pred| {
242+
let pred = pred.with_self_ty(tcx, tp_ty);
243+
let pred = tcx.erase_regions(pred);
244+
Obligation::new(tcx, ObligationCause::dummy(), param_env, pred)
245+
}));
246+
let type_impls_trait = ocx.select_all_or_error().is_empty();
252247

253248
if type_impls_trait {
254249
let vtable_ptr = self.get_vtable_ptr(tp_ty, preds)?;

0 commit comments

Comments
 (0)