pub static SUSPICIOUS_DOUBLE_REF_OP: &Lint
Expand description

The suspicious_double_ref_op lint checks for usage of .clone()/.borrow()/.deref() on an &&T when T: !Deref/Borrow/Clone, which means the call will return the inner &T, instead of performing the operation on the underlying T and can be confusing.

Example

struct Foo;
let foo = &&Foo;
let clone: &Foo = foo.clone();

{{produces}}

Explanation

Since Foo doesn’t implement Clone, running .clone() only dereferences the double reference, instead of cloning the inner type which should be what was intended.