Skip to content

Syntax error in patterns should elide missing field errors #59145

Closed
@estebank

Description

@estebank

The following code

struct S {
    a: usize,
    b: usize,
}

fn main() {
    let s = S { a: 4, b: 2 };
    let S {a , ref b: _ } = s;
}

produces the following error:

error: expected `,`
 --> src/main.rs:8:20
  |
8 |     let S {a , ref b: _ } = s;
  |                    ^

error[E0027]: pattern does not mention fields `a`, `b`
 --> src/main.rs:8:9
  |
8 |     let S {a , ref b: _ } = s;
  |         ^^^^^^^^^^^^^^^^^ missing fields `a`, `b`

It shouldn't complain about the missing fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions