File tree 1 file changed +24
-2
lines changed
1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -730,7 +730,7 @@ declare_clippy_lint! {
730
730
}
731
731
732
732
declare_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`.
734
734
///
735
735
/// **Why is this bad?** As a convention, `new` methods are used to make a new
736
736
/// instance of a type.
@@ -747,9 +747,31 @@ declare_clippy_lint! {
747
747
/// }
748
748
/// }
749
749
/// ```
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
+ /// ```
750
772
pub NEW_RET_NO_SELF ,
751
773
style,
752
- "not returning `Self` in a `new` method"
774
+ "not returning type containing `Self` in a `new` method"
753
775
}
754
776
755
777
declare_clippy_lint ! {
You can’t perform that action at this time.
0 commit comments