-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Extend rustc_on_implemented
to improve more ?
error messages
#85596
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
Conversation
rustc_on_implemented
to improve a ?
-on-ControlFlow
error messagerustc_on_implemented
to improve more ?
error messages
ca45e7e
to
b6d1cf1
Compare
b6d1cf1
to
8be6799
Compare
--> $DIR/bad-interconversion.rs:22:22 | ||
| | ||
LL | / fn result_to_option() -> Option<u16> { | ||
LL | | Some(Err("hello")?) | ||
| | ^ this `?` produces `Result<Infallible, &str>`, which is incompatible with `Option<u16>` | ||
| | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be clearer if we mentioned something like if you want to discard the Result::Err(&str)
or something along those lines 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the residual being "coloured" with the Try
type does make it harder to put in this error message nicely. I guess it would be less bad with just Result<!, &str>
, but Infallible
is long enough to be distracting. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more worried about confusing newcomers than anything else, anyone that already knows about Result
, Option
and .ok()
wouldn't be confused regardless of wording, but someone who doesn't yet have a good grasp of what an enum
even or that hasn't internalized Result::Err
is the error information might be helped with things being more spelled out. Either way, I'm ok with the current wording.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been looking at the quadratic growth of the on-unimplemented attribute here and been wondering if it should turn into custom code for it at some point. If at some point in the future you get inspired with a great idea for how these error should look, feel free to assign me an issue. (Or, of course, just do it yourself if that's easier that answering my inevitable noob questions 😅)
@bors r+ |
📌 Commit 8be6799 has been approved by |
☀️ Test successful - checks-actions |
_Self
could match the generic definition; this adds that functionality for matching the generic definition of type parameters too.Your advice welcome on the wording of all these messages, and which things belong in the message/label/note.
r? @estebank