1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(exhaustive_integer_patterns)]
12 #![feature(exclusive_range_pattern)]
13 #![deny(unreachable_patterns)]
15 use std::{char, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128};
20 // A single range covering the entire domain.
25 // A combination of ranges and values.
26 // These are currently allowed to be overlapping.
32 200 => {} //~ ERROR unreachable pattern
36 // An incomplete set of values.
37 match x { //~ ERROR non-exhaustive patterns: `128u8...255u8` not covered
41 // A more incomplete set of values.
42 match x { //~ ERROR non-exhaustive patterns
50 match x { //~ ERROR non-exhaustive patterns
53 -2..=20 => {} //~ ERROR unreachable pattern
57 // Let's test other types too!
59 '\u{0}' ..= char::MAX => {} // ok
63 0 ..= usize::MAX => {} // ok
67 0 ..= u16::MAX => {} // ok
71 0 ..= u32::MAX => {} // ok
75 0 ..= u64::MAX => {} // ok
79 0 ..= u128::MAX => {} // ok
83 isize::MIN ..= isize::MAX => {} // ok
87 -128..=127 => {} // ok
91 i16::MIN ..= i16::MAX => {} // ok
95 i32::MIN ..= i32::MAX => {} // ok
99 i64::MIN ..= i64::MAX => {} // ok
103 i128::MIN ..= i128::MAX => {} // ok