diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 532949e47a17a..011b053f89809 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -851,8 +851,8 @@ impl<'a> Builder<'a> { } rustflags.env("RUSTFLAGS_BOOTSTRAP"); if cmd == "clippy" { - // clippy overwrites any sysroot we pass on the command line. - // Tell it to use the appropriate sysroot instead. + // clippy overwrites sysroot if we pass it to cargo. + // Pass it directly to clippy instead. // NOTE: this can't be fixed in clippy because we explicitly don't set `RUSTC`, // so it has no way of knowing the sysroot. rustflags.arg("--sysroot"); @@ -867,8 +867,7 @@ impl<'a> Builder<'a> { // Explicitly does *not* set `--cfg=bootstrap`, since we're using a nightly clippy. let host_version = Command::new("rustc").arg("--version").output().map_err(|_| ()); let output = host_version.and_then(|output| { - if output.status.success() - { + if output.status.success() { Ok(output) } else { Err(()) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index b88dca0a9ed34..2e3cfc98c8cf2 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -16,12 +16,23 @@ pub struct Std { /// Returns args for the subcommand itself (not for cargo) fn args(builder: &Builder<'_>) -> Vec { + fn strings<'a>(arr: &'a [&str]) -> impl Iterator + 'a { + arr.iter().copied().map(String::from) + } + if let Subcommand::Clippy { fix, .. } = builder.config.cmd { - let mut args = vec!["--".to_owned(), "--cap-lints".to_owned(), "warn".to_owned()]; + let mut args = vec![]; if fix { - args.insert(0, "--fix".to_owned()); - args.insert(0, "-Zunstable-options".to_owned()); + #[rustfmt::skip] + args.extend(strings(&[ + "--fix", "-Zunstable-options", + // FIXME: currently, `--fix` gives an error while checking tests for libtest, + // possibly because libtest is not yet built in the sysroot. + // As a workaround, avoid checking tests and benches when passed --fix. + "--lib", "--bins", "--examples", + ])); } + args.extend(strings(&["--", "--cap-lints", "warn"])); args } else { vec![]