@@ -10,8 +10,9 @@ use if_chain::if_chain;
10
10
use crate :: utils:: { snippet, span_lint_and_sugg} ;
11
11
12
12
declare_clippy_lint ! {
13
- /// **What it does:** Checks for struct constructors where the order of the field init
14
- /// shorthand in the constructor is inconsistent with the order in the struct definition.
13
+ /// **What it does:** Checks for struct constructors where all fields are shorthand and
14
+ /// the order of the field init shorthand in the constructor is inconsistent
15
+ /// with the order in the struct definition.
15
16
///
16
17
/// **Why is this bad?** Since the order of fields in a constructor doesn't affect the
17
18
/// resulted instance as the below example indicates,
@@ -25,11 +26,11 @@ declare_clippy_lint! {
25
26
/// let x = 1;
26
27
/// let y = 2;
27
28
///
28
- /// // This assertion never fails.
29
+ /// // This assertion never fails:
29
30
/// assert_eq!(Foo { x, y }, Foo { y, x });
30
31
/// ```
31
32
///
32
- /// inconsistent order means nothing and just decreases readability and consistency.
33
+ /// inconsistent order can be confusing and decreases readability and consistency.
33
34
///
34
35
/// **Known problems:** None.
35
36
///
@@ -42,6 +43,7 @@ declare_clippy_lint! {
42
43
/// }
43
44
/// let x = 1;
44
45
/// let y = 2;
46
+ ///
45
47
/// Foo { y, x };
46
48
/// ```
47
49
///
@@ -107,7 +109,7 @@ impl LateLintPass<'_> for InconsistentStructConstructor {
107
109
cx,
108
110
INCONSISTENT_STRUCT_CONSTRUCTOR ,
109
111
expr. span,
110
- "inconsistent struct constructor " ,
112
+ "struct constructor field order is inconsistent with struct definition field order " ,
111
113
"try" ,
112
114
sugg,
113
115
Applicability :: MachineApplicable ,
0 commit comments