rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

Fix some false-positive cases of `explicit_auto_deref`

Open tesuji opened this issue 1 year ago • 1 comments

changelog: [explicit_auto_deref] Fix some false-positive cases

Partially fix OP of #9841 Fix #12969

tesuji avatar Jun 21 '24 23:06 tesuji

r? @blyxyas

rustbot has assigned @blyxyas. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Jun 21 '24 23:06 rustbot

And could you also squash your comments down into a single one?

xFrednet avatar Jul 02 '24 16:07 xFrednet

The fix for #9841 does not seem to be general enough.

If you add an extra ref and deref (ie the following code), a false positive still triggers, and an invalid suggestion is still issued.

pub fn takes_array_ref<T, const N: usize>(array: &&&[T; N]) {
    takes_slice(**array) // clippy still suggests to remove both dereferences
}

pub fn takes_slice<T>(_slice: &[T]) {
    todo!()
}

wr7 avatar Jul 02 '24 17:07 wr7

That makes sense, thank you :D

Then we're just waiting for a squash of the commits =^.^=

xFrednet avatar Jul 02 '24 17:07 xFrednet

Then we're just waiting for a squash of the commits =^.^=

Done!

LGTM, could you explain why #9841 is only partially fixed?

That's because of https://github.com/rust-lang/rust-clippy/issues/9841#issuecomment-1925688007, which is important too.

tesuji avatar Jul 03 '24 14:07 tesuji

Thank you!


Roses are red, The CI is green, Let's merge this quick, No conflicts seen

xFrednet avatar Jul 03 '24 18:07 xFrednet

:pushpin: Commit c4c41d135227a0a34ddc941ccb6be9296e4cceff has been approved by xFrednet

It is now in the queue for this repository.

bors avatar Jul 03 '24 18:07 bors

:hourglass: Testing commit c4c41d135227a0a34ddc941ccb6be9296e4cceff with merge 0f4035fde309871fd62ba6e3f641de00fe65738d...

bors avatar Jul 03 '24 18:07 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: xFrednet Pushing 0f4035fde309871fd62ba6e3f641de00fe65738d to master...

bors avatar Jul 03 '24 18:07 bors