Closed
Description
Talking to some folks at RustConf recently a common point of confusion seemed to be "where are semicolons required?" The compiler seemingly has arcane restrictions at the beginning and this means that we can perhaps improve errors in this respect to help guide beginners!
For example, in this code:
pub fn foo() {
if true {
3
} else {
foo();
}
}
it yields the error:
error[E0308]: mismatched types
--> foo.rs:3:9
|
3 | 3
| ^ expected (), found integral variable
|
= note: expected type `()`
= note: found type `{integer}`
error: aborting due to previous error
Perhaps we could detect that the other branch of the if
has a semicolon, and as a result a semicolon here is probably also the fix?