Skip to content

overlapping_range_endpoints false positive #117648

Closed
@benluelo

Description

@benluelo

Code

match (0i8, 0i8) {
    (0, _) => {}
    // change either of these to not overlap and it will error
    (..=-1, ..=0) => {}
    (1.., 0..) => {}
    (1.., ..=-1) | (..=-1, 1..) => {}
}

Current output

warning: multiple patterns overlap on their endpoints
 --> src/main.rs:6:15
  |
5 |         (..=-1, ..=0) => {}
  |                 ---- this range overlaps on `0_i8`...
6 |         (1.., 0..) => {}
  |               ^^^ ... with this range
  |
  = note: you likely meant to write mutually exclusive ranges
  = note: `#[warn(overlapping_range_endpoints)]` on by default

Desired output

no output, pattern is exhaustive. addressing the warning causes an error as it is no longer exhaustive.

Rationale and extra context

No response

Other cases

No response

Anything else?

this is only occurring on nightly (at least as of 2023-11-01, i haven't tested anything sooner)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.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