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/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/lib.rs') diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index e4b1f92e4..90b5b17e2 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -518,6 +518,10 @@ impl Binders { pub fn skip_binders(&self) -> &T { &self.value } + + pub fn into_value_and_skipped_binders(self) -> (T, usize) { + (self.value, self.num_binders) + } } impl Binders<&T> { @@ -985,7 +989,7 @@ impl Ty { .generic_predicates(id.parent) .into_iter() .map(|pred| pred.clone().subst(&substs)) - .filter(|wc| match &wc { + .filter(|wc| match &wc.skip_binders() { WhereClause::Implemented(tr) => tr.self_type_parameter() == self, WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), @@ -993,7 +997,6 @@ impl Ty { }) => proj.self_type_parameter() == self, _ => false, }) - .map(Binders::wrap_empty) .collect_vec(); Some(predicates) -- cgit v1.2.3