Skip to content

Enable clippy::redundant_clone lint #169

Description

@tupe12334

What

Enable the clippy::redundant_clone lint (set to deny) in core/Cargo.toml, continuing the crate's incremental lint-ratcheting policy (each PR promotes one more lint to deny).

What it catches

clippy::redundant_clone flags .clone() (and .to_owned() / .to_vec() style) calls whose result is the last use of the cloned value — i.e. the original is never used again, so the clone allocates a fresh copy for nothing. The owned value could have been moved instead.

Example:

let name = config.name.clone(); // config.name never used after this
return Step::new(name);          // -> just move config.name

Why it improves code quality

  • Removes needless heap allocations / deep copies — a real, if small, runtime + memory win, especially on hot paths that clone String/Vec/owned structs.
  • States intent honestly — a .clone() signals "I need an independent copy"; when the original is dead, the clone is noise that misleads the reader.
  • Completes the crate's existing clone-hygiene familyimplicit_clone and cloned_instead_of_copied are already denied; redundant_clone closes the remaining gap (clones that should have been moves).

Scope

There are zero current violations, so this is a clean lock-in that prevents regressions — consistent with the other deny-on-clean lints already in core/Cargo.toml. cargo clippy --all-targets, cargo build, and cargo test all pass with the lint enabled.


This issue was opened by the "Clippy lint improvements → issue + PR (Rust repos) → Slack" routine of moadim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions