Skip to content

False warning of multiple patterns overlaping #120052

Closed as not planned
Closed as not planned
@zdila

Description

@zdila

rustc version: rustc 1.75.0 (82e1608 2023-12-21)

relevant settings: nothing

Following code reports a warning:

pub fn test() {
  let zoom = 2;
  let class = "foo";

  match (zoom, class) {
      (13.., "railway") => {}
      (12..=13, "highway") => {}
      _ => {}
  }
}
warning: multiple patterns overlap on their endpoints
 --> src/test.rs:7:8
  |
6 |       (13.., "railway") => {}
  |        ---- this range overlaps on `13_i32`...
7 |       (12..=13, "highway") => {}
  |        ^^^^^^^ ... with this range
  |
  = note: you likely meant to write mutually exclusive ranges

But branches are mutually exclusive because of the second element in the tuple.

The code is a minimal testcase. Original code contains much more branches (ranges, classes, predicates)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions