Skip to content

Add a lint for unnecessary by-ref pattern #7880

@huonw

Description

@huonw

There are several (many?) instances in rust/src where one has, for example,

match a_function_returning_option() {
    Some(ref a) => { move_a(a.clone()) }
    None => { do_whatever() }
}

The ref a is entirely unnecessary; a could be moved out in the pattern, saving a clone.

(This would have to be careful to not lint when e.g. a is used as a reference in the body, and probably other situations.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions