Skip to content

Commit e5af43d

Browse files
committed
UI test cleanup: Extract match_overlapping_arm tests
1 parent 5172271 commit e5af43d

File tree

4 files changed

+245
-227
lines changed

4 files changed

+245
-227
lines changed

tests/ui/match_overlapping_arm.rs

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution.
3+
//
4+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7+
// option. This file may not be copied, modified, or distributed
8+
// except according to those terms.
9+
10+
#![feature(exclusive_range_pattern)]
11+
#![warn(clippy::match_overlapping_arm)]
12+
#![allow(clippy::redundant_pattern_matching)]
13+
14+
/// Tests for match_overlapping_arm
15+
16+
fn overlapping() {
17+
const FOO : u64 = 2;
18+
19+
match 42 {
20+
0 ... 10 => println!("0 ... 10"),
21+
0 ... 11 => println!("0 ... 11"),
22+
_ => (),
23+
}
24+
25+
match 42 {
26+
0 ... 5 => println!("0 ... 5"),
27+
6 ... 7 => println!("6 ... 7"),
28+
FOO ... 11 => println!("0 ... 11"),
29+
_ => (),
30+
}
31+
32+
match 42 {
33+
2 => println!("2"),
34+
0 ... 5 => println!("0 ... 5"),
35+
_ => (),
36+
}
37+
38+
match 42 {
39+
2 => println!("2"),
40+
0 ... 2 => println!("0 ... 2"),
41+
_ => (),
42+
}
43+
44+
match 42 {
45+
0 ... 10 => println!("0 ... 10"),
46+
11 ... 50 => println!("11 ... 50"),
47+
_ => (),
48+
}
49+
50+
match 42 {
51+
2 => println!("2"),
52+
0 .. 2 => println!("0 .. 2"),
53+
_ => (),
54+
}
55+
56+
match 42 {
57+
0 .. 10 => println!("0 .. 10"),
58+
10 .. 50 => println!("10 .. 50"),
59+
_ => (),
60+
}
61+
62+
match 42 {
63+
0 .. 11 => println!("0 .. 11"),
64+
0 ... 11 => println!("0 ... 11"),
65+
_ => (),
66+
}
67+
68+
if let None = Some(42) {
69+
// nothing
70+
} else if let None = Some(42) {
71+
// another nothing :-)
72+
}
73+
}
74+
75+
fn main() {}

tests/ui/match_overlapping_arm.stderr

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
error: some ranges overlap
2+
--> $DIR/match_overlapping_arm.rs:20:9
3+
|
4+
20 | 0 ... 10 => println!("0 ... 10"),
5+
| ^^^^^^^^
6+
|
7+
= note: `-D clippy::match-overlapping-arm` implied by `-D warnings`
8+
note: overlaps with this
9+
--> $DIR/match_overlapping_arm.rs:21:9
10+
|
11+
21 | 0 ... 11 => println!("0 ... 11"),
12+
| ^^^^^^^^
13+
14+
error: some ranges overlap
15+
--> $DIR/match_overlapping_arm.rs:26:9
16+
|
17+
26 | 0 ... 5 => println!("0 ... 5"),
18+
| ^^^^^^^
19+
|
20+
note: overlaps with this
21+
--> $DIR/match_overlapping_arm.rs:28:9
22+
|
23+
28 | FOO ... 11 => println!("0 ... 11"),
24+
| ^^^^^^^^^^
25+
26+
error: some ranges overlap
27+
--> $DIR/match_overlapping_arm.rs:34:9
28+
|
29+
34 | 0 ... 5 => println!("0 ... 5"),
30+
| ^^^^^^^
31+
|
32+
note: overlaps with this
33+
--> $DIR/match_overlapping_arm.rs:33:9
34+
|
35+
33 | 2 => println!("2"),
36+
| ^
37+
38+
error: some ranges overlap
39+
--> $DIR/match_overlapping_arm.rs:40:9
40+
|
41+
40 | 0 ... 2 => println!("0 ... 2"),
42+
| ^^^^^^^
43+
|
44+
note: overlaps with this
45+
--> $DIR/match_overlapping_arm.rs:39:9
46+
|
47+
39 | 2 => println!("2"),
48+
| ^
49+
50+
error: some ranges overlap
51+
--> $DIR/match_overlapping_arm.rs:63:9
52+
|
53+
63 | 0 .. 11 => println!("0 .. 11"),
54+
| ^^^^^^^
55+
|
56+
note: overlaps with this
57+
--> $DIR/match_overlapping_arm.rs:64:9
58+
|
59+
64 | 0 ... 11 => println!("0 ... 11"),
60+
| ^^^^^^^^
61+
62+
error: aborting due to 5 previous errors
63+

tests/ui/matches.rs

-59
Original file line numberDiff line numberDiff line change
@@ -74,65 +74,6 @@ fn ref_pats() {
7474
}
7575
}
7676

77-
fn overlapping() {
78-
const FOO : u64 = 2;
79-
80-
match 42 {
81-
0 ... 10 => println!("0 ... 10"),
82-
0 ... 11 => println!("0 ... 11"),
83-
_ => (),
84-
}
85-
86-
match 42 {
87-
0 ... 5 => println!("0 ... 5"),
88-
6 ... 7 => println!("6 ... 7"),
89-
FOO ... 11 => println!("0 ... 11"),
90-
_ => (),
91-
}
92-
93-
match 42 {
94-
2 => println!("2"),
95-
0 ... 5 => println!("0 ... 5"),
96-
_ => (),
97-
}
98-
99-
match 42 {
100-
2 => println!("2"),
101-
0 ... 2 => println!("0 ... 2"),
102-
_ => (),
103-
}
104-
105-
match 42 {
106-
0 ... 10 => println!("0 ... 10"),
107-
11 ... 50 => println!("11 ... 50"),
108-
_ => (),
109-
}
110-
111-
match 42 {
112-
2 => println!("2"),
113-
0 .. 2 => println!("0 .. 2"),
114-
_ => (),
115-
}
116-
117-
match 42 {
118-
0 .. 10 => println!("0 .. 10"),
119-
10 .. 50 => println!("10 .. 50"),
120-
_ => (),
121-
}
122-
123-
match 42 {
124-
0 .. 11 => println!("0 .. 11"),
125-
0 ... 11 => println!("0 ... 11"),
126-
_ => (),
127-
}
128-
129-
if let None = Some(42) {
130-
// nothing
131-
} else if let None = Some(42) {
132-
// another nothing :-)
133-
}
134-
}
135-
13677
fn match_wild_err_arm() {
13778
let x: Result<i32, &str> = Ok(3);
13879

0 commit comments

Comments
 (0)