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.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs
index df0ea4368..d11708299 100644
--- a/crates/hir_ty/src/utils.rs
+++ b/crates/hir_ty/src/utils.rs
@@ -66,13 +66,15 @@ fn direct_super_trait_refs(db: &dyn HirDatabase, trait_ref: &TraitRef) -> Vec<Tr
66 .filter_map(|pred| { 66 .filter_map(|pred| {
67 pred.as_ref().filter_map(|pred| match pred.skip_binders() { 67 pred.as_ref().filter_map(|pred| match pred.skip_binders() {
68 // FIXME: how to correctly handle higher-ranked bounds here? 68 // FIXME: how to correctly handle higher-ranked bounds here?
69 WhereClause::Implemented(tr) => { 69 WhereClause::Implemented(tr) => Some(
70 Some(tr.clone().shift_bound_vars_out(DebruijnIndex::ONE)) 70 tr.clone()
71 } 71 .shifted_out_to(DebruijnIndex::ONE)
72 .expect("FIXME unexpected higher-ranked trait bound"),
73 ),
72 _ => None, 74 _ => None,
73 }) 75 })
74 }) 76 })
75 .map(|pred| pred.subst(&trait_ref.substitution)) 77 .map(|pred| pred.substitute(&Interner, &trait_ref.substitution))
76 .collect() 78 .collect()
77} 79}
78 80
@@ -103,6 +105,8 @@ pub(super) fn all_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<Tra
103/// we have `Self: Trait<u32, i32>` and `Trait<T, U>: OtherTrait<U>` we'll get 105/// we have `Self: Trait<u32, i32>` and `Trait<T, U>: OtherTrait<U>` we'll get
104/// `Self: OtherTrait<i32>`. 106/// `Self: OtherTrait<i32>`.
105pub(super) fn all_super_trait_refs(db: &dyn HirDatabase, trait_ref: TraitRef) -> Vec<TraitRef> { 107pub(super) fn all_super_trait_refs(db: &dyn HirDatabase, trait_ref: TraitRef) -> Vec<TraitRef> {
108 // FIXME: replace by Chalk's `super_traits`, maybe make this a query
109
106 // we need to take care a bit here to avoid infinite loops in case of cycles 110 // we need to take care a bit here to avoid infinite loops in case of cycles
107 // (i.e. if we have `trait A: B; trait B: A;`) 111 // (i.e. if we have `trait A: B; trait B: A;`)
108 let mut result = vec![trait_ref]; 112 let mut result = vec![trait_ref];