-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Make diagnostics clearer for ?
operator
#75029
Conversation
= note: `?` operator cannot convert from `isize` to `std::result::Result<isize, ()>` | ||
= help: `?` operator unwraps `Result` or `Option` and propagates its `Err` or `None` |
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.
It's verbose?
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.
In my opinion this last note is not necessary. The clarification with concrete types of the first note should be enough, and people may be using the try_trait
feature with custom types where this won't apply.
Though I can see this as The explanation that makes it clear for some people.
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 agree, I feel the second note is probably unnecessary, no-one is likely to try to use ?
without knowing that Result
and Option
are supported.
☔ The latest upstream changes (presumably #74862) made this pull request unmergeable. Please resolve the merge conflicts. |
LL | let y: u32 = x?.try_into().unwrap(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ |
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.
The suggestion seems to be using the incorrect Span
. It should be replacing the ?
with the new code.
Closing this due to inactivity. |
Make diagnostics clearer for `?` operators Re-submission of rust-lang#75029, fixes rust-lang#71309 This also revives the `content` methods removed by rust-lang#83185. r? `@estebank`
Fixes #71309
r? @estebank