Skip to content

False positive for clippy::needless_borrows_for_generic_args #16538

@mgeier

Description

@mgeier

Summary

Following Clippy's suggestion and removing &mut from &mut data would lead to data (which is a built-in arrray) being copied instead of being mutated.

See also https://users.rust-lang.org/t/false-positive-for-clippy-needless-borrows-for-generic-args/138147.

Lint Name

needless_borrows_for_generic_args

Reproducer

Go to https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=5f88142da1ad985c8da2d12c22a7bac9 and run Clippy.

I saw this happen:

warning: the borrowed expression implements the required traits
  --> src/main.rs:10:13
   |
10 |     process(&mut data);
   |             ^^^^^^^^^ help: change this to: `data`
   |

I expected to see this happen:

no warning

Version


Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions