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

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

Closed
hkmatsumoto opened this issue Sep 22, 2021 · 0 comments · Fixed by #95396
Closed

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

hkmatsumoto opened this issue Sep 22, 2021 · 0 comments · Fixed by #95396
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hkmatsumoto
Copy link
Member

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.

@hkmatsumoto hkmatsumoto added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 22, 2021
@TaKO8Ki TaKO8Ki self-assigned this Mar 27, 2022
@bors bors closed this as completed in b3e46a9 Mar 28, 2022
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants