Add a test case for u128::MAX - 1
This commit is contained in:
parent
61b6363cb1
commit
6a957e172a
@ -1501,6 +1501,8 @@ enum Endpoint {
|
||||
if let Endpoint::Both = a.1 {
|
||||
split_ctors.push(IntRange::range_to_ctor(tcx, ty, a.0..=a.0));
|
||||
}
|
||||
// Integer overflow cannot occur here, because only the first point may be
|
||||
// u128::MIN and only the last may be u128::MAX.
|
||||
let c = match a.1 {
|
||||
Endpoint::Start => a.0,
|
||||
Endpoint::End | Endpoint::Both => a.0 + 1,
|
||||
|
@ -140,21 +140,26 @@ fn main() {
|
||||
}
|
||||
|
||||
match (0u8, true) { //~ ERROR non-exhaustive patterns
|
||||
(0..=125, false) => {}
|
||||
(128..=255, false) => {}
|
||||
(0..=255, true) => {}
|
||||
(0 ..= 125, false) => {}
|
||||
(128 ..= 255, false) => {}
|
||||
(0 ..= 255, true) => {}
|
||||
}
|
||||
|
||||
match (0u8, true) { // ok
|
||||
(0..=125, false) => {}
|
||||
(128..=255, false) => {}
|
||||
(0..=255, true) => {}
|
||||
(125..128, false) => {}
|
||||
(0 ..= 125, false) => {}
|
||||
(128 ..= 255, false) => {}
|
||||
(0 ..= 255, true) => {}
|
||||
(125 .. 128, false) => {}
|
||||
}
|
||||
|
||||
match 0u8 { // ok
|
||||
0..2 => {}
|
||||
1..=2 => {}
|
||||
0 .. 2 => {}
|
||||
1 ..= 2 => {}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
const lim: u128 = u128::MAX - 1;
|
||||
match 0u128 { //~ ERROR non-exhaustive patterns
|
||||
0 ..= lim => {}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,12 @@ error[E0004]: non-exhaustive patterns: `(126u8..=127u8, false)` not covered
|
||||
LL | match (0u8, true) { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^^^^^^^ pattern `(126u8..=127u8, false)` not covered
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211455u128` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:162:11
|
||||
|
|
||||
LL | match 0u128 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^ pattern `340282366920938463463374607431768211455u128` not covered
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
|
Loading…
Reference in New Issue
Block a user