Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e87594e

Browse files
committed
Add some tests
1 parent 39ed139 commit e87594e

File tree

8 files changed

+276
-164
lines changed

8 files changed

+276
-164
lines changed

tests/ui/or-patterns/exhaustiveness-pass.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,12 @@ fn main() {
3535
((0, 0) | (1, 0),) => {}
3636
_ => {}
3737
}
38+
match ((0, 0),) {
39+
((x, y) | (y, x),) if x == 0 => {}
40+
_ => {}
41+
}
42+
match 0 {
43+
0 | 0 if 0 == 0 => {}
44+
_ => {}
45+
}
3846
}

tests/ui/or-patterns/exhaustiveness-unreachable-pattern.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![deny(unreachable_patterns)]
22

33
// We wrap patterns in a tuple because top-level or-patterns were special-cased.
4+
#[rustfmt::skip]
45
fn main() {
56
match (0u8,) {
67
(1 | 2,) => {}
@@ -73,6 +74,11 @@ fn main() {
7374
| 0] => {} //~ ERROR unreachable
7475
_ => {}
7576
}
77+
match (true, 0) {
78+
(true, 0 | 0) => {} //~ ERROR unreachable
79+
(_, 0 | 0) => {} //~ ERROR unreachable
80+
_ => {}
81+
}
7682
match &[][..] {
7783
[0] => {}
7884
[0, _] => {}
@@ -149,4 +155,8 @@ fn main() {
149155
| true, //~ ERROR unreachable
150156
false | true) => {}
151157
}
158+
match (true, true) {
159+
(x, y)
160+
| (y, x) => {} //~ ERROR unreachable
161+
}
152162
}
Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unreachable pattern
2-
--> $DIR/exhaustiveness-unreachable-pattern.rs:7:9
2+
--> $DIR/exhaustiveness-unreachable-pattern.rs:8:9
33
|
44
LL | (1,) => {}
55
| ^^^^
@@ -11,128 +11,140 @@ LL | #![deny(unreachable_patterns)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

1313
error: unreachable pattern
14-
--> $DIR/exhaustiveness-unreachable-pattern.rs:12:9
14+
--> $DIR/exhaustiveness-unreachable-pattern.rs:13:9
1515
|
1616
LL | (2,) => {}
1717
| ^^^^
1818

1919
error: unreachable pattern
20-
--> $DIR/exhaustiveness-unreachable-pattern.rs:18:9
20+
--> $DIR/exhaustiveness-unreachable-pattern.rs:19:9
2121
|
2222
LL | (1 | 2,) => {}
2323
| ^^^^^^^^
2424

2525
error: unreachable pattern
26-
--> $DIR/exhaustiveness-unreachable-pattern.rs:23:9
26+
--> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
2727
|
2828
LL | (1, 3) => {}
2929
| ^^^^^^
3030

3131
error: unreachable pattern
32-
--> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
32+
--> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
3333
|
3434
LL | (1, 4) => {}
3535
| ^^^^^^
3636

3737
error: unreachable pattern
38-
--> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
38+
--> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
3939
|
4040
LL | (2, 4) => {}
4141
| ^^^^^^
4242

4343
error: unreachable pattern
44-
--> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
44+
--> $DIR/exhaustiveness-unreachable-pattern.rs:27:9
4545
|
4646
LL | (2 | 1, 4) => {}
4747
| ^^^^^^^^^^
4848

4949
error: unreachable pattern
50-
--> $DIR/exhaustiveness-unreachable-pattern.rs:28:9
50+
--> $DIR/exhaustiveness-unreachable-pattern.rs:29:9
5151
|
5252
LL | (1, 4 | 5) => {}
5353
| ^^^^^^^^^^
5454

5555
error: unreachable pattern
56-
--> $DIR/exhaustiveness-unreachable-pattern.rs:36:9
56+
--> $DIR/exhaustiveness-unreachable-pattern.rs:37:9
5757
|
5858
LL | (Some(1),) => {}
5959
| ^^^^^^^^^^
6060

6161
error: unreachable pattern
62-
--> $DIR/exhaustiveness-unreachable-pattern.rs:37:9
62+
--> $DIR/exhaustiveness-unreachable-pattern.rs:38:9
6363
|
6464
LL | (None,) => {}
6565
| ^^^^^^^
6666

6767
error: unreachable pattern
68-
--> $DIR/exhaustiveness-unreachable-pattern.rs:42:9
68+
--> $DIR/exhaustiveness-unreachable-pattern.rs:43:9
6969
|
7070
LL | ((1..=4,),) => {}
7171
| ^^^^^^^^^^^
7272

7373
error: unreachable pattern
74-
--> $DIR/exhaustiveness-unreachable-pattern.rs:47:14
74+
--> $DIR/exhaustiveness-unreachable-pattern.rs:48:14
7575
|
7676
LL | (1 | 1,) => {}
7777
| ^
7878

7979
error: unreachable pattern
80-
--> $DIR/exhaustiveness-unreachable-pattern.rs:51:19
80+
--> $DIR/exhaustiveness-unreachable-pattern.rs:52:19
8181
|
8282
LL | (0 | 1) | 1 => {}
8383
| ^
8484

8585
error: unreachable pattern
86-
--> $DIR/exhaustiveness-unreachable-pattern.rs:57:14
86+
--> $DIR/exhaustiveness-unreachable-pattern.rs:58:14
8787
|
8888
LL | 0 | (0 | 0) => {}
8989
| ^
9090

9191
error: unreachable pattern
92-
--> $DIR/exhaustiveness-unreachable-pattern.rs:57:18
92+
--> $DIR/exhaustiveness-unreachable-pattern.rs:58:18
9393
|
9494
LL | 0 | (0 | 0) => {}
9595
| ^
9696

9797
error: unreachable pattern
98-
--> $DIR/exhaustiveness-unreachable-pattern.rs:65:13
98+
--> $DIR/exhaustiveness-unreachable-pattern.rs:66:13
9999
|
100100
LL | / Some(
101101
LL | | 0 | 0) => {}
102102
| |______________________^
103103

104104
error: unreachable pattern
105-
--> $DIR/exhaustiveness-unreachable-pattern.rs:71:15
105+
--> $DIR/exhaustiveness-unreachable-pattern.rs:72:15
106106
|
107107
LL | | 0
108108
| ^
109109

110110
error: unreachable pattern
111-
--> $DIR/exhaustiveness-unreachable-pattern.rs:73:15
111+
--> $DIR/exhaustiveness-unreachable-pattern.rs:74:15
112112
|
113113
LL | | 0] => {}
114114
| ^
115115

116116
error: unreachable pattern
117-
--> $DIR/exhaustiveness-unreachable-pattern.rs:81:10
117+
--> $DIR/exhaustiveness-unreachable-pattern.rs:78:20
118+
|
119+
LL | (true, 0 | 0) => {}
120+
| ^
121+
122+
error: unreachable pattern
123+
--> $DIR/exhaustiveness-unreachable-pattern.rs:79:17
124+
|
125+
LL | (_, 0 | 0) => {}
126+
| ^
127+
128+
error: unreachable pattern
129+
--> $DIR/exhaustiveness-unreachable-pattern.rs:87:10
118130
|
119131
LL | [1
120132
| ^
121133

122134
error: unreachable pattern
123-
--> $DIR/exhaustiveness-unreachable-pattern.rs:93:10
135+
--> $DIR/exhaustiveness-unreachable-pattern.rs:99:10
124136
|
125137
LL | [true
126138
| ^^^^
127139

128140
error: unreachable pattern
129-
--> $DIR/exhaustiveness-unreachable-pattern.rs:100:36
141+
--> $DIR/exhaustiveness-unreachable-pattern.rs:106:36
130142
|
131143
LL | (true | false, None | Some(true
132144
| ^^^^
133145

134146
error: unreachable pattern
135-
--> $DIR/exhaustiveness-unreachable-pattern.rs:105:14
147+
--> $DIR/exhaustiveness-unreachable-pattern.rs:111:14
136148
|
137149
LL | (true
138150
| ^^^^
@@ -143,28 +155,34 @@ LL | (true | false, None | Some(t_or_f!())) => {}
143155
= note: this error originates in the macro `t_or_f` (in Nightly builds, run with -Z macro-backtrace for more info)
144156

145157
error: unreachable pattern
146-
--> $DIR/exhaustiveness-unreachable-pattern.rs:116:14
158+
--> $DIR/exhaustiveness-unreachable-pattern.rs:122:14
147159
|
148160
LL | Some(0
149161
| ^
150162

151163
error: unreachable pattern
152-
--> $DIR/exhaustiveness-unreachable-pattern.rs:135:19
164+
--> $DIR/exhaustiveness-unreachable-pattern.rs:141:19
153165
|
154166
LL | | false) => {}
155167
| ^^^^^
156168

157169
error: unreachable pattern
158-
--> $DIR/exhaustiveness-unreachable-pattern.rs:143:15
170+
--> $DIR/exhaustiveness-unreachable-pattern.rs:149:15
159171
|
160172
LL | | true) => {}
161173
| ^^^^
162174

163175
error: unreachable pattern
164-
--> $DIR/exhaustiveness-unreachable-pattern.rs:149:15
176+
--> $DIR/exhaustiveness-unreachable-pattern.rs:155:15
165177
|
166178
LL | | true,
167179
| ^^^^
168180

169-
error: aborting due to 26 previous errors
181+
error: unreachable pattern
182+
--> $DIR/exhaustiveness-unreachable-pattern.rs:160:15
183+
|
184+
LL | | (y, x) => {}
185+
| ^^^^^^
186+
187+
error: aborting due to 29 previous errors
170188

tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
2-
--> $DIR/pointer-sized-int.rs:48:11
2+
--> $DIR/pointer-sized-int.rs:65:11
33
|
44
LL | match 7usize {}
55
| ^^^^^^

0 commit comments

Comments
 (0)