diff --git a/src/main.rs b/src/main.rs index 6bd4123ddeb45..7589f42a7b4d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,8 @@ Usage: cargo clippy [options] [--] [...] Common options: + --no-deps Run Clippy only on the given crate, without linting the dependencies + --fix Automatically apply lint suggestions. This flag implies `--no-deps` -h, --help Print this message -V, --version Print version info and exit @@ -71,6 +73,7 @@ impl ClippyCmd { { let mut cargo_subcommand = "check"; let mut args = vec![]; + let mut clippy_args: Vec = vec![]; for arg in old_args.by_ref() { match arg.as_str() { @@ -78,6 +81,10 @@ impl ClippyCmd { cargo_subcommand = "fix"; continue; }, + "--no-deps" => { + clippy_args.push("--no-deps".into()); + continue; + }, "--" => break, _ => {}, } @@ -85,7 +92,7 @@ impl ClippyCmd { args.push(arg); } - let mut clippy_args: Vec = old_args.collect(); + clippy_args.append(&mut (old_args.collect())); if cargo_subcommand == "fix" && !clippy_args.iter().any(|arg| arg == "--no-deps") { clippy_args.push("--no-deps".into()); } diff --git a/tests/dogfood.rs b/tests/dogfood.rs index 7de130c7dbefa..a996f9df144eb 100644 --- a/tests/dogfood.rs +++ b/tests/dogfood.rs @@ -76,8 +76,8 @@ fn test_no_deps_ignores_path_deps_in_workspaces() { .env("CARGO_INCREMENTAL", "0") .arg("clippy") .args(&["-p", "subcrate"]) - .arg("--") .arg("--no-deps") + .arg("--") .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir .args(&["--cfg", r#"feature="primary_package_test""#]) .output()