-
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
Nonconflicting Conflicting impl in trait object when trait and object impl same item name #45251
Comments
Actually, I'm not even sure there should be a conflict here. Inherent methods are supposed to win out over all trait methods. And since the implementations don't seem to overlap, I can only presume that the conflicting implementation are false altogether. |
Trait objects are a special case, trait method and inherent method on a trait with the same name are supposed to conflict because someone (IIRC, @nrc) in the past thought it would prevent errors. |
If that's the case, then the error should happen without having to call the function. I'd be okay with making it a hard error to have a trait object implement an item with the same name as its trait. Just make sure there's a specific error for this. Although with |
This still needs to be tagged. cc @kennytm |
Closing in favor of issue #51402 |
Playpen
Source
Error Message
The error message here suggests that there are three implementations that define the associated item when in reality, there can only be two. It's not possible to call the implementation on Trait + std::marker::Sync + std::marker::Send + 'static` because the type is not Sync. So the error message should not show that implementation.
At least, that is what I believe the error to be. For if you comment out either the default implementation on line 2 or the inherent implementation on line 12, then the program actually compiles.
The text was updated successfully, but these errors were encountered: