Closed
Description
For the following code:
struct S(i32, f32);
enum E {
S(i32, f32),
}
fn main() {
let x = E::S(1, 2.2);
match x {
E::S {} => {}
}
let y = S(1, 2.2);
match y {
S {} => {}
}
}
we currently emit
error[E0027]: pattern does not mention fields `0`, `1`
--> src/main.rs:8:9
|
8 | E::S {} => {}
| ^^^^^^^ missing fields `0`, `1`
|
help: include the missing fields in the pattern
|
8 | E::S { 0, 1 } => {}
| ^^^^^^^^
help: if you don't care about these missing fields, you can explicitely ignore them
|
8 | E::S { .. } => {}
| ^^^^^^
error[E0027]: pattern does not mention fields `0`, `1`
--> src/main.rs:12:9
|
12 | S {} => {}
| ^^^^ missing fields `0`, `1`
|
help: include the missing fields in the pattern
|
12 | S { 0, 1 } => {}
| ^^^^^^^^
help: if you don't care about these missing fields, you can explicitely ignore them
|
12 | S { .. } => {}
| ^^^^^^
but struct patterns cannot refer to tuple field names with numbers, as the parser expects identifiers.
I think that 1) the parser should be changed to accept the positions, but ultimately reject them, suggesting to use the tuple syntax and 2) that the suggestion should be for the tuple syntax to begin with.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.