Typically, when acquiring a read lock the caller should try to drop the read guard as soon as possible. So on types that are cloneable it's straightforward to call .clone().
When fixing a bunch of lint issues and seeing the calling clone_on_copy lint, the easiest fix is to remove .clone(), which will compile. However, this can result in a deadlock since the previous guard will no longer be dropped without an explicit dereference.
Is it possible for the lint to skip types that are Drop + Copy or Drop + Clone?
Summary
Consider a RwLock on a Clone and/or Copy type.
Typically, when acquiring a read lock the caller should try to drop the read guard as soon as possible. So on types that are cloneable it's straightforward to call
.clone()
.When fixing a bunch of lint issues and seeing the calling clone_on_copy lint, the easiest fix is to remove
.clone()
, which will compile. However, this can result in a deadlock since the previous guard will no longer be dropped without an explicit dereference.Is it possible for the lint to skip types that are
Drop + Copy
orDrop + Clone
?Reproducer
No response
Version
No response
Additional Labels
@rustbot
l-suggestion-causes-error