mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Fix return type of self_type_parameter
This commit is contained in:
parent
6777a4975d
commit
9b4ecd3723
@ -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::<Vec<_>>();
|
||||
|
@ -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::<Vec<_>>();
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user