Skip to content

Error suggestion for E0027 (pattern missing field) contains erroneous comma #78511

Closed
@mk12

Description

@mk12

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4f2737c4c44adb53103b875e0b7044cd

struct Foo {
    x: i32,
    y: i32,
}

fn test(Foo {
    x,
}: Foo) {}

I expected to see this happen:

A suggestion to change x, to x, ..

Instead, this happened:

A suggestion to change x, to x, .., (note the extra comma!)

With the comma at the end, I get a parser error and a suggestion to remove the comma.

Meta

Nightly on playground: 1.49.0-nightly (2020-10-27 07e968b)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions