-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
I have made the following small example to illustrate a warning of redudant-clone
I've been getting:
#[derive(Clone)]
struct NoCopy;
fn foo<F: Fn()>(_: &NoCopy, _: F) {}
fn main() {
let data = NoCopy;
foo(&data.clone(), move || {
let _ = data;
});
}
Which gives me:
warning: redundant clone
--> src/main.rs:8:14
|
8 | foo(&data.clone(), move || {
| ^^^^^^^^ help: remove this
|
= note: `#[warn(clippy::redundant_clone)]` on by default
note: cloned value is neither consumed nor mutated
--> src/main.rs:8:10
|
8 | foo(&data.clone(), move || {
| ^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
warning: 1 warning emitted
However, removing the clone would result in a error as the data will be moved to the closure while still borrowed as an argument to foo
. Am I right to think this is a false positive, or am I messing something to fix this?
$ cargo clippy -V
clippy 0.0.212 (769d12e 2020-05-12)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have