Skip to content

bindings_with_variant_name is unhelpful and incorrect for function arguments #88730

Closed
@RDambrosio016

Description

@RDambrosio016

Given the following code:

#![allow(non_camel_case_types, unused_variables, dead_code)]

enum Foo {
    c
}

fn foo(c: Foo) {}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e6829290d29151853fdd98844ba6391c

The current output is:

warning[E0170]: pattern binding `c` is named the same as one of the variants of the type `Foo`
 --> src/lib.rs:7:8
  |
7 | fn foo(c: Foo) {}
  |        ^ help: to match on the variant, qualify the path: `Foo::c`
  |
  = note: `#[warn(bindings_with_variant_name)]` on by default

Ideally the lint should not trigger on such a pattern, it does not really make sense and the suggestion is wrong altogether,

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.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