Skip to content

Don't suggest replacing a field when the fix does not type checks #89166

Closed
@hkmatsumoto

Description

@hkmatsumoto

Follow-up to #87960 (comment)

Given the following code:

enum Foo {
    Bar { alpha: u8, bravo: u8, charlie: u8 },
}

fn foo(foo: Foo) {
    match foo {
        Foo::Bar {
            alpha,
            beta: "foo",
            charlie
        } => {}
    }
}

The nightly output includes:

error[E0026]: variant `Foo::Bar` does not have a field named `beta`
 --> src/lib.rs:9:13
  |
9 |             beta: "foo",
  |             ^^^^
  |             |
  |             variant `Foo::Bar` does not have this field
  |             help: `Foo::Bar` has a field named `bravo`

However, ideally, this suggestion shouldn't be present because of bravo: u8.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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