Open timothee-haudebourg opened 2 years ago
Not a GATs issue:
pub trait Covariant<'a> {
type Target;
fn unwrap<'c>(target: <Self as Covariant<'c>>::Target) -> Self where Self: Covariant<'c>;
}
error[E0284]: type annotations needed: cannot satisfy `<Self as Covariant<'c>>::Target == _`
--> src/lib.rs:3:5
|
3 | fn unwrap<'c>(target: <Self as Covariant<'c>>::Target) -> Self where Self: Covariant<'c>;
| ^^^^^^ cannot satisfy `<Self as Covariant<'c>>::Target == _`
Sorry for the title, I don't really know how to describe this issue otherwise. I've been playing with GATs and trying to define a trait that would allow me to encode covariance. I came up with the following erroneous code. I know why it cannot work, but I am surprised by the error messages I got:
Everything works well without the
unwrap
function. But with it, I get some weird error messages:The compiler is unable to prove the equality of
<Self as Covariant<'c>>::Target<'a>
with...'_
? How is that possible? What does it mean? Fine. Then I tried to help it a little by replacing this complicated type with a type parameter, who knows:I get something even weirder in return:
How can
Self
be a type parameter? What does'a::<Self, 'a>
even mean?