Skip to content

error: Trait not implemented for type... on the line of the implementation for the type #18809

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
soltanmm opened this issue Nov 9, 2014 · 2 comments
Labels
A-trait-system Area: Trait system

Comments

@soltanmm
Copy link

soltanmm commented Nov 9, 2014

This was the smallest I could make it. Commenting out the lines for either T0 or T1 or making T0 and T1 the same type allows compilation to finish successfully.

#![feature(associated_types)]
trait Tup {
    type T0;
    type T1;
}
impl Tup for int {
    type T0 = f32;
    type T1 = ();
}
fn main() {
}

Error:

a.rs:6:1: 9:2 error: the trait `Tup` is not implemented for the type `int`
a.rs:6 impl Tup for int {
a.rs:7     type T0 = f32;
a.rs:8     type T1 = ();
a.rs:9 }
a.rs:6:1: 9:2 note: the trait `Tup` must be implemented because it is required by `Tup`
a.rs:6 impl Tup for int {
a.rs:7     type T0 = f32;
a.rs:8     type T1 = ();
a.rs:9 }
error: aborting due to previous error

What I don't understand is: why in the world is it even complaining about Tup implementations when no one is using Tup? Is this some sort of weird interaction with trait object types?

(rustc at commit a2f303a, Linux)

@jpetkau
Copy link

jpetkau commented Nov 10, 2014

I've been seeing this too, any time I have a trait with two associated types that are different. Still happens as of the current nightly.

Strangely, if you make them the same (i.e. "type T0 = f32; type T1 = f32;" in the impl), the error goes away.

@huonw huonw added A-trait-system Area: Trait system I-wrong labels Nov 12, 2014
@nham
Copy link
Contributor

nham commented May 6, 2015

This seems to be fixed. The example compiles on rustc 1.1.0-nightly (435622028 2015-05-04) (built 2015-05-05)

nham pushed a commit to nham/rust that referenced this issue Jun 20, 2015
bors added a commit that referenced this issue Jun 21, 2015
lnicola pushed a commit to lnicola/rust that referenced this issue Jan 7, 2025
internal: Do not render closure ids in hover messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants