aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/utils.rs')
-rw-r--r--crates/hir_ty/src/utils.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs
index e3e244268..af880c065 100644
--- a/crates/hir_ty/src/utils.rs
+++ b/crates/hir_ty/src/utils.rs
@@ -2,11 +2,10 @@
2//! query, but can't be computed directly from `*Data` (ie, which need a `db`). 2//! query, but can't be computed directly from `*Data` (ie, which need a `db`).
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::generics::WherePredicateTarget;
6use hir_def::{ 5use hir_def::{
7 adt::VariantData, 6 adt::VariantData,
8 db::DefDatabase, 7 db::DefDatabase,
9 generics::{GenericParams, TypeParamData, TypeParamProvenance}, 8 generics::{GenericParams, TypeParamData, TypeParamProvenance, WherePredicateTypeTarget},
10 path::Path, 9 path::Path,
11 resolver::{HasResolver, TypeNs}, 10 resolver::{HasResolver, TypeNs},
12 type_ref::TypeRef, 11 type_ref::TypeRef,
@@ -27,14 +26,19 @@ fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {
27 generic_params 26 generic_params
28 .where_predicates 27 .where_predicates
29 .iter() 28 .iter()
30 .filter_map(|pred| match &pred.target { 29 .filter_map(|pred| match pred {
31 WherePredicateTarget::TypeRef(TypeRef::Path(p)) if p == &Path::from(name![Self]) => { 30 hir_def::generics::WherePredicate::TypeBound { target, bound } => match target {
32 pred.bound.as_path() 31 WherePredicateTypeTarget::TypeRef(TypeRef::Path(p))
33 } 32 if p == &Path::from(name![Self]) =>
34 WherePredicateTarget::TypeParam(local_id) if Some(*local_id) == trait_self => { 33 {
35 pred.bound.as_path() 34 bound.as_path()
36 } 35 }
37 _ => None, 36 WherePredicateTypeTarget::TypeParam(local_id) if Some(*local_id) == trait_self => {
37 bound.as_path()
38 }
39 _ => None,
40 },
41 hir_def::generics::WherePredicate::Lifetime { .. } => None,
38 }) 42 })
39 .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) { 43 .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) {
40 Some(TypeNs::TraitId(t)) => Some(t), 44 Some(TypeNs::TraitId(t)) => Some(t),