1 // Test various non-exhaustive matches for `X..`, `..=X` and `..X` ranges.
3 #![feature(exclusive_range_pattern)]
4 #![allow(illegal_floating_point_literal_pattern)]
9 ($s:expr, $($t:tt)+) => {
10 match $s { $($t)+ => {} }
15 m!(0f32, f32::NEG_INFINITY..); //~ ERROR non-exhaustive patterns: `_` not covered
16 m!(0f32, ..f32::INFINITY); //~ ERROR non-exhaustive patterns: `_` not covered
20 const ALMOST_MAX: char = '\u{10fffe}';
21 const ALMOST_MIN: char = '\u{1}';
22 const VAL: char = 'a';
23 const VAL_1: char = 'b';
24 const VAL_2: char = 'c';
25 m!('a', ..core::char::MAX); //~ ERROR non-exhaustive patterns
26 m!('a', ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
27 m!('a', ALMOST_MIN..); //~ ERROR non-exhaustive patterns
28 m!('a', ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
29 m!('a', ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
30 m!('a', ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
35 const ALMOST_MAX: u8 = u8::MAX - 1;
36 const ALMOST_MIN: u8 = u8::MIN + 1;
38 const VAL_1: u8 = VAL + 1;
39 const VAL_2: u8 = VAL + 2;
40 m!(0, ..u8::MAX); //~ ERROR non-exhaustive patterns
41 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
42 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
43 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
44 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
45 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
48 const ALMOST_MAX: u16 = u16::MAX - 1;
49 const ALMOST_MIN: u16 = u16::MIN + 1;
51 const VAL_1: u16 = VAL + 1;
52 const VAL_2: u16 = VAL + 2;
53 m!(0, ..u16::MAX); //~ ERROR non-exhaustive patterns
54 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
55 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
56 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
57 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
58 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
61 const ALMOST_MAX: u32 = u32::MAX - 1;
62 const ALMOST_MIN: u32 = u32::MIN + 1;
64 const VAL_1: u32 = VAL + 1;
65 const VAL_2: u32 = VAL + 2;
66 m!(0, ..u32::MAX); //~ ERROR non-exhaustive patterns
67 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
68 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
69 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
70 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
71 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
74 const ALMOST_MAX: u64 = u64::MAX - 1;
75 const ALMOST_MIN: u64 = u64::MIN + 1;
77 const VAL_1: u64 = VAL + 1;
78 const VAL_2: u64 = VAL + 2;
79 m!(0, ..u64::MAX); //~ ERROR non-exhaustive patterns
80 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
81 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
82 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
83 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
84 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
87 const ALMOST_MAX: u128 = u128::MAX - 1;
88 const ALMOST_MIN: u128 = u128::MIN + 1;
90 const VAL_1: u128 = VAL + 1;
91 const VAL_2: u128 = VAL + 2;
92 m!(0, ..u128::MAX); //~ ERROR non-exhaustive patterns
93 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
94 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
95 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
96 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
97 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
103 const ALMOST_MAX: i8 = i8::MAX - 1;
104 const ALMOST_MIN: i8 = i8::MIN + 1;
106 const VAL_1: i8 = VAL + 1;
107 const VAL_2: i8 = VAL + 2;
108 m!(0, ..i8::MAX); //~ ERROR non-exhaustive patterns
109 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
110 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
111 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
112 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
113 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
116 const ALMOST_MAX: i16 = i16::MAX - 1;
117 const ALMOST_MIN: i16 = i16::MIN + 1;
119 const VAL_1: i16 = VAL + 1;
120 const VAL_2: i16 = VAL + 2;
121 m!(0, ..i16::MAX); //~ ERROR non-exhaustive patterns
122 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
123 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
124 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
125 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
126 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
129 const ALMOST_MAX: i32 = i32::MAX - 1;
130 const ALMOST_MIN: i32 = i32::MIN + 1;
132 const VAL_1: i32 = VAL + 1;
133 const VAL_2: i32 = VAL + 2;
134 m!(0, ..i32::MAX); //~ ERROR non-exhaustive patterns
135 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
136 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
137 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
138 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
139 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
142 const ALMOST_MAX: i64 = i64::MAX - 1;
143 const ALMOST_MIN: i64 = i64::MIN + 1;
145 const VAL_1: i64 = VAL + 1;
146 const VAL_2: i64 = VAL + 2;
147 m!(0, ..i64::MAX); //~ ERROR non-exhaustive patterns
148 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
149 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
150 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
151 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
152 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns
155 const ALMOST_MAX: i128 = i128::MAX - 1;
156 const ALMOST_MIN: i128 = i128::MIN + 1;
157 const VAL: i128 = 42;
158 const VAL_1: i128 = VAL + 1;
159 const VAL_2: i128 = VAL + 2;
160 m!(0, ..i128::MAX); //~ ERROR non-exhaustive patterns
161 m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns
162 m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns
163 m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns
164 m!(0, ..=VAL | VAL_2..); //~ ERROR non-exhaustive patterns
165 m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns