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/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'crates/hir/src/lib.rs') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index e3ac37e4c..1844942a6 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -57,8 +57,8 @@ use hir_ty::{ to_assoc_type_id, traits::{FnTrait, Solution, SolutionVariables}, AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, Cast, DebruijnIndex, - InEnvironment, Interner, ProjectionTy, Scalar, Substitution, Ty, TyDefId, TyKind, - TyVariableKind, WhereClause, + InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar, Substitution, Ty, + TyDefId, TyKind, TyVariableKind, WhereClause, }; use itertools::Itertools; use rustc_hash::FxHashSet; @@ -2022,7 +2022,7 @@ impl Type { pub fn as_impl_traits(&self, db: &dyn HirDatabase) -> Option> { self.ty.value.impl_trait_bounds(db).map(|it| { it.into_iter() - .filter_map(|pred| match pred { + .filter_map(|pred| match pred.skip_binders() { hir_ty::WhereClause::Implemented(trait_ref) => { Some(Trait::from(trait_ref.hir_trait_id())) } @@ -2061,11 +2061,11 @@ impl Type { fn walk_bounds( db: &dyn HirDatabase, type_: &Type, - bounds: &[WhereClause], + bounds: &[QuantifiedWhereClause], cb: &mut impl FnMut(Type), ) { for pred in bounds { - match pred { + match pred.skip_binders() { WhereClause::Implemented(trait_ref) => { cb(type_.clone()); // skip the self type. it's likely the type we just got the bounds from @@ -2107,7 +2107,12 @@ impl Type { } } TyKind::Dyn(bounds) => { - walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); + walk_bounds( + db, + &type_.derived(ty.clone()), + bounds.bounds.skip_binders().interned(), + cb, + ); } TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => { -- cgit v1.2.3