Skip to content

fix(job_queue): Handle Clippy CLI arguments in fix message#16652

Merged
epage merged 2 commits intorust-lang:masterfrom
blyxyas:handle-clippy-args-fix
Feb 23, 2026
Merged

fix(job_queue): Handle Clippy CLI arguments in fix message#16652
epage merged 2 commits intorust-lang:masterfrom
blyxyas:handle-clippy-args-fix

Conversation

@blyxyas
Copy link
Member

@blyxyas blyxyas commented Feb 18, 2026

fixes #16637

What does this PR try to resolve?

Clippy lints can be enabled via the command line via cargo clippy -- -Wclippy::lint, and these need to be included in the cargo fix command (because if a lint is not emitted, it's not fixed, and some lints are allow-by-default)


When cargo clippy is executed, Clippy sets the env. var CLIPPY_ARGS to the arguments that were passed to Clippy, separated by the string __CLIPPY_HACKERY__. To avoid breaking behaviour in between runs (like in fix), we should maintain those arguments.

This PR takes that CLIPPY_ARGS env var (if it exists), replaces the __CLIPPY_HACKERY__ separator and appends it to the suggested cargo clippy --fix command when emitting fixable warnings.

How to test and review this PR?

Via copying a crate (in my case, tokio-1.38.1) and executing the following commands:

rustup run nightly ~/git/cargo/target/debug/cargo clippy -- -Wclippy::pedantic -Aclippy::allow_attributes -Wclippy::dbg_macro -Wclippy::eq_op

In order to get some warnings. If any fixable warning is emitted, the output message should end with:

warning: `tokio` (lib) generated 42 warnings (run `cargo clippy --fix --lib -p tokio -- -Wclippy::pedantic -Aclippy::allow_attributes -Wclippy::dbg_macro -Wclippy::eq_op` to apply 16 suggestions)

Now, testing with the suggested command (in this case, also with the version pinned @1.38.1):

rustup run nightly ~/git/cargo/target/debug/cargo clippy --fix --lib -p tokio@1.38.1 -- -Wclippy::pedantic -Aclippy::allow_attributes -Wclippy::dbg_macro -Wclippy::eq_op

All warnings (including those allow-by-default pedantic lints!) should be fixed now.

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2026

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@blyxyas blyxyas force-pushed the handle-clippy-args-fix branch from 3e2fc30 to a1de9f6 Compare February 18, 2026 18:22
@epage
Copy link
Contributor

epage commented Feb 18, 2026

Thanks!

@blyxyas blyxyas force-pushed the handle-clippy-args-fix branch 3 times, most recently from c2e50aa to 7519507 Compare February 18, 2026 23:06
@blyxyas blyxyas force-pushed the handle-clippy-args-fix branch from a9b2b5c to 1a4e54f Compare February 22, 2026 21:10
@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@blyxyas
Copy link
Member Author

blyxyas commented Feb 22, 2026

Sorry for so much force-pushing, but the commit reordering seems to have messed up the git history, so I had to rebase.

fixes rust-lang#16637

Clippy lints can be enabled via the command line via `cargo clippy -- -Wclippy::lint`, and these need to be included in the `cargo fix` command for the emitting lints to actually be fixed.
Thus, add them to the "run `..` to apply .. suggestions" message.

Only suggest when running from clippy-driver
@blyxyas blyxyas force-pushed the handle-clippy-args-fix branch from 1a4e54f to 4e786ef Compare February 23, 2026 19:14
Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage epage enabled auto-merge February 23, 2026 19:22
@epage epage added this pull request to the merge queue Feb 23, 2026
Merged via the queue into rust-lang:master with commit e349c66 Feb 23, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 23, 2026
arlosi added a commit to arlosi/rust that referenced this pull request Feb 25, 2026
8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0
2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000
- fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674)
- doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671)
- Fix typo in cargo-yank docs (rust-lang/cargo#16656)
- fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652)
- Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661)
- Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659)
- fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621)
- test(build-std): Update error message (rust-lang/cargo#16658)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Feb 26, 2026
Update cargo submodule

8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000
- fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674)
- doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671)
- Fix typo in cargo-yank docs (rust-lang/cargo#16656)
- fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652)
- Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661)
- Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659)
- fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621)
- test(build-std): Update error message (rust-lang/cargo#16658)
@rustbot rustbot added this to the 1.95.0 milestone Feb 26, 2026
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Feb 26, 2026
Update cargo submodule

8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000
- fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674)
- doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671)
- Fix typo in cargo-yank docs (rust-lang/cargo#16656)
- fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652)
- Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661)
- Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659)
- fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621)
- test(build-std): Update error message (rust-lang/cargo#16658)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include CLI lints on cargo fix suggestions when running Clippy

3 participants