From 9df0a41321b8dd3fc48da9b34b3f79b0c37051b7 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 28 May 2018 15:30:02 -0300 Subject: [PATCH 1/3] Add polonius compare mode --- src/tools/compiletest/src/common.rs | 3 +++ src/tools/compiletest/src/runtest.rs | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index b2ce5ce52f719..951a72fec6891 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -99,18 +99,21 @@ impl fmt::Display for Mode { #[derive(Clone, PartialEq)] pub enum CompareMode { Nll, + Polonius, } impl CompareMode { pub(crate) fn to_str(&self) -> &'static str { match *self { CompareMode::Nll => "nll", + CompareMode::Polonius => "polonius", } } pub fn parse(s: String) -> CompareMode { match s.as_str() { "nll" => CompareMode::Nll, + "polonius" => CompareMode::Polonius, x => panic!("unknown --compare-mode option: {}", x), } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9ff80cc1d3c30..f1e0c2bea0e40 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1729,6 +1729,9 @@ impl<'test> TestCx<'test> { Some(CompareMode::Nll) => { rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]); } + Some(CompareMode::Polonius) => { + rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]); + } None => {} } @@ -2898,8 +2901,14 @@ impl<'test> TestCx<'test> { &self.config.compare_mode, kind, ); - if !path.exists() && self.config.compare_mode.is_some() { - // fallback! + + if !path.exists() { + if let Some(CompareMode::Polonius) = self.config.compare_mode { + path = expected_output_path(&self.testpaths, self.revision, &Some(CompareMode::Nll), kind); + } + } + + if !path.exists() { path = expected_output_path(&self.testpaths, self.revision, &None, kind); } From b970feedc272f324a27103b39d5d0b67646d10f0 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 28 May 2018 19:44:33 -0300 Subject: [PATCH 2/3] Add compare-mode to x.py --- src/bootstrap/builder.rs | 1 + src/bootstrap/flags.rs | 11 +++++++++++ src/bootstrap/test.rs | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f84ddf8a17d13..e987d3fa4fa6e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1457,6 +1457,7 @@ mod __test { fail_fast: true, doc_tests: DocTests::No, bless: false, + compare_mode: None, }; let build = Build::new(config); diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 90dd5d819b0da..f1473d19393aa 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -61,6 +61,7 @@ pub enum Subcommand { paths: Vec, /// Whether to automatically update stderr/stdout files bless: bool, + compare_mode: Option, test_args: Vec, rustc_args: Vec, fail_fast: bool, @@ -176,6 +177,7 @@ To learn more about a subcommand, run `./x.py -h`"); 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"); }, @@ -262,6 +264,7 @@ Arguments: ./x.py test src/libstd --test-args hash_map ./x.py test src/libstd --stage 0 ./x.py test src/test/ui --bless + ./x.py test src/test/ui --compare-mode nll If no arguments are passed then the complete artifacts for that stage are compiled and tested. @@ -327,6 +330,7 @@ Arguments: 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"), @@ -436,6 +440,13 @@ impl Subcommand { _ => false, } } + + pub fn compare_mode(&self) -> Option<&str> { + match *self { + Subcommand::Test { ref compare_mode, .. } => compare_mode.as_ref().map(|s| &s[..]), + _ => None, + } + } } fn split(s: Vec) -> Vec { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 7a4924f03c8d2..a0a51659ba3dc 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -887,7 +887,6 @@ impl Step for Compiletest { let target = self.target; let mode = self.mode; let suite = self.suite; - let compare_mode = self.compare_mode; // Path for test suite let suite_path = self.path.unwrap_or(""); @@ -965,6 +964,8 @@ impl Step for Compiletest { cmd.arg("--bless"); } + let compare_mode = builder.config.cmd.compare_mode().or(self.compare_mode); + if let Some(ref nodejs) = builder.config.nodejs { cmd.arg("--nodejs").arg(nodejs); } From b39a1d6f1a30ba29f25d7141038b9a5bf0126e36 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 30 May 2018 14:33:43 -0300 Subject: [PATCH 3/3] Run rustfmt --- src/bootstrap/builder.rs | 1246 ++++++++++++++++---------- src/bootstrap/flags.rs | 228 +++-- src/bootstrap/test.rs | 391 ++++---- src/tools/compiletest/src/runtest.rs | 124 ++- 4 files changed, 1206 insertions(+), 783 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index e987d3fa4fa6e..4fdb36b3f6e95 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -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; @@ -18,26 +19,25 @@ use std::hash::Hash; 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), - Suite (PathBuf) + Set(BTreeSet), + Suite(PathBuf), } impl PathSet { @@ -130,14 +130,18 @@ impl 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 @@ impl StepDescription { 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 @@ impl StepDescription { } fn run(v: &[StepDescription], builder: &Builder, paths: &[PathBuf]) { - let should_runs = v.iter().map(|desc| { - (desc.should_run)(ShouldRun::new(builder)) - }).collect::>(); + let should_runs = v + .iter() + .map(|desc| (desc.should_run)(ShouldRun::new(builder))) + .collect::>(); // 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 @@ impl<'a> ShouldRun<'a> { // 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 @@ impl<'a> Builder<'a> { }}; } 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 @@ impl<'a> Builder<'a> { } 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 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { /// obtained through this function, since it ensures that they are valid /// (i.e., built and assembled). pub fn compiler(&self, stage: u32, host: Interned) -> 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 { @@ -467,7 +577,9 @@ impl<'a> Builder<'a> { /// 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 + &self, + compiler: Compiler, + target: Interned, ) -> Interned { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] struct Libdir { @@ -489,8 +601,12 @@ impl<'a> Builder<'a> { } 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 @@ impl<'a> Builder<'a> { // 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 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { /// 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, - cmd: &str) -> Command { + pub fn cargo( + &self, + compiler: Compiler, + mode: Mode, + target: Interned, + 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 @@ impl<'a> Builder<'a> { } 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 @@ impl<'a> Builder<'a> { // // 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 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { // 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 @@ impl<'a> Builder<'a> { // 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 @@ impl<'a> Builder<'a> { } }; 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 @@ impl<'a> Builder<'a> { let mut stack = self.stack.borrow_mut(); for stack_step in stack.iter() { // should skip - if stack_step.downcast_ref::().map_or(true, |stack_step| *stack_step != step) { + if stack_step + .downcast_ref::() + .map_or(true, |stack_step| *stack_step != step) + { continue; } let mut out = String::new(); @@ -909,7 +1063,9 @@ impl<'a> Builder<'a> { { 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 @@ impl<'a> Builder<'a> { { 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 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { 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 @@ impl<'a> Builder<'a> { #[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 @@ mod __test { 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::>(); - config.targets = config.hosts.clone().into_iter() - .chain(target.iter().map(|s| INTERNER.intern_str(s))).collect::>(); + config.hosts = vec![config.build] + .clone() + .into_iter() + .chain(host.iter().map(|s| INTERNER.intern_str(s))) + .collect::>(); + config.targets = config + .hosts + .clone() + .into_iter() + .chain(target.iter().map(|s| INTERNER.intern_str(s))) + .collect::>(); config } @@ -1004,21 +1179,27 @@ mod __test { let a = INTERNER.intern_str("A"); - assert_eq!(first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Mingw { host: a }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Std { + assert_eq!( + first(builder.cache.all::()), + &[dist::Docs { stage: 2, host: a },] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Mingw { host: a },] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + },] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Std { compiler: Compiler { host: a, stage: 2 }, target: a, - }, - ]); + },] + ); assert_eq!(first(builder.cache.all::()), &[dist::Src]); } @@ -1031,27 +1212,36 @@ mod __test { let a = INTERNER.intern_str("A"); let b = INTERNER.intern_str("B"); - assert_eq!(first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Mingw { host: a }, - dist::Mingw { host: b }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - 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 { stage: 2, host: a }, + dist::Docs { stage: 2, host: b }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Mingw { host: a }, dist::Mingw { host: b },] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + },] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + 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]); } @@ -1064,28 +1254,41 @@ mod __test { let a = INTERNER.intern_str("A"); let b = INTERNER.intern_str("B"); - assert_eq!(first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Mingw { host: a }, - dist::Mingw { host: b }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - 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 { stage: 2, host: a }, + dist::Docs { stage: 2, host: b }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Mingw { host: a }, dist::Mingw { host: b },] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + }, + dist::Rustc { + compiler: Compiler { host: b, stage: 2 } + }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + 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]); } @@ -1099,34 +1302,50 @@ mod __test { let b = INTERNER.intern_str("B"); let c = INTERNER.intern_str("C"); - assert_eq!(first(builder.cache.all::()), &[ - 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 { host: a }, - dist::Mingw { host: b }, - dist::Mingw { host: c }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - 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 { stage: 2, host: a }, + dist::Docs { stage: 2, host: b }, + dist::Docs { stage: 2, host: c }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + dist::Mingw { host: a }, + dist::Mingw { host: b }, + dist::Mingw { host: c }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + }, + dist::Rustc { + compiler: Compiler { host: b, stage: 2 } + }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + 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]); } @@ -1142,31 +1361,40 @@ mod __test { let b = INTERNER.intern_str("B"); let c = INTERNER.intern_str("C"); - assert_eq!(first(builder.cache.all::()), &[ - 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 { host: a }, - dist::Mingw { host: b }, - dist::Mingw { host: c }, - ]); + assert_eq!( + first(builder.cache.all::()), + &[ + 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 { host: a }, + dist::Mingw { host: b }, + dist::Mingw { host: c }, + ] + ); assert_eq!(first(builder.cache.all::()), &[]); - assert_eq!(first(builder.cache.all::()), &[ - 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 { + 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::()), &[]); } @@ -1179,87 +1407,109 @@ mod __test { let a = INTERNER.intern_str("A"); let b = INTERNER.intern_str("B"); - assert_eq!(first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Mingw { host: a }, - dist::Mingw { host: b }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, - ]); - assert_eq!(first(builder.cache.all::()), &[ - 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 { stage: 2, host: a }, + dist::Docs { stage: 2, host: b }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[dist::Mingw { host: a }, dist::Mingw { host: b },] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + }, + dist::Rustc { + compiler: Compiler { host: b, stage: 2 } + }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + 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]); - assert_eq!(first(builder.cache.all::()), &[ - 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 { - 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 { - 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 { + 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 { + 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 { + 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 @@ mod __test { assert!(!builder.cache.all::().is_empty()); assert!(!builder.cache.all::().is_empty()); - assert_eq!(first(builder.cache.all::()), &[ - 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 { - 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 { + 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 { + 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 @@ mod __test { let c = INTERNER.intern_str("C"); assert!(!builder.cache.all::().is_empty()); - assert_eq!(first(builder.cache.all::()), &[ - 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 { - 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 { - 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 { + 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 { + 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 { + 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 @@ mod __test { // Ensure we don't build any compiler artifacts. assert!(builder.cache.all::().is_empty()); - assert_eq!(first(builder.cache.all::()), &[ - test::Crate { + assert_eq!( + first(builder.cache.all::()), + &[test::Crate { compiler: Compiler { host, stage: 0 }, target: host, mode: Mode::Libstd, test_kind: test::TestKind::Test, krate: INTERNER.intern_str("std"), - }, - ]); + },] + ); } } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index f1473d19393aa..e5dceccdf8b9e 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -19,10 +19,10 @@ use std::process; 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 @@ impl Default for 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 [options] [...] Subcommands: @@ -106,7 +107,8 @@ Subcommands: dist Build distribution artifacts install Install distribution artifacts -To learn more about a subcommand, run `./x.py -h`"); +To learn more about a subcommand, run `./x.py -h`" + ); let mut opts = Options::new(); // Options common to all subcommands @@ -124,33 +126,39 @@ To learn more about a subcommand, run `./x.py -h`"); 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 @@ To learn more about a subcommand, run `./x.py -h`"); // 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 @@ To learn more about a subcommand, run `./x.py -h`"); ); 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 @@ To learn more about a subcommand, run `./x.py -h`"); 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 @@ Arguments: 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 @@ Arguments: 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 @@ Arguments: 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 @@ Arguments: 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::>(); + let paths = matches.free[1..] + .iter() + .map(|p| p.into()) + .collect::>(); let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| { if fs::metadata("config.toml").is_ok() { @@ -309,9 +343,12 @@ Arguments: 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 @@ Arguments: } 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 @@ Arguments: 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 @@ Arguments: 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::>(), + .into_iter() + .map(|x| INTERNER.intern_string(x)) + .collect::>(), target: split(matches.opt_strs("target")) - .into_iter().map(|x| INTERNER.intern_string(x)).collect::>(), + .into_iter() + .map(|x| INTERNER.intern_string(x)) + .collect::>(), 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::>(), + .into_iter() + .map(|p| p.into()) + .collect::>(), warnings: matches.opt_str("warnings").map(|v| v == "deny"), } } @@ -403,9 +427,11 @@ Arguments: 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 @@ impl Subcommand { 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 @@ impl Subcommand { 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) -> Vec { - 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() } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a0a51659ba3dc..9284778679215 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -15,26 +15,26 @@ 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 @@ impl From for TestKind { 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 @@ impl Step for Linkcheck { 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 @@ impl Step for Cargotest { /// 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 @@ impl Step for Cargotest { 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 @@ impl Step for Cargo { 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 @@ impl Step for Cargo { // 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 @@ impl Step for Rls { 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 @@ impl Step for Rustfmt { 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 @@ impl Step for Miri { }); 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 @@ impl Step for Clippy { }); 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 @@ impl Step for Clippy { 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 @@ impl Step for RustdocTheme { 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 @@ impl Step for RustdocJS { }); 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 @@ impl Step for Compiletest { builder.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), - host: target + host: target, }); } @@ -926,7 +953,8 @@ impl Step for Compiletest { // 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 @@ impl Step for Compiletest { // 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 @@ impl Step for Compiletest { 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 @@ impl Step for Compiletest { // 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 @@ impl Step for Compiletest { 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 @@ impl Step for Compiletest { 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 @@ impl Step for Compiletest { 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 @@ impl Step for DocTest { 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 @@ impl Step for DocTest { 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 @@ impl Step for ErrorIndex { 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 @@ impl Step for ErrorIndex { .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 @@ impl Step for CrateNotDefault { } } - #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Crate { pub compiler: Compiler, @@ -1449,10 +1510,11 @@ impl Step for Crate { 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 @@ impl Step for Crate { } 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 @@ impl Step for CrateRustdoc { 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 @@ impl Step for CrateRustdoc { 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 @@ impl Step for CrateRustdoc { } 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 @@ impl Step for RemoteCopyLibs { 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 @@ impl Step for RemoteCopyLibs { 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 @@ impl Step for RemoteCopyLibs { 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 @@ impl Step for Distcheck { 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 @@ impl Step for Distcheck { 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: diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index f1e0c2bea0e40..5daf192e2db2e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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 regex::Regex; 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 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 @@ impl<'test> TestCx<'test> { } _ => { - 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { // 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::>(); @@ -1351,7 +1352,8 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { /// 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { } } Ui => { - if !self.props + if !self + .props .compile_flags .iter() .any(|s| s.starts_with("--error-format")) @@ -1704,7 +1713,13 @@ impl<'test> TestCx<'test> { } 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 @@ impl<'test> TestCx<'test> { fn split_maybe_args(&self, argstr: &Option) -> Vec { 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 @@ impl<'test> TestCx<'test> { } 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { // 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { // 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 @@ impl<'test> TestCx<'test> { } } - 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 @@ impl<'test> TestCx<'test> { // 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 @@ impl<'test> TestCx<'test> { // 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { } 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 @@ impl<'test> TestCx<'test> { 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(); } }