-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc wrongly reports conflicting trait implementations #31115
Comments
A variation using associated types does compile: http://is.gd/GPGNj9 |
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 |
@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. |
Sorry, to be clear: this is working as intended. |
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 |
The full story is a bit more complicated than that. You can get the scoop in @nikomatsakis's epic blog post. |
fails with E0119, although the Self types don't overlap.
Playpen: http://is.gd/vT98nf, fails on Stable, Beta, and Nightly.
The text was updated successfully, but these errors were encountered: