Make diagnostics clearer for ? operator#75029
Make diagnostics clearer for ? operator#75029JohnTitor wants to merge 1 commit intorust-lang:masterfrom
? operator#75029Conversation
| = 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.
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.
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.
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