File tree 1 file changed +12
-13
lines changed
1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,10 @@ use if_chain::if_chain;
23
23
/// **What it does:** Checks for types with a `fn new() -> Self` method and no
24
24
/// implementation of
25
25
/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html).
26
- ///
27
- /// It detects both the case when a manual
28
- /// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)
29
- /// implementation is required and also when it can be created with
26
+ ///
27
+ /// It detects both the case when a manual
28
+ /// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)
29
+ /// implementation is required and also when it can be created with
30
30
/// `#[derive(Default)]
31
31
///
32
32
/// **Why is this bad?** The user might expect to be able to use
@@ -58,42 +58,41 @@ use if_chain::if_chain;
58
58
/// }
59
59
/// }
60
60
/// ```
61
- ///
62
- /// Or, if
61
+ ///
62
+ /// Or, if
63
63
/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)
64
64
/// can be derived by `#[derive(Default)]`:
65
- ///
65
+ ///
66
66
/// ```rust
67
67
/// struct Foo;
68
- ///
68
+ ///
69
69
/// impl Foo {
70
70
/// fn new() -> Self {
71
71
/// Foo
72
72
/// }
73
73
/// }
74
74
/// ```
75
- ///
75
+ ///
76
76
/// Instead, use:
77
- ///
77
+ ///
78
78
/// ```rust
79
79
/// #[derive(Default)]
80
80
/// struct Foo;
81
- ///
81
+ ///
82
82
/// impl Foo {
83
83
/// fn new() -> Self {
84
84
/// Foo
85
85
/// }
86
86
/// }
87
87
/// ```
88
- ///
88
+ ///
89
89
/// You can also have `new()` call `Default::default()`.
90
90
declare_clippy_lint ! {
91
91
pub NEW_WITHOUT_DEFAULT ,
92
92
style,
93
93
"`fn new() -> Self` method without `Default` implementation"
94
94
}
95
95
96
-
97
96
#[ derive( Clone , Default ) ]
98
97
pub struct NewWithoutDefault {
99
98
impling_types : Option < NodeSet > ,
You can’t perform that action at this time.
0 commit comments