]>
Commit | Line | Data |
---|---|---|
781aab86 | 1 | //@aux-build:proc_macros.rs |
353b0b11 | 2 | |
f20569fa XL |
3 | #![warn(clippy::inconsistent_struct_constructor)] |
4 | #![allow(clippy::redundant_field_names)] | |
5 | #![allow(clippy::unnecessary_operation)] | |
6 | #![allow(clippy::no_effect)] | |
7 | #![allow(dead_code)] | |
8 | ||
353b0b11 FG |
9 | extern crate proc_macros; |
10 | ||
f20569fa XL |
11 | #[derive(Default)] |
12 | struct Foo { | |
13 | x: i32, | |
14 | y: i32, | |
15 | z: i32, | |
16 | } | |
17 | ||
18 | mod without_base { | |
19 | use super::Foo; | |
20 | ||
353b0b11 | 21 | #[proc_macros::inline_macros] |
f20569fa XL |
22 | fn test() { |
23 | let x = 1; | |
24 | let y = 1; | |
25 | let z = 1; | |
26 | ||
27 | // Should lint. | |
28 | Foo { y, x, z }; | |
29 | ||
cdc7bbd5 XL |
30 | // Should NOT lint. |
31 | // issue #7069. | |
353b0b11 FG |
32 | inline!({ |
33 | let x = 1; | |
34 | let y = 1; | |
35 | let z = 1; | |
36 | Foo { y, x, z } | |
37 | }); | |
cdc7bbd5 | 38 | |
064997fb | 39 | // Should NOT lint because the order is the same as in the definition. |
f20569fa XL |
40 | Foo { x, y, z }; |
41 | ||
42 | // Should NOT lint because z is not a shorthand init. | |
43 | Foo { y, x, z: z }; | |
44 | } | |
45 | } | |
46 | ||
47 | mod with_base { | |
48 | use super::Foo; | |
49 | ||
50 | fn test() { | |
51 | let x = 1; | |
52 | let z = 1; | |
53 | ||
54 | // Should lint. | |
55 | Foo { | |
56 | z, | |
57 | x, | |
58 | ..Default::default() | |
59 | }; | |
60 | ||
61 | // Should NOT lint because the order is consistent with the definition. | |
62 | Foo { | |
63 | x, | |
64 | z, | |
65 | ..Default::default() | |
66 | }; | |
67 | ||
68 | // Should NOT lint because z is not a shorthand init. | |
69 | Foo { | |
70 | z: z, | |
71 | x, | |
72 | ..Default::default() | |
73 | }; | |
74 | } | |
75 | } | |
76 | ||
77 | fn main() {} |