Hi,

I think traits with type parameters just don't work very 'as expected'
yet. Relevant to your example you can't yet do

    impl Foo<X1> for int {}
    impl Foo<X2> for int {}

because the type parameter isn't taken into account for coherence checks
and so those are conflicting implementations. I don't have a good
solution for you, but this issue has been mentioned here:
https://github.com/mozilla/rust/issues/5527#issuecomment-17809177

Also I think that `impl<T...> ... for T` isn't yet well-supported
either: https://github.com/mozilla/rust/issues/3429#issuecomment-8405280

-benh

On Mon, 2013-09-30 at 00:06 -0700, Vadim wrote:
> Hi,
> I don't understand why the following produces an error:
> 
> >cat test.rs
> 
> trait Foo<T> {}
> struct X1;
> struct X2;
> 
> impl<T: Foo<X1>> Foo<X2> for T {}
> 
> fn main() {}
> 
> >rustc test.rs
> test.rs:6:0: 6:33 error: expected Foo<X2>, but found Foo<X1> (expected
> struct X2 but found struct X1)
> test.rs:6 impl<T: Foo<X1>> Foo<X2> for T {}
>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> error: aborting due to previous error
> 
> 
> 
> I'm trying to say "Any type that implements Foo<X1> also implements
> Foo<X2>"...   What's wrong here?
> 
> 
> 
> 
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to