2018-10-30 15:36:52 -05:00
|
|
|
#![feature(exclusive_range_pattern)]
|
2020-01-11 04:39:43 -06:00
|
|
|
#![feature(half_open_range_patterns)]
|
2018-10-30 15:36:52 -05:00
|
|
|
#![warn(clippy::match_overlapping_arm)]
|
|
|
|
#![allow(clippy::redundant_pattern_matching)]
|
|
|
|
|
|
|
|
/// Tests for match_overlapping_arm
|
|
|
|
|
|
|
|
fn overlapping() {
|
2018-12-09 16:26:16 -06:00
|
|
|
const FOO: u64 = 2;
|
2018-10-30 15:36:52 -05:00
|
|
|
|
|
|
|
match 42 {
|
2019-06-01 00:54:47 -05:00
|
|
|
0..=10 => println!("0 ... 10"),
|
|
|
|
0..=11 => println!("0 ... 11"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2019-06-01 00:54:47 -05:00
|
|
|
0..=5 => println!("0 ... 5"),
|
|
|
|
6..=7 => println!("6 ... 7"),
|
|
|
|
FOO..=11 => println!("0 ... 11"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
2 => println!("2"),
|
2019-06-01 00:54:47 -05:00
|
|
|
0..=5 => println!("0 ... 5"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
2 => println!("2"),
|
2019-06-01 00:54:47 -05:00
|
|
|
0..=2 => println!("0 ... 2"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2019-06-01 00:54:47 -05:00
|
|
|
0..=10 => println!("0 ... 10"),
|
|
|
|
11..=50 => println!("11 ... 50"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
2 => println!("2"),
|
2018-12-09 16:26:16 -06:00
|
|
|
0..2 => println!("0 .. 2"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2018-12-09 16:26:16 -06:00
|
|
|
0..10 => println!("0 .. 10"),
|
|
|
|
10..50 => println!("10 .. 50"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2018-12-09 16:26:16 -06:00
|
|
|
0..11 => println!("0 .. 11"),
|
2019-06-01 00:54:47 -05:00
|
|
|
0..=11 => println!("0 ... 11"),
|
2018-10-30 15:36:52 -05:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2021-01-15 11:51:00 -06:00
|
|
|
match 42 {
|
|
|
|
5..7 => println!("5 .. 7"),
|
|
|
|
0..10 => println!("0 .. 10"),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
5..10 => println!("5 .. 10"),
|
|
|
|
0..=10 => println!("0 ... 10"),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2021-01-24 05:28:59 -06:00
|
|
|
match 42 {
|
|
|
|
0..14 => println!("0 .. 14"),
|
|
|
|
5..10 => println!("5 .. 10"),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
5..14 => println!("5 .. 14"),
|
|
|
|
0..=10 => println!("0 ... 10"),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
0..7 => println!("0 .. 7"),
|
|
|
|
0..=10 => println!("0 ... 10"),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2020-01-11 12:05:47 -06:00
|
|
|
/*
|
|
|
|
// FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns
|
2020-01-11 04:39:43 -06:00
|
|
|
match 42 {
|
|
|
|
0.. => println!("0 .. 42"),
|
|
|
|
3.. => println!("3 .. 42"),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
..=23 => println!("0 ... 23"),
|
|
|
|
..26 => println!("0 .. 26"),
|
|
|
|
_ => (),
|
|
|
|
}
|
2020-01-11 12:05:47 -06:00
|
|
|
*/
|
2020-01-11 04:39:43 -06:00
|
|
|
|
2018-10-30 15:36:52 -05:00
|
|
|
if let None = Some(42) {
|
|
|
|
// nothing
|
|
|
|
} else if let None = Some(42) {
|
|
|
|
// another nothing :-)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|