Skip to content

Commit a1de9f6

Browse files
committed
fix(job_queue): Handle Clippy CLI arguments in fix message
fixes #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.
1 parent 8cc0cb1 commit a1de9f6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • src/cargo/core/compiler/job_queue

src/cargo/core/compiler/job_queue/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,9 +1105,18 @@ impl<'gctx> DrainState<'gctx> {
11051105
if fixable > 1 {
11061106
suggestions.push_str("s")
11071107
}
1108+
11081109
let _ = write!(
11091110
message,
1110-
" (run `{command} --{args}` to apply {suggestions})"
1111+
" (run `{command} --{args}{}` to apply {suggestions})",
1112+
if let Ok(cli_lints) = gctx.get_env("CLIPPY_ARGS") {
1113+
// Clippy can take lints through the CLI, each lint flag is separated by "__CLIPPY_HACKER__".
1114+
let cli_lints = cli_lints.replace("__CLIPPY_HACKERY__", " ");
1115+
let cli_lints = cli_lints.trim_ascii_end(); // Remove that last space left by __CLIPPY_HACKERY__
1116+
format!(" -- {cli_lints}")
1117+
} else {
1118+
"".to_owned()
1119+
}
11111120
);
11121121
}
11131122
}

0 commit comments

Comments
 (0)