The following code:
trait A<C> {}
trait B {}
impl<T: A<C>, C> B for T {}
gives:
error[E0207]: the type parameter `C` is not constrained by the impl trait, self type, or predicates
--> src/lib.rs:5:15
|
5 | impl<T: A<C>, C> B for T {}
| ^ unconstrained type parameter
Although it's clear that C
is needed for the generic constraint over T
.
Moreover, if I use associated types:
trait A {
type C;
}
trait B {}
impl<T: A<C = C>, C> B for T {}
The code compiles fine!
Can someone explain this please?