Skip to content

Include CLI lints on cargo fix suggestions when running Clippy #16637

@blyxyas

Description

@blyxyas

Problem

cc rust-lang/rust-clippy#16547

On Clippy lints can be enabled via the command line via cargo clippy -- -Wclippy::lint, and these need to be included in the cargo fix for the emitting lints to actually be fixed.

Steps

If I have some code that raises an allow-by-default lint:

fn foo(s: &str) {
    dbg!(s); // would raise `dbg_macro`
}

and run Clippy with that lint explicitly enabled:

cargo clippy -- -W clippy::dbg_macro

then I get the following output:

warning: the `dbg!` macro is intended as a debugging tool
 --> src/main.rs:3:5
  |
3 |     dbg!(s);
  |     ^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#dbg_macro
  = note: requested on the command line with `-W clippy::dbg-macro`
help: remove the invocation before committing it to a version control system
  |
3 -     dbg!(s);
3 +     s;
  |

warning: `tst` (bin "tst") generated 1 warning (run `cargo clippy --fix --bin "tst" -p tst` to apply 1 suggestion)

but running the suggested command (cargo clippy --fix --bin "tst" -p tst) won't actually apply the suggestion, as Clippy won't even think about linting on dbg!() -- what's needed is cargo clippy --fix --bin "tst" -p tst -- -W clippy::dbg_macro

Possible Solution(s)

No response

Notes

The relevant code is in src/cargo/core/compiler/job_queue/mod.rs:1085~1112.

Version

cargo 1.93.0-nightly (636800288 2025-10-31)
release: 1.93.0-nightly
commit-hash: 6368002885a04cbeae39a82cf5118f941559a40a
commit-date: 2025-10-31
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.15.0-DEV (sys:0.4.83+curl-8.15.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Garuda Linux Soaring (Broadwing) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions