Skip to content

Commit

Permalink
Fix ellipsis_inclusive_range_patterns lint warnings
Browse files Browse the repository at this point in the history
Changed from `allow` to `warn` in rust-lang/rust#61342
  • Loading branch information
phansch committed Jun 1, 2019
1 parent b1762e3 commit 6feef17
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions tests/ui/match_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ fn match_bool() {

// Not linted
match option {
1...10 => 1,
11...20 => 2,
1..=10 => 1,
11..=20 => 2,
_ => 3,
};
}
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/match_overlapping_arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ fn overlapping() {
const FOO: u64 = 2;

match 42 {
0...10 => println!("0 ... 10"),
0...11 => println!("0 ... 11"),
0..=10 => println!("0 ... 10"),
0..=11 => println!("0 ... 11"),
_ => (),
}

match 42 {
0...5 => println!("0 ... 5"),
6...7 => println!("6 ... 7"),
FOO...11 => println!("0 ... 11"),
0..=5 => println!("0 ... 5"),
6..=7 => println!("6 ... 7"),
FOO..=11 => println!("0 ... 11"),
_ => (),
}

match 42 {
2 => println!("2"),
0...5 => println!("0 ... 5"),
0..=5 => println!("0 ... 5"),
_ => (),
}

match 42 {
2 => println!("2"),
0...2 => println!("0 ... 2"),
0..=2 => println!("0 ... 2"),
_ => (),
}

match 42 {
0...10 => println!("0 ... 10"),
11...50 => println!("11 ... 50"),
0..=10 => println!("0 ... 10"),
11..=50 => println!("11 ... 50"),
_ => (),
}

Expand All @@ -52,7 +52,7 @@ fn overlapping() {

match 42 {
0..11 => println!("0 .. 11"),
0...11 => println!("0 ... 11"),
0..=11 => println!("0 ... 11"),
_ => (),
}

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/match_overlapping_arm.stderr
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:11:9
|
LL | 0...10 => println!("0 ... 10"),
LL | 0..=10 => println!("0 ... 10"),
| ^^^^^^
|
= note: `-D clippy::match-overlapping-arm` implied by `-D warnings`
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:12:9
|
LL | 0...11 => println!("0 ... 11"),
LL | 0..=11 => println!("0 ... 11"),
| ^^^^^^

error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:17:9
|
LL | 0...5 => println!("0 ... 5"),
LL | 0..=5 => println!("0 ... 5"),
| ^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:19:9
|
LL | FOO...11 => println!("0 ... 11"),
LL | FOO..=11 => println!("0 ... 11"),
| ^^^^^^^^

error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:25:9
|
LL | 0...5 => println!("0 ... 5"),
LL | 0..=5 => println!("0 ... 5"),
| ^^^^^
|
note: overlaps with this
Expand All @@ -38,7 +38,7 @@ LL | 2 => println!("2"),
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:31:9
|
LL | 0...2 => println!("0 ... 2"),
LL | 0..=2 => println!("0 ... 2"),
| ^^^^^
|
note: overlaps with this
Expand All @@ -56,7 +56,7 @@ LL | 0..11 => println!("0 .. 11"),
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:55:9
|
LL | 0...11 => println!("0 ... 11"),
LL | 0..=11 => println!("0 ... 11"),
| ^^^^^^

error: aborting due to 5 previous errors
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/single_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn single_match() {

let z = (1u8, 1u8);
match z {
(2...3, 7...9) => dummy(),
(2..=3, 7..=9) => dummy(),
_ => {},
};

Expand All @@ -35,7 +35,7 @@ fn single_match() {

// Not linted (no block with statements in the single arm)
match z {
(2...3, 7...9) => println!("{:?}", z),
(2..=3, 7..=9) => println!("{:?}", z),
_ => println!("nope"),
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/single_match.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ error: you seem to be trying to use match for destructuring a single pattern. Co
--> $DIR/single_match.rs:25:5
|
LL | / match z {
LL | | (2...3, 7...9) => dummy(),
LL | | (2..=3, 7..=9) => dummy(),
LL | | _ => {},
LL | | };
| |_____^ help: try this: `if let (2...3, 7...9) = z { dummy() }`
| |_____^ help: try this: `if let (2..=3, 7..=9) = z { dummy() }`

error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> $DIR/single_match.rs:54:5
Expand Down

0 comments on commit 6feef17

Please sign in to comment.