]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-shorthand-field.rs
Rollup merge of #57278 - mati865:config_clippy, r=alexcrichton
[rust.git] / src / test / ui / lint / lint-shorthand-field.rs
1 #![allow(nonstandard_style, unused_variables)]
2 #![deny(non_shorthand_field_patterns)]
3
4 struct Foo {
5     x: isize,
6     y: isize,
7 }
8
9 fn main() {
10     {
11         let Foo {
12             x: x, //~ ERROR the `x:` in this pattern is redundant
13             y: ref y, //~ ERROR the `y:` in this pattern is redundant
14         } = Foo { x: 0, y: 0 };
15
16         let Foo {
17             x,
18             ref y,
19         } = Foo { x: 0, y: 0 };
20     }
21
22     {
23         const x: isize = 1;
24
25         match (Foo { x: 1, y: 1 }) {
26             Foo { x: x, ..} => {},
27             _ => {},
28         }
29     }
30
31     {
32         struct Bar {
33             x: x,
34         }
35
36         struct x;
37
38         match (Bar { x: x }) {
39             Bar { x: x } => {},
40         }
41     }
42
43     {
44         struct Bar {
45             x: Foo,
46         }
47
48         enum Foo { x }
49
50         match (Bar { x: Foo::x }) {
51             Bar { x: Foo::x } => {},
52         }
53     }
54 }