diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 519298c33..9cb557ba6 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -491,6 +491,7 @@ pub fn overlapping(ranges: &[SpannedRange]) -> Option<(&SpannedRange, & match (self.value(), other.value()) { (Bound::Included(a), Bound::Included(b)) | (Bound::Excluded(a), Bound::Excluded(b)) => a.cmp(&b), + // Range patterns cannot be unbounded (yet) (Bound::Unbounded, _) | (_, Bound::Unbounded) => unimplemented!(), (Bound::Included(a), Bound::Excluded(b)) => { diff --git a/tests/compile-fail/matches.rs b/tests/compile-fail/matches.rs index 61a1ec51d..7f6bd73d2 100644 --- a/tests/compile-fail/matches.rs +++ b/tests/compile-fail/matches.rs @@ -229,14 +229,14 @@ fn overlapping() { match 42 { 0 ... 10 => println!("0 ... 10"), //~ERROR: some ranges overlap - 0 ... 11 => println!("0 ... 10"), //~NOTE overlaps with this + 0 ... 11 => println!("0 ... 11"), //~NOTE overlaps with this _ => (), } match 42 { 0 ... 5 => println!("0 ... 5"), //~ERROR: some ranges overlap 6 ... 7 => println!("6 ... 7"), - FOO ... 11 => println!("0 ... 10"), //~NOTE overlaps with this + FOO ... 11 => println!("0 ... 11"), //~NOTE overlaps with this _ => (), } @@ -248,13 +248,13 @@ fn overlapping() { match 42 { 2 => println!("2"), //~NOTE overlaps with this - 0 ... 2 => println!("0 ... 5"), //~ERROR: some ranges overlap + 0 ... 2 => println!("0 ... 2"), //~ERROR: some ranges overlap _ => (), } match 42 { 0 ... 10 => println!("0 ... 10"), - 11 ... 50 => println!("0 ... 10"), + 11 ... 50 => println!("11 ... 50"), _ => (), } @@ -265,8 +265,8 @@ fn overlapping() { } match 42 { - 0 .. 10 => println!("0 ... 10"), - 10 .. 50 => println!("0 ... 10"), + 0 .. 10 => println!("0 .. 10"), + 10 .. 50 => println!("10 .. 50"), _ => (), }