Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error in patterns should elide missing field errors #59145

Closed
estebank opened this issue Mar 12, 2019 · 0 comments
Closed

Syntax error in patterns should elide missing field errors #59145

estebank opened this issue Mar 12, 2019 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@estebank
Copy link
Contributor

estebank commented Mar 12, 2019

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.

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Mar 12, 2019
Centril added a commit to Centril/rust that referenced this issue Mar 28, 2019
…davis

Do not complain about unmentioned fields in recovered patterns

When the parser has to recover from malformed code in a pattern, do not
complain about missing fields.

Fix rust-lang#59145.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

1 participant