1 // Test various non-exhaustive matches for `X..`, `..=X` and `..X` ranges.
3 #![feature(half_open_range_patterns)]
4 #![feature(exclusive_range_pattern)]
5 #![allow(illegal_floating_point_literal_pattern)]
10 ($s:expr, $($t:tt)+) => {
11 match $s { $($t)+ => {} }
16 m!(0f32, f32::NEG_INFINITY..); //~ ERROR non-exhaustive patterns: `_` not covered
17 m!(0f32, ..f32::INFINITY); //~ ERROR non-exhaustive patterns: `_` not covered
21 const ALMOST_MAX: char = '\u{10fffe}';
22 const ALMOST_MIN: char = '\u{1}';
23 const VAL: char = 'a';
24 const VAL_1: char = 'b';
25 const VAL_2: char = 'c';
26 m!('a', ..core::char::MAX); //~ ERROR non-exhaustive patterns
27 m!('a', ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
28 m!('a', ALMOST_MIN..); //~ ERROR non-exhaustive patterns
29 m!('a', ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
30 m!('a', ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
31 m!('a', ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
36 const ALMOST_MAX: u8 = u8::MAX - 1;
37 const ALMOST_MIN: u8 = u8::MIN + 1;
39 const VAL_1: u8 = VAL + 1;
40 const VAL_2: u8 = VAL + 2;
41 m!(0, ..u8::MAX); //~ ERROR non-exhaustive patterns
42 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
43 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
44 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
45 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
46 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
49 const ALMOST_MAX: u16 = u16::MAX - 1;
50 const ALMOST_MIN: u16 = u16::MIN + 1;
52 const VAL_1: u16 = VAL + 1;
53 const VAL_2: u16 = VAL + 2;
54 m!(0, ..u16::MAX); //~ ERROR non-exhaustive patterns
55 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
56 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
57 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
58 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
59 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
62 const ALMOST_MAX: u32 = u32::MAX - 1;
63 const ALMOST_MIN: u32 = u32::MIN + 1;
65 const VAL_1: u32 = VAL + 1;
66 const VAL_2: u32 = VAL + 2;
67 m!(0, ..u32::MAX); //~ ERROR non-exhaustive patterns
68 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
69 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
70 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
71 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
72 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
75 const ALMOST_MAX: u64 = u64::MAX - 1;
76 const ALMOST_MIN: u64 = u64::MIN + 1;
78 const VAL_1: u64 = VAL + 1;
79 const VAL_2: u64 = VAL + 2;
80 m!(0, ..u64::MAX); //~ ERROR non-exhaustive patterns
81 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
82 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
83 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
84 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
85 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
88 const ALMOST_MAX: u128 = u128::MAX - 1;
89 const ALMOST_MIN: u128 = u128::MIN + 1;
91 const VAL_1: u128 = VAL + 1;
92 const VAL_2: u128 = VAL + 2;
93 m!(0, ..u128::MAX); //~ ERROR non-exhaustive patterns
94 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
95 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
96 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
97 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
98 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
104 const ALMOST_MAX: i8 = i8::MAX - 1;
105 const ALMOST_MIN: i8 = i8::MIN + 1;
107 const VAL_1: i8 = VAL + 1;
108 const VAL_2: i8 = VAL + 2;
109 m!(0, ..i8::MAX); //~ ERROR non-exhaustive patterns
110 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
111 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
112 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
113 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
114 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
117 const ALMOST_MAX: i16 = i16::MAX - 1;
118 const ALMOST_MIN: i16 = i16::MIN + 1;
120 const VAL_1: i16 = VAL + 1;
121 const VAL_2: i16 = VAL + 2;
122 m!(0, ..i16::MAX); //~ ERROR non-exhaustive patterns
123 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
124 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
125 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
126 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
127 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
130 const ALMOST_MAX: i32 = i32::MAX - 1;
131 const ALMOST_MIN: i32 = i32::MIN + 1;
133 const VAL_1: i32 = VAL + 1;
134 const VAL_2: i32 = VAL + 2;
135 m!(0, ..i32::MAX); //~ ERROR non-exhaustive patterns
136 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
137 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
138 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
139 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
140 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
143 const ALMOST_MAX: i64 = i64::MAX - 1;
144 const ALMOST_MIN: i64 = i64::MIN + 1;
146 const VAL_1: i64 = VAL + 1;
147 const VAL_2: i64 = VAL + 2;
148 m!(0, ..i64::MAX); //~ ERROR non-exhaustive patterns
149 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
150 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
151 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
152 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
153 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
156 const ALMOST_MAX: i128 = i128::MAX - 1;
157 const ALMOST_MIN: i128 = i128::MIN + 1;
158 const VAL: i128 = 42;
159 const VAL_1: i128 = VAL + 1;
160 const VAL_2: i128 = VAL + 2;
161 m!(0, ..i128::MAX); //~ ERROR non-exhaustive patterns
162 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
163 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
164 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
165 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
166 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns