aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-07 19:41:52 +0100
committerFlorian Diebold <[email protected]>2021-04-07 19:41:52 +0100
commit9b4ecd3723c0184706d1276759846ebf3fdff944 (patch)
treee32e0458498407d8a914b468deabab667b7caeed /crates/hir_ty/src
parent6777a4975d6a88928fda3e3b3f0bb05d98c61060 (diff)
Fix return type of `self_type_parameter`
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/chalk_ext.rs4
-rw-r--r--crates/hir_ty/src/display.rs4
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs4
-rw-r--r--crates/hir_ty/src/types.rs8
4 files changed, 10 insertions, 10 deletions
diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs
index 95538eff7..4ea91787e 100644
--- a/crates/hir_ty/src/chalk_ext.rs
+++ b/crates/hir_ty/src/chalk_ext.rs
@@ -199,12 +199,12 @@ impl TyExt for Ty {
199 .map(|pred| pred.clone().substitute(&Interner, &substs)) 199 .map(|pred| pred.clone().substitute(&Interner, &substs))
200 .filter(|wc| match &wc.skip_binders() { 200 .filter(|wc| match &wc.skip_binders() {
201 WhereClause::Implemented(tr) => { 201 WhereClause::Implemented(tr) => {
202 tr.self_type_parameter(&Interner) == self 202 &tr.self_type_parameter(&Interner) == self
203 } 203 }
204 WhereClause::AliasEq(AliasEq { 204 WhereClause::AliasEq(AliasEq {
205 alias: AliasTy::Projection(proj), 205 alias: AliasTy::Projection(proj),
206 ty: _, 206 ty: _,
207 }) => proj.self_type_parameter(&Interner) == self, 207 }) => &proj.self_type_parameter(&Interner) == self,
208 _ => false, 208 _ => false,
209 }) 209 })
210 .collect::<Vec<_>>(); 210 .collect::<Vec<_>>();
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 52c2d6347..90801ef2d 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -616,12 +616,12 @@ impl HirDisplay for Ty {
616 .map(|pred| pred.clone().substitute(&Interner, &substs)) 616 .map(|pred| pred.clone().substitute(&Interner, &substs))
617 .filter(|wc| match &wc.skip_binders() { 617 .filter(|wc| match &wc.skip_binders() {
618 WhereClause::Implemented(tr) => { 618 WhereClause::Implemented(tr) => {
619 tr.self_type_parameter(&Interner) == self 619 &tr.self_type_parameter(&Interner) == self
620 } 620 }
621 WhereClause::AliasEq(AliasEq { 621 WhereClause::AliasEq(AliasEq {
622 alias: AliasTy::Projection(proj), 622 alias: AliasTy::Projection(proj),
623 ty: _, 623 ty: _,
624 }) => proj.self_type_parameter(&Interner) == self, 624 }) => &proj.self_type_parameter(&Interner) == self,
625 _ => false, 625 _ => false,
626 }) 626 })
627 .collect::<Vec<_>>(); 627 .collect::<Vec<_>>();
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index f64b5f4f8..701359e6f 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -509,7 +509,7 @@ pub(super) fn generic_predicate_to_inline_bound(
509 let (pred, binders) = pred.as_ref().into_value_and_skipped_binders(); 509 let (pred, binders) = pred.as_ref().into_value_and_skipped_binders();
510 match pred { 510 match pred {
511 WhereClause::Implemented(trait_ref) => { 511 WhereClause::Implemented(trait_ref) => {
512 if trait_ref.self_type_parameter(&Interner) != &self_ty_shifted_in { 512 if trait_ref.self_type_parameter(&Interner) != self_ty_shifted_in {
513 // we can only convert predicates back to type bounds if they 513 // we can only convert predicates back to type bounds if they
514 // have the expected self type 514 // have the expected self type
515 return None; 515 return None;
@@ -522,7 +522,7 @@ pub(super) fn generic_predicate_to_inline_bound(
522 Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound))) 522 Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound)))
523 } 523 }
524 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { 524 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => {
525 if projection_ty.self_type_parameter(&Interner) != &self_ty_shifted_in { 525 if projection_ty.self_type_parameter(&Interner) != self_ty_shifted_in {
526 return None; 526 return None;
527 } 527 }
528 let trait_ = projection_ty.trait_(db); 528 let trait_ = projection_ty.trait_(db);
diff --git a/crates/hir_ty/src/types.rs b/crates/hir_ty/src/types.rs
index c25bc2d6a..72be7e04f 100644
--- a/crates/hir_ty/src/types.rs
+++ b/crates/hir_ty/src/types.rs
@@ -30,8 +30,8 @@ pub struct ProjectionTy {
30} 30}
31 31
32impl ProjectionTy { 32impl ProjectionTy {
33 pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { 33 pub fn self_type_parameter(&self, interner: &Interner) -> Ty {
34 &self.substitution.interned()[0].assert_ty_ref(interner) 34 self.substitution.interned()[0].assert_ty_ref(interner).clone()
35 } 35 }
36} 36}
37 37
@@ -413,8 +413,8 @@ pub struct TraitRef {
413} 413}
414 414
415impl TraitRef { 415impl TraitRef {
416 pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { 416 pub fn self_type_parameter(&self, interner: &Interner) -> Ty {
417 &self.substitution.at(interner, 0).assert_ty_ref(interner) 417 self.substitution.at(interner, 0).assert_ty_ref(interner).clone()
418 } 418 }
419} 419}
420 420