diff options
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/display.rs | 6 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 17 |
2 files changed, 16 insertions, 7 deletions
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index 9f6d7be48..c96ebb50a 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs | |||
@@ -236,7 +236,11 @@ impl HirDisplay for TypeParam { | |||
236 | write!(f, "{}", self.name(f.db))?; | 236 | write!(f, "{}", self.name(f.db))?; |
237 | let bounds = f.db.generic_predicates_for_param(self.id); | 237 | let bounds = f.db.generic_predicates_for_param(self.id); |
238 | let substs = Substitution::type_params(f.db, self.id.parent); | 238 | let substs = Substitution::type_params(f.db, self.id.parent); |
239 | let predicates = bounds.iter().cloned().map(|b| b.subst(&substs)).collect::<Vec<_>>(); | 239 | let predicates = bounds |
240 | .iter() | ||
241 | .cloned() | ||
242 | .map(|b| hir_ty::Binders::new(0, b.subst(&substs))) | ||
243 | .collect::<Vec<_>>(); | ||
240 | if !(predicates.is_empty() || f.omit_verbose_types()) { | 244 | if !(predicates.is_empty() || f.omit_verbose_types()) { |
241 | write_bounds_like_dyn_trait_with_prefix(":", &predicates, f)?; | 245 | write_bounds_like_dyn_trait_with_prefix(":", &predicates, f)?; |
242 | } | 246 | } |
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 | }; |
63 | use itertools::Itertools; | 63 | use itertools::Itertools; |
64 | use rustc_hash::FxHashSet; | 64 | use 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) => { |