Skip to content

Confusing error with trait with multiple associated types #20521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
apasel422 opened this issue Jan 4, 2015 · 2 comments
Closed

Confusing error with trait with multiple associated types #20521

apasel422 opened this issue Jan 4, 2015 · 2 comments

Comments

@apasel422
Copy link
Contributor

I'm not sure if the following should work, but the error message is not helpful:

#![feature(associated_types)]

pub trait Foo {
    type L;
    type R;
}

pub struct Bar<C, D>(C, D);

impl<C: Foo, D: Foo<L = C::L, R = C::R>> Foo for Bar<C, D> {
    type L = C::L;
    type R = C::R;
}

On rustc 0.13.0-nightly (c6c786671 2015-01-04 00:50:59 +0000) this yields:

lib.rs:10:1: 13:2 error: type annotations required: cannot resolve `<D as Foo>::L == <C as Foo>::L`
lib.rs:10 impl<C: Foo, D: Foo<L = C::L, R = C::R>> Foo for Bar<C, D> {
lib.rs:11     type L = C::L;
lib.rs:12     type R = C::R;
lib.rs:13 }

Removing the second associated type from Foo (R) compiles successfully.

@apasel422
Copy link
Contributor Author

The following also compiles successfully:

#![feature(associated_types)]

pub trait Foo {
    type L;
    type R;
}

pub struct Bar<C, D>(C, D);

impl<C: Foo, D: Foo<L = C::L>> Foo for Bar<C, D> {
    type L = C::L;
    type R = C::R;
}

@apasel422
Copy link
Contributor Author

This was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant