Skip to content

False positive on match_same_arms #860

Closed
@llogiq

Description

@llogiq

Example: Any kind of xor-like handling, e.g. let Foo be one variant of an enum:

match (x, y) {
    (Foo(_), Foo(_)) => None,
    (Foo(x), _) |
    (_, Foo(x)) => Some(x),
    _ => None
}

This will trigger the lint, because the position of the arms is not taken into account.

@regexident suggested to only lint adjacent same arms. Another option would be to check if those arms are disjunct and can be reordered without changing semantics, but that is obviously much much harder to do in the general case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveT-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions