2015-03-26 20:34:27 -05:00
|
|
|
#![feature(slice_patterns)]
|
2017-04-29 03:02:42 -05:00
|
|
|
#![allow(illegal_floating_point_literal_pattern)]
|
2015-03-26 20:34:27 -05:00
|
|
|
|
2018-12-16 21:21:47 -06:00
|
|
|
enum T { A, B }
|
2010-12-02 16:50:00 -06:00
|
|
|
|
2012-02-15 02:40:42 -06:00
|
|
|
fn main() {
|
2018-12-16 21:21:47 -06:00
|
|
|
let x = T::A;
|
|
|
|
match x { T::B => { } } //~ ERROR non-exhaustive patterns: `A` not covered
|
2014-06-19 13:55:12 -05:00
|
|
|
match true { //~ ERROR non-exhaustive patterns: `false` not covered
|
2012-08-03 21:59:04 -05:00
|
|
|
true => {}
|
2012-02-15 02:40:42 -06:00
|
|
|
}
|
2015-01-31 10:23:42 -06:00
|
|
|
match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
|
2014-01-03 17:08:48 -06:00
|
|
|
None => {}
|
2012-02-15 02:40:42 -06:00
|
|
|
}
|
2018-11-30 07:53:15 -06:00
|
|
|
match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)`
|
|
|
|
// and `(_, _, 5i32..=2147483647i32)` not covered
|
2012-08-03 21:59:04 -05:00
|
|
|
(_, _, 4) => {}
|
2012-02-15 02:40:42 -06:00
|
|
|
}
|
2018-12-16 21:21:47 -06:00
|
|
|
match (T::A, T::A) { //~ ERROR non-exhaustive patterns: `(A, A)` not covered
|
|
|
|
(T::A, T::B) => {}
|
|
|
|
(T::B, T::A) => {}
|
2012-04-24 04:13:25 -05:00
|
|
|
}
|
2018-12-16 21:21:47 -06:00
|
|
|
match T::A { //~ ERROR non-exhaustive patterns: `B` not covered
|
|
|
|
T::A => {}
|
2012-05-03 10:35:12 -05:00
|
|
|
}
|
2012-04-24 04:13:25 -05:00
|
|
|
// This is exhaustive, though the algorithm got it wrong at one point
|
2018-12-16 21:21:47 -06:00
|
|
|
match (T::A, T::B) {
|
|
|
|
(T::A, _) => {}
|
|
|
|
(_, T::A) => {}
|
|
|
|
(T::B, T::B) => {}
|
2012-04-24 04:13:25 -05:00
|
|
|
}
|
2016-10-29 16:54:04 -05:00
|
|
|
let vec = vec![Some(42), None, Some(21)];
|
2015-02-01 20:53:25 -06:00
|
|
|
let vec: &[Option<isize>] = &vec;
|
2016-03-11 04:54:59 -06:00
|
|
|
match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered
|
|
|
|
[Some(..), None, ref tail..] => {}
|
|
|
|
[Some(..), Some(..), ref tail..] => {}
|
2012-12-08 14:22:43 -06:00
|
|
|
[None] => {}
|
|
|
|
}
|
2016-10-29 16:54:04 -05:00
|
|
|
let vec = vec![1];
|
2015-02-01 20:53:25 -06:00
|
|
|
let vec: &[isize] = &vec;
|
2016-03-11 04:54:59 -06:00
|
|
|
match *vec {
|
|
|
|
[_, ref tail..] => (),
|
2012-12-08 14:22:43 -06:00
|
|
|
[] => ()
|
|
|
|
}
|
2016-10-29 16:54:04 -05:00
|
|
|
let vec = vec![0.5f32];
|
2015-02-01 20:53:25 -06:00
|
|
|
let vec: &[f32] = &vec;
|
2016-03-11 04:54:59 -06:00
|
|
|
match *vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered
|
2012-12-08 14:22:43 -06:00
|
|
|
[0.1, 0.2, 0.3] => (),
|
|
|
|
[0.1, 0.2] => (),
|
|
|
|
[0.1] => (),
|
|
|
|
[] => ()
|
|
|
|
}
|
2016-10-29 16:54:04 -05:00
|
|
|
let vec = vec![Some(42), None, Some(21)];
|
2015-02-01 20:53:25 -06:00
|
|
|
let vec: &[Option<isize>] = &vec;
|
2016-03-11 04:54:59 -06:00
|
|
|
match *vec {
|
|
|
|
[Some(..), None, ref tail..] => {}
|
|
|
|
[Some(..), Some(..), ref tail..] => {}
|
|
|
|
[None, None, ref tail..] => {}
|
|
|
|
[None, Some(..), ref tail..] => {}
|
2012-12-08 14:22:43 -06:00
|
|
|
[Some(_)] => {}
|
|
|
|
[None] => {}
|
|
|
|
[] => {}
|
|
|
|
}
|
2012-02-15 02:40:42 -06:00
|
|
|
}
|