Skip to content

Commit 29ea2f0

Browse files
Handle RPITITs in defaulted trait methods
Here, we lower the method's return type twice: once with RPITITs as assoc types, and once with the RPITITs as opaques, as if it was repeated on the impl.
1 parent b7692b9 commit 29ea2f0

File tree

5 files changed

+385
-174
lines changed

5 files changed

+385
-174
lines changed

crates/hir-ty/src/display.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@ impl HirDisplay for ProjectionTy {
684684
),
685685
&assoc_type
686686
.bounds
687-
.skip_binders()
687+
.clone()
688+
.substitute(Interner, &self.substitution)
688689
.iter()
689690
.map(|bound| {
690691
// We ignore `Self` anyway when formatting, so it's fine put an error type in it.

crates/hir-ty/src/lower.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use crate::{
5252
FnSubst, ImplTrait, ImplTraitId, ImplTraits, Interner, Lifetime, LifetimeData,
5353
LifetimeOutlives, PlaceholderIndex, PolyFnSig, ProgramClause, ProjectionTy,
5454
QuantifiedWhereClause, QuantifiedWhereClauses, Substitution, TraitEnvironment, TraitRef,
55-
TraitRefExt, Ty, TyBuilder, TyKind, VariableKind, VariableKinds, WhereClause, all_super_traits,
55+
TraitRefExt, Ty, TyBuilder, TyKind, VariableKinds, WhereClause, all_super_traits,
5656
chalk_db::generic_predicate_to_inline_bound,
5757
consteval::{intern_const_ref, path_to_const, unknown_const, unknown_const_as_generic},
5858
db::HirDatabase,
@@ -450,8 +450,7 @@ impl<'a> TyLoweringContext<'a> {
450450
|a| ImplTraitId::TypeAliasImplTrait(a, idx),
451451
);
452452
let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into();
453-
let generics = generics(self.db, origin.either(|f| f.into(), |a| a.into()));
454-
let parameters = generics.bound_vars_subst(self.db, self.in_binders);
453+
let parameters = self.subst_for_generics();
455454
TyKind::OpaqueType(opaque_ty_id, parameters).intern(Interner)
456455
}
457456
ImplTraitLoweringMode::Disallowed => {
@@ -519,15 +518,7 @@ impl<'a> TyLoweringContext<'a> {
519518

520519
let assoc_type_binders = VariableKinds::from_iter(
521520
Interner,
522-
method_generics.iter_id().map(|param_id| match param_id {
523-
GenericParamId::TypeParamId(_) => {
524-
VariableKind::Ty(chalk_ir::TyVariableKind::General)
525-
}
526-
GenericParamId::ConstParamId(param_id) => {
527-
VariableKind::Const(self.db.const_param_ty(param_id))
528-
}
529-
GenericParamId::LifetimeParamId(_) => VariableKind::Lifetime,
530-
}),
521+
variable_kinds_from_generics(self.db, method_generics.iter_id()),
531522
);
532523

533524
let returned_subst = self.subst_for_generics();

0 commit comments

Comments
 (0)