File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 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;
2323/// **What it does:** Checks for types with a `fn new() -> Self` method and no
2424/// implementation of
2525/// [`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
3030/// `#[derive(Default)]
3131///
3232/// **Why is this bad?** The user might expect to be able to use
@@ -58,42 +58,41 @@ use if_chain::if_chain;
5858/// }
5959/// }
6060/// ```
61- ///
62- /// Or, if
61+ ///
62+ /// Or, if
6363/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)
6464/// can be derived by `#[derive(Default)]`:
65- ///
65+ ///
6666/// ```rust
6767/// struct Foo;
68- ///
68+ ///
6969/// impl Foo {
7070/// fn new() -> Self {
7171/// Foo
7272/// }
7373/// }
7474/// ```
75- ///
75+ ///
7676/// Instead, use:
77- ///
77+ ///
7878/// ```rust
7979/// #[derive(Default)]
8080/// struct Foo;
81- ///
81+ ///
8282/// impl Foo {
8383/// fn new() -> Self {
8484/// Foo
8585/// }
8686/// }
8787/// ```
88- ///
88+ ///
8989/// You can also have `new()` call `Default::default()`.
9090declare_clippy_lint ! {
9191 pub NEW_WITHOUT_DEFAULT ,
9292 style,
9393 "`fn new() -> Self` method without `Default` implementation"
9494}
9595
96-
9796#[ derive( Clone , Default ) ]
9897pub struct NewWithoutDefault {
9998 impling_types : Option < NodeSet > ,
You can’t perform that action at this time.
0 commit comments