mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 04:03:11 +00:00
Pass interner to TraitRef::self_type_parameter
This commit is contained in:
parent
aefcbf2758
commit
d7546d8c23
@ -592,20 +592,21 @@ impl HirDisplay for Ty {
|
||||
}
|
||||
TypeParamProvenance::ArgumentImplTrait => {
|
||||
let substs = generics.type_params_subst(f.db);
|
||||
let bounds = f
|
||||
.db
|
||||
.generic_predicates(id.parent)
|
||||
.into_iter()
|
||||
.map(|pred| pred.clone().subst(&substs))
|
||||
.filter(|wc| match &wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => tr.self_type_parameter() == self,
|
||||
WhereClause::AliasEq(AliasEq {
|
||||
alias: AliasTy::Projection(proj),
|
||||
ty: _,
|
||||
}) => proj.self_type_parameter(&Interner) == self,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let bounds =
|
||||
f.db.generic_predicates(id.parent)
|
||||
.into_iter()
|
||||
.map(|pred| pred.clone().subst(&substs))
|
||||
.filter(|wc| match &wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => {
|
||||
tr.self_type_parameter(&Interner) == self
|
||||
}
|
||||
WhereClause::AliasEq(AliasEq {
|
||||
alias: AliasTy::Projection(proj),
|
||||
ty: _,
|
||||
}) => proj.self_type_parameter(&Interner) == self,
|
||||
_ => false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
write_bounds_like_dyn_trait_with_prefix("impl", &bounds, f)?;
|
||||
}
|
||||
}
|
||||
@ -780,7 +781,7 @@ impl TraitRef {
|
||||
return write!(f, "{}", TYPE_HINT_TRUNCATION);
|
||||
}
|
||||
|
||||
self.self_type_parameter().hir_fmt(f)?;
|
||||
self.self_type_parameter(&Interner).hir_fmt(f)?;
|
||||
if use_as {
|
||||
write!(f, " as ")?;
|
||||
} else {
|
||||
|
@ -165,8 +165,8 @@ impl<T: TypeWalk> Binders<T> {
|
||||
}
|
||||
|
||||
impl TraitRef {
|
||||
pub fn self_type_parameter(&self) -> &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)
|
||||
}
|
||||
|
||||
pub fn hir_trait_id(&self) -> TraitId {
|
||||
@ -473,7 +473,9 @@ impl Ty {
|
||||
.into_iter()
|
||||
.map(|pred| pred.clone().subst(&substs))
|
||||
.filter(|wc| match &wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => tr.self_type_parameter() == self,
|
||||
WhereClause::Implemented(tr) => {
|
||||
tr.self_type_parameter(&Interner) == self
|
||||
}
|
||||
WhereClause::AliasEq(AliasEq {
|
||||
alias: AliasTy::Projection(proj),
|
||||
ty: _,
|
||||
|
@ -941,7 +941,8 @@ pub(crate) fn trait_environment_query(
|
||||
for pred in resolver.where_predicates_in_scope() {
|
||||
for pred in ctx.lower_where_predicate(pred, false) {
|
||||
if let WhereClause::Implemented(tr) = &pred.skip_binders() {
|
||||
traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id()));
|
||||
traits_in_scope
|
||||
.push((tr.self_type_parameter(&Interner).clone(), tr.hir_trait_id()));
|
||||
}
|
||||
let program_clause: chalk_ir::ProgramClause<Interner> =
|
||||
pred.clone().to_chalk(db).cast(&Interner);
|
||||
|
@ -539,7 +539,7 @@ pub(super) fn generic_predicate_to_inline_bound(
|
||||
let self_ty_shifted_in = self_ty.clone().shift_bound_vars(DebruijnIndex::ONE);
|
||||
match &pred.value {
|
||||
WhereClause::Implemented(trait_ref) => {
|
||||
if trait_ref.self_type_parameter() != &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;
|
||||
|
Loading…
Reference in New Issue
Block a user