Closed
Description
Summary
I have some weird looking code which has a reborrow pattern for reasons I don’t understand but which seem to be wrong anyways: It uses &*arc
to turn an Arc<T>
into a &T
, which is weird but the rustc compiler never seemed to mind.
Clippy now suggests to remove the &*
entirely, which seems wrong.
Lint Name
explicit_auto_deref
Reproducer
I tried this code:
struct Foo;
let arc = std::sync::Arc::new(Foo);
fn f(_: &Foo) {}
f(&*arc);
I saw this happen:
warning: deref which would be done by auto-deref
--> crates/symbolicator/src/main.rs:53:8
|
53 | f(&*arc);
| ^^^^ help: try this: `arc`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
I expected to see this happen:
It should suggest using just &arc
, as I still need to borrow it to be able to deref.
Version
rustc 1.65.0-nightly (f03ce3096 2022-08-08)
binary: rustc
commit-hash: f03ce30962cf1b2a5158667eabae8bf6e8d1cb03
commit-date: 2022-08-08
host: x86_64-apple-darwin
release: 1.65.0-nightly
LLVM version: 14.0.6
Additional Labels
No response