-
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
Suggest alternative return type for Option
s and Result
s
#61277
Comments
Notice that if the function is not
|
Can you tell me the rough location of the code that does this? I imagine it'll be easy enough to change or remove the |
rust/src/librustc_typeck/check/mod.rs Lines 3858 to 3915 in f0c2bdf
rust/src/librustc_typeck/check/mod.rs Lines 3729 to 3738 in f0c2bdf
rust/src/librustc_typeck/check/mod.rs Lines 3707 to 3714 in f0c2bdf
You'll probably have to add some differentiation between |
So in |
This adds a suggestion for main() methods with default () return if the resulting expression has a type that implements `std::process::Termination`. This fixes rust-lang#61277.
Given the following code:
Rust reports an error for using
?
and suggests adding;
after theSome(())
. A preferrable Option (pun intended) is to suggest changing the return type toOption<()>
when the body's result type isOption<_>
and there exists at least one?
in the body. Similarly, if we haveResult
s, we might want to try to infer a useful return type, e.g.cc @estebank (diagnostics)
The text was updated successfully, but these errors were encountered: