]>
Commit | Line | Data |
---|---|---|
abe05a73 XL |
1 | struct UnitStruct; |
2 | struct TupleStruct(); | |
3 | struct BracedStruct{} | |
4 | ||
5 | enum E { | |
6 | UnitVariant, | |
7 | TupleVariant(), | |
8 | BracedVariant{}, | |
9 | } | |
10 | use E::*; | |
11 | ||
12 | const CONST: () = (); | |
13 | static STATIC: () = (); | |
14 | ||
15 | fn function() {} | |
16 | ||
17 | fn main() { | |
18 | let doesnt_matter = 0; | |
19 | ||
20 | match UnitStruct { | |
21 | UnitStruct => {} // OK, `UnitStruct` is a unit struct pattern | |
22 | } | |
23 | match doesnt_matter { | |
24 | TupleStruct => {} //~ ERROR match bindings cannot shadow tuple structs | |
25 | } | |
26 | match doesnt_matter { | |
27 | BracedStruct => {} // OK, `BracedStruct` is a fresh binding | |
28 | } | |
29 | match UnitVariant { | |
30 | UnitVariant => {} // OK, `UnitVariant` is a unit variant pattern | |
31 | } | |
32 | match doesnt_matter { | |
33 | TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants | |
34 | } | |
35 | match doesnt_matter { | |
487cf647 | 36 | BracedVariant => {} // OK, `BracedVariant` is a fresh binding |
abe05a73 XL |
37 | } |
38 | match CONST { | |
39 | CONST => {} // OK, `CONST` is a const pattern | |
40 | } | |
41 | match doesnt_matter { | |
42 | STATIC => {} //~ ERROR match bindings cannot shadow statics | |
43 | } | |
44 | match doesnt_matter { | |
45 | function => {} // OK, `function` is a fresh binding | |
46 | } | |
47 | ||
48 | let UnitStruct = UnitStruct; // OK, `UnitStruct` is a unit struct pattern | |
49 | let TupleStruct = doesnt_matter; //~ ERROR let bindings cannot shadow tuple structs | |
50 | let BracedStruct = doesnt_matter; // OK, `BracedStruct` is a fresh binding | |
51 | let UnitVariant = UnitVariant; // OK, `UnitVariant` is a unit variant pattern | |
52 | let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants | |
487cf647 | 53 | let BracedVariant = doesnt_matter; // OK, `BracedVariant` is a fresh binding |
abe05a73 XL |
54 | let CONST = CONST; // OK, `CONST` is a const pattern |
55 | let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics | |
56 | let function = doesnt_matter; // OK, `function` is a fresh binding | |
57 | } |