Skip to content

Unnecessary &mut should be warned #53759

Closed
@upsuper

Description

@upsuper

Given the following code:

fn foo(_: &mut usize) {}
let mut a = 0;
let mut b = &mut a;
foo(&mut b);

there is no warning saying that the &mut in the last line is unnecessary.

Some novice don't always have clear idea about where should have &mut so they may add lots of unnecessary ones which leads to more unnecessary mut variables.

It might be helpful if we can warn on this case so that they know this isn't necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions