Skip to content

Commit 9b4ecd3

Browse files
committed
Fix return type of self_type_parameter
1 parent 6777a49 commit 9b4ecd3

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

crates/hir_ty/src/chalk_ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ impl TyExt for Ty {
199199
.map(|pred| pred.clone().substitute(&Interner, &substs))
200200
.filter(|wc| match &wc.skip_binders() {
201201
WhereClause::Implemented(tr) => {
202-
tr.self_type_parameter(&Interner) == self
202+
&tr.self_type_parameter(&Interner) == self
203203
}
204204
WhereClause::AliasEq(AliasEq {
205205
alias: AliasTy::Projection(proj),
206206
ty: _,
207-
}) => proj.self_type_parameter(&Interner) == self,
207+
}) => &proj.self_type_parameter(&Interner) == self,
208208
_ => false,
209209
})
210210
.collect::<Vec<_>>();

crates/hir_ty/src/display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,12 @@ impl HirDisplay for Ty {
616616
.map(|pred| pred.clone().substitute(&Interner, &substs))
617617
.filter(|wc| match &wc.skip_binders() {
618618
WhereClause::Implemented(tr) => {
619-
tr.self_type_parameter(&Interner) == self
619+
&tr.self_type_parameter(&Interner) == self
620620
}
621621
WhereClause::AliasEq(AliasEq {
622622
alias: AliasTy::Projection(proj),
623623
ty: _,
624-
}) => proj.self_type_parameter(&Interner) == self,
624+
}) => &proj.self_type_parameter(&Interner) == self,
625625
_ => false,
626626
})
627627
.collect::<Vec<_>>();

crates/hir_ty/src/traits/chalk/mapping.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ pub(super) fn generic_predicate_to_inline_bound(
509509
let (pred, binders) = pred.as_ref().into_value_and_skipped_binders();
510510
match pred {
511511
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 {
513513
// we can only convert predicates back to type bounds if they
514514
// have the expected self type
515515
return None;
@@ -522,7 +522,7 @@ pub(super) fn generic_predicate_to_inline_bound(
522522
Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound)))
523523
}
524524
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 {
526526
return None;
527527
}
528528
let trait_ = projection_ty.trait_(db);

crates/hir_ty/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub struct ProjectionTy {
3030
}
3131

3232
impl ProjectionTy {
33-
pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
34-
&self.substitution.interned()[0].assert_ty_ref(interner)
33+
pub fn self_type_parameter(&self, interner: &Interner) -> Ty {
34+
self.substitution.interned()[0].assert_ty_ref(interner).clone()
3535
}
3636
}
3737

@@ -413,8 +413,8 @@ pub struct TraitRef {
413413
}
414414

415415
impl TraitRef {
416-
pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
417-
&self.substitution.at(interner, 0).assert_ty_ref(interner)
416+
pub fn self_type_parameter(&self, interner: &Interner) -> Ty {
417+
self.substitution.at(interner, 0).assert_ty_ref(interner).clone()
418418
}
419419
}
420420

0 commit comments

Comments
 (0)