Closed
Description
This small snippet
fn func() -> u8 {
0
}
fn main() {
match () {
() => func()
}
}
suggests adding a semicolon after the function call to rectify the mismatched types.
error[E0308]: mismatched types
--> src/main.rs:7:15
|
5 | fn main() {
| - expected `()` because of default return type
6 | match () {
7 | () => func()
| ^^^^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found `u8`
error: aborting due to previous error
However, this is also a syntax error (below), and the correct suggestion would be to wrap the function call in braces.
error: `match` arm body without braces
--> src/main.rs:7:15
|
7 | () => func();
| -- ^^^^^^- help: use a comma to end a `match` arm expression: `,`
| | |
| | this statement is not surrounded by a body
| while parsing the `match` arm starting here
error: aborting due to previous error
Meta
Using rustc nightly 2021-04-04 c755ee4ce8cae6ea977d
(playground)