Skip to content

Commit 2c0a4df

Browse files
committed
reimplement arg passthrough for clippy-driver
Prior to this change, the old cargo subcommand version of `cargo clippy` had a feature to pass trailing args down to clippy-driver but when this the subcommand was reimplemented inside of cargo this feature was left out accidentally. This change readds the feature to to capture all args after a trailing -- and forward them down to clippy-driver via an env variable.
1 parent 572eaf2 commit 2c0a4df

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/bin/cargo/commands/clippy.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use cargo::util;
66
pub fn cli() -> App {
77
subcommand("clippy-preview")
88
.about("Checks a package to catch common mistakes and improve your Rust code.")
9+
.arg(Arg::with_name("args").multiple(true))
910
.arg_package_spec(
1011
"Package(s) to check",
1112
"Check all packages in the workspace",
@@ -69,7 +70,15 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
6970
.into());
7071
}
7172

72-
let wrapper = util::process(util::config::clippy_driver());
73+
let mut wrapper = util::process(util::config::clippy_driver());
74+
75+
if let Some(old_args) = args.values_of("args") {
76+
let clippy_args: String = old_args
77+
.map(|arg| format!("{}__CLIPPY_HACKERY__", arg))
78+
.collect();
79+
wrapper.env("CLIPPY_ARGS", clippy_args);
80+
}
81+
7382
compile_opts.build_config.primary_unit_rustc = Some(wrapper);
7483
compile_opts.build_config.force_rebuild = true;
7584

0 commit comments

Comments
 (0)