Skip to content

cargo clippy --fix don't remove redundant mut #14617

Open
@MCJOHN974

Description

@MCJOHN974

Summary

cargo clippy --fix can autofix more problems

Reproducer

I tried this code:

fn foo(_x: &i32) {}

fn main() {
    let mut x = 5i32;
    foo(&mut x);         // this mut is redundant
}

I expected to see this happen:

cargo clippy --fix removes this redundant mut.

Instead, this happened:

cargo clippy --fix warns about this redundant mut

I don't see any use cases were this mut can make side effects and it is not safe to remove it automatically. Is it just not implemented yet or there are some cases where auto removing this mut can bring side effects?

Version

rustc 1.85.0-nightly (21fe748be 2024-12-11)
binary: rustc
commit-hash: 21fe748be15271ea5804e0507cd699b675efe038
commit-date: 2024-12-11
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.5

Additional Labels

No response

Summary Notes

Generated by triagebot, see help for how to add more

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions