Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprustc wrongly reports conflicting trait implementations #31115
Comments
This comment has been minimized.
This comment has been minimized.
|
A variation using associated types does compile: http://is.gd/GPGNj9 |
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated T-lang I don't have time to really dig into it, but I suspect the bug here might be that the associated type version does compile (although the two examples are fairly different: the second one only has three traits but the first one has 4?). Rust tries to avoid reasoning about implementations that don't exist, unless it absolutely has to (which is what the cc @rust-lang/lang, but especially @nikomatsakis |
rust-highfive
added
the
I-nominated
label
Jan 24, 2016
huonw
added
the
T-lang
label
Jan 24, 2016
This comment has been minimized.
This comment has been minimized.
|
@huonw is correct. The particular problem here is that a downstream crate could add an impl of struct MyNewType;
impl Foo for MyNewType {
type Bar = MyNewType;
}
impl Alternate<MyNewType> for MyNewType {}(I'm not sure if I have the nest of traits quite right here, but hopefully you get the basic idea). The point is, because downstream crates can impl existing traits if they apply Some of this kind of thing is described in the rebalancing coherence RFC. |
This comment has been minimized.
This comment has been minimized.
|
Sorry, to be clear: this is working as intended. |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the explanations, I see now that this is not a bug. In a little more experimentation after filing, I found that only the type parameter for In particular, I had assumed that the orphan rule would provide protection against implementations of Assuming the above is correct, it would make sense for the associated type version to compile, as the |
This comment has been minimized.
This comment has been minimized.
The full story is a bit more complicated than that. You can get the scoop in @nikomatsakis's epic blog post. |
rphmeier commentedJan 22, 2016
fails with E0119, although the Self types don't overlap.
Playpen: http://is.gd/vT98nf, fails on Stable, Beta, and Nightly.