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;
|
2022-09-02 22:01:35 -05:00
|
|
|
match x { T::B => { } } //~ ERROR non-exhaustive patterns: `T::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
|
|
|
}
|
2020-06-19 11:57:15 -05:00
|
|
|
match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, i32::MIN..=3_i32)`
|
|
|
|
// and `(_, _, 5_i32..=i32::MAX)` not covered
|
2012-08-03 21:59:04 -05:00
|
|
|
(_, _, 4) => {}
|
2012-02-15 02:40:42 -06:00
|
|
|
}
|
2022-09-02 22:01:35 -05:00
|
|
|
match (T::A, T::A) { //~ ERROR non-exhaustive patterns: `(T::A, T::A)` and `(T::B, T::B)` not covered
|
2018-12-16 21:21:47 -06:00
|
|
|
(T::A, T::B) => {}
|
|
|
|
(T::B, T::A) => {}
|
2012-04-24 04:13:25 -05:00
|
|
|
}
|
2022-09-02 22:01:35 -05:00
|
|
|
match T::A { //~ ERROR non-exhaustive patterns: `T::B` not covered
|
2018-12-16 21:21:47 -06:00
|
|
|
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
|
2019-07-07 18:47:46 -05:00
|
|
|
[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 {
|
2019-07-07 18:47:46 -05:00
|
|
|
[_, 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;
|
2019-11-03 17:11:04 -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 {
|
2019-07-07 18:47:46 -05:00
|
|
|
[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
|
|
|
}
|