Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ fn args(builder: &Builder<'_>) -> Vec<String> {
arr.iter().copied().map(String::from)
}

if let Subcommand::Clippy { fix, .. } = builder.config.cmd {
if let Subcommand::Clippy { fix, only, .. } = &builder.config.cmd {
let mut args = vec![];
if fix {
if *fix {
#[rustfmt::skip]
args.extend(strings(&[
"--fix", "-Zunstable-options",
Expand All @@ -33,6 +33,14 @@ fn args(builder: &Builder<'_>) -> Vec<String> {
]));
}
args.extend(strings(&["--", "--cap-lints", "warn"]));
// only run specified lints
if let Some(only) = only {
args.push("-Aclippy::all".into());
let allow_lints: Vec<_> =
only.split(",").map(|lintname| format!("-Wclippy::{}", lintname)).collect();

args.extend(allow_lints);
}
args
} else {
vec![]
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub enum Subcommand {
Clippy {
fix: bool,
paths: Vec<PathBuf>,
only: Option<String>,
},
Fix {
paths: Vec<PathBuf>,
Expand Down Expand Up @@ -276,6 +277,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
}
"clippy" => {
opts.optflag("", "fix", "automatically apply lint suggestions");
opts.optopt("", "only", "only run specified clippy lints", "clippy_lint_name");
}
"doc" => {
opts.optflag("", "open", "open the docs in a browser");
Expand Down Expand Up @@ -517,7 +519,11 @@ Arguments:
"check" | "c" => {
Subcommand::Check { paths, all_targets: matches.opt_present("all-targets") }
}
"clippy" => Subcommand::Clippy { paths, fix: matches.opt_present("fix") },
"clippy" => Subcommand::Clippy {
paths,
fix: matches.opt_present("fix"),
only: matches.opt_str("only"),
},
"fix" => Subcommand::Fix { paths },
"test" | "t" => Subcommand::Test {
paths,
Expand Down