RS.CLIPPY.REDUNDANT_CLONE

`clone()` of an owned value that is going to be dropped immediately

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: redundant_clone. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for a redundant clone() (and its relatives) which clones an owned value that is going to be dropped without further use.

Why is this bad?

It is not always possible for the compiler to eliminate useless allocations and deallocations generated by redundant clone()s.

Known problems

False-negatives: analysis performed by this lint is conservative and limited.

Example

{
    let x = Foo::new();
    call(x.clone());
    call(x.clone()); // this can just pass `x`
}

["lorem", "ipsum"].join(" ").to_string();

Path::new("/a/b").join("c").to_path_buf();