-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
The compiler reports conflicting even no real conflicting #22865
Comments
Nothing in the types prevents this, so it's possible for a conflict to arise though - there's nothing that prevents your library or any code that uses your library from doing this: struct Point;
impl Square for Point {
fn length(&self) -> f64 { 0.0 }
}
impl Circle for Point {
fn radius(&self) -> f64 { 0.0 }
} Now the implementation of |
Well, there's conflicting implementation detection, isn't there? For example, a The example taken in this issue (which has had many like it appear) really shows (in my opinion) why Rust should switch from preventing POTENTIAL conflicts to preventing ACTUAL conflicts. Why should POTENTIAL conflicts prevent useful things from being done? Sure, warnings would be nice, but errors? In general, I am against that "Additions should never be breaking" idea, yes it's not the most intuitive thing to debug that your program doesn't build with new stuff that's only been additive, but the error messages are helpful enough that it's easy to understand where and why a conflict occurs, whereas thinking your whole architecture around potential conflicts is really hard and limiting (at least, until we get proper specialization). |
When compiling, it gives:
Actually, the user must impl only one of the Square/Circle to a type, there is no conflicting. But it seems that the compiler reports the conflicting too early. I think the compiler should report until the conflicting is really happened (the user impl the both traits to a type). Workaround for it is simple, but the above code is simpler and more readablity than workarounds.
The text was updated successfully, but these errors were encountered: