Skip to content
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

Trait "is not implemented for the type" with associated types and blanket impls #19479

Closed
comex opened this issue Dec 2, 2014 · 0 comments · Fixed by #20404
Closed

Trait "is not implemented for the type" with associated types and blanket impls #19479

comex opened this issue Dec 2, 2014 · 0 comments · Fixed by #20404
Labels
A-associated-items Area: Associated items (types, constants & functions)

Comments

@comex
Copy link
Contributor

comex commented Dec 2, 2014

This may be a duplicate of #19058, but the code looks somewhat different - there is only one associated type. Here, the idea is to blanket impl a trait with an associated type based on another.

#![feature(associated_types)]
trait Base {}
trait AssocA {
    type X: Base;
}
trait AssocB {
    type Y: Base;
}
impl<T: AssocA> AssocB for T {
    type Y = <T as AssocA>::X;
}

fn main() {}

produces

asty.rs:9:1: 11:2 error: the trait `Base` is not implemented for the type `X`
asty.rs:9 impl<T: AssocA> AssocB for T {
asty.rs:10     type Y = <T as AssocA>::X;
asty.rs:11 }
asty.rs:9:1: 11:2 note: the trait `Base` must be implemented because it is required by `AssocB`
asty.rs:9 impl<T: AssocA> AssocB for T {
asty.rs:10     type Y = <T as AssocA>::X;
asty.rs:11 }

which is clearly wrong, since AssocA::X is required to implement Base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants