From 590c41635952e19c3caae525a827499dbd360049 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 21 Mar 2021 13:22:22 +0100 Subject: Introduce QuantifiedWhereClause and DynTy analogous to Chalk This introduces a bunch of new binders in lots of places, which we have to be careful about, but we had to add them at some point. --- crates/hir_ty/src/infer/unify.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 1fc03c8f4..35b0a2059 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -310,9 +310,18 @@ impl InferenceTable { (TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true, - (TyKind::Dyn(dyn1), TyKind::Dyn(dyn2)) if dyn1.len() == dyn2.len() => { - for (pred1, pred2) in dyn1.iter().zip(dyn2.iter()) { - if !self.unify_preds(pred1, pred2, depth + 1) { + (TyKind::Dyn(dyn1), TyKind::Dyn(dyn2)) + if dyn1.bounds.skip_binders().interned().len() + == dyn2.bounds.skip_binders().interned().len() => + { + for (pred1, pred2) in dyn1 + .bounds + .skip_binders() + .interned() + .iter() + .zip(dyn2.bounds.skip_binders().interned().iter()) + { + if !self.unify_preds(pred1.skip_binders(), pred2.skip_binders(), depth + 1) { return false; } } -- cgit v1.2.3 From 1d5c4a77fb33cab7bf8f9d2edc6dd26b09ef65f3 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 21 Mar 2021 17:40:14 +0100 Subject: Use QuantifiedWhereClause in generic_predicates as well Still far too much binder skipping going on; I find it hard to imagine this is all correct, but the tests pass. --- crates/hir_ty/src/infer/expr.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 79bbc5dab..17849d552 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -11,6 +11,7 @@ use hir_def::{ AssocContainerId, FieldId, Lookup, }; use hir_expand::name::{name, Name}; +use stdx::always; use syntax::ast::RangeOp; use crate::{ @@ -936,7 +937,9 @@ impl<'a> InferenceContext<'a> { let def: CallableDefId = from_chalk(self.db, *fn_def); let generic_predicates = self.db.generic_predicates(def.into()); for predicate in generic_predicates.iter() { - let predicate = predicate.clone().subst(parameters); + let (predicate, binders) = + predicate.clone().subst(parameters).into_value_and_skipped_binders(); + always!(binders == 0); // quantified where clauses not yet handled self.obligations.push(predicate.cast(&Interner)); } // add obligation for trait implementation, if this is a trait method -- cgit v1.2.3