Skip to content

Lint against calling .clone() on an otherwise copyable value. #27266

Closed
@eddyb

Description

@eddyb

Certain types could start out as having contents that move and then switch to only copyable field, or could just be missing #[deriving(Copy)] initially.

If Copy is implemented after that type has been used in a large codebase (there's a few cases in rustc itself), there will likely be many .clone() calls around, and finding which ones belong to the type could be tedious.

A lint would ease this work, by suggesting the replacement of an unnecessary x.clone() call with a dereference (if x is a reference to the type being cloned - could use the autoderef count here) or nothing at all (since using a Copy lvalue as an rvalue will just copy it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions