]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/binding/empty-types-in-patterns.rs
Rollup merge of #56914 - glaubitz:ignore-tests, r=alexcrichton
[rust.git] / src / test / run-pass / binding / empty-types-in-patterns.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.
4 //
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.
10
11 // run-pass
12 #![feature(never_type)]
13 #![feature(exhaustive_patterns)]
14 #![feature(slice_patterns)]
15 #![allow(unreachable_patterns)]
16 #![allow(unreachable_code)]
17 #![allow(unused_variables)]
18
19 #[allow(dead_code)]
20 fn foo(z: !) {
21     let x: Result<!, !> = Ok(z);
22
23     let Ok(_y) = x;
24     let Err(_y) = x;
25
26     let x = [z; 1];
27
28     match x {};
29     match x {
30         [q] => q,
31     };
32 }
33
34 fn bar(nevers: &[!]) {
35     match nevers {
36         &[]  => (),
37     };
38
39     match nevers {
40         &[]  => (),
41         &[_]  => (),
42         &[_, _, _, ..]  => (),
43     };
44 }
45
46 fn main() {
47     let x: Result<u32, !> = Ok(123);
48     let Ok(y) = x;
49
50     assert_eq!(123, y);
51
52     match x {
53         Ok(y) => y,
54     };
55
56     match x {
57         Ok(y) => y,
58         Err(e) => match e {},
59     };
60
61     let x: Result<u32, &!> = Ok(123);
62     match x {
63         Ok(y) => y,
64         Err(_) => unimplemented!(),
65     };
66
67     bar(&[]);
68 }
69