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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.5 KiB
Rust
Raw Normal View History

2020-12-02 14:24:20 -06:00
// revisions: allow deny
2020-11-20 13:03:56 -06:00
#![feature(exclusive_range_pattern)]
2020-12-02 14:24:20 -06:00
#![cfg_attr(allow, feature(precise_pointer_size_matching))]
2020-11-20 13:03:56 -06:00
macro_rules! m {
($s:expr, $($t:tt)+) => {
match $s { $($t)+ => {} }
}
}
fn main() {
match 0usize {
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
0 ..= usize::MAX => {}
}
match 0isize {
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
isize::MIN ..= isize::MAX => {}
}
m!(0usize, 0..=usize::MAX);
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!(0usize, 0..5 | 5..=usize::MAX);
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!(0usize, 0..usize::MAX | usize::MAX);
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!(0isize, isize::MIN..=isize::MAX);
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!(0isize, isize::MIN..5 | 5..=isize::MAX);
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!(0isize, isize::MIN..isize::MAX | isize::MAX);
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
m!((0isize, true), (isize::MIN..5, true)
| (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false));
2020-12-02 14:24:20 -06:00
//[deny]~^^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
match 0isize {
2020-12-02 14:24:20 -06:00
//[deny]~^ ERROR non-exhaustive patterns
2020-11-20 13:03:56 -06:00
isize::MIN ..= -1 => {}
0 => {}
1 ..= isize::MAX => {}
}
match 7usize {}
//~^ ERROR non-exhaustive patterns
}