Open
Description
Given the following code:
fn main() {
let _ = vec[1].iter().next()?;
Some(())
}
Rust reports an error for using ?
and suggests adding ;
after the Some(())
. A preferrable Option (pun intended) is to suggest changing the return type to Option<()>
when the body's result type is Option<_>
and there exists at least one ?
in the body. Similarly, if we have Result
s, we might want to try to infer a useful return type, e.g.
fn main() {
let _ = std::fs::File::open("foo.txt")?;
Ok(())
}
cc @estebank (diagnostics)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.