aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index c46529879..ad908f957 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -106,6 +106,10 @@ impl ProjectionTy {
106 } 106 }
107 } 107 }
108 108
109 pub fn self_type_parameter(&self) -> &Ty {
110 &self.substitution[0]
111 }
112
109 fn trait_(&self, db: &dyn HirDatabase) -> TraitId { 113 fn trait_(&self, db: &dyn HirDatabase) -> TraitId {
110 match from_assoc_type_id(self.associated_ty_id).lookup(db.upcast()).container { 114 match from_assoc_type_id(self.associated_ty_id).lookup(db.upcast()).container {
111 AssocContainerId::TraitId(it) => it, 115 AssocContainerId::TraitId(it) => it,
@@ -936,10 +940,19 @@ impl Ty {
936 let param_data = &generic_params.types[id.local_id]; 940 let param_data = &generic_params.types[id.local_id];
937 match param_data.provenance { 941 match param_data.provenance {
938 hir_def::generics::TypeParamProvenance::ArgumentImplTrait => { 942 hir_def::generics::TypeParamProvenance::ArgumentImplTrait => {
943 let substs = Substitution::type_params(db, id.parent);
939 let predicates = db 944 let predicates = db
940 .generic_predicates_for_param(id) 945 .generic_predicates(id.parent)
941 .into_iter() 946 .into_iter()
942 .map(|pred| pred.value.clone()) 947 .map(|pred| pred.clone().subst(&substs))
948 .filter(|wc| match &wc {
949 WhereClause::Implemented(tr) => tr.self_type_parameter() == self,
950 WhereClause::AliasEq(AliasEq {
951 alias: AliasTy::Projection(proj),
952 ty: _,
953 }) => proj.self_type_parameter() == self,
954 _ => false,
955 })
943 .collect_vec(); 956 .collect_vec();
944 957
945 Some(predicates) 958 Some(predicates)