From 835d1cec5905edf722a75fd369cdbbccb1cc414e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 2 Jul 2021 00:16:36 +0200 Subject: [PATCH] Substitute self type instead of fusing binders --- crates/hir_ty/src/infer/closure.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/hir_ty/src/infer/closure.rs b/crates/hir_ty/src/infer/closure.rs index 7a37b4bf018..2de4c0f5db0 100644 --- a/crates/hir_ty/src/infer/closure.rs +++ b/crates/hir_ty/src/infer/closure.rs @@ -1,6 +1,6 @@ //! Inference of closure parameter types based on the closure's expected type. -use chalk_ir::{AliasTy, FnSubst, WhereClause}; +use chalk_ir::{cast::Cast, AliasTy, FnSubst, WhereClause}; use hir_def::HasModule; use smallvec::SmallVec; @@ -44,9 +44,9 @@ impl InferenceContext<'_> { .map(|tid| to_chalk_trait_id(tid)) .collect(); - for bound in dyn_ty.bounds.map_ref(|b| b.iter(&Interner)) { - let bound = bound.map(|b| b.clone()).fuse_binders(&Interner); - + let self_ty = TyKind::Error.intern(&Interner); + let bounds = dyn_ty.bounds.clone().substitute(&Interner, &[self_ty.cast(&Interner)]); + for bound in bounds.iter(&Interner) { // NOTE(skip_binders): the extracted types are rebound by the returned `FnPointer` match bound.skip_binders() { WhereClause::AliasEq(eq) => match &eq.alias {