Skip to content

Commit 6971c5d

Browse files
committed
Add some extra edge case tests
1 parent dec5563 commit 6971c5d

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/librustc_mir/hair/pattern/_match.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,8 @@ fn split_grouped_constructors<'p, 'a: 'p, 'tcx: 'a>(
14411441
let ctor_range = IntRange::from_ctor(tcx, &ctor).unwrap();
14421442

14431443
/// Represents a border between 2 integers. Because the intervals spanning borders
1444-
/// must be able to cover every integer, we need 2^128 + 1 such borders.
1444+
/// must be able to cover every integer, we need to be able to represent
1445+
/// 2^128 + 1 such borders.
14451446
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
14461447
enum Border {
14471448
JustBefore(u128),

src/test/ui/exhaustive_integer_patterns.rs

+8
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,12 @@ fn main() {
162162
match 0u128 { //~ ERROR non-exhaustive patterns
163163
0 ..= LIM => {}
164164
}
165+
166+
match 0u128 { //~ ERROR non-exhaustive patterns
167+
0 ..= 4 => {}
168+
}
169+
170+
match 0u128 { //~ ERROR non-exhaustive patterns
171+
4 ..= u128::MAX => {}
172+
}
165173
}

src/test/ui/exhaustive_integer_patterns.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211455u
7070
LL | match 0u128 { //~ ERROR non-exhaustive patterns
7171
| ^^^^^ pattern `340282366920938463463374607431768211455u128` not covered
7272

73-
error: aborting due to 11 previous errors
73+
error[E0004]: non-exhaustive patterns: `5u128..=340282366920938463463374607431768211455u128` not covered
74+
--> $DIR/exhaustive_integer_patterns.rs:166:11
75+
|
76+
LL | match 0u128 { //~ ERROR non-exhaustive patterns
77+
| ^^^^^ pattern `5u128..=340282366920938463463374607431768211455u128` not covered
78+
79+
error[E0004]: non-exhaustive patterns: `0u128..=3u128` not covered
80+
--> $DIR/exhaustive_integer_patterns.rs:170:11
81+
|
82+
LL | match 0u128 { //~ ERROR non-exhaustive patterns
83+
| ^^^^^ pattern `0u128..=3u128` not covered
84+
85+
error: aborting due to 13 previous errors
7486

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

0 commit comments

Comments
 (0)