rust-lang/rust-clippy

New lint: clone on arguments taken by reference

Open

#2.074 geöffnet am 19. Sept. 2017

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Rust (1.391 Forks)batch import
A-lintL-unnecessaryT-middlegood first issue

Repository-Metriken

Stars
 (10.406 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 19T 22h) (113 gemergte PRs in 30 T)

Beschreibung

If a function takes an argument by reference, but later calls .clone() on it (or otherwise requires an impl Clone or impl Copy from it), lint that taking it by ownership allows the caller to pass in its memory rather than forcing a clone on the data.

I don't know if this is possible, but can it default to allow on public functions and deny on crate-private functions (due to the API change)?

Contributor Guide