From 9b4ecd3723c0184706d1276759846ebf3fdff944 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 20:41:52 +0200 Subject: Fix return type of `self_type_parameter` --- crates/hir_ty/src/chalk_ext.rs | 4 ++-- crates/hir_ty/src/display.rs | 4 ++-- crates/hir_ty/src/traits/chalk/mapping.rs | 4 ++-- crates/hir_ty/src/types.rs | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/hir_ty') 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 { .map(|pred| pred.clone().substitute(&Interner, &substs)) .filter(|wc| match &wc.skip_binders() { WhereClause::Implemented(tr) => { - tr.self_type_parameter(&Interner) == self + &tr.self_type_parameter(&Interner) == self } WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), ty: _, - }) => proj.self_type_parameter(&Interner) == self, + }) => &proj.self_type_parameter(&Interner) == self, _ => false, }) .collect::>(); 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 { .map(|pred| pred.clone().substitute(&Interner, &substs)) .filter(|wc| match &wc.skip_binders() { WhereClause::Implemented(tr) => { - tr.self_type_parameter(&Interner) == self + &tr.self_type_parameter(&Interner) == self } WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), ty: _, - }) => proj.self_type_parameter(&Interner) == self, + }) => &proj.self_type_parameter(&Interner) == self, _ => false, }) .collect::>(); 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( let (pred, binders) = pred.as_ref().into_value_and_skipped_binders(); match pred { WhereClause::Implemented(trait_ref) => { - if trait_ref.self_type_parameter(&Interner) != &self_ty_shifted_in { + if trait_ref.self_type_parameter(&Interner) != self_ty_shifted_in { // we can only convert predicates back to type bounds if they // have the expected self type return None; @@ -522,7 +522,7 @@ pub(super) fn generic_predicate_to_inline_bound( Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound))) } WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { - if projection_ty.self_type_parameter(&Interner) != &self_ty_shifted_in { + if projection_ty.self_type_parameter(&Interner) != self_ty_shifted_in { return None; } 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 { } impl ProjectionTy { - pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { - &self.substitution.interned()[0].assert_ty_ref(interner) + pub fn self_type_parameter(&self, interner: &Interner) -> Ty { + self.substitution.interned()[0].assert_ty_ref(interner).clone() } } @@ -413,8 +413,8 @@ pub struct TraitRef { } impl TraitRef { - pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { - &self.substitution.at(interner, 0).assert_ty_ref(interner) + pub fn self_type_parameter(&self, interner: &Interner) -> Ty { + self.substitution.at(interner, 0).assert_ty_ref(interner).clone() } } -- cgit v1.2.3