]> git.lizzy.rs Git - rust.git/blob - src/test/ui/empty/empty-struct-unit-pat.rs
Rollup merge of #53317 - estebank:abolish-ice, r=oli-obk
[rust.git] / src / test / ui / empty / empty-struct-unit-pat.rs
1 // Copyright 2015 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 // Can't use unit struct as tuple struct pattern
12
13 // aux-build:empty-struct.rs
14
15 extern crate empty_struct;
16 use empty_struct::*;
17
18 struct Empty2;
19
20 enum E {
21     Empty4
22 }
23
24 fn main() {
25     let e2 = Empty2;
26     let e4 = E::Empty4;
27     let xe2 = XEmpty2;
28     let xe4 = XE::XEmpty4;
29
30     match e2 {
31         Empty2() => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2`
32     }
33     match xe2 {
34         XEmpty2() => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2`
35     }
36     match e2 {
37         Empty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2`
38     }
39     match xe2 {
40         XEmpty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2`
41     }
42
43     match e4 {
44         E::Empty4() => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4`
45     }
46     match xe4 {
47         XE::XEmpty4() => (),
48         //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4`
49         _ => {},
50     }
51     match e4 {
52         E::Empty4(..) => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4`
53     }
54     match xe4 {
55         XE::XEmpty4(..) => (),
56         //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4`
57         _ => {},
58     }
59 }