-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
338 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/ui/pattern/usefulness/integer-ranges/gap_between_ranges.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#![feature(exclusive_range_pattern)] | ||
#![deny(overlapping_range_endpoints)] | ||
|
||
macro_rules! m { | ||
($s:expr, $t1:pat, $t2:pat) => { | ||
match $s { | ||
$t1 => {} | ||
$t2 => {} | ||
_ => {} | ||
} | ||
}; | ||
} | ||
|
||
fn main() { | ||
m!(0u8, 20..30, 31..=40); //~ ERROR multiple ranges are one apart | ||
m!(0u8, 31..=40, 20..30); //~ ERROR multiple ranges are one apart | ||
m!(0u8, 20..30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints | ||
m!(0u8, 20..30, 30..=40); | ||
m!(0u8, 20..30, 31..=40); //~ ERROR multiple ranges are one apart | ||
m!(0u8, 20..30, 32..=40); | ||
m!(0u8, 20..30, 31); //~ ERROR multiple ranges are one apart | ||
m!(0u8, 20..30, 31..=32); //~ ERROR multiple ranges are one apart | ||
m!(0u8, 30, 30..=40); | ||
m!(0u8, 30, 31..=40); | ||
m!(0u8, 30, 32..=40); //~ ERROR multiple ranges are one apart | ||
|
||
match 0u8 { | ||
0..10 => {} | ||
10 => {} | ||
11..20 => {} | ||
_ => {} | ||
} | ||
|
||
match 0u8 { | ||
0..10 => {} | ||
21..30 => {} //~ ERROR multiple ranges are one apart | ||
11..20 => {} //~ ERROR multiple ranges are one apart | ||
_ => {} | ||
} | ||
match (0u8, true) { | ||
(0..10, true) => {} | ||
(11..20, true) => {} //~ ERROR multiple ranges are one apart | ||
(11..20, false) => {} //~ ERROR multiple ranges are one apart | ||
_ => {} | ||
} | ||
match (true, 0u8) { | ||
(true, 0..10) => {} | ||
(true, 11..20) => {} //~ ERROR multiple ranges are one apart | ||
(false, 11..20) => {} //~ ERROR multiple ranges are one apart | ||
_ => {} | ||
} | ||
match Some(0u8) { | ||
Some(0..10) => {} | ||
Some(11..20) => {} //~ ERROR multiple ranges are one apart | ||
_ => {} | ||
} | ||
} |
Oops, something went wrong.