Closed
Description
The following program
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
enum E {
V { field: bool }
}
fn test_E(x: E) {
if x == E::V { field: false } {}
}
error: expected identifier, found keyword `false`
--> src/lib.rs:6:27
|
6 | if x == E::V { field: false } {}
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
6 | if x == E::V { field: r#false } {}
| ^^^^^^^
error: expected type, found keyword `false`
--> src/lib.rs:6:27
|
6 | if x == E::V { field: false } {}
| ^^^^^ expecting a type here because of type ascription
error[E0423]: expected value, found struct variant `E::V`
--> src/lib.rs:6:13
|
6 | if x == E::V { field: false } {}
| ^^^^ did you mean `E::V { /* fields */ }`?
error: aborting due to 3 previous errors
This is not very helpful: If I replace E::V
by a struct constructor, it suggests adding parentheses, which is the real solution (the error is still not great, but better than this). Instead "did you mean E::V
" is leading in the totally wrong direction.