about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmerentius <Emerentius@arcor.de>2020-04-10 19:08:31 +0200
committerGitHub <noreply@github.com>2020-04-10 19:08:31 +0200
commited72dc411918d5d39795954447a6d99aeb85a12e (patch)
tree690fcaa30466b992938fa3c6c9956e74f10b5238
parent34763a5f3632b1d9081ba0245a729174996f0b38 (diff)
downloadrust-ed72dc411918d5d39795954447a6d99aeb85a12e.tar.gz
rust-ed72dc411918d5d39795954447a6d99aeb85a12e.zip
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
-rw-r--r--clippy_lints/src/methods/mod.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index be9b369112a..28384923f02 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<Foo, FooError> {
+    ///         # 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! {