Open
Description
The following code
fn foo() -> Option<usize> {
let x = Some(42).unwrap()?;
x
}
currently emits
error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> src/lib.rs:2:13
|
2 | let x = Some(42).unwrap()?;
| ^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `{integer}`
|
= help: the trait `Try` is not implemented for `{integer}`
but it should suggest removing the .unwrap()
.
Inspired by https://x.com/jonasfovea/status/1808961128812183774
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.