about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2020-10-26 21:18:28 -0400
committerJoshua Nelson <jyn514@gmail.com>2020-11-05 18:06:09 -0500
commit8d2fa72fc8064e7800e9d2a6512fa7eb302e8d8d (patch)
treee5612ce90d986271e4792115eccc9464f57312be /src
parent31ecd2a124ff9c466c9661862aa0a0ad2d48d1a1 (diff)
downloadrust-8d2fa72fc8064e7800e9d2a6512fa7eb302e8d8d.tar.gz
rust-8d2fa72fc8064e7800e9d2a6512fa7eb302e8d8d.zip
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`
```
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/builder.rs7
-rw-r--r--src/bootstrap/check.rs17
2 files changed, 17 insertions, 7 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 532949e47a1..011b053f898 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 b88dca0a9ed..2e3cfc98c8c 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<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![]