rust-lang / rust-lang/rust-clippy

`--cap-lints` ignored by `clippy --fix`

Open
#9,703 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

While the --cap-lints flag is correctly taken into account when using cargo clippy, it is ignored when using cargo clippy --fix.

I'm not sure if the unexpected behaviour comes from the clippy driver or from rustfix, but passing the flags directly using RUSTFLAGS work as intended.

Reproducer

I tried this code:

pub struct Foo;

impl Foo {
    pub fn new() -> Foo { // new_without_default AND use_self
        Self
    }
}

fn main() {
    let a: u8; // unused_variables
}

running: cargo clippy --fix -- --cap-lints=allow

I expected to see this happen:

Nothing, same behaviour as for RUSTFLAGS="--cap-lints=allow" cargo clippy --fix

Instead, this happened:

Suggestions were applied

Version
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: aarch64-apple-darwin
release: 1.64.0
LLVM version: 14.0.6
Additional Labels

No response

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

Reproduce the issue with the provided Rust code using cargo clippy --fix -- --cap-lints=allow, then compare it with the RUSTFLAGS invocation. Trace how --cap-lints is passed through the Clippy driver and rustfix; done means cargo clippy --fix applies no suggestions when the flag is set to allow.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.