-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiler does not error when implementing the same trait twice on generic types that are bounded by Copy #7555
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
Comments
Even if we happen to remove |
Nominated for production ready, this is a nasty coherence bug. |
Accepted for milestone 5, production-ready |
#5527 is related |
I believe this was due to the hack in coherence that was |
…ffate Fixes for `branches_sharing_code` fixes rust-lang#7198 fixes rust-lang#7452 fixes rust-lang#7555 fixes rust-lang#7589 changelog: Don't suggest moving modifications to locals used in any of the condition expressions in `branches_sharing_code` changelog: Don't suggest moving anything after a local with a significant drop in `branches_sharing_code`
In this code snippet, we impl a trait on all types that implement Bar. However, we impl the trait twice, and this correctly does not compile:
But, if instead of bounding our generics with Bar we bound them with the built-in Copy trait, this compiles successfully!
However, if you uncomment the lines that actually attempt to invoke .foo(), this code will fail to compile with "multiple applicable methods in scope".
Given that the non-built-in trait correctly prevents compilation at definition-time rather than waiting for invocation, I think it would be correct for
Copy
to do the same.The text was updated successfully, but these errors were encountered: