aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/display.rs31
-rw-r--r--crates/hir_ty/src/lib.rs8
-rw-r--r--crates/hir_ty/src/lower.rs3
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs2
4 files changed, 24 insertions, 20 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 965476a05..1108e5a10 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -592,20 +592,21 @@ impl HirDisplay for Ty {
592 } 592 }
593 TypeParamProvenance::ArgumentImplTrait => { 593 TypeParamProvenance::ArgumentImplTrait => {
594 let substs = generics.type_params_subst(f.db); 594 let substs = generics.type_params_subst(f.db);
595 let bounds = f 595 let bounds =
596 .db 596 f.db.generic_predicates(id.parent)
597 .generic_predicates(id.parent) 597 .into_iter()
598 .into_iter() 598 .map(|pred| pred.clone().subst(&substs))
599 .map(|pred| pred.clone().subst(&substs)) 599 .filter(|wc| match &wc.skip_binders() {
600 .filter(|wc| match &wc.skip_binders() { 600 WhereClause::Implemented(tr) => {
601 WhereClause::Implemented(tr) => tr.self_type_parameter() == self, 601 tr.self_type_parameter(&Interner) == self
602 WhereClause::AliasEq(AliasEq { 602 }
603 alias: AliasTy::Projection(proj), 603 WhereClause::AliasEq(AliasEq {
604 ty: _, 604 alias: AliasTy::Projection(proj),
605 }) => proj.self_type_parameter(&Interner) == self, 605 ty: _,
606 _ => false, 606 }) => proj.self_type_parameter(&Interner) == self,
607 }) 607 _ => false,
608 .collect::<Vec<_>>(); 608 })
609 .collect::<Vec<_>>();
609 write_bounds_like_dyn_trait_with_prefix("impl", &bounds, f)?; 610 write_bounds_like_dyn_trait_with_prefix("impl", &bounds, f)?;
610 } 611 }
611 } 612 }
@@ -780,7 +781,7 @@ impl TraitRef {
780 return write!(f, "{}", TYPE_HINT_TRUNCATION); 781 return write!(f, "{}", TYPE_HINT_TRUNCATION);
781 } 782 }
782 783
783 self.self_type_parameter().hir_fmt(f)?; 784 self.self_type_parameter(&Interner).hir_fmt(f)?;
784 if use_as { 785 if use_as {
785 write!(f, " as ")?; 786 write!(f, " as ")?;
786 } else { 787 } else {
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 80dd7aaca..adfdcaa37 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -165,8 +165,8 @@ impl<T: TypeWalk> Binders<T> {
165} 165}
166 166
167impl TraitRef { 167impl TraitRef {
168 pub fn self_type_parameter(&self) -> &Ty { 168 pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
169 &self.substitution.at(&Interner, 0).assert_ty_ref(&Interner) 169 &self.substitution.at(interner, 0).assert_ty_ref(interner)
170 } 170 }
171 171
172 pub fn hir_trait_id(&self) -> TraitId { 172 pub fn hir_trait_id(&self) -> TraitId {
@@ -473,7 +473,9 @@ impl Ty {
473 .into_iter() 473 .into_iter()
474 .map(|pred| pred.clone().subst(&substs)) 474 .map(|pred| pred.clone().subst(&substs))
475 .filter(|wc| match &wc.skip_binders() { 475 .filter(|wc| match &wc.skip_binders() {
476 WhereClause::Implemented(tr) => tr.self_type_parameter() == self, 476 WhereClause::Implemented(tr) => {
477 tr.self_type_parameter(&Interner) == self
478 }
477 WhereClause::AliasEq(AliasEq { 479 WhereClause::AliasEq(AliasEq {
478 alias: AliasTy::Projection(proj), 480 alias: AliasTy::Projection(proj),
479 ty: _, 481 ty: _,
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index ba48be4ad..e9e4e69ad 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -941,7 +941,8 @@ pub(crate) fn trait_environment_query(
941 for pred in resolver.where_predicates_in_scope() { 941 for pred in resolver.where_predicates_in_scope() {
942 for pred in ctx.lower_where_predicate(pred, false) { 942 for pred in ctx.lower_where_predicate(pred, false) {
943 if let WhereClause::Implemented(tr) = &pred.skip_binders() { 943 if let WhereClause::Implemented(tr) = &pred.skip_binders() {
944 traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id())); 944 traits_in_scope
945 .push((tr.self_type_parameter(&Interner).clone(), tr.hir_trait_id()));
945 } 946 }
946 let program_clause: chalk_ir::ProgramClause<Interner> = 947 let program_clause: chalk_ir::ProgramClause<Interner> =
947 pred.clone().to_chalk(db).cast(&Interner); 948 pred.clone().to_chalk(db).cast(&Interner);
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 240f9d456..67e88ebf4 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -539,7 +539,7 @@ pub(super) fn generic_predicate_to_inline_bound(
539 let self_ty_shifted_in = self_ty.clone().shift_bound_vars(DebruijnIndex::ONE); 539 let self_ty_shifted_in = self_ty.clone().shift_bound_vars(DebruijnIndex::ONE);
540 match &pred.value { 540 match &pred.value {
541 WhereClause::Implemented(trait_ref) => { 541 WhereClause::Implemented(trait_ref) => {
542 if trait_ref.self_type_parameter() != &self_ty_shifted_in { 542 if trait_ref.self_type_parameter(&Interner) != &self_ty_shifted_in {
543 // we can only convert predicates back to type bounds if they 543 // we can only convert predicates back to type bounds if they
544 // have the expected self type 544 // have the expected self type
545 return None; 545 return None;