Associated type projections don't play well with HRTBs and normalization #30472
Closed
Description
trait MyFrom<T> {}
impl<T> MyFrom<T> for T {}
trait MyInto<T> {}
impl<T, U> MyInto<U> for T where U: MyFrom<T> {}
trait A<'self_> {
type T;
}
trait B: for<'self_> A<'self_> {
//type U: for<'self_> MyFrom<<Self as A<'self_>>::T>; // <-- this won't compile
type U: for<'self_> MyInto<<Self as A<'self_>>::T>; // <-- but this will
}
struct M;
impl<'self_> A<'self_> for M {
type T = usize;
}
impl B for M {
type U = usize;
}
fn main() {}
This could've been written with MyInto
written as Into
and similarly for MyFrom
/From
. It was written this way only to make explicit the necessity of one blanket impl for satisfying the other.
I'm guessing that extensional equality is not judged, even though it is possible to make such a judgment and such a judgment must be made to compile code that compiles today. <Self as A<'self_>>::T
on line 12 ought to be equated to usize
(which must be detected at some other point in time else line 13 wouldn't be able to compile).
EDIT: Playing around a bit, it looks more and more like it's all about the HKL bounds...
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Lazy normalization (tracking issue: #60471)Area: Lifetimes / regionsArea: Type systemCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.