]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/non-exhaustive-match.rs
1 // Copyright 2012 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(slice_patterns)]
12 #![allow(illegal_floating_point_literal_pattern)]
18 match x { t::b => { }
} //~ ERROR non-exhaustive patterns: `a` not covered
19 match true { //~ ERROR non-exhaustive patterns: `false` not covered
22 match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
25 match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered
28 match (t
::a
, t
::a
) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered
32 match t
::a
{ //~ ERROR non-exhaustive patterns: `b` not covered
35 // This is exhaustive, though the algorithm got it wrong at one point
41 let vec
= vec
![Some(42), None
, Some(21)];
42 let vec
: &[Option
<isize>] = &vec
;
43 match *vec
{ //~ ERROR non-exhaustive patterns: `[]` not covered
44 [Some(..), None
, ref tail
..] => {}
45 [Some(..), Some(..), ref tail
..] => {}
49 let vec
: &[isize] = &vec
;
51 [_
, ref tail
..] => (),
54 let vec
= vec
![0.5f32];
55 let vec
: &[f32] = &vec
;
56 match *vec
{ //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered
57 [0.1, 0.2, 0.3] => (),
62 let vec
= vec
![Some(42), None
, Some(21)];
63 let vec
: &[Option
<isize>] = &vec
;
65 [Some(..), None
, ref tail
..] => {}
66 [Some(..), Some(..), ref tail
..] => {}
67 [None
, None
, ref tail
..] => {}
68 [None
, Some(..), ref tail
..] => {}