aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/lib.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-21 12:22:22 +0000
committerFlorian Diebold <[email protected]>2021-03-21 17:01:14 +0000
commit590c41635952e19c3caae525a827499dbd360049 (patch)
treeeca7c162975ef901b723d255512e61c047e838b8 /crates/hir/src/lib.rs
parent35868c4f7dc479dd5f731a2785ec6a203046ea9c (diff)
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.
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs17
1 files changed, 11 insertions, 6 deletions
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::{
57 to_assoc_type_id, 57 to_assoc_type_id,
58 traits::{FnTrait, Solution, SolutionVariables}, 58 traits::{FnTrait, Solution, SolutionVariables},
59 AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, Cast, DebruijnIndex, 59 AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, Cast, DebruijnIndex,
60 InEnvironment, Interner, ProjectionTy, Scalar, Substitution, Ty, TyDefId, TyKind, 60 InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar, Substitution, Ty,
61 TyVariableKind, WhereClause, 61 TyDefId, TyKind, TyVariableKind, WhereClause,
62}; 62};
63use itertools::Itertools; 63use itertools::Itertools;
64use rustc_hash::FxHashSet; 64use rustc_hash::FxHashSet;
@@ -2022,7 +2022,7 @@ impl Type {
2022 pub fn as_impl_traits(&self, db: &dyn HirDatabase) -> Option<Vec<Trait>> { 2022 pub fn as_impl_traits(&self, db: &dyn HirDatabase) -> Option<Vec<Trait>> {
2023 self.ty.value.impl_trait_bounds(db).map(|it| { 2023 self.ty.value.impl_trait_bounds(db).map(|it| {
2024 it.into_iter() 2024 it.into_iter()
2025 .filter_map(|pred| match pred { 2025 .filter_map(|pred| match pred.skip_binders() {
2026 hir_ty::WhereClause::Implemented(trait_ref) => { 2026 hir_ty::WhereClause::Implemented(trait_ref) => {
2027 Some(Trait::from(trait_ref.hir_trait_id())) 2027 Some(Trait::from(trait_ref.hir_trait_id()))
2028 } 2028 }
@@ -2061,11 +2061,11 @@ impl Type {
2061 fn walk_bounds( 2061 fn walk_bounds(
2062 db: &dyn HirDatabase, 2062 db: &dyn HirDatabase,
2063 type_: &Type, 2063 type_: &Type,
2064 bounds: &[WhereClause], 2064 bounds: &[QuantifiedWhereClause],
2065 cb: &mut impl FnMut(Type), 2065 cb: &mut impl FnMut(Type),
2066 ) { 2066 ) {
2067 for pred in bounds { 2067 for pred in bounds {
2068 match pred { 2068 match pred.skip_binders() {
2069 WhereClause::Implemented(trait_ref) => { 2069 WhereClause::Implemented(trait_ref) => {
2070 cb(type_.clone()); 2070 cb(type_.clone());
2071 // skip the self type. it's likely the type we just got the bounds from 2071 // skip the self type. it's likely the type we just got the bounds from
@@ -2107,7 +2107,12 @@ impl Type {
2107 } 2107 }
2108 } 2108 }
2109 TyKind::Dyn(bounds) => { 2109 TyKind::Dyn(bounds) => {
2110 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); 2110 walk_bounds(
2111 db,
2112 &type_.derived(ty.clone()),
2113 bounds.bounds.skip_binders().interned(),
2114 cb,
2115 );
2111 } 2116 }
2112 2117
2113 TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => { 2118 TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => {