Closed
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.