Skip to content

False positive with match_same_arms #2185

Closed
@jDomantas

Description

@jDomantas

If two arms have same values after inlining constants, clippy will report a lint on those arms. Is this a good idea? In my code I had two constants that were semantically different but happened to have the same value, and the suggested replacement did not really make sense.

Here's an example that triggers the lint:

const FOO: u32 = 4;
const BAR: u32 = 4;

fn main() {
    match 1 {
        1 => FOO,
        2 => BAR,
        _ => 0,
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions