Skip to content

Commit 4059fc3

Browse files
committed
Add tests
1 parent 0d410be commit 4059fc3

File tree

3 files changed

+80
-14
lines changed

3 files changed

+80
-14
lines changed

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:58:11
33
|
44
LL | match 7usize {}
55
| ^^^^^^

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

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: `_` not covered
2-
--> $DIR/pointer-sized-int.rs:12:11
2+
--> $DIR/pointer-sized-int.rs:14:11
33
|
44
LL | match 0usize {
55
| ^^^^^^ pattern `_` not covered
@@ -14,7 +14,7 @@ LL + _ => todo!()
1414
|
1515

1616
error[E0004]: non-exhaustive patterns: `_` not covered
17-
--> $DIR/pointer-sized-int.rs:17:11
17+
--> $DIR/pointer-sized-int.rs:19:11
1818
|
1919
LL | match 0isize {
2020
| ^^^^^^ pattern `_` not covered
@@ -29,7 +29,21 @@ LL + _ => todo!()
2929
|
3030

3131
error[E0004]: non-exhaustive patterns: `_` not covered
32-
--> $DIR/pointer-sized-int.rs:22:8
32+
--> $DIR/pointer-sized-int.rs:24:8
33+
|
34+
LL | m!(0usize, 0..);
35+
| ^^^^^^ pattern `_` not covered
36+
|
37+
= note: the matched value is of type `usize`
38+
= note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
39+
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
40+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
41+
|
42+
LL | match $s { $($t)+ => {}, _ => todo!() }
43+
| ++++++++++++++
44+
45+
error[E0004]: non-exhaustive patterns: `_` not covered
46+
--> $DIR/pointer-sized-int.rs:26:8
3347
|
3448
LL | m!(0usize, 0..=usize::MAX);
3549
| ^^^^^^ pattern `_` not covered
@@ -43,7 +57,7 @@ LL | match $s { $($t)+ => {}, _ => todo!() }
4357
| ++++++++++++++
4458

4559
error[E0004]: non-exhaustive patterns: `_` not covered
46-
--> $DIR/pointer-sized-int.rs:24:8
60+
--> $DIR/pointer-sized-int.rs:28:8
4761
|
4862
LL | m!(0usize, 0..5 | 5..=usize::MAX);
4963
| ^^^^^^ pattern `_` not covered
@@ -57,7 +71,7 @@ LL | match $s { $($t)+ => {}, _ => todo!() }
5771
| ++++++++++++++
5872

5973
error[E0004]: non-exhaustive patterns: `_` not covered
60-
--> $DIR/pointer-sized-int.rs:26:8
74+
--> $DIR/pointer-sized-int.rs:30:8
6175
|
6276
LL | m!(0usize, 0..usize::MAX | usize::MAX);
6377
| ^^^^^^ pattern `_` not covered
@@ -71,7 +85,7 @@ LL | match $s { $($t)+ => {}, _ => todo!() }
7185
| ++++++++++++++
7286

7387
error[E0004]: non-exhaustive patterns: `(_, _)` not covered
74-
--> $DIR/pointer-sized-int.rs:28:8
88+
--> $DIR/pointer-sized-int.rs:32:8
7589
|
7690
LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
7791
| ^^^^^^^^^^^^^^ pattern `(_, _)` not covered
@@ -85,7 +99,35 @@ LL | match $s { $($t)+ => {}, (_, _) => todo!() }
8599
| +++++++++++++++++++
86100

87101
error[E0004]: non-exhaustive patterns: `_` not covered
88-
--> $DIR/pointer-sized-int.rs:31:8
102+
--> $DIR/pointer-sized-int.rs:34:8
103+
|
104+
LL | m!(0usize, 0..=usize::MAX | usize::MAX..);
105+
| ^^^^^^ pattern `_` not covered
106+
|
107+
= note: the matched value is of type `usize`
108+
= note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
109+
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
110+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
111+
|
112+
LL | match $s { $($t)+ => {}, _ => todo!() }
113+
| ++++++++++++++
114+
115+
error[E0004]: non-exhaustive patterns: `_` not covered
116+
--> $DIR/pointer-sized-int.rs:37:8
117+
|
118+
LL | m!(0isize, ..0 | 0..);
119+
| ^^^^^^ pattern `_` not covered
120+
|
121+
= note: the matched value is of type `isize`
122+
= note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
123+
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
124+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
125+
|
126+
LL | match $s { $($t)+ => {}, _ => todo!() }
127+
| ++++++++++++++
128+
129+
error[E0004]: non-exhaustive patterns: `_` not covered
130+
--> $DIR/pointer-sized-int.rs:39:8
89131
|
90132
LL | m!(0isize, isize::MIN..=isize::MAX);
91133
| ^^^^^^ pattern `_` not covered
@@ -99,7 +141,7 @@ LL | match $s { $($t)+ => {}, _ => todo!() }
99141
| ++++++++++++++
100142

101143
error[E0004]: non-exhaustive patterns: `_` not covered
102-
--> $DIR/pointer-sized-int.rs:33:8
144+
--> $DIR/pointer-sized-int.rs:41:8
103145
|
104146
LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX);
105147
| ^^^^^^ pattern `_` not covered
@@ -113,7 +155,7 @@ LL | match $s { $($t)+ => {}, _ => todo!() }
113155
| ++++++++++++++
114156

115157
error[E0004]: non-exhaustive patterns: `_` not covered
116-
--> $DIR/pointer-sized-int.rs:35:8
158+
--> $DIR/pointer-sized-int.rs:43:8
117159
|
118160
LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
119161
| ^^^^^^ pattern `_` not covered
@@ -127,7 +169,7 @@ LL | match $s { $($t)+ => {}, _ => todo!() }
127169
| ++++++++++++++
128170

129171
error[E0004]: non-exhaustive patterns: `(_, _)` not covered
130-
--> $DIR/pointer-sized-int.rs:37:8
172+
--> $DIR/pointer-sized-int.rs:45:8
131173
|
132174
LL | m!((0isize, true), (isize::MIN..5, true)
133175
| ^^^^^^^^^^^^^^ pattern `(_, _)` not covered
@@ -141,7 +183,21 @@ LL | match $s { $($t)+ => {}, (_, _) => todo!() }
141183
| +++++++++++++++++++
142184

143185
error[E0004]: non-exhaustive patterns: `_` not covered
144-
--> $DIR/pointer-sized-int.rs:41:11
186+
--> $DIR/pointer-sized-int.rs:48:8
187+
|
188+
LL | m!(0isize, ..=isize::MIN | isize::MIN..=isize::MAX | isize::MAX..);
189+
| ^^^^^^ pattern `_` not covered
190+
|
191+
= note: the matched value is of type `isize`
192+
= note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
193+
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
194+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
195+
|
196+
LL | match $s { $($t)+ => {}, _ => todo!() }
197+
| ++++++++++++++
198+
199+
error[E0004]: non-exhaustive patterns: `_` not covered
200+
--> $DIR/pointer-sized-int.rs:51:11
145201
|
146202
LL | match 0isize {
147203
| ^^^^^^ pattern `_` not covered
@@ -156,7 +212,7 @@ LL + _ => todo!()
156212
|
157213

158214
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
159-
--> $DIR/pointer-sized-int.rs:48:11
215+
--> $DIR/pointer-sized-int.rs:58:11
160216
|
161217
LL | match 7usize {}
162218
| ^^^^^^
@@ -169,6 +225,6 @@ LL + _ => todo!(),
169225
LL + }
170226
|
171227

172-
error: aborting due to 12 previous errors
228+
error: aborting due to 16 previous errors
173229

174230
For more information about this error, try `rustc --explain E0004`.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// revisions: allow deny
22
#![feature(exclusive_range_pattern)]
33
#![cfg_attr(allow, feature(precise_pointer_size_matching))]
4+
#![allow(overlapping_range_endpoints)]
45

56
macro_rules! m {
67
($s:expr, $($t:tt)+) => {
78
match $s { $($t)+ => {} }
89
}
910
}
1011

12+
#[rustfmt::skip]
1113
fn main() {
1214
match 0usize {
1315
//[deny]~^ ERROR non-exhaustive patterns
@@ -19,6 +21,8 @@ fn main() {
1921
isize::MIN ..= isize::MAX => {}
2022
}
2123

24+
m!(0usize, 0..);
25+
//[deny]~^ ERROR non-exhaustive patterns
2226
m!(0usize, 0..=usize::MAX);
2327
//[deny]~^ ERROR non-exhaustive patterns
2428
m!(0usize, 0..5 | 5..=usize::MAX);
@@ -27,7 +31,11 @@ fn main() {
2731
//[deny]~^ ERROR non-exhaustive patterns
2832
m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
2933
//[deny]~^ ERROR non-exhaustive patterns
34+
m!(0usize, 0..=usize::MAX | usize::MAX..);
35+
//[deny]~^ ERROR non-exhaustive patterns
3036

37+
m!(0isize, ..0 | 0..);
38+
//[deny]~^ ERROR non-exhaustive patterns
3139
m!(0isize, isize::MIN..=isize::MAX);
3240
//[deny]~^ ERROR non-exhaustive patterns
3341
m!(0isize, isize::MIN..5 | 5..=isize::MAX);
@@ -37,6 +45,8 @@ fn main() {
3745
m!((0isize, true), (isize::MIN..5, true)
3846
| (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false));
3947
//[deny]~^^ ERROR non-exhaustive patterns
48+
m!(0isize, ..=isize::MIN | isize::MIN..=isize::MAX | isize::MAX..);
49+
//[deny]~^ ERROR non-exhaustive patterns
4050

4151
match 0isize {
4252
//[deny]~^ ERROR non-exhaustive patterns

0 commit comments

Comments
 (0)