Closed
Description
The following code:
fn main() {
|| {
if false {
return 1;
}
};
}
produces the following error message:
error[E0308]: mismatched types
--> src/main.rs:3:9
|
3 | / if false {
4 | | return 1;
5 | | }
| |_________^ expected integer, found `()`
The message doesn't explain why an integer was expected here. If the user doesn't explicitly annotate the return type of the closure, we should point to the expression that caused the return type to get inferred to begin with.
Metadata
Metadata
Assignees
Labels
Area: Closures (`|…| { … }`)Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.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.Relevant to the compiler team, which will review and decide on the PR/issue.