Skip to content

Replace Arc::clone(foo) with foo.clone()

Ian Jackson requested to merge Diziet/arti:clone-clone into main

This pattern was required by clippy::clone_on_ref_ptr. But that lint is no longer enabled, since !352 (merged).

Remove it, because:

  • It gets in the way of refactoring. If, in Arc::clone(&t), the Arc is moved inside t's type, t.clone() still works, but obviously Arc::clone() doesn't.

  • It is longer to type, and more awkward and IMO harder to read

I made this change by:

  git-grep -l Arc::clone | xargs perl -i~ -pe 's/Arc::clone\(\&?([^()]+)\)/$1.clone()/g'

and then undoing the two adjacent call sites in arti-bench where type inference required Arc::clone to be explicitly specified.

Merge request reports

Loading