-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-bugCategory: bugCategory: bugCommand-clippyS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.
Description
Problem
After running cargo clippy -- -W clippy::doc_markdown
, Cargo suggests
warning: `cargo` (lib) generated 83 warnings (run `cargo clippy --fix --lib -p cargo` to apply 79 suggestions)
To make the suggestion work, I believe trailing cli arguments should be added. That is
cargo clippy --fix --lib -p cargo -- -W clippy::doc_markdown`.
Steps
- Switch the toolchain to the version mentioned below.
- Checkout
rust-lang/cargo
to 0b2c38f. - Run
cargo clippy -- -W clippy::doc_markdown
. - Copy the suggested commmand and run it.
- Nothing happen. Nothing fixed.
Possible Solution(s)
Suggest trailing varargs here? Not sure if it could be a bit overkill though.
cargo/src/cargo/core/compiler/job_queue.rs
Lines 1286 to 1320 in 0b2c38f
if let FixableWarnings::Positive(fixable) = count.fixable { | |
// `cargo fix` doesnt have an option for custom builds | |
if !unit.target.is_custom_build() { | |
// To make sure the correct command is shown for `clippy` we | |
// check if `RUSTC_WORKSPACE_WRAPPER` is set and pointing towards | |
// `clippy-driver`. | |
let clippy = std::ffi::OsStr::new("clippy-driver"); | |
let command = match rustc_workspace_wrapper.as_ref().and_then(|x| x.file_stem()) | |
{ | |
Some(wrapper) if wrapper == clippy => "cargo clippy --fix", | |
_ => "cargo fix", | |
}; | |
let mut args = { | |
let named = unit.target.description_named(); | |
// if its a lib we need to add the package to fix | |
if unit.target.is_lib() { | |
format!("{} -p {}", named, unit.pkg.name()) | |
} else { | |
named | |
} | |
}; | |
if unit.mode.is_rustc_test() | |
&& !(unit.target.is_test() || unit.target.is_bench()) | |
{ | |
args.push_str(" --tests"); | |
} | |
let mut suggestions = format!("{} suggestion", fixable); | |
if fixable > 1 { | |
suggestions.push_str("s") | |
} | |
drop(write!( | |
message, | |
" (run `{command} --{args}` to apply {suggestions})" | |
)) | |
} |
Notes
Version
cargo 1.69.0-nightly (e84a7928d 2023-01-31)
release: 1.69.0-nightly
commit-hash: e84a7928d93a31f284b497c214a2ece69b4d7719
commit-date: 2023-01-31
host: aarch64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.79.1 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.6.3 [64-bit]
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-bugCategory: bugCategory: bugCommand-clippyS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.