File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -730,7 +730,7 @@ declare_clippy_lint! {
730730}
731731
732732declare_clippy_lint ! {
733- /// **What it does:** Checks for `new` not returning `Self`.
733+ /// **What it does:** Checks for `new` not returning a type that contains `Self`.
734734 ///
735735 /// **Why is this bad?** As a convention, `new` methods are used to make a new
736736 /// instance of a type.
@@ -747,9 +747,31 @@ declare_clippy_lint! {
747747 /// }
748748 /// }
749749 /// ```
750+ ///
751+ /// ```rust
752+ /// # struct Foo;
753+ /// # struct FooError;
754+ /// impl Foo {
755+ /// // Good. Return type contains `Self`
756+ /// fn new() -> Result<Foo, FooError> {
757+ /// # Ok(Foo)
758+ /// }
759+ /// }
760+ /// ```
761+ ///
762+ /// ```rust
763+ /// # struct Foo;
764+ /// struct Bar(Foo);
765+ /// impl Foo {
766+ /// // Bad. The type name must contain `Self`.
767+ /// fn new() -> Bar {
768+ /// # Bar(Foo)
769+ /// }
770+ /// }
771+ /// ```
750772 pub NEW_RET_NO_SELF ,
751773 style,
752- "not returning `Self` in a `new` method"
774+ "not returning type containing `Self` in a `new` method"
753775}
754776
755777declare_clippy_lint ! {
You can’t perform that action at this time.
0 commit comments