Skip to content

Commit e50656d

Browse files
committed
Pass through extra args in cargo dev lint
1 parent bbe6e94 commit e50656d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clippy_dev/src/lint.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn exit_if_err(status: io::Result<ExitStatus>) {
1313
}
1414
}
1515

16-
pub fn run(path: &str) {
16+
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a str>) {
1717
let is_file = match fs::metadata(path) {
1818
Ok(metadata) => metadata.is_file(),
1919
Err(e) => {
@@ -30,6 +30,7 @@ pub fn run(path: &str) {
3030
.args(["-Z", "no-codegen"])
3131
.args(["--edition", "2021"])
3232
.arg(path)
33+
.args(args)
3334
.status(),
3435
);
3536
} else {
@@ -42,6 +43,8 @@ pub fn run(path: &str) {
4243
.expect("failed to create tempdir");
4344

4445
let status = Command::new(cargo_clippy_path())
46+
.arg("clippy")
47+
.args(args)
4548
.current_dir(path)
4649
.env("CARGO_TARGET_DIR", target.as_ref())
4750
.status();

clippy_dev/src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ fn main() {
7676
},
7777
("lint", Some(matches)) => {
7878
let path = matches.value_of("path").unwrap();
79-
lint::run(path);
79+
let args = matches.values_of("args").into_iter().flatten();
80+
lint::run(path, args);
8081
},
8182
("rename_lint", Some(matches)) => {
8283
let old_name = matches.value_of("old_name").unwrap();
@@ -278,11 +279,19 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
278279
Lint a package directory:
279280
cargo dev lint tests/ui-cargo/wildcard_dependencies/fail
280281
cargo dev lint ~/my-project
282+
283+
Run rustfix:
284+
cargo dev lint ~/my-project -- --fix
281285
"})
282286
.arg(
283287
Arg::with_name("path")
284288
.required(true)
285289
.help("The path to a file or package directory to lint"),
290+
)
291+
.arg(
292+
Arg::with_name("args")
293+
.multiple(true)
294+
.help("Pass extra arguments to cargo/clippy-driver"),
286295
),
287296
)
288297
.subcommand(

0 commit comments

Comments
 (0)