Get --fix working for everything except rustdoc

Here's the error for rustdoc:

```
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
error: no library targets found in package `rustdoc-tool`
```
This commit is contained in:
Joshua Nelson 2020-10-26 21:18:28 -04:00
parent 31ecd2a124
commit 8d2fa72fc8
2 changed files with 17 additions and 7 deletions

View File

@ -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(())

View File

@ -16,12 +16,23 @@ pub struct Std {
/// Returns args for the subcommand itself (not for cargo)
fn args(builder: &Builder<'_>) -> Vec<String> {
fn strings<'a>(arr: &'a [&str]) -> impl Iterator<Item = String> + '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![]