]> git.lizzy.rs Git - rust.git/commitdiff
Run rustfmt
authorSantiago Pastorino <spastorino@gmail.com>
Wed, 30 May 2018 17:33:43 +0000 (14:33 -0300)
committerSantiago Pastorino <spastorino@gmail.com>
Wed, 30 May 2018 17:36:23 +0000 (14:36 -0300)
src/bootstrap/builder.rs
src/bootstrap/flags.rs
src/bootstrap/test.rs
src/tools/compiletest/src/runtest.rs

index e987d3fa4fa6e9fc73f781342c95709094753420..4fdb36b3f6e959431c6553023c6910e85f0bcb5d 100644 (file)
@@ -11,6 +11,7 @@
 use std::any::Any;
 use std::cell::{Cell, RefCell};
 use std::collections::BTreeSet;
+use std::collections::HashMap;
 use std::env;
 use std::fmt::Debug;
 use std::fs;
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
 use std::process::Command;
-use std::time::{Instant, Duration};
-use std::collections::HashMap;
+use std::time::{Duration, Instant};
 
+use cache::{Cache, Interned, INTERNER};
+use check;
 use compile;
-use install;
 use dist;
-use util::{exe, libdir, add_lib_path};
-use {Build, Mode, DocTests};
-use cache::{INTERNER, Interned, Cache};
-use check;
-use test;
-use flags::Subcommand;
 use doc;
-use tool;
+use flags::Subcommand;
+use install;
 use native;
+use test;
+use tool;
+use util::{add_lib_path, exe, libdir};
+use {Build, DocTests, Mode};
 
 pub use Compiler;
 
-use petgraph::Graph;
 use petgraph::graph::NodeIndex;
+use petgraph::Graph;
 
 pub struct Builder<'a> {
     pub build: &'a Build,
@@ -112,8 +112,8 @@ struct StepDescription {
 
 #[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)]
 pub enum PathSet {
-    Set (BTreeSet<PathBuf>),
-    Suite (PathBuf)
+    Set(BTreeSet<PathBuf>),
+    Suite(PathBuf),
 }
 
 impl PathSet {
@@ -130,14 +130,18 @@ fn one<P: Into<PathBuf>>(path: P) -> PathSet {
     fn has(&self, needle: &Path) -> bool {
         match self {
             PathSet::Set(set) => set.iter().any(|p| p.ends_with(needle)),
-            PathSet::Suite(_) => false
+            PathSet::Suite(_) => false,
         }
     }
 
     fn path(&self, builder: &Builder) -> PathBuf {
         match self {
-            PathSet::Set(set) => set.iter().next().unwrap_or(&builder.build.src).to_path_buf(),
-            PathSet::Suite(path) => PathBuf::from(path)
+            PathSet::Set(set) => set
+                .iter()
+                .next()
+                .unwrap_or(&builder.build.src)
+                .to_path_buf(),
+            PathSet::Suite(path) => PathBuf::from(path),
         }
     }
 }
@@ -158,8 +162,10 @@ fn maybe_run(&self, builder: &Builder, pathset: &PathSet) {
             eprintln!("Skipping {:?} because it is excluded", pathset);
             return;
         } else if !builder.config.exclude.is_empty() {
-            eprintln!("{:?} not skipped for {:?} -- not in {:?}", pathset,
-                self.name, builder.config.exclude);
+            eprintln!(
+                "{:?} not skipped for {:?} -- not in {:?}",
+                pathset, self.name, builder.config.exclude
+            );
         }
         let hosts = &builder.hosts;
 
@@ -188,14 +194,18 @@ fn maybe_run(&self, builder: &Builder, pathset: &PathSet) {
     }
 
     fn run(v: &[StepDescription], builder: &Builder, paths: &[PathBuf]) {
-        let should_runs = v.iter().map(|desc| {
-            (desc.should_run)(ShouldRun::new(builder))
-        }).collect::<Vec<_>>();
+        let should_runs = v
+            .iter()
+            .map(|desc| (desc.should_run)(ShouldRun::new(builder)))
+            .collect::<Vec<_>>();
 
         // sanity checks on rules
         for (desc, should_run) in v.iter().zip(&should_runs) {
-            assert!(!should_run.paths.is_empty(),
-                "{:?} should have at least one pathset", desc.name);
+            assert!(
+                !should_run.paths.is_empty(),
+                "{:?} should have at least one pathset",
+                desc.name
+            );
         }
 
         if paths.is_empty() {
@@ -278,16 +288,15 @@ pub fn path(self, path: &str) -> Self {
 
     // multiple aliases for the same job
     pub fn paths(mut self, paths: &[&str]) -> Self {
-        self.paths.insert(PathSet::Set(paths.iter().map(PathBuf::from).collect()));
+        self.paths
+            .insert(PathSet::Set(paths.iter().map(PathBuf::from).collect()));
         self
     }
 
     pub fn is_suite_path(&self, path: &Path) -> Option<&PathSet> {
-        self.paths.iter().find(|pathset| {
-            match pathset {
-                PathSet::Suite(p) => path.starts_with(p),
-                PathSet::Set(_) => false
-            }
+        self.paths.iter().find(|pathset| match pathset {
+            PathSet::Suite(p) => path.starts_with(p),
+            PathSet::Set(_) => false,
         })
     }
 
@@ -326,40 +335,135 @@ macro_rules! describe {
             }};
         }
         match kind {
-            Kind::Build => describe!(compile::Std, compile::Test, compile::Rustc,
-                compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex,
-                tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
-                tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
-                tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
-                native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
-            Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend,
-                check::Rustdoc),
-            Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
-                test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
-                test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,
-                test::UiFullDeps, test::RunPassFullDeps, test::RunFailFullDeps,
-                test::CompileFailFullDeps, test::IncrementalFullDeps, test::Rustdoc, test::Pretty,
-                test::RunPassPretty, test::RunFailPretty, test::RunPassValgrindPretty,
-                test::RunPassFullDepsPretty, test::RunFailFullDepsPretty,
-                test::Crate, test::CrateLibrustc, test::CrateRustdoc, test::Linkcheck,
-                test::Cargotest, test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck,
+            Kind::Build => describe!(
+                compile::Std,
+                compile::Test,
+                compile::Rustc,
+                compile::StartupObjects,
+                tool::BuildManifest,
+                tool::Rustbook,
+                tool::ErrorIndex,
+                tool::UnstableBookGen,
+                tool::Tidy,
+                tool::Linkchecker,
+                tool::CargoTest,
+                tool::Compiletest,
+                tool::RemoteTestServer,
+                tool::RemoteTestClient,
+                tool::RustInstaller,
+                tool::Cargo,
+                tool::Rls,
+                tool::Rustdoc,
+                tool::Clippy,
+                native::Llvm,
+                tool::Rustfmt,
+                tool::Miri,
+                native::Lld
+            ),
+            Kind::Check => describe!(
+                check::Std,
+                check::Test,
+                check::Rustc,
+                check::CodegenBackend,
+                check::Rustdoc
+            ),
+            Kind::Test => describe!(
+                test::Tidy,
+                test::Bootstrap,
+                test::Ui,
+                test::RunPass,
+                test::CompileFail,
+                test::ParseFail,
+                test::RunFail,
+                test::RunPassValgrind,
+                test::MirOpt,
+                test::Codegen,
+                test::CodegenUnits,
+                test::Incremental,
+                test::Debuginfo,
+                test::UiFullDeps,
+                test::RunPassFullDeps,
+                test::RunFailFullDeps,
+                test::CompileFailFullDeps,
+                test::IncrementalFullDeps,
+                test::Rustdoc,
+                test::Pretty,
+                test::RunPassPretty,
+                test::RunFailPretty,
+                test::RunPassValgrindPretty,
+                test::RunPassFullDepsPretty,
+                test::RunFailFullDepsPretty,
+                test::Crate,
+                test::CrateLibrustc,
+                test::CrateRustdoc,
+                test::Linkcheck,
+                test::Cargotest,
+                test::Cargo,
+                test::Rls,
+                test::ErrorIndex,
+                test::Distcheck,
                 test::RunMakeFullDeps,
-                test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample,
-                test::TheBook, test::UnstableBook, test::RustcBook,
-                test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
+                test::Nomicon,
+                test::Reference,
+                test::RustdocBook,
+                test::RustByExample,
+                test::TheBook,
+                test::UnstableBook,
+                test::RustcBook,
+                test::Rustfmt,
+                test::Miri,
+                test::Clippy,
+                test::RustdocJS,
+                test::RustdocTheme,
                 // Run run-make last, since these won't pass without make on Windows
-                test::RunMake, test::RustdocUi),
+                test::RunMake,
+                test::RustdocUi
+            ),
             Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
-            Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
-                doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
-                doc::Rustdoc, doc::ErrorIndex, doc::Nomicon, doc::Reference, doc::RustdocBook,
-                doc::RustByExample, doc::RustcBook, doc::CargoBook),
-            Kind::Dist => describe!(dist::Docs, dist::RustcDocs, dist::Mingw, dist::Rustc,
-                dist::DebuggerScripts, dist::Std, dist::Analysis, dist::Src,
-                dist::PlainSourceTarball, dist::Cargo, dist::Rls, dist::Rustfmt, dist::Extended,
-                dist::HashSign),
-            Kind::Install => describe!(install::Docs, install::Std, install::Cargo, install::Rls,
-                install::Rustfmt, install::Analysis, install::Src, install::Rustc),
+            Kind::Doc => describe!(
+                doc::UnstableBook,
+                doc::UnstableBookGen,
+                doc::TheBook,
+                doc::Standalone,
+                doc::Std,
+                doc::Test,
+                doc::WhitelistedRustc,
+                doc::Rustc,
+                doc::Rustdoc,
+                doc::ErrorIndex,
+                doc::Nomicon,
+                doc::Reference,
+                doc::RustdocBook,
+                doc::RustByExample,
+                doc::RustcBook,
+                doc::CargoBook
+            ),
+            Kind::Dist => describe!(
+                dist::Docs,
+                dist::RustcDocs,
+                dist::Mingw,
+                dist::Rustc,
+                dist::DebuggerScripts,
+                dist::Std,
+                dist::Analysis,
+                dist::Src,
+                dist::PlainSourceTarball,
+                dist::Cargo,
+                dist::Rls,
+                dist::Rustfmt,
+                dist::Extended,
+                dist::HashSign
+            ),
+            Kind::Install => describe!(
+                install::Docs,
+                install::Std,
+                install::Cargo,
+                install::Rls,
+                install::Rustfmt,
+                install::Analysis,
+                install::Src,
+                install::Rustc
+            ),
         }
     }
 
@@ -394,10 +498,12 @@ pub fn get_help(build: &Build, subcommand: &str) -> Option<String> {
         }
         let mut help = String::from("Available paths:\n");
         for pathset in should_run.paths {
-            if let PathSet::Set(set) = pathset{
-                set.iter().for_each(|path| help.push_str(
-                    format!("    ./x.py {} {}\n", subcommand, path.display()).as_str()
-                    ))
+            if let PathSet::Set(set) = pathset {
+                set.iter().for_each(|path| {
+                    help.push_str(
+                        format!("    ./x.py {} {}\n", subcommand, path.display()).as_str(),
+                    )
+                })
             }
         }
         Some(help)
@@ -428,11 +534,13 @@ pub fn new(build: &Build) -> Builder {
             parent: Cell::new(None),
         };
 
-
         if kind == Kind::Dist {
-            assert!(!builder.config.test_miri, "Do not distribute with miri enabled.\n\
+            assert!(
+                !builder.config.test_miri,
+                "Do not distribute with miri enabled.\n\
                 The distributed libraries would include all MIR (increasing binary size).
-                The distributed MIR would include validation statements.");
+                The distributed MIR would include validation statements."
+            );
         }
 
         builder
@@ -457,7 +565,9 @@ fn run_step_descriptions(&self, v: &[StepDescription], paths: &[PathBuf]) {
     /// obtained through this function, since it ensures that they are valid
     /// (i.e., built and assembled).
     pub fn compiler(&self, stage: u32, host: Interned<String>) -> Compiler {
-        self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } })
+        self.ensure(compile::Assemble {
+            target_compiler: Compiler { stage, host },
+        })
     }
 
     pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> {
@@ -467,7 +577,9 @@ pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> {
     /// Returns the libdir where the standard library and other artifacts are
     /// found for a compiler's sysroot.
     pub fn sysroot_libdir(
-        &self, compiler: Compiler, target: Interned<String>
+        &self,
+        compiler: Compiler,
+        target: Interned<String>,
     ) -> Interned<PathBuf> {
         #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
         struct Libdir {
@@ -489,8 +601,12 @@ fn run(self, builder: &Builder) -> Interned<PathBuf> {
                 } else {
                     Path::new("lib")
                 };
-                let sysroot = builder.sysroot(self.compiler).join(lib)
-                    .join("rustlib").join(self.target).join("lib");
+                let sysroot = builder
+                    .sysroot(self.compiler)
+                    .join(lib)
+                    .join("rustlib")
+                    .join(self.target)
+                    .join("lib");
                 let _ = fs::remove_dir_all(&sysroot);
                 t!(fs::create_dir_all(&sysroot));
                 INTERNER.intern_path(sysroot)
@@ -524,7 +640,7 @@ pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
         // compiler live next to the compiler and the system will find them
         // automatically.
         if cfg!(windows) {
-            return
+            return;
         }
 
         add_lib_path(vec![self.rustc_libdir(compiler)], cmd);
@@ -535,7 +651,9 @@ pub fn rustc(&self, compiler: Compiler) -> PathBuf {
         if compiler.is_snapshot(self) {
             self.initial_rustc.clone()
         } else {
-            self.sysroot(compiler).join("bin").join(exe("rustc", &compiler.host))
+            self.sysroot(compiler)
+                .join("bin")
+                .join(exe("rustc", &compiler.host))
         }
     }
 
@@ -547,12 +665,15 @@ pub fn rustdoc_cmd(&self, host: Interned<String>) -> Command {
         let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc"));
         let compiler = self.compiler(self.top_stage, host);
         cmd.env("RUSTC_STAGE", compiler.stage.to_string())
-           .env("RUSTC_SYSROOT", self.sysroot(compiler))
-           .env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build))
-           .env("CFG_RELEASE_CHANNEL", &self.config.channel)
-           .env("RUSTDOC_REAL", self.rustdoc(host))
-           .env("RUSTDOC_CRATE_VERSION", self.rust_version())
-           .env("RUSTC_BOOTSTRAP", "1");
+            .env("RUSTC_SYSROOT", self.sysroot(compiler))
+            .env(
+                "RUSTDOC_LIBDIR",
+                self.sysroot_libdir(compiler, self.config.build),
+            )
+            .env("CFG_RELEASE_CHANNEL", &self.config.channel)
+            .env("RUSTDOC_REAL", self.rustdoc(host))
+            .env("RUSTDOC_CRATE_VERSION", self.rust_version())
+            .env("RUSTC_BOOTSTRAP", "1");
         if let Some(linker) = self.linker(host) {
             cmd.env("RUSTC_TARGET_LINKER", linker);
         }
@@ -566,17 +687,20 @@ pub fn rustdoc_cmd(&self, host: Interned<String>) -> Command {
     /// rustc compiler, its output will be scoped by `mode`'s output directory,
     /// it will pass the `--target` flag for the specified `target`, and will be
     /// executing the Cargo command `cmd`.
-    pub fn cargo(&self,
-             compiler: Compiler,
-             mode: Mode,
-             target: Interned<String>,
-             cmd: &str) -> Command {
+    pub fn cargo(
+        &self,
+        compiler: Compiler,
+        mode: Mode,
+        target: Interned<String>,
+        cmd: &str,
+    ) -> Command {
         let mut cargo = Command::new(&self.initial_cargo);
         let out_dir = self.stage_out(compiler, mode);
-        cargo.env("CARGO_TARGET_DIR", out_dir)
-             .arg(cmd)
-             .arg("--target")
-             .arg(target);
+        cargo
+            .env("CARGO_TARGET_DIR", out_dir)
+            .arg(cmd)
+            .arg("--target")
+            .arg(target);
 
         // Set a flag for `check` so that certain build scripts can do less work
         // (e.g. not building/requiring LLVM).
@@ -619,8 +743,14 @@ pub fn cargo(&self,
         }
 
         if !extra_args.is_empty() {
-            cargo.env("RUSTFLAGS",
-                format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args));
+            cargo.env(
+                "RUSTFLAGS",
+                format!(
+                    "{} {}",
+                    env::var("RUSTFLAGS").unwrap_or_default(),
+                    extra_args
+                ),
+            );
         }
 
         let want_rustdoc = self.doc_tests != DocTests::No;
@@ -631,23 +761,29 @@ pub fn cargo(&self,
         //
         // These variables are primarily all read by
         // src/bootstrap/bin/{rustc.rs,rustdoc.rs}
-        cargo.env("RUSTBUILD_NATIVE_DIR", self.native_dir(target))
-             .env("RUSTC", self.out.join("bootstrap/debug/rustc"))
-             .env("RUSTC_REAL", self.rustc(compiler))
-             .env("RUSTC_STAGE", stage.to_string())
-             .env("RUSTC_DEBUG_ASSERTIONS",
-                  self.config.rust_debug_assertions.to_string())
-             .env("RUSTC_SYSROOT", self.sysroot(compiler))
-             .env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
-             .env("RUSTC_RPATH", self.config.rust_rpath.to_string())
-             .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
-             .env("RUSTDOC_REAL", if cmd == "doc" || (cmd == "test" && want_rustdoc) {
-                 self.rustdoc(compiler.host)
-             } else {
-                 PathBuf::from("/path/to/nowhere/rustdoc/not/required")
-             })
-             .env("TEST_MIRI", self.config.test_miri.to_string())
-             .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
+        cargo
+            .env("RUSTBUILD_NATIVE_DIR", self.native_dir(target))
+            .env("RUSTC", self.out.join("bootstrap/debug/rustc"))
+            .env("RUSTC_REAL", self.rustc(compiler))
+            .env("RUSTC_STAGE", stage.to_string())
+            .env(
+                "RUSTC_DEBUG_ASSERTIONS",
+                self.config.rust_debug_assertions.to_string(),
+            )
+            .env("RUSTC_SYSROOT", self.sysroot(compiler))
+            .env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
+            .env("RUSTC_RPATH", self.config.rust_rpath.to_string())
+            .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
+            .env(
+                "RUSTDOC_REAL",
+                if cmd == "doc" || (cmd == "test" && want_rustdoc) {
+                    self.rustdoc(compiler.host)
+                } else {
+                    PathBuf::from("/path/to/nowhere/rustdoc/not/required")
+                },
+            )
+            .env("TEST_MIRI", self.config.test_miri.to_string())
+            .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
 
         if let Some(host_linker) = self.linker(compiler.host) {
             cargo.env("RUSTC_HOST_LINKER", host_linker);
@@ -659,7 +795,10 @@ pub fn cargo(&self,
             cargo.env("RUSTC_ERROR_FORMAT", error_format);
         }
         if cmd != "build" && cmd != "check" && want_rustdoc {
-            cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build)));
+            cargo.env(
+                "RUSTDOC_LIBDIR",
+                self.rustc_libdir(self.compiler(2, self.config.build)),
+            );
         }
 
         if mode == Mode::Tool {
@@ -667,11 +806,17 @@ pub fn cargo(&self,
             // enabled in the config.  Adding debuginfo makes them several times larger.
             if self.config.rust_debuginfo_tools {
                 cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
-                cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
+                cargo.env(
+                    "RUSTC_DEBUGINFO_LINES",
+                    self.config.rust_debuginfo_lines.to_string(),
+                );
             }
         } else {
             cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
-            cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
+            cargo.env(
+                "RUSTC_DEBUGINFO_LINES",
+                self.config.rust_debuginfo_lines.to_string(),
+            );
             cargo.env("RUSTC_FORCE_UNSTABLE", "1");
 
             // Currently the compiler depends on crates from crates.io, and
@@ -718,11 +863,13 @@ pub fn cargo(&self,
         // If LLVM support is disabled we need to use the snapshot compiler to compile
         // build scripts, as the new compiler doesn't support executables.
         if mode == Mode::Libstd || !self.config.llvm_enabled {
-            cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
-                 .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
+            cargo
+                .env("RUSTC_SNAPSHOT", &self.initial_rustc)
+                .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
         } else {
-            cargo.env("RUSTC_SNAPSHOT", self.rustc(compiler))
-                 .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
+            cargo
+                .env("RUSTC_SNAPSHOT", self.rustc(compiler))
+                .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
         }
 
         // Ignore incremental modes except for stage0, since we're
@@ -780,32 +927,36 @@ pub fn cargo(&self,
                 }
             };
             let cc = ccacheify(&self.cc(target));
-            cargo.env(format!("CC_{}", target), &cc)
-                 .env("CC", &cc);
+            cargo.env(format!("CC_{}", target), &cc).env("CC", &cc);
 
             let cflags = self.cflags(target).join(" ");
-            cargo.env(format!("CFLAGS_{}", target), cflags.clone())
-                 .env("CFLAGS", cflags.clone());
+            cargo
+                .env(format!("CFLAGS_{}", target), cflags.clone())
+                .env("CFLAGS", cflags.clone());
 
             if let Some(ar) = self.ar(target) {
                 let ranlib = format!("{} s", ar.display());
-                cargo.env(format!("AR_{}", target), ar)
-                     .env("AR", ar)
-                     .env(format!("RANLIB_{}", target), ranlib.clone())
-                     .env("RANLIB", ranlib);
+                cargo
+                    .env(format!("AR_{}", target), ar)
+                    .env("AR", ar)
+                    .env(format!("RANLIB_{}", target), ranlib.clone())
+                    .env("RANLIB", ranlib);
             }
 
             if let Ok(cxx) = self.cxx(target) {
                 let cxx = ccacheify(&cxx);
-                cargo.env(format!("CXX_{}", target), &cxx)
-                     .env("CXX", &cxx)
-                     .env(format!("CXXFLAGS_{}", target), cflags.clone())
-                     .env("CXXFLAGS", cflags);
+                cargo
+                    .env(format!("CXX_{}", target), &cxx)
+                    .env("CXX", &cxx)
+                    .env(format!("CXXFLAGS_{}", target), cflags.clone())
+                    .env("CXXFLAGS", cflags);
             }
         }
 
-        if cmd == "build" && mode == Mode::Libstd
-            && self.config.extended && compiler.is_final_stage(self)
+        if cmd == "build"
+            && mode == Mode::Libstd
+            && self.config.extended
+            && compiler.is_final_stage(self)
         {
             cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
         }
@@ -893,7 +1044,10 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
             let mut stack = self.stack.borrow_mut();
             for stack_step in stack.iter() {
                 // should skip
-                if stack_step.downcast_ref::<S>().map_or(true, |stack_step| *stack_step != step) {
+                if stack_step
+                    .downcast_ref::<S>()
+                    .map_or(true, |stack_step| *stack_step != step)
+                {
                     continue;
                 }
                 let mut out = String::new();
@@ -909,7 +1063,9 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
                 {
                     let mut graph = self.graph.borrow_mut();
                     let parent = self.parent.get();
-                    let us = *self.graph_nodes.borrow_mut()
+                    let us = *self
+                        .graph_nodes
+                        .borrow_mut()
                         .entry(format!("{:?}", step))
                         .or_insert_with(|| graph.add_node(format!("{:?}", step)));
                     if let Some(parent) = parent {
@@ -928,7 +1084,9 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
         {
             let mut graph = self.graph.borrow_mut();
             let parent = self.parent.get();
-            let us = *self.graph_nodes.borrow_mut()
+            let us = *self
+                .graph_nodes
+                .borrow_mut()
                 .entry(format!("{:?}", step))
                 .or_insert_with(|| graph.add_node(format!("{:?}", step)));
             self.parent.set(Some(us));
@@ -950,10 +1108,12 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
         self.parent.set(prev_parent);
 
         if self.config.print_step_timings && dur > Duration::from_millis(100) {
-            println!("[TIMING] {:?} -- {}.{:03}",
-                     step,
-                     dur.as_secs(),
-                     dur.subsec_nanos() / 1_000_000);
+            println!(
+                "[TIMING] {:?} -- {}.{:03}",
+                step,
+                dur.as_secs(),
+                dur.subsec_nanos() / 1_000_000
+            );
         }
 
         {
@@ -961,7 +1121,11 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
             let cur_step = stack.pop().expect("step stack empty");
             assert_eq!(cur_step.downcast_ref(), Some(&step));
         }
-        self.verbose(&format!("{}< {:?}", "  ".repeat(self.stack.borrow().len()), step));
+        self.verbose(&format!(
+            "{}< {:?}",
+            "  ".repeat(self.stack.borrow().len()),
+            step
+        ));
         self.cache.put(step, out.clone());
         out
     }
@@ -969,9 +1133,9 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
 
 #[cfg(test)]
 mod __test {
+    use super::*;
     use config::Config;
     use std::thread;
-    use super::*;
 
     fn configure(host: &[&str], target: &[&str]) -> Config {
         let mut config = Config::default_opts();
@@ -980,15 +1144,26 @@ fn configure(host: &[&str], target: &[&str]) -> Config {
         config.run_host_only = true;
         config.dry_run = true;
         // try to avoid spurious failures in dist where we create/delete each others file
-        let dir = config.out.join("tmp-rustbuild-tests")
-            .join(&thread::current().name().unwrap_or("unknown").replace(":", "-"));
+        let dir = config.out.join("tmp-rustbuild-tests").join(
+            &thread::current()
+                .name()
+                .unwrap_or("unknown")
+                .replace(":", "-"),
+        );
         t!(fs::create_dir_all(&dir));
         config.out = dir;
         config.build = INTERNER.intern_str("A");
-        config.hosts = vec![config.build].clone().into_iter()
-            .chain(host.iter().map(|s| INTERNER.intern_str(s))).collect::<Vec<_>>();
-        config.targets = config.hosts.clone().into_iter()
-            .chain(target.iter().map(|s| INTERNER.intern_str(s))).collect::<Vec<_>>();
+        config.hosts = vec![config.build]
+            .clone()
+            .into_iter()
+            .chain(host.iter().map(|s| INTERNER.intern_str(s)))
+            .collect::<Vec<_>>();
+        config.targets = config
+            .hosts
+            .clone()
+            .into_iter()
+            .chain(target.iter().map(|s| INTERNER.intern_str(s)))
+            .collect::<Vec<_>>();
         config
     }
 
@@ -1004,21 +1179,27 @@ fn dist_baseline() {
 
         let a = INTERNER.intern_str("A");
 
-        assert_eq!(first(builder.cache.all::<dist::Docs>()), &[
-            dist::Docs { stage: 2, host: a },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[
-            dist::Mingw { host: a },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[
-            dist::Rustc { compiler: Compiler { host: a, stage: 2 } },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Std>()), &[
-            dist::Std {
+        assert_eq!(
+            first(builder.cache.all::<dist::Docs>()),
+            &[dist::Docs { stage: 2, host: a },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Mingw>()),
+            &[dist::Mingw { host: a },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Rustc>()),
+            &[dist::Rustc {
+                compiler: Compiler { host: a, stage: 2 }
+            },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Std>()),
+            &[dist::Std {
                 compiler: Compiler { host: a, stage: 2 },
                 target: a,
-            },
-        ]);
+            },]
+        );
         assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
     }
 
@@ -1031,27 +1212,36 @@ fn dist_with_targets() {
         let a = INTERNER.intern_str("A");
         let b = INTERNER.intern_str("B");
 
-        assert_eq!(first(builder.cache.all::<dist::Docs>()), &[
-            dist::Docs { stage: 2, host: a },
-            dist::Docs { stage: 2, host: b },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[
-            dist::Mingw { host: a },
-            dist::Mingw { host: b },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[
-            dist::Rustc { compiler: Compiler { host: a, stage: 2 } },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Std>()), &[
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<dist::Docs>()),
+            &[
+                dist::Docs { stage: 2, host: a },
+                dist::Docs { stage: 2, host: b },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Mingw>()),
+            &[dist::Mingw { host: a }, dist::Mingw { host: b },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Rustc>()),
+            &[dist::Rustc {
+                compiler: Compiler { host: a, stage: 2 }
+            },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Std>()),
+            &[
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+            ]
+        );
         assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
     }
 
@@ -1064,28 +1254,41 @@ fn dist_with_hosts() {
         let a = INTERNER.intern_str("A");
         let b = INTERNER.intern_str("B");
 
-        assert_eq!(first(builder.cache.all::<dist::Docs>()), &[
-            dist::Docs { stage: 2, host: a },
-            dist::Docs { stage: 2, host: b },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[
-            dist::Mingw { host: a },
-            dist::Mingw { host: b },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[
-            dist::Rustc { compiler: Compiler { host: a, stage: 2 } },
-            dist::Rustc { compiler: Compiler { host: b, stage: 2 } },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Std>()), &[
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<dist::Docs>()),
+            &[
+                dist::Docs { stage: 2, host: a },
+                dist::Docs { stage: 2, host: b },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Mingw>()),
+            &[dist::Mingw { host: a }, dist::Mingw { host: b },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Rustc>()),
+            &[
+                dist::Rustc {
+                    compiler: Compiler { host: a, stage: 2 }
+                },
+                dist::Rustc {
+                    compiler: Compiler { host: b, stage: 2 }
+                },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Std>()),
+            &[
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+            ]
+        );
         assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
     }
 
@@ -1099,34 +1302,50 @@ fn dist_with_targets_and_hosts() {
         let b = INTERNER.intern_str("B");
         let c = INTERNER.intern_str("C");
 
-        assert_eq!(first(builder.cache.all::<dist::Docs>()), &[
-            dist::Docs { stage: 2, host: a },
-            dist::Docs { stage: 2, host: b },
-            dist::Docs { stage: 2, host: c },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[
-            dist::Mingw { host: a },
-            dist::Mingw { host: b },
-            dist::Mingw { host: c },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[
-            dist::Rustc { compiler: Compiler { host: a, stage: 2 } },
-            dist::Rustc { compiler: Compiler { host: b, stage: 2 } },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Std>()), &[
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: c,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<dist::Docs>()),
+            &[
+                dist::Docs { stage: 2, host: a },
+                dist::Docs { stage: 2, host: b },
+                dist::Docs { stage: 2, host: c },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Mingw>()),
+            &[
+                dist::Mingw { host: a },
+                dist::Mingw { host: b },
+                dist::Mingw { host: c },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Rustc>()),
+            &[
+                dist::Rustc {
+                    compiler: Compiler { host: a, stage: 2 }
+                },
+                dist::Rustc {
+                    compiler: Compiler { host: b, stage: 2 }
+                },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Std>()),
+            &[
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: c,
+                },
+            ]
+        );
         assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
     }
 
@@ -1142,31 +1361,40 @@ fn dist_with_target_flag() {
         let b = INTERNER.intern_str("B");
         let c = INTERNER.intern_str("C");
 
-        assert_eq!(first(builder.cache.all::<dist::Docs>()), &[
-            dist::Docs { stage: 2, host: a },
-            dist::Docs { stage: 2, host: b },
-            dist::Docs { stage: 2, host: c },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[
-            dist::Mingw { host: a },
-            dist::Mingw { host: b },
-            dist::Mingw { host: c },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<dist::Docs>()),
+            &[
+                dist::Docs { stage: 2, host: a },
+                dist::Docs { stage: 2, host: b },
+                dist::Docs { stage: 2, host: c },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Mingw>()),
+            &[
+                dist::Mingw { host: a },
+                dist::Mingw { host: b },
+                dist::Mingw { host: c },
+            ]
+        );
         assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[]);
-        assert_eq!(first(builder.cache.all::<dist::Std>()), &[
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: c,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<dist::Std>()),
+            &[
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: c,
+                },
+            ]
+        );
         assert_eq!(first(builder.cache.all::<dist::Src>()), &[]);
     }
 
@@ -1179,87 +1407,109 @@ fn dist_with_same_targets_and_hosts() {
         let a = INTERNER.intern_str("A");
         let b = INTERNER.intern_str("B");
 
-        assert_eq!(first(builder.cache.all::<dist::Docs>()), &[
-            dist::Docs { stage: 2, host: a },
-            dist::Docs { stage: 2, host: b },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[
-            dist::Mingw { host: a },
-            dist::Mingw { host: b },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[
-            dist::Rustc { compiler: Compiler { host: a, stage: 2 } },
-            dist::Rustc { compiler: Compiler { host: b, stage: 2 } },
-        ]);
-        assert_eq!(first(builder.cache.all::<dist::Std>()), &[
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            dist::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<dist::Docs>()),
+            &[
+                dist::Docs { stage: 2, host: a },
+                dist::Docs { stage: 2, host: b },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Mingw>()),
+            &[dist::Mingw { host: a }, dist::Mingw { host: b },]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Rustc>()),
+            &[
+                dist::Rustc {
+                    compiler: Compiler { host: a, stage: 2 }
+                },
+                dist::Rustc {
+                    compiler: Compiler { host: b, stage: 2 }
+                },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<dist::Std>()),
+            &[
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                dist::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+            ]
+        );
         assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
-        assert_eq!(first(builder.cache.all::<compile::Std>()), &[
-            compile::Std {
-                compiler: Compiler { host: a, stage: 0 },
-                target: a,
-            },
-            compile::Std {
-                compiler: Compiler { host: a, stage: 1 },
-                target: a,
-            },
-            compile::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            compile::Std {
-                compiler: Compiler { host: a, stage: 1 },
-                target: b,
-            },
-            compile::Std {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-        ]);
-        assert_eq!(first(builder.cache.all::<compile::Test>()), &[
-            compile::Test {
-                compiler: Compiler { host: a, stage: 0 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 1 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 1 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-        ]);
-        assert_eq!(first(builder.cache.all::<compile::Assemble>()), &[
-            compile::Assemble {
-                target_compiler: Compiler { host: a, stage: 0 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: a, stage: 1 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: a, stage: 2 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: b, stage: 2 },
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<compile::Std>()),
+            &[
+                compile::Std {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: a,
+                },
+                compile::Std {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: a,
+                },
+                compile::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                compile::Std {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: b,
+                },
+                compile::Std {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<compile::Test>()),
+            &[
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<compile::Assemble>()),
+            &[
+                compile::Assemble {
+                    target_compiler: Compiler { host: a, stage: 0 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: a, stage: 1 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: a, stage: 2 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: b, stage: 2 },
+                },
+            ]
+        );
     }
 
     #[test]
@@ -1274,83 +1524,89 @@ fn build_default() {
 
         assert!(!builder.cache.all::<compile::Std>().is_empty());
         assert!(!builder.cache.all::<compile::Assemble>().is_empty());
-        assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 0 },
-                target: a,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 1 },
-                target: a,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: b, stage: 2 },
-                target: a,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 0 },
-                target: b,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 1 },
-                target: b,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: b, stage: 2 },
-                target: b,
-            },
-        ]);
-
-        assert_eq!(first(builder.cache.all::<compile::Test>()), &[
-            compile::Test {
-                compiler: Compiler { host: a, stage: 0 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 1 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: b, stage: 2 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 0 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 1 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: b, stage: 2 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: c,
-            },
-            compile::Test {
-                compiler: Compiler { host: b, stage: 2 },
-                target: c,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<compile::Rustc>()),
+            &[
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: a,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: a,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: a,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: b,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: b,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: b,
+                },
+            ]
+        );
+
+        assert_eq!(
+            first(builder.cache.all::<compile::Test>()),
+            &[
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: c,
+                },
+                compile::Test {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: c,
+                },
+            ]
+        );
     }
 
     #[test]
@@ -1366,84 +1622,93 @@ fn build_with_target_flag() {
         let c = INTERNER.intern_str("C");
 
         assert!(!builder.cache.all::<compile::Std>().is_empty());
-        assert_eq!(first(builder.cache.all::<compile::Assemble>()), &[
-            compile::Assemble {
-                target_compiler: Compiler { host: a, stage: 0 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: a, stage: 1 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: b, stage: 1 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: a, stage: 2 },
-            },
-            compile::Assemble {
-                target_compiler: Compiler { host: b, stage: 2 },
-            },
-        ]);
-        assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 0 },
-                target: a,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 1 },
-                target: a,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 0 },
-                target: b,
-            },
-            compile::Rustc {
-                compiler: Compiler { host: a, stage: 1 },
-                target: b,
-            },
-        ]);
-
-        assert_eq!(first(builder.cache.all::<compile::Test>()), &[
-            compile::Test {
-                compiler: Compiler { host: a, stage: 0 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 1 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: b, stage: 2 },
-                target: a,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 0 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 1 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: b, stage: 2 },
-                target: b,
-            },
-            compile::Test {
-                compiler: Compiler { host: a, stage: 2 },
-                target: c,
-            },
-            compile::Test {
-                compiler: Compiler { host: b, stage: 2 },
-                target: c,
-            },
-        ]);
+        assert_eq!(
+            first(builder.cache.all::<compile::Assemble>()),
+            &[
+                compile::Assemble {
+                    target_compiler: Compiler { host: a, stage: 0 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: a, stage: 1 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: b, stage: 1 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: a, stage: 2 },
+                },
+                compile::Assemble {
+                    target_compiler: Compiler { host: b, stage: 2 },
+                },
+            ]
+        );
+        assert_eq!(
+            first(builder.cache.all::<compile::Rustc>()),
+            &[
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: a,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: a,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: b,
+                },
+                compile::Rustc {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: b,
+                },
+            ]
+        );
+
+        assert_eq!(
+            first(builder.cache.all::<compile::Test>()),
+            &[
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: a,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 0 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 1 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: b,
+                },
+                compile::Test {
+                    compiler: Compiler { host: a, stage: 2 },
+                    target: c,
+                },
+                compile::Test {
+                    compiler: Compiler { host: b, stage: 2 },
+                    target: c,
+                },
+            ]
+        );
     }
 
     #[test]
@@ -1472,14 +1737,15 @@ fn test_with_no_doc_stage0() {
 
         // Ensure we don't build any compiler artifacts.
         assert!(builder.cache.all::<compile::Rustc>().is_empty());
-        assert_eq!(first(builder.cache.all::<test::Crate>()), &[
-            test::Crate {
+        assert_eq!(
+            first(builder.cache.all::<test::Crate>()),
+            &[test::Crate {
                 compiler: Compiler { host, stage: 0 },
                 target: host,
                 mode: Mode::Libstd,
                 test_kind: test::TestKind::Test,
                 krate: INTERNER.intern_str("std"),
-            },
-        ]);
+            },]
+        );
     }
 }
index f1473d19393aa0b4f9828c0a13ffa3390139cddd..e5dceccdf8b9e557b659d99aed8532ec3686682f 100644 (file)
 
 use getopts::Options;
 
-use {Build, DocTests};
+use builder::Builder;
 use config::Config;
 use metadata;
-use builder::Builder;
+use {Build, DocTests};
 
 use cache::{Interned, INTERNER};
 
@@ -93,7 +93,8 @@ fn default() -> Subcommand {
 impl Flags {
     pub fn parse(args: &[String]) -> Flags {
         let mut extra_help = String::new();
-        let mut subcommand_help = format!("\
+        let mut subcommand_help = format!(
+            "\
 Usage: x.py <subcommand> [options] [<paths>...]
 
 Subcommands:
@@ -106,7 +107,8 @@ pub fn parse(args: &[String]) -> Flags {
     dist        Build distribution artifacts
     install     Install distribution artifacts
 
-To learn more about a subcommand, run `./x.py <subcommand> -h`");
+To learn more about a subcommand, run `./x.py <subcommand> -h`"
+        );
 
         let mut opts = Options::new();
         // Options common to all subcommands
@@ -124,33 +126,39 @@ pub fn parse(args: &[String]) -> Flags {
         opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
         opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
         opts.optflag("h", "help", "print this help message");
-        opts.optopt("", "warnings", "if value is deny, will deny warnings, otherwise use default",
-            "VALUE");
+        opts.optopt(
+            "",
+            "warnings",
+            "if value is deny, will deny warnings, otherwise use default",
+            "VALUE",
+        );
         opts.optopt("", "error-format", "rustc error format", "FORMAT");
 
         // fn usage()
-        let usage = |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! {
-            println!("{}", opts.usage(subcommand_help));
-            if !extra_help.is_empty() {
-                println!("{}", extra_help);
-            }
-            process::exit(exit_code);
-        };
+        let usage =
+            |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! {
+                println!("{}", opts.usage(subcommand_help));
+                if !extra_help.is_empty() {
+                    println!("{}", extra_help);
+                }
+                process::exit(exit_code);
+            };
 
         // We can't use getopt to parse the options until we have completed specifying which
         // options are valid, but under the current implementation, some options are conditional on
         // the subcommand. Therefore we must manually identify the subcommand first, so that we can
         // complete the definition of the options.  Then we can use the getopt::Matches object from
         // there on out.
-        let subcommand = args.iter().find(|&s|
+        let subcommand = args.iter().find(|&s| {
             (s == "build")
-            || (s == "check")
-            || (s == "test")
-            || (s == "bench")
-            || (s == "doc")
-            || (s == "clean")
-            || (s == "dist")
-            || (s == "install"));
+                || (s == "check")
+                || (s == "test")
+                || (s == "bench")
+                || (s == "doc")
+                || (s == "clean")
+                || (s == "dist")
+                || (s == "install")
+        });
         let subcommand = match subcommand {
             Some(s) => s,
             None => {
@@ -165,7 +173,7 @@ pub fn parse(args: &[String]) -> Flags {
 
         // Some subcommands get extra options
         match subcommand.as_str() {
-            "test"  => {
+            "test" => {
                 opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
                 opts.optmulti("", "test-args", "extra arguments", "ARGS");
                 opts.optmulti(
@@ -176,12 +184,25 @@ pub fn parse(args: &[String]) -> Flags {
                 );
                 opts.optflag("", "no-doc", "do not run doc tests");
                 opts.optflag("", "doc", "only run doc tests");
-                opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests");
-                opts.optopt("", "compare-mode", "mode describing what file the actual ui output will be compared to", "COMPARE MODE");
-            },
-            "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
-            "clean" => { opts.optflag("", "all", "clean all build artifacts"); },
-            _ => { },
+                opts.optflag(
+                    "",
+                    "bless",
+                    "update all stderr/stdout files of failing ui tests",
+                );
+                opts.optopt(
+                    "",
+                    "compare-mode",
+                    "mode describing what file the actual ui output will be compared to",
+                    "COMPARE MODE",
+                );
+            }
+            "bench" => {
+                opts.optmulti("", "test-args", "extra arguments", "ARGS");
+            }
+            "clean" => {
+                opts.optflag("", "all", "clean all build artifacts");
+            }
+            _ => {}
         };
 
         // Done specifying what options are possible, so do the getopts parsing
@@ -201,21 +222,24 @@ pub fn parse(args: &[String]) -> Flags {
                 if check_subcommand != subcommand {
                     pass_sanity_check = false;
                 }
-            },
+            }
             None => {
                 pass_sanity_check = false;
             }
         }
         if !pass_sanity_check {
             println!("{}\n", subcommand_help);
-            println!("Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
-                      You may need to move some options to after the subcommand.\n");
+            println!(
+                "Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
+                 You may need to move some options to after the subcommand.\n"
+            );
             process::exit(1);
         }
         // Extra help text for some commands
         match subcommand.as_str() {
             "build" => {
-                subcommand_help.push_str("\n
+                subcommand_help.push_str(
+                    "\n
 Arguments:
     This subcommand accepts a number of paths to directories to the crates
     and/or artifacts to compile. For example:
@@ -237,10 +261,12 @@ pub fn parse(args: &[String]) -> Flags {
     This will first build everything once (like --stage 0 without further
     arguments would), and then use the compiler built in stage 0 to build
     src/libtest and its dependencies.
-    Once this is done, build/$ARCH/stage1 contains a usable compiler.");
+    Once this is done, build/$ARCH/stage1 contains a usable compiler.",
+                );
             }
             "check" => {
-                subcommand_help.push_str("\n
+                subcommand_help.push_str(
+                    "\n
 Arguments:
     This subcommand accepts a number of paths to directories to the crates
     and/or artifacts to compile. For example:
@@ -252,10 +278,12 @@ pub fn parse(args: &[String]) -> Flags {
     also that since we use `cargo check`, by default this will automatically enable incremental
     compilation, so there's no need to pass it separately, though it won't hurt. We also completely
     ignore the stage passed, as there's no way to compile in non-stage 0 without actually building
-    the compiler.");
+    the compiler.",
+                );
             }
             "test" => {
-                subcommand_help.push_str("\n
+                subcommand_help.push_str(
+                    "\n
 Arguments:
     This subcommand accepts a number of paths to directories to tests that
     should be compiled and run. For example:
@@ -270,10 +298,12 @@ pub fn parse(args: &[String]) -> Flags {
     compiled and tested.
 
         ./x.py test
-        ./x.py test --stage 1");
+        ./x.py test --stage 1",
+                );
             }
             "doc" => {
-                subcommand_help.push_str("\n
+                subcommand_help.push_str(
+                    "\n
 Arguments:
     This subcommand accepts a number of paths to directories of documentation
     to build. For example:
@@ -285,12 +315,16 @@ pub fn parse(args: &[String]) -> Flags {
     If no arguments are passed then everything is documented:
 
         ./x.py doc
-        ./x.py doc --stage 1");
+        ./x.py doc --stage 1",
+                );
             }
-            _ => { }
+            _ => {}
         };
         // Get any optional paths which occur after the subcommand
-        let paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>();
+        let paths = matches.free[1..]
+            .iter()
+            .map(|p| p.into())
+            .collect::<Vec<PathBuf>>();
 
         let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
             if fs::metadata("config.toml").is_ok() {
@@ -309,9 +343,12 @@ pub fn parse(args: &[String]) -> Flags {
             let maybe_rules_help = Builder::get_help(&build, subcommand.as_str());
             extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str());
         } else if subcommand.as_str() != "clean" {
-            extra_help.push_str(format!(
-                "Run `./x.py {} -h -v` to see a list of available paths.",
-                subcommand).as_str());
+            extra_help.push_str(
+                format!(
+                    "Run `./x.py {} -h -v` to see a list of available paths.",
+                    subcommand
+                ).as_str(),
+            );
         }
 
         // User passed in -h/--help?
@@ -320,38 +357,28 @@ pub fn parse(args: &[String]) -> Flags {
         }
 
         let cmd = match subcommand.as_str() {
-            "build" => {
-                Subcommand::Build { paths: paths }
-            }
-            "check" => {
-                Subcommand::Check { paths: paths }
-            }
-            "test" => {
-                Subcommand::Test {
-                    paths,
-                    bless: matches.opt_present("bless"),
-                    compare_mode: matches.opt_str("compare-mode"),
-                    test_args: matches.opt_strs("test-args"),
-                    rustc_args: matches.opt_strs("rustc-args"),
-                    fail_fast: !matches.opt_present("no-fail-fast"),
-                    doc_tests: if matches.opt_present("doc") {
-                        DocTests::Only
-                    } else if matches.opt_present("no-doc") {
-                        DocTests::No
-                    } else {
-                        DocTests::Yes
-                    }
-                }
-            }
-            "bench" => {
-                Subcommand::Bench {
-                    paths,
-                    test_args: matches.opt_strs("test-args"),
-                }
-            }
-            "doc" => {
-                Subcommand::Doc { paths: paths }
-            }
+            "build" => Subcommand::Build { paths: paths },
+            "check" => Subcommand::Check { paths: paths },
+            "test" => Subcommand::Test {
+                paths,
+                bless: matches.opt_present("bless"),
+                compare_mode: matches.opt_str("compare-mode"),
+                test_args: matches.opt_strs("test-args"),
+                rustc_args: matches.opt_strs("rustc-args"),
+                fail_fast: !matches.opt_present("no-fail-fast"),
+                doc_tests: if matches.opt_present("doc") {
+                    DocTests::Only
+                } else if matches.opt_present("no-doc") {
+                    DocTests::No
+                } else {
+                    DocTests::Yes
+                },
+            },
+            "bench" => Subcommand::Bench {
+                paths,
+                test_args: matches.opt_strs("test-args"),
+            },
+            "doc" => Subcommand::Doc { paths: paths },
             "clean" => {
                 if paths.len() > 0 {
                     println!("\nclean does not take a path argument\n");
@@ -362,22 +389,13 @@ pub fn parse(args: &[String]) -> Flags {
                     all: matches.opt_present("all"),
                 }
             }
-            "dist" => {
-                Subcommand::Dist {
-                    paths,
-                }
-            }
-            "install" => {
-                Subcommand::Install {
-                    paths,
-                }
-            }
+            "dist" => Subcommand::Dist { paths },
+            "install" => Subcommand::Install { paths },
             _ => {
                 usage(1, &opts, &subcommand_help, &extra_help);
             }
         };
 
-
         Flags {
             verbose: matches.opt_count("verbose"),
             stage: matches.opt_str("stage").map(|j| j.parse().unwrap()),
@@ -386,15 +404,21 @@ pub fn parse(args: &[String]) -> Flags {
             rustc_error_format: matches.opt_str("error-format"),
             keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
             host: split(matches.opt_strs("host"))
-                .into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(),
+                .into_iter()
+                .map(|x| INTERNER.intern_string(x))
+                .collect::<Vec<_>>(),
             target: split(matches.opt_strs("target"))
-                .into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(),
+                .into_iter()
+                .map(|x| INTERNER.intern_string(x))
+                .collect::<Vec<_>>(),
             config: cfg_file,
             jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()),
             cmd,
             incremental: matches.opt_present("incremental"),
             exclude: split(matches.opt_strs("exclude"))
-                .into_iter().map(|p| p.into()).collect::<Vec<_>>(),
+                .into_iter()
+                .map(|p| p.into())
+                .collect::<Vec<_>>(),
             warnings: matches.opt_str("warnings").map(|v| v == "deny"),
         }
     }
@@ -403,9 +427,11 @@ pub fn parse(args: &[String]) -> Flags {
 impl Subcommand {
     pub fn test_args(&self) -> Vec<&str> {
         match *self {
-            Subcommand::Test { ref test_args, .. } |
-            Subcommand::Bench { ref test_args, .. } => {
-                test_args.iter().flat_map(|s| s.split_whitespace()).collect()
+            Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
+                test_args
+                    .iter()
+                    .flat_map(|s| s.split_whitespace())
+                    .collect()
             }
             _ => Vec::new(),
         }
@@ -413,9 +439,10 @@ pub fn test_args(&self) -> Vec<&str> {
 
     pub fn rustc_args(&self) -> Vec<&str> {
         match *self {
-            Subcommand::Test { ref rustc_args, .. } => {
-                rustc_args.iter().flat_map(|s| s.split_whitespace()).collect()
-            }
+            Subcommand::Test { ref rustc_args, .. } => rustc_args
+                .iter()
+                .flat_map(|s| s.split_whitespace())
+                .collect(),
             _ => Vec::new(),
         }
     }
@@ -443,12 +470,17 @@ pub fn bless(&self) -> bool {
 
     pub fn compare_mode(&self) -> Option<&str> {
         match *self {
-            Subcommand::Test { ref compare_mode, .. } => compare_mode.as_ref().map(|s| &s[..]),
+            Subcommand::Test {
+                ref compare_mode, ..
+            } => compare_mode.as_ref().map(|s| &s[..]),
             _ => None,
         }
     }
 }
 
 fn split(s: Vec<String>) -> Vec<String> {
-    s.iter().flat_map(|s| s.split(',')).map(|s| s.to_string()).collect()
+    s.iter()
+        .flat_map(|s| s.split(','))
+        .map(|s| s.to_string())
+        .collect()
 }
index a0a51659ba3dccc4a1e41d7579c4e6ae27338365..92847786792156e1b44b01f9051fa2831ee4c9a6 100644 (file)
 
 use std::env;
 use std::ffi::OsString;
-use std::iter;
 use std::fmt;
 use std::fs::{self, File};
-use std::path::{PathBuf, Path};
-use std::process::Command;
 use std::io::Read;
+use std::iter;
+use std::path::{Path, PathBuf};
+use std::process::Command;
 
 use build_helper::{self, output};
 
-use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
-use Crate as CargoCrate;
-use cache::{INTERNER, Interned};
+use builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
+use cache::{Interned, INTERNER};
 use compile;
 use dist;
+use flags::Subcommand;
 use native;
 use tool::{self, Tool};
-use util::{self, dylib_path, dylib_path_var};
-use {Mode, DocTests};
 use toolstate::ToolState;
-use flags::Subcommand;
+use util::{self, dylib_path, dylib_path_var};
+use Crate as CargoCrate;
+use {DocTests, Mode};
 
 const ADB_TEST_DIR: &str = "/data/tmp/work";
 
@@ -52,7 +52,7 @@ fn from(kind: Kind) -> Self {
         match kind {
             Kind::Test => TestKind::Test,
             Kind::Bench => TestKind::Bench,
-            _ => panic!("unexpected kind in crate: {:?}", kind)
+            _ => panic!("unexpected kind in crate: {:?}", kind),
         }
     }
 }
@@ -124,13 +124,18 @@ fn run(self, builder: &Builder) {
         builder.default_doc(None);
 
         let _time = util::timeit(&builder);
-        try_run(builder, builder.tool_cmd(Tool::Linkchecker)
-                              .arg(builder.out.join(host).join("doc")));
+        try_run(
+            builder,
+            builder
+                .tool_cmd(Tool::Linkchecker)
+                .arg(builder.out.join(host).join("doc")),
+        );
     }
 
     fn should_run(run: ShouldRun) -> ShouldRun {
         let builder = run.builder;
-        run.path("src/tools/linkchecker").default_condition(builder.config.docs)
+        run.path("src/tools/linkchecker")
+            .default_condition(builder.config.docs)
     }
 
     fn make_run(run: RunConfig) {
@@ -165,7 +170,10 @@ fn make_run(run: RunConfig) {
     /// test` to ensure that we don't regress the test suites there.
     fn run(self, builder: &Builder) {
         let compiler = builder.compiler(self.stage, self.host);
-        builder.ensure(compile::Rustc { compiler, target: compiler.host });
+        builder.ensure(compile::Rustc {
+            compiler,
+            target: compiler.host,
+        });
 
         // Note that this is a short, cryptic, and not scoped directory name. This
         // is currently to minimize the length of path on Windows where we otherwise
@@ -175,10 +183,13 @@ fn run(self, builder: &Builder) {
 
         let _time = util::timeit(&builder);
         let mut cmd = builder.tool_cmd(Tool::CargoTest);
-        try_run(builder, cmd.arg(&builder.initial_cargo)
-                          .arg(&out_dir)
-                          .env("RUSTC", builder.rustc(compiler))
-                          .env("RUSTDOC", builder.rustdoc(compiler.host)));
+        try_run(
+            builder,
+            cmd.arg(&builder.initial_cargo)
+                .arg(&out_dir)
+                .env("RUSTC", builder.rustc(compiler))
+                .env("RUSTDOC", builder.rustdoc(compiler.host)),
+        );
     }
 }
 
@@ -207,9 +218,14 @@ fn make_run(run: RunConfig) {
     fn run(self, builder: &Builder) {
         let compiler = builder.compiler(self.stage, self.host);
 
-        builder.ensure(tool::Cargo { compiler, target: self.host });
+        builder.ensure(tool::Cargo {
+            compiler,
+            target: self.host,
+        });
         let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
-        cargo.arg("--manifest-path").arg(builder.src.join("src/tools/cargo/Cargo.toml"));
+        cargo
+            .arg("--manifest-path")
+            .arg(builder.src.join("src/tools/cargo/Cargo.toml"));
         if !builder.fail_fast {
             cargo.arg("--no-fail-fast");
         }
@@ -221,7 +237,10 @@ fn run(self, builder: &Builder) {
         // available.
         cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
 
-        try_run(builder, cargo.env("PATH", &path_for_cargo(builder, compiler)));
+        try_run(
+            builder,
+            cargo.env("PATH", &path_for_cargo(builder, compiler)),
+        );
     }
 }
 
@@ -262,11 +281,7 @@ fn run(self, builder: &Builder) {
             return;
         }
 
-        let mut cargo = tool::prepare_tool_cargo(builder,
-                                                 compiler,
-                                                 host,
-                                                 "test",
-                                                 "src/tools/rls");
+        let mut cargo = tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rls");
 
         // Don't build tests dynamically, just a pain to work with
         cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -316,11 +331,8 @@ fn run(self, builder: &Builder) {
             return;
         }
 
-        let mut cargo = tool::prepare_tool_cargo(builder,
-                                                 compiler,
-                                                 host,
-                                                 "test",
-                                                 "src/tools/rustfmt");
+        let mut cargo =
+            tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rustfmt");
 
         // Don't build tests dynamically, just a pain to work with
         cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -372,7 +384,9 @@ fn run(self, builder: &Builder) {
         });
         if let Some(miri) = miri {
             let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
-            cargo.arg("--manifest-path").arg(builder.src.join("src/tools/miri/Cargo.toml"));
+            cargo
+                .arg("--manifest-path")
+                .arg(builder.src.join("src/tools/miri/Cargo.toml"));
 
             // Don't build tests dynamically, just a pain to work with
             cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -428,7 +442,9 @@ fn run(self, builder: &Builder) {
         });
         if let Some(clippy) = clippy {
             let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
-            cargo.arg("--manifest-path").arg(builder.src.join("src/tools/clippy/Cargo.toml"));
+            cargo
+                .arg("--manifest-path")
+                .arg(builder.src.join("src/tools/clippy/Cargo.toml"));
 
             // Don't build tests dynamically, just a pain to work with
             cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -436,7 +452,9 @@ fn run(self, builder: &Builder) {
             cargo.env("SYSROOT", builder.sysroot(compiler));
             cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
             cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
-            let host_libs = builder.stage_out(compiler, Mode::Tool).join(builder.cargo_dir());
+            let host_libs = builder
+                .stage_out(compiler, Mode::Tool)
+                .join(builder.cargo_dir());
             cargo.env("HOST_LIBS", host_libs);
             // clippy tests need to find the driver
             cargo.env("CLIPPY_DRIVER_PATH", clippy);
@@ -478,23 +496,30 @@ fn should_run(run: ShouldRun) -> ShouldRun {
     fn make_run(run: RunConfig) {
         let compiler = run.builder.compiler(run.builder.top_stage, run.host);
 
-        run.builder.ensure(RustdocTheme {
-            compiler: compiler,
-        });
+        run.builder.ensure(RustdocTheme { compiler: compiler });
     }
 
     fn run(self, builder: &Builder) {
         let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
         let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
         cmd.arg(rustdoc.to_str().unwrap())
-           .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap())
-           .env("RUSTC_STAGE", self.compiler.stage.to_string())
-           .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
-           .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
-           .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
-           .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
-           .env("RUSTDOC_CRATE_VERSION", builder.rust_version())
-           .env("RUSTC_BOOTSTRAP", "1");
+            .arg(
+                builder
+                    .src
+                    .join("src/librustdoc/html/static/themes")
+                    .to_str()
+                    .unwrap(),
+            )
+            .env("RUSTC_STAGE", self.compiler.stage.to_string())
+            .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
+            .env(
+                "RUSTDOC_LIBDIR",
+                builder.sysroot_libdir(self.compiler, self.compiler.host),
+            )
+            .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
+            .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
+            .env("RUSTDOC_CRATE_VERSION", builder.rust_version())
+            .env("RUSTC_BOOTSTRAP", "1");
         if let Some(linker) = builder.linker(self.compiler.host) {
             cmd.env("RUSTC_TARGET_LINKER", linker);
         }
@@ -534,7 +559,9 @@ fn run(self, builder: &Builder) {
             });
             builder.run(&mut command);
         } else {
-            builder.info(&format!("No nodejs found, skipping \"src/test/rustdoc-js\" tests"));
+            builder.info(&format!(
+                "No nodejs found, skipping \"src/test/rustdoc-js\" tests"
+            ));
         }
     }
 }
@@ -918,7 +945,7 @@ fn run(self, builder: &Builder) {
 
             builder.ensure(dist::DebuggerScripts {
                 sysroot: builder.sysroot(compiler),
-                host: target
+                host: target,
             });
         }
 
@@ -926,7 +953,8 @@ fn run(self, builder: &Builder) {
             // FIXME: Does pretty need librustc compiled? Note that there are
             // fulldeps test suites with mode = pretty as well.
             mode == "pretty" ||
-            mode == "rustdoc" {
+            mode == "rustdoc"
+        {
             builder.ensure(compile::Rustc { compiler, target });
         }
 
@@ -939,26 +967,34 @@ fn run(self, builder: &Builder) {
         // compiletest currently has... a lot of arguments, so let's just pass all
         // of them!
 
-        cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
-        cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
+        cmd.arg("--compile-lib-path")
+            .arg(builder.rustc_libdir(compiler));
+        cmd.arg("--run-lib-path")
+            .arg(builder.sysroot_libdir(compiler, target));
         cmd.arg("--rustc-path").arg(builder.rustc(compiler));
 
         let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
 
         // Avoid depending on rustdoc when we don't need it.
-        if mode == "rustdoc" ||
-           (mode == "run-make" && suite.ends_with("fulldeps")) ||
-           (mode == "ui" && is_rustdoc_ui) {
-            cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
+        if mode == "rustdoc"
+            || (mode == "run-make" && suite.ends_with("fulldeps"))
+            || (mode == "ui" && is_rustdoc_ui)
+        {
+            cmd.arg("--rustdoc-path")
+                .arg(builder.rustdoc(compiler.host));
         }
 
-        cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
-        cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
-        cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
+        cmd.arg("--src-base")
+            .arg(builder.src.join("src/test").join(suite));
+        cmd.arg("--build-base")
+            .arg(testdir(builder, compiler.host).join(suite));
+        cmd.arg("--stage-id")
+            .arg(format!("stage{}-{}", compiler.stage, target));
         cmd.arg("--mode").arg(mode);
         cmd.arg("--target").arg(target);
         cmd.arg("--host").arg(&*compiler.host);
-        cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
+        cmd.arg("--llvm-filecheck")
+            .arg(builder.llvm_filecheck(builder.config.build));
 
         if builder.config.cmd.bless() {
             cmd.arg("--bless");
@@ -994,8 +1030,10 @@ fn run(self, builder: &Builder) {
         cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
 
         let mut targetflags = flags.clone();
-        targetflags.push(format!("-Lnative={}",
-                                 builder.test_helpers_out(target).display()));
+        targetflags.push(format!(
+            "-Lnative={}",
+            builder.test_helpers_out(target).display()
+        ));
         cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
 
         cmd.arg("--docck-python").arg(builder.python());
@@ -1021,13 +1059,16 @@ fn run(self, builder: &Builder) {
 
         // Get paths from cmd args
         let paths = match &builder.config.cmd {
-            Subcommand::Test { ref paths, ..} => &paths[..],
-            _ => &[]
+            Subcommand::Test { ref paths, .. } => &paths[..],
+            _ => &[],
         };
 
         // Get test-args by striping suite path
-        let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) &&
-           p.is_file()).map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap()).collect();
+        let mut test_args: Vec<&str> = paths
+            .iter()
+            .filter(|p| p.starts_with(suite_path) && p.is_file())
+            .map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
+            .collect();
 
         test_args.append(&mut builder.config.cmd.test_args());
 
@@ -1059,32 +1100,44 @@ fn run(self, builder: &Builder) {
             if !builder.config.dry_run && suite == "run-make-fulldeps" {
                 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
                 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
-                cmd.arg("--cc").arg(builder.cc(target))
-                .arg("--cxx").arg(builder.cxx(target).unwrap())
-                .arg("--cflags").arg(builder.cflags(target).join(" "))
-                .arg("--llvm-components").arg(llvm_components.trim())
-                .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
+                cmd.arg("--cc")
+                    .arg(builder.cc(target))
+                    .arg("--cxx")
+                    .arg(builder.cxx(target).unwrap())
+                    .arg("--cflags")
+                    .arg(builder.cflags(target).join(" "))
+                    .arg("--llvm-components")
+                    .arg(llvm_components.trim())
+                    .arg("--llvm-cxxflags")
+                    .arg(llvm_cxxflags.trim());
                 if let Some(ar) = builder.ar(target) {
                     cmd.arg("--ar").arg(ar);
                 }
             }
         }
         if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
-            builder.info(
-                &format!("Ignoring run-make test suite as they generally don't work without LLVM"));
+            builder.info(&format!(
+                "Ignoring run-make test suite as they generally don't work without LLVM"
+            ));
             return;
         }
 
         if suite != "run-make-fulldeps" {
-            cmd.arg("--cc").arg("")
-               .arg("--cxx").arg("")
-               .arg("--cflags").arg("")
-               .arg("--llvm-components").arg("")
-               .arg("--llvm-cxxflags").arg("");
+            cmd.arg("--cc")
+                .arg("")
+                .arg("--cxx")
+                .arg("")
+                .arg("--cflags")
+                .arg("")
+                .arg("--llvm-components")
+                .arg("")
+                .arg("--llvm-cxxflags")
+                .arg("");
         }
 
         if builder.remote_tested(target) {
-            cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
+            cmd.arg("--remote-test-client")
+                .arg(builder.tool_exe(Tool::RemoteTestClient));
         }
 
         // Running a C compiler on MSVC requires a few env vars to be set, to be
@@ -1117,7 +1170,7 @@ fn run(self, builder: &Builder) {
         if target.contains("android") {
             // Assume that cc for this target comes from the android sysroot
             cmd.arg("--android-cross-path")
-               .arg(builder.cc(target).parent().unwrap().parent().unwrap());
+                .arg(builder.cc(target).parent().unwrap().parent().unwrap());
         } else {
             cmd.arg("--android-cross-path").arg("");
         }
@@ -1125,16 +1178,20 @@ fn run(self, builder: &Builder) {
         builder.ci_env.force_coloring_in_ci(&mut cmd);
 
         let _folder = builder.fold_output(|| format!("test_{}", suite));
-        builder.info(&format!("Check compiletest suite={} mode={} ({} -> {})",
-                 suite, mode, &compiler.host, target));
+        builder.info(&format!(
+            "Check compiletest suite={} mode={} ({} -> {})",
+            suite, mode, &compiler.host, target
+        ));
         let _time = util::timeit(&builder);
         try_run(builder, &mut cmd);
 
         if let Some(compare_mode) = compare_mode {
             cmd.arg("--compare-mode").arg(compare_mode);
             let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
-            builder.info(&format!("Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
-                                  suite, mode, compare_mode, &compiler.host, target));
+            builder.info(&format!(
+                "Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
+                suite, mode, compare_mode, &compiler.host, target
+            ));
             let _time = util::timeit(&builder);
             try_run(builder, &mut cmd);
         }
@@ -1165,7 +1222,10 @@ fn should_run(run: ShouldRun) -> ShouldRun {
     fn run(self, builder: &Builder) {
         let compiler = self.compiler;
 
-        builder.ensure(compile::Test { compiler, target: compiler.host });
+        builder.ensure(compile::Test {
+            compiler,
+            target: compiler.host,
+        });
 
         // Do a breadth-first traversal of the `src/doc` directory and just run
         // tests for all files that end in `*.md`
@@ -1177,7 +1237,7 @@ fn run(self, builder: &Builder) {
         while let Some(p) = stack.pop() {
             if p.is_dir() {
                 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
-                continue
+                continue;
             }
 
             if p.extension().and_then(|s| s.to_str()) != Some("md") {
@@ -1284,7 +1344,10 @@ fn make_run(run: RunConfig) {
     fn run(self, builder: &Builder) {
         let compiler = self.compiler;
 
-        builder.ensure(compile::Std { compiler, target: compiler.host });
+        builder.ensure(compile::Std {
+            compiler,
+            target: compiler.host,
+        });
 
         let dir = testdir(builder, compiler.host);
         t!(fs::create_dir_all(&dir));
@@ -1296,7 +1359,6 @@ fn run(self, builder: &Builder) {
             .env("CFG_BUILD", &builder.config.build)
             .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
 
-
         let _folder = builder.fold_output(|| "test_error_index");
         builder.info(&format!("Testing error-index stage{}", compiler.stage));
         let _time = util::timeit(&builder);
@@ -1314,7 +1376,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool
                 return true;
             }
         }
-        Err(_) => {},
+        Err(_) => {}
     }
 
     builder.info(&format!("doc tests for: {}", markdown.display()));
@@ -1431,7 +1493,6 @@ fn run(self, builder: &Builder) {
     }
 }
 
-
 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
 pub struct Crate {
     pub compiler: Compiler,
@@ -1449,10 +1510,11 @@ fn should_run(mut run: ShouldRun) -> ShouldRun {
         let builder = run.builder;
         run = run.krate("test");
         for krate in run.builder.in_tree_crates("std") {
-            if krate.is_local(&run.builder) &&
-                !krate.name.contains("jemalloc") &&
-                !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) &&
-                krate.name != "dlmalloc" {
+            if krate.is_local(&run.builder)
+                && !krate.name.contains("jemalloc")
+                && !(krate.name.starts_with("rustc_") && krate.name.ends_with("san"))
+                && krate.name != "dlmalloc"
+            {
                 run = run.path(krate.local_path(&builder).to_str().unwrap());
             }
         }
@@ -1567,38 +1629,59 @@ fn run(self, builder: &Builder) {
         }
 
         if target.contains("emscripten") {
-            cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
-                      builder.config.nodejs.as_ref().expect("nodejs not configured"));
+            cargo.env(
+                format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
+                builder
+                    .config
+                    .nodejs
+                    .as_ref()
+                    .expect("nodejs not configured"),
+            );
         } else if target.starts_with("wasm32") {
             // Warn about running tests without the `wasm_syscall` feature enabled.
             // The javascript shim implements the syscall interface so that test
             // output can be correctly reported.
             if !builder.config.wasm_syscall {
-                builder.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \
-                          test output may not be visible."));
+                builder.info(&format!(
+                    "Libstd was built without `wasm_syscall` feature enabled: \
+                     test output may not be visible."
+                ));
             }
 
             // On the wasm32-unknown-unknown target we're using LTO which is
             // incompatible with `-C prefer-dynamic`, so disable that here
             cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
 
-            let node = builder.config.nodejs.as_ref()
+            let node = builder
+                .config
+                .nodejs
+                .as_ref()
                 .expect("nodejs not configured");
-            let runner = format!("{} {}/src/etc/wasm32-shim.js",
-                                 node.display(),
-                                 builder.src.display());
+            let runner = format!(
+                "{} {}/src/etc/wasm32-shim.js",
+                node.display(),
+                builder.src.display()
+            );
             cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
         } else if builder.remote_tested(target) {
-            cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
-                      format!("{} run",
-                              builder.tool_exe(Tool::RemoteTestClient).display()));
+            cargo.env(
+                format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
+                format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display()),
+            );
         }
 
         let _folder = builder.fold_output(|| {
-            format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
+            format!(
+                "{}_stage{}-{}",
+                test_kind.subcommand(),
+                compiler.stage,
+                krate
+            )
         });
-        builder.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
-                &compiler.host, target));
+        builder.info(&format!(
+            "{} {} stage{} ({} -> {})",
+            test_kind, krate, compiler.stage, &compiler.host, target
+        ));
         let _time = util::timeit(&builder);
         try_run(builder, &mut cargo);
     }
@@ -1636,11 +1719,13 @@ fn run(self, builder: &Builder) {
         let compiler = builder.compiler(builder.top_stage, self.host);
         let target = compiler.host;
 
-        let mut cargo = tool::prepare_tool_cargo(builder,
-                                                 compiler,
-                                                 target,
-                                                 test_kind.subcommand(),
-                                                 "src/tools/rustdoc");
+        let mut cargo = tool::prepare_tool_cargo(
+            builder,
+            compiler,
+            target,
+            test_kind.subcommand(),
+            "src/tools/rustdoc",
+        );
         if test_kind.subcommand() == "test" && !builder.fail_fast {
             cargo.arg("--no-fail-fast");
         }
@@ -1654,11 +1739,12 @@ fn run(self, builder: &Builder) {
             cargo.arg("--quiet");
         }
 
-        let _folder = builder.fold_output(|| {
-            format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
-        });
-        builder.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
-                &compiler.host, target));
+        let _folder = builder
+            .fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage));
+        builder.info(&format!(
+            "{} rustdoc stage{} ({} -> {})",
+            test_kind, compiler.stage, &compiler.host, target
+        ));
         let _time = util::timeit(&builder);
 
         try_run(builder, &mut cargo);
@@ -1666,12 +1752,13 @@ fn run(self, builder: &Builder) {
 }
 
 fn envify(s: &str) -> String {
-    s.chars().map(|c| {
-        match c {
+    s.chars()
+        .map(|c| match c {
             '-' => '_',
             c => c,
-        }
-    }).flat_map(|c| c.to_uppercase()).collect()
+        })
+        .flat_map(|c| c.to_uppercase())
+        .collect()
 }
 
 /// Some test suites are run inside emulators or on remote devices, and most
@@ -1700,7 +1787,7 @@ fn run(self, builder: &Builder) {
         let compiler = self.compiler;
         let target = self.target;
         if !builder.remote_tested(target) {
-            return
+            return;
         }
 
         builder.ensure(compile::Test { compiler, target });
@@ -1714,9 +1801,9 @@ fn run(self, builder: &Builder) {
         let tool = builder.tool_exe(Tool::RemoteTestClient);
         let mut cmd = Command::new(&tool);
         cmd.arg("spawn-emulator")
-           .arg(target)
-           .arg(&server)
-           .arg(builder.out.join("tmp"));
+            .arg(target)
+            .arg(&server)
+            .arg(builder.out.join("tmp"));
         if let Some(rootfs) = builder.qemu_rootfs(target) {
             cmd.arg(rootfs);
         }
@@ -1727,9 +1814,7 @@ fn run(self, builder: &Builder) {
             let f = t!(f);
             let name = f.file_name().into_string().unwrap();
             if util::is_dylib(&name) {
-                builder.run(Command::new(&tool)
-                                  .arg("push")
-                                  .arg(f.path()));
+                builder.run(Command::new(&tool).arg("push").arg(f.path()));
             }
         }
     }
@@ -1762,17 +1847,21 @@ fn run(self, builder: &Builder) {
 
         let mut cmd = Command::new("tar");
         cmd.arg("-xzf")
-           .arg(builder.ensure(dist::PlainSourceTarball))
-           .arg("--strip-components=1")
-           .current_dir(&dir);
+            .arg(builder.ensure(dist::PlainSourceTarball))
+            .arg("--strip-components=1")
+            .current_dir(&dir);
         builder.run(&mut cmd);
-        builder.run(Command::new("./configure")
-                         .args(&builder.config.configure_args)
-                         .arg("--enable-vendor")
-                         .current_dir(&dir));
-        builder.run(Command::new(build_helper::make(&builder.config.build))
-                         .arg("check")
-                         .current_dir(&dir));
+        builder.run(
+            Command::new("./configure")
+                .args(&builder.config.configure_args)
+                .arg("--enable-vendor")
+                .current_dir(&dir),
+        );
+        builder.run(
+            Command::new(build_helper::make(&builder.config.build))
+                .arg("check")
+                .current_dir(&dir),
+        );
 
         // Now make sure that rust-src has all of libstd's dependencies
         builder.info(&format!("Distcheck rust-src"));
@@ -1782,17 +1871,19 @@ fn run(self, builder: &Builder) {
 
         let mut cmd = Command::new("tar");
         cmd.arg("-xzf")
-           .arg(builder.ensure(dist::Src))
-           .arg("--strip-components=1")
-           .current_dir(&dir);
+            .arg(builder.ensure(dist::Src))
+            .arg("--strip-components=1")
+            .current_dir(&dir);
         builder.run(&mut cmd);
 
         let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
-        builder.run(Command::new(&builder.initial_cargo)
-                         .arg("generate-lockfile")
-                         .arg("--manifest-path")
-                         .arg(&toml)
-                         .current_dir(&dir));
+        builder.run(
+            Command::new(&builder.initial_cargo)
+                .arg("generate-lockfile")
+                .arg("--manifest-path")
+                .arg(&toml)
+                .current_dir(&dir),
+        );
     }
 }
 
@@ -1808,11 +1899,11 @@ impl Step for Bootstrap {
     fn run(self, builder: &Builder) {
         let mut cmd = Command::new(&builder.initial_cargo);
         cmd.arg("test")
-           .current_dir(builder.src.join("src/bootstrap"))
-           .env("RUSTFLAGS", "-Cdebuginfo=2")
-           .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
-           .env("RUSTC_BOOTSTRAP", "1")
-           .env("RUSTC", &builder.initial_rustc);
+            .current_dir(builder.src.join("src/bootstrap"))
+            .env("RUSTFLAGS", "-Cdebuginfo=2")
+            .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
+            .env("RUSTC_BOOTSTRAP", "1")
+            .env("RUSTC", &builder.initial_rustc);
         if let Some(flags) = option_env!("RUSTFLAGS") {
             // Use the same rustc flags for testing as for "normal" compilation,
             // so that Cargo doesn’t recompile the entire dependency graph every time:
index f1e0c2bea0e4043196b79b0211bbd3cd908e7e42..5daf192e2db2ed2224d2520a74ba9c2de1645e2a 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use common::CompareMode;
-use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
+use common::{expected_output_path, UI_FIXED, UI_STDERR, UI_STDOUT};
 use common::{output_base_dir, output_base_name, output_testname_unique};
 use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
 use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
@@ -24,8 +24,8 @@
 use rustfix::{apply_suggestions, get_suggestions_from_json};
 use util::{logv, PathBufExt};
 
-use std::collections::{HashMap, HashSet, VecDeque};
 use std::collections::hash_map::DefaultHasher;
+use std::collections::{HashMap, HashSet, VecDeque};
 use std::env;
 use std::ffi::OsString;
 use std::fmt;
@@ -48,9 +48,7 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
     }
 
     lazy_static! {
-        static ref LOCK: Mutex<()> = {
-            Mutex::new(())
-        };
+        static ref LOCK: Mutex<()> = { Mutex::new(()) };
     }
     // Error mode is a global variable, so lock it so only one thread will change it
     let _lock = LOCK.lock().unwrap();
@@ -743,7 +741,8 @@ fn run_debuginfo_gdb_test_no_opt(&self) {
             }
 
             _ => {
-                let rust_src_root = self.config
+                let rust_src_root = self
+                    .config
                     .find_rust_src_root()
                     .expect("Could not find Rust source root");
                 let rust_pp_module_rel_path = Path::new("./src/etc");
@@ -905,7 +904,8 @@ fn run_debuginfo_lldb_test_no_opt(&self) {
         script_str.push_str("version\n");
 
         // Switch LLDB into "Rust mode"
-        let rust_src_root = self.config
+        let rust_src_root = self
+            .config
             .find_rust_src_root()
             .expect("Could not find Rust source root");
         let rust_pp_module_rel_path = Path::new("./src/etc/lldb_rust_formatters.py");
@@ -1052,7 +1052,8 @@ fn cleanup_debug_info_options(&self, options: &Option<String>) -> Option<String>
 
         // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
         let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()];
-        let new_options = self.split_maybe_args(options)
+        let new_options = self
+            .split_maybe_args(options)
             .into_iter()
             .filter(|x| !options_to_remove.contains(x))
             .collect::<Vec<String>>();
@@ -1351,7 +1352,8 @@ fn document(&self, out_dir: &Path) -> ProcRes {
 
         let aux_dir = self.aux_output_dir_name();
 
-        let rustdoc_path = self.config
+        let rustdoc_path = self
+            .config
             .rustdoc_path
             .as_ref()
             .expect("--rustdoc-path passed");
@@ -1449,7 +1451,8 @@ fn exec_compiled_test(&self) -> ProcRes {
     /// For each `aux-build: foo/bar` annotation, we check to find the
     /// file in a `auxiliary` directory relative to the test itself.
     fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths {
-        let test_ab = self.testpaths
+        let test_ab = self
+            .testpaths
             .file
             .parent()
             .expect("test file path has no parent")
@@ -1464,7 +1467,8 @@ fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths {
 
         TestPaths {
             file: test_ab,
-            relative_dir: self.testpaths
+            relative_dir: self
+                .testpaths
                 .relative_dir
                 .join(self.output_testname_unique())
                 .join("auxiliary")
@@ -1617,16 +1621,20 @@ fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> C
         let mut rustc = if !is_rustdoc {
             Command::new(&self.config.rustc_path)
         } else {
-            Command::new(&self.config
-                .rustdoc_path
-                .clone()
-                .expect("no rustdoc built yet"))
+            Command::new(
+                &self
+                    .config
+                    .rustdoc_path
+                    .clone()
+                    .expect("no rustdoc built yet"),
+            )
         };
         // FIXME Why is -L here?
-        rustc.arg(input_file);//.arg("-L").arg(&self.config.build_base);
+        rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base);
 
         // Optionally prevent default --target if specified in test compile-flags.
-        let custom_target = self.props
+        let custom_target = self
+            .props
             .compile_flags
             .iter()
             .any(|x| x.starts_with("--target"));
@@ -1670,7 +1678,8 @@ fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> C
                 }
             }
             Ui => {
-                if !self.props
+                if !self
+                    .props
                     .compile_flags
                     .iter()
                     .any(|s| s.starts_with("--error-format"))
@@ -1704,7 +1713,13 @@ fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> C
         }
 
         if self.props.skip_codegen {
-            assert!(!self.props.compile_flags.iter().any(|s| s.starts_with("--emit")));
+            assert!(
+                !self
+                    .props
+                    .compile_flags
+                    .iter()
+                    .any(|s| s.starts_with("--emit"))
+            );
             rustc.args(&["--emit", "metadata"]);
         }
 
@@ -1812,7 +1827,8 @@ fn make_run_args(&self) -> ProcArgs {
 
     fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> {
         match *argstr {
-            Some(ref s) => s.split(' ')
+            Some(ref s) => s
+                .split(' ')
                 .filter_map(|s| {
                     if s.chars().all(|c| c.is_whitespace()) {
                         None
@@ -2125,7 +2141,8 @@ fn check_rustdoc_test_option(&self, res: ProcRes) {
         }
 
         let mut tested = 0;
-        for _ in res.stdout
+        for _ in res
+            .stdout
             .split('\n')
             .filter(|s| s.starts_with("test "))
             .inspect(|s| {
@@ -2136,7 +2153,8 @@ fn check_rustdoc_test_option(&self, res: ProcRes) {
                         tested += 1;
                         let mut iter = tmp[1].split("(line ");
                         iter.next();
-                        let line = iter.next()
+                        let line = iter
+                            .next()
                             .unwrap_or(")")
                             .split(')')
                             .next()
@@ -2290,7 +2308,8 @@ fn str_to_mono_item(s: &str) -> MonoItem {
 
             let full_string = format!("{}{}", PREFIX, s.trim().to_owned());
 
-            let parts: Vec<&str> = s.split(CGU_MARKER)
+            let parts: Vec<&str> = s
+                .split(CGU_MARKER)
                 .map(str::trim)
                 .filter(|s| !s.is_empty())
                 .collect();
@@ -2375,7 +2394,8 @@ fn run_incremental_test(&self) {
         // FIXME -- use non-incremental mode as an oracle? That doesn't apply
         // to #[rustc_dirty] and clean tests I guess
 
-        let revision = self.revision
+        let revision = self
+            .revision
             .expect("incremental tests require a list of revisions");
 
         // Incremental workproduct directory should have already been created.
@@ -2421,7 +2441,8 @@ fn incremental_dir(&self) -> PathBuf {
 
     fn run_rmake_test(&self) {
         let cwd = env::current_dir().unwrap();
-        let src_root = self.config
+        let src_root = self
+            .config
             .src_base
             .parent()
             .unwrap()
@@ -2438,8 +2459,10 @@ fn run_rmake_test(&self) {
         create_dir_all(&tmpdir).unwrap();
 
         let host = &self.config.host;
-        let make = if host.contains("bitrig") || host.contains("dragonfly")
-            || host.contains("freebsd") || host.contains("netbsd")
+        let make = if host.contains("bitrig")
+            || host.contains("dragonfly")
+            || host.contains("freebsd")
+            || host.contains("netbsd")
             || host.contains("openbsd")
         {
             "gmake"
@@ -2494,7 +2517,8 @@ fn run_rmake_test(&self) {
             // MSYS doesn't like passing flags of the form `/foo` as it thinks it's
             // a path and instead passes `C:\msys64\foo`, so convert all
             // `/`-arguments to MSVC here to `-` arguments.
-            let cflags = self.config
+            let cflags = self
+                .config
                 .cflags
                 .split(' ')
                 .map(|s| s.replace("/", "-"))
@@ -2516,7 +2540,8 @@ fn run_rmake_test(&self) {
             }
         }
 
-        let output = cmd.spawn()
+        let output = cmd
+            .spawn()
             .and_then(read2_abbreviated)
             .expect("failed to spawn `make`");
         if !output.status.success() {
@@ -2557,7 +2582,8 @@ fn run_ui_test(&self) {
         // if the user specified a format in the ui test
         // print the output to the stderr file, otherwise extract
         // the rendered error messages from json and print them
-        let explicit = self.props
+        let explicit = self
+            .props
             .compile_flags
             .iter()
             .any(|s| s.contains("--error-format"));
@@ -2587,22 +2613,27 @@ fn run_ui_test(&self) {
             // don't test rustfix with nll right now
         } else if self.props.run_rustfix {
             // Apply suggestions from rustc to the code itself
-            let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
+            let unfixed_code = self
+                .load_expected_output_from_path(&self.testpaths.file)
                 .unwrap();
             let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
-            let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect(
-                &format!("failed to apply suggestions for {:?} with rustfix", self.testpaths.file)
-            );
+            let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect(&format!(
+                "failed to apply suggestions for {:?} with rustfix",
+                self.testpaths.file
+            ));
 
             errors += self.compare_output("fixed", &fixed_code, &expected_fixed);
         } else if !expected_fixed.is_empty() {
-            panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \
-                    file was found");
+            panic!(
+                "the `// run-rustfix` directive wasn't found but a `*.fixed` \
+                 file was found"
+            );
         }
 
         if errors > 0 {
             println!("To update references, rerun the tests and pass the `--bless` flag");
-            let relative_path_to_file = self.testpaths
+            let relative_path_to_file = self
+                .testpaths
                 .relative_dir
                 .join(self.testpaths.file.file_name().unwrap());
             println!(
@@ -2784,11 +2815,7 @@ fn compare_mir_test_output(&self, test_name: &str, expected_content: &[ExpectedL
                  Test Name: {}\n\
                  Expected:\n{}\n\
                  Actual:\n{}",
-                extra_msg,
-                expected_line,
-                test_name,
-                expected_content,
-                normalize_all
+                extra_msg, expected_line, test_name, expected_content, normalize_all
             );
         };
 
@@ -2904,7 +2931,12 @@ fn expected_output_path(&self, kind: &str) -> PathBuf {
 
         if !path.exists() {
             if let Some(CompareMode::Polonius) = self.config.compare_mode {
-                path = expected_output_path(&self.testpaths, self.revision, &Some(CompareMode::Nll), kind);
+                path = expected_output_path(
+                    &self.testpaths,
+                    self.revision,
+                    &Some(CompareMode::Nll),
+                    kind,
+                );
             }
         }
 
@@ -2973,7 +3005,8 @@ fn compare_output(&self, kind: &str, actual: &str, expected: &str) -> usize {
         }
 
         let mode = self.config.compare_mode.as_ref().map_or("", |m| m.to_str());
-        let output_file = self.output_base_name()
+        let output_file = self
+            .output_base_name()
             .with_extra_extension(self.revision.unwrap_or(""))
             .with_extra_extension(mode)
             .with_extra_extension(kind);
@@ -3023,7 +3056,8 @@ fn compare_output(&self, kind: &str, actual: &str, expected: &str) -> usize {
 
     fn create_stamp(&self) {
         let mut f = File::create(::stamp(&self.config, self.testpaths, self.revision)).unwrap();
-        f.write_all(compute_stamp_hash(&self.config).as_bytes()).unwrap();
+        f.write_all(compute_stamp_hash(&self.config).as_bytes())
+            .unwrap();
     }
 }