]>
Commit | Line | Data |
---|---|---|
dfeec247 XL |
1 | // run-rustfix |
2 | ||
3 | #![allow(nonstandard_style, unused_variables, unused_mut)] | |
1a4d82fc JJ |
4 | #![deny(non_shorthand_field_patterns)] |
5 | ||
6 | struct Foo { | |
7 | x: isize, | |
8 | y: isize, | |
9 | } | |
10 | ||
11 | fn main() { | |
12 | { | |
13 | let Foo { | |
14 | x: x, //~ ERROR the `x:` in this pattern is redundant | |
15 | y: ref y, //~ ERROR the `y:` in this pattern is redundant | |
16 | } = Foo { x: 0, y: 0 }; | |
17 | ||
18 | let Foo { | |
19 | x, | |
20 | ref y, | |
21 | } = Foo { x: 0, y: 0 }; | |
22 | } | |
23 | ||
24 | { | |
25 | const x: isize = 1; | |
26 | ||
27 | match (Foo { x: 1, y: 1 }) { | |
28 | Foo { x: x, ..} => {}, | |
29 | _ => {}, | |
30 | } | |
31 | } | |
32 | ||
33 | { | |
34 | struct Bar { | |
35 | x: x, | |
36 | } | |
37 | ||
38 | struct x; | |
39 | ||
40 | match (Bar { x: x }) { | |
41 | Bar { x: x } => {}, | |
42 | } | |
43 | } | |
44 | ||
45 | { | |
46 | struct Bar { | |
47 | x: Foo, | |
48 | } | |
49 | ||
50 | enum Foo { x } | |
51 | ||
52 | match (Bar { x: Foo::x }) { | |
53 | Bar { x: Foo::x } => {}, | |
54 | } | |
55 | } | |
dfeec247 XL |
56 | |
57 | { | |
58 | struct Baz { | |
59 | x: isize, | |
60 | y: isize, | |
61 | z: isize, | |
62 | } | |
63 | ||
64 | let Baz { | |
65 | x: mut x, //~ ERROR the `x:` in this pattern is redundant | |
66 | y: ref y, //~ ERROR the `y:` in this pattern is redundant | |
67 | z: ref mut z, //~ ERROR the `z:` in this pattern is redundant | |
68 | } = Baz { x: 0, y: 0, z: 0 }; | |
69 | } | |
1a4d82fc | 70 | } |