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

Improve needless_borrow lint #7977

Merged
merged 1 commit into from
Nov 18, 2021
Merged

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Nov 15, 2021

fixes: #5327
fixes: #1726
fixes: #1212

This is merging needless_borrow into the dereference pass in preparation for explicit_auto_deref. explicit_auto_deref needs to implement most of what needless_borrow implements in order to work.

There is a minor regression here where let x: &str = &x.deref() will trigger needless_borrow without triggering explicit_deref_methods. Removing the redundant borrow will cause explicit_deref_methods to trigger. This will be fixed when explicit_auto_deref is implemented.

changelog: Lint needless_borrow when a borrow is auto-derefed more than once
changelog: Lint needless_borrow in the trailing expression of a block for a match arm

@rust-highfive
Copy link

r? @xFrednet

(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 Nov 15, 2021
* Lint when a borrow is auto dereferenced more than once
* Lint when the expression is used as the expression of a block for a match arm

Moves `needless_borrow` and `ref_binding_to_reference` to `dereference`
lint pass in preperation for `explicit_auto_deref` lint.
@xFrednet
Copy link
Member

xFrednet commented Nov 18, 2021

Looks good to me. The code is nicely constructed, good job 👍

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 18, 2021

📌 Commit 8ded385 has been approved by xFrednet

@bors
Copy link
Collaborator

bors commented Nov 18, 2021

⌛ Testing commit 8ded385 with merge 2776076...

@bors
Copy link
Collaborator

bors commented Nov 18, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 2776076 to master...

@bors bors merged commit 2776076 into rust-lang:master Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
4 participants