rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
10.89k stars 1.46k forks source link

Emit the `needless_pass_by_ref_mut` lint on `self` arguments as well #12693

Closed GuillaumeGomez closed 3 weeks ago

GuillaumeGomez commented 3 weeks ago

Fixes https://github.com/rust-lang/rust-clippy/issues/12589. Fixes https://github.com/rust-lang/rust-clippy/issues/9591.

The first commit fixes a bug I uncovered while working on this: sometimes, the mutable borrow "event" happens before the alias one, which makes some argument detected as not used mutably even if they are. The fix was simply to fill the map with the aliases afterwards.

The second commit removes the restriction to not run self argument for the needless_pass_by_ref_mut lint.

changelog: emit the needless_pass_by_ref_mut lint on self arguments as well

r? @Manishearth

Manishearth commented 3 weeks ago

@bors r+

bors commented 3 weeks ago

:pushpin: Commit 0999867ec5036b55825c3bb94f0820dde1e61e6a has been approved by Manishearth

It is now in the queue for this repository.

bors commented 3 weeks ago

:hourglass: Testing commit 0999867ec5036b55825c3bb94f0820dde1e61e6a with merge 2795a6018944a5918b7d276267165484f5d62d6a...

bors commented 3 weeks ago

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Manishearth Pushing 2795a6018944a5918b7d276267165484f5d62d6a to master...