Skip to content

New lint for redundant clone in format! #5142

Open
@david-mcgillicuddy-moixa

Description

If somebody writes format!("foo: {}", foo.clone()) is that always redundant (since format takes a reference to its arguments and then drops them instantly)? Maybe make sure it doesn't trigger on e.g. foo.clone().bar() since that isn't necessarily redundant.

I feel like this is a specific case of cloning an immutable non-owned type that you don't then retain but that'd require proper compiler support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-hardCall for participation: This a hard problem and requires more experience or effort to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions