-
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
#[diagnostic::on_unimplemented] hint not shown for associated type mismatch #125231
Comments
I believe that this is expected behavior.
As a more general note: Anything in the |
I though that this might be expected, though it still seems inconsistent to me. It becomes more obvious when you introduce another layer of indirection: Code#[diagnostic::on_unimplemented(message = "Very important message!")]
trait TheImportantOne {}
trait Intermediate {}
trait ImplementationDetail {
type Restriction;
}
impl<T: Intermediate> TheImportantOne for T {}
impl<T: ImplementationDetail<Restriction = ()>> Intermediate for T {}
// Comment out this `impl` to show the expected error message.
impl ImplementationDetail for u8 {
type Restriction = u8;
}
fn verify<T: TheImportantOne>() {}
pub fn main() {
verify::<u8>();
} Without the
With the
To me, it feels like the final error message / code should not matter. As soon we get to the And I could resolve that highest-level problem by simply doing I guess the current behavior makes sense if Anyway, you can look at this as a bug, and enhancement request, or just some feedback, so feel free to close as "working as intended" if you think that's what it is. |
It makes sense as a feature request. We never had this for |
I would argue that the "correct" behaviour is highly dependent on your use case. Is it more correct to suggest to implement In my personal opinion the correct solution for the former way would be to use the upcoming |
I've opened #125717 to address this via the |
Using the nightly only |
Awesome, thank you! I'll close this, then, because it seems like the behavior with just |
Code
Current output
Desired output
The "Very important message!" should be shown somewhere in the output (similar to what is shown if
impl ImplementationDetail for u8
is missing entirely).Rationale and extra context
The fundamental error is
required for `u8` to implement `TheImportantOne`
in both cases (impl ImplementationDetail for u8
completely missing andimpl ImplementationDetail for u8
having the wrongRestriction
type). As such, I would expect theon_unimplemented
message to display in both cases.Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: