From ed72dc411918d5d39795954447a6d99aeb85a12e Mon Sep 17 00:00:00 2001 From: Emerentius Date: Fri, 10 Apr 2020 19:08:31 +0200 Subject: [PATCH 1/2] Update documentation for new_ret_no_self The lint was changed to be more lenient than the documentation implies in PR #3338. Related issue #3313 --- clippy_lints/src/methods/mod.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index be9b369112af..28384923f02e 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -730,7 +730,7 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `new` not returning `Self`. + /// **What it does:** Checks for `new` not returning a type that contains `Self`. /// /// **Why is this bad?** As a convention, `new` methods are used to make a new /// instance of a type. @@ -747,9 +747,31 @@ declare_clippy_lint! { /// } /// } /// ``` + /// + /// ```rust + /// # struct Foo; + /// # struct FooError; + /// impl Foo { + /// // Good. Return type contains `Self` + /// fn new() -> Result { + /// # Ok(Foo) + /// } + /// } + /// ``` + /// + /// ```rust + /// # struct Foo; + /// struct Bar(Foo); + /// impl Foo { + /// // Bad. The type name must contain `Self`. + /// fn new() -> Bar { + /// # Bar(Foo) + /// } + /// } + /// ``` pub NEW_RET_NO_SELF, style, - "not returning `Self` in a `new` method" + "not returning type containing `Self` in a `new` method" } declare_clippy_lint! { From e98c7a45d44cfed922699fbc1d61f3802d08b867 Mon Sep 17 00:00:00 2001 From: Emerentius Date: Sun, 12 Apr 2020 23:47:58 +0200 Subject: [PATCH 2/2] update lints --- src/lintlist/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs index edebaff9f142..935ea180ebe2 100644 --- a/src/lintlist/mod.rs +++ b/src/lintlist/mod.rs @@ -1448,7 +1448,7 @@ pub static ref ALL_LINTS: Vec = vec![ Lint { name: "new_ret_no_self", group: "style", - desc: "not returning `Self` in a `new` method", + desc: "not returning type containing `Self` in a `new` method", deprecation: None, module: "methods", },