Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for new_ret_no_self #5448

Merged
merged 2 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ pub static ref ALL_LINTS: Vec<Lint> = 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",
},
Expand Down