Skip to content

Commit 25ba911

Browse files
committed
Add guarded arms to tests
1 parent 07064de commit 25ba911

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/test/ui/exhaustive_integer_patterns.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,16 @@ fn main() {
120120
match 0i128 {
121121
i128::MIN ..= i128::MAX => {} // ok
122122
}
123+
124+
// Make sure that guards don't factor into the exhaustiveness checks.
125+
match 0u8 { //~ ERROR non-exhaustive patterns
126+
0 .. 128 => {}
127+
128 ..= 255 if true => {}
128+
}
129+
130+
match 0u8 {
131+
0 .. 128 => {}
132+
128 ..= 255 if false => {}
133+
128 ..= 255 => {} // ok, because previous arm was guarded
134+
}
123135
}

src/test/ui/exhaustive_integer_patterns.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ error[E0004]: non-exhaustive patterns: `0i16` not covered
4646
LL | match 0i16 { //~ ERROR non-exhaustive patterns
4747
| ^^^^ pattern `0i16` not covered
4848

49-
error: aborting due to 7 previous errors
49+
error[E0004]: non-exhaustive patterns: `128u8..=255u8` not covered
50+
--> $DIR/exhaustive_integer_patterns.rs:125:11
51+
|
52+
LL | match 0u8 { //~ ERROR non-exhaustive patterns
53+
| ^^^ pattern `128u8..=255u8` not covered
54+
55+
error: aborting due to 8 previous errors
5056

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

0 commit comments

Comments
 (0)