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

Add lint for explicit deref and deref_mut method calls #5226

Merged
merged 6 commits into from
Apr 15, 2020

Conversation

ThibsG
Copy link
Contributor

@ThibsG ThibsG commented Feb 25, 2020

This PR adds the lint explicit_deref_method that suggests replacing deref() and deref_mut() with &*a and &mut *a.

It doesn't lint inside macros.

This PR is the continuation of #3258.

changelog: Add lint explicit_deref_method.

Fixes: #1566

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch 3 times, most recently from 8e0ba68 to edb0798 Compare February 26, 2020 14:49
@JohnTitor JohnTitor added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 27, 2020
@ThibsG ThibsG force-pushed the DerefExplicit1566 branch 3 times, most recently from c4ac113 to ed02e83 Compare March 1, 2020 16:40
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
@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 Mar 3, 2020
@bors
Copy link
Contributor

bors commented Mar 5, 2020

☔ The latest upstream changes (presumably #5230) made this pull request unmergeable. Please resolve the merge conflicts.

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from ed02e83 to d524ef1 Compare March 14, 2020 22:15
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.

Can you add a few more tests for some of the expression types listed in ExprPrecedence

clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from 853c015 to 1468303 Compare March 22, 2020 22:04
@bors
Copy link
Contributor

bors commented Mar 23, 2020

☔ The latest upstream changes (presumably #5319) made this pull request unmergeable. Please resolve the merge conflicts.

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from 1468303 to f21f5fb Compare March 27, 2020 21:28
@bors
Copy link
Contributor

bors commented Mar 30, 2020

☔ The latest upstream changes (presumably #5380) made this pull request unmergeable. Please resolve the merge conflicts.

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from f21f5fb to d558792 Compare March 30, 2020 15:38
@ThibsG ThibsG requested a review from flip1995 March 30, 2020 15:57
@bors
Copy link
Contributor

bors commented Mar 30, 2020

☔ The latest upstream changes (presumably #5294) made this pull request unmergeable. Please resolve the merge conflicts.

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from d558792 to b79ddac Compare March 31, 2020 07:22
@bors
Copy link
Contributor

bors commented Mar 31, 2020

☔ The latest upstream changes (presumably #5398) made this pull request unmergeable. Please resolve the merge conflicts.

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch 2 times, most recently from 3b9429c to 481c662 Compare April 2, 2020 07:32
@bors
Copy link
Contributor

bors commented Apr 8, 2020

☔ The latest upstream changes (presumably #5438) made this pull request unmergeable. Please resolve the merge conflicts.

@flip1995 flip1995 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Apr 8, 2020
@ThibsG ThibsG force-pushed the DerefExplicit1566 branch 2 times, most recently from 72f3c22 to fbfed04 Compare April 9, 2020 07:18
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! This looks really good. Just some cleanup left to do.

clippy_lints/src/dereference.rs Outdated Show resolved Hide resolved
@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 Apr 15, 2020
@flip1995
Copy link
Member

Sorry for taking so long for the review. I don't have an excuse, just wasn't really motivated to review PRs recently.

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from fbfed04 to 14a8842 Compare April 15, 2020 15:13
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!

@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 Apr 15, 2020
@ThibsG
Copy link
Contributor Author

ThibsG commented Apr 15, 2020

It's totally fine not to instant review PRs 😉
plus you updated Clippy so we don't have to constantly update lints count/array size to keep the PR mergeable 👍

@ThibsG ThibsG force-pushed the DerefExplicit1566 branch from 14a8842 to 3c2bbcf Compare April 15, 2020 15:18
@flip1995
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 15, 2020

📌 Commit 3c2bbcf has been approved by flip1995

@bors
Copy link
Contributor

bors commented Apr 15, 2020

🌲 The tree is currently closed for pull requests below priority 1, this pull request will be tested once the tree is reopened

bors added a commit that referenced this pull request Apr 15, 2020
Rollup of 5 pull requests

Successful merges:

 - #5226 (Add lint for explicit deref and deref_mut method calls)
 - #5248 (Add lint on large non scalar const)
 - #5430 (Disallow bit-shifting in integer_arithmetic)
 - #5466 (large_enum_variant: Report sizes of variants)
 - #5468 (Zero single char names)

Failed merges:

r? @ghost

changelog: rollup
@bors bors merged commit 3481bf4 into rust-lang:master Apr 15, 2020
@ThibsG ThibsG deleted the DerefExplicit1566 branch April 15, 2020 20:20
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 direct calls to deref or deref_mut
5 participants