- 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 thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.
Description
Hi folks,
I ran this code under Clippy:
fn foo() { let mut vec = Vec::new(); let key = (0, 0); vec.push(key.clone()); let _ = key.clone(); }
Clippy produced this error:
error: using `clone` on a `Copy` type --> src/lib.rs:7:13 | 7 | let _ = key.clone(); | ^^^^^^^^^^^ help: try removing the `clone` call: `key` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
I expected to see same error in vec.push(key.clone())
but Clippy is silent about it. After removing .clone()
in line 5 it does compile fine, so I assume it is redundant.
Can someone explain to me what is the difference here?
Output of cargo clippy -V
clippy 0.0.212 (4ee1206 2020-02-01)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.