mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
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
This commit is contained in:
parent
34763a5f36
commit
ed72dc4119
1 changed files with 24 additions and 2 deletions
|
@ -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! {
|
||||
|
|
Loading…
Reference in a new issue