rust-lang / rust-lang/rust-clippy

Provide a way to enable auto-fixing of lints with MaybeIncorrect applicability

Open
#11,158 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I have an enormous codebase, where I would like to apply the unnecessary-wraps lint, which has MaybeIncorrect applicability. The problem is that there are so many errors reported with this lint that it will take me several hours of work to just manually go over each one and apply them manually.

What is most disappointing is that clippy already knows how to fix that code, because it shows me the correct fixes in its output, and my human task becomes to mechanically copy-paste the suggestions from clippy. I'd prefer much more to have an option to include MaybeIncorrect lint into cargo clippy --fix for example something like:

cargo clippy --fix --allow-maybe-incorrect

I agree, that MaybeIncorrect may break code, but what if 99% of the fixes they do are, in fact, correct? It will be much more productive if I let cargo clippy apply MaybeIncorrect lints, then check for compile errors, fix them manually, and review the git diff manually as the last step to cover all changes that were made as the double-check. This switches the work for the human from manually applying each-and-every lint to basically reviewing the work of clippy (as if clippy was my own clever-but-sometimes-dumb junior developer).

In simple words, it's faster to fix all the wrong changes that MaybeIncorrect lint did than manually fix everything that it reports.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how cargo clippy --fix handles lint applicability and how MaybeIncorrect suggestions are currently reported. Define the opt-in behavior requested by --allow-maybe-incorrect, including how it interacts with existing fix options, then verify the change with Clippy's fix-related tests and compilation checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.