]> git.proxmox.com Git - rustc.git/blob - src/test/ui/binding/empty-types-in-patterns.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / binding / empty-types-in-patterns.rs
1 // run-pass
2 #![feature(never_type, never_type_fallback)]
3 #![feature(exhaustive_patterns)]
4 #![feature(slice_patterns)]
5 #![allow(unreachable_patterns)]
6 #![allow(unreachable_code)]
7 #![allow(unused_variables)]
8
9 #[allow(dead_code)]
10 fn foo(z: !) {
11 let x: Result<!, !> = Ok(z);
12
13 let Ok(_y) = x;
14 let Err(_y) = x;
15
16 let x = [z; 1];
17
18 match x {};
19 match x {
20 [q] => q,
21 };
22 }
23
24 fn bar(nevers: &[!]) {
25 match nevers {
26 &[] => (),
27 };
28
29 match nevers {
30 &[] => (),
31 &[_] => (),
32 &[_, _, _, ..] => (),
33 };
34 }
35
36 fn main() {
37 let x: Result<u32, !> = Ok(123);
38 let Ok(y) = x;
39
40 assert_eq!(123, y);
41
42 match x {
43 Ok(y) => y,
44 };
45
46 match x {
47 Ok(y) => y,
48 Err(e) => match e {},
49 };
50
51 let x: Result<u32, &!> = Ok(123);
52 match x {
53 Ok(y) => y,
54 Err(_) => unimplemented!(),
55 };
56
57 bar(&[]);
58 }