-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The expected type and the found type seem to be reversed here. The error says it expected () and found i32, but it seems to me that it expected i32 and found ().
fn do_stuff(x: i32) -> i32 {
if x < 0 {
return 0;
} else {
if 1 == 1 {
return 1;
}
}
}Errors:
Compiling playground v0.0.1 (/playground)
error[E0317]: `if` may be missing an `else` clause
--> src/lib.rs:5:9
|
5 | / if 1 == 1 {
6 | | return 1;
7 | | }
| |_________^ expected `()`, found `i32`
|
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
error: aborting due to previous error
For more information about this error, try `rustc --explain E0317`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.