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

New lint against Self as an arbitrary self type #5869

Merged
merged 6 commits into from
Aug 10, 2020

Conversation

wiomoc
Copy link
Contributor

@wiomoc wiomoc commented Aug 4, 2020

Fixes #5861

changelog: * [needless_arbitrary_self_type] #5869

@rust-highfive
Copy link

r? @flip1995

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 4, 2020
@wiomoc wiomoc force-pushed the feature/implicit-self branch 2 times, most recently from 3b74a9a to b34bf8b Compare August 4, 2020 18:54
@flip1995
Copy link
Member

flip1995 commented Aug 4, 2020

r? @ebroto

Copy link
Member

@ebroto ebroto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I left some thoughts.

cc @flip1995

CHANGELOG.md Outdated Show resolved Hide resolved
clippy_lints/src/needless_fn_self_type.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_fn_self_type.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_fn_self_type.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_fn_self_type.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_fn_self_type.rs Outdated Show resolved Hide resolved
tests/ui/needless_fn_self_type.rs Outdated Show resolved Hide resolved
tests/ui/needless_fn_self_type.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_fn_self_type.rs Outdated Show resolved Hide resolved
Copy link
Member

@ebroto ebroto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Just two minor nits.

Also, could you update the PR description to specify the changelog line? Something like:

changelog: * [`needless_arbitrary_self_type`] [#5869](https://github.com/rust-lang/rust-clippy/pull/5869)

This will help the person writing the CHANGELOG.

And now that we're at it, changing rel #5861 to Fixes #5861 will automatically close the issue after merging, which I think it's relevant in this case.

clippy_lints/src/needless_arbitrary_self_type.rs Outdated Show resolved Hide resolved
tests/ui/needless_arbitrary_self_type.fixed Show resolved Hide resolved
@ebroto
Copy link
Member

ebroto commented Aug 5, 2020

LGTM, thanks!

@flip1995 I think this is ready to merge if you agree

Comment on lines 42 to 43
LL | pub fn mut_ref_mut_bad(mut self: &mut Self) {
| ^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self`
Copy link
Member

@flip1995 flip1995 Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this semantically the same?

I think the original code makes the reference mutable. The suggested code is just a mutable reference.

Is mut &mut self valid code? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To answer my question: Yes this is the case: Playground

Admittedly this seems like an constructed example for mut self: &mut Self, but code similar to this does actually exist. (IIRC tokio has similar code in its codebase)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, the suggestion is only equivalent for the mut self: Self case, and mut &mut self triggers a parser error.

@flip1995
Copy link
Member

flip1995 commented Aug 7, 2020

Everything else LGTM 👍

@flip1995 flip1995 added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 7, 2020
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Waiting for rustup.

@flip1995 flip1995 added S-waiting-on-bors Status: The marked PR was approved and is only waiting bors and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Aug 7, 2020
@flip1995
Copy link
Member

@bors r=ebroto,flip1995 rollup

@bors
Copy link
Collaborator

bors commented Aug 10, 2020

📌 Commit bfe610c has been approved by ebroto,flip1995

bors added a commit that referenced this pull request Aug 10, 2020
Rollup of 5 pull requests

Successful merges:

 - #5825 (Add the new lint `same_item_push`)
 - #5869 (New lint against `Self` as an arbitrary self type)
 - #5870 (enable #[allow(clippy::unsafe_derive_deserialize)])
 - #5871 (Lint .min(x).max(y) with x < y)
 - #5874 (Make the docs clearer for new contributors)

Failed merges:

r? @ghost

changelog: rollup
@bors bors merged commit 8ee57ee into rust-lang:master Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: The marked PR was approved and is only waiting bors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint against Self as an arbitrary self type
5 participants