Why can't a higher grade of the From <> attribute be evaluated on the associated type, but can Into <>?

 trait A<'self_> { type T; } trait B: for<'self_> A<'self_> { type U: for<'self_> From<<Self as A<'self_>>::T>; // <-- this won't compile // type U: for<'self_> Into<<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() {} 

playpen link

Why the line marked as “this will not compile” will not compile (although From<T> is implemented for all T ), while the character marked “but it will” (which depends on whether Into depends on From in the standard library) ?

I suspect this is a legitimate mistake, but it would be better not to record anything and add to the noise, if just something special in From vs. Into that I did not know about.

+5
source share

Source: https://habr.com/ru/post/1238215/


All Articles