From a82db656fddc37d40d1fd4dd3da87f703478e59a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 4 Nov 2017 20:05:10 +0100 Subject: [PATCH 1/2] cargo fmt --- src/cargo.rs | 60 ++++++++--------------- src/cli.rs | 6 +-- src/extensions.rs | 17 +++---- src/flock.rs | 31 +++++------- src/main.rs | 48 +++++++------------ src/rustc.rs | 34 ++++++++----- src/sysroot.rs | 120 ++++++++++++++++++++-------------------------- src/util.rs | 12 ++--- src/xargo.rs | 9 ++-- tests/smoke.rs | 66 ++++++++++--------------- 10 files changed, 164 insertions(+), 239 deletions(-) diff --git a/src/cargo.rs b/src/cargo.rs index 39e5f59..d0e53a5 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -26,9 +26,7 @@ impl Rustflags { while let Some(flag) = flags.next() { if flag == "-C" { if let Some(next) = flags.next() { - if next.starts_with("link-arg=") || - next.starts_with("link-args=") - { + if next.starts_with("link-arg=") || next.starts_with("link-args=") { // don't hash linker arguments } else { flag.hash(hasher); @@ -55,7 +53,6 @@ impl Rustflags { impl fmt::Display for Rustflags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.flags.join(" "), f) - } } @@ -76,10 +73,7 @@ impl Rustdocflags { } } -pub fn rustdocflags( - config: Option<&Config>, - target: &str, -) -> Result { +pub fn rustdocflags(config: Option<&Config>, target: &str) -> Result { flags(config, target, "rustdocflags").map(|fs| Rustdocflags { flags: fs }) } @@ -87,11 +81,7 @@ pub fn rustdocflags( /// Returns the flags for `tool` (e.g. rustflags) /// /// This looks into the environment and into `.cargo/config` -fn flags( - config: Option<&Config>, - target: &str, - tool: &str, -) -> Result> { +fn flags(config: Option<&Config>, target: &str, tool: &str) -> Result> { if let Some(t) = env::var_os(tool.to_uppercase()) { return Ok( t.to_string_lossy() @@ -109,8 +99,7 @@ fn flags( .or_else(|| { build = true; config.table.lookup(&format!("build.{}", tool)) - }) - { + }) { let mut flags = vec![]; let mut error = false; @@ -131,13 +120,13 @@ fn flags( if build { Err(format!( ".cargo/config: build.{} must be an array \ - of strings", + of strings", tool ))? } else { Err(format!( ".cargo/config: target.{}.{} must be an \ - array of strings", + array of strings", target, tool ))? @@ -154,9 +143,9 @@ fn flags( } pub fn run(args: &Args, verbose: bool) -> Result { - Command::new("cargo").args(args.all()).run_and_get_status( - verbose, - ) + Command::new("cargo") + .args(args.all()) + .run_and_get_status(verbose) } pub struct Config { @@ -166,11 +155,8 @@ pub struct Config { impl Config { pub fn target(&self) -> Result> { if let Some(v) = self.table.lookup("build.target") { - Ok(Some( - v.as_str().ok_or_else( - || format!(".cargo/config: build.target must be a string"), - )?, - )) + Ok(Some(v.as_str() + .ok_or_else(|| format!(".cargo/config: build.target must be a string"))?)) } else { Ok(None) } @@ -178,14 +164,12 @@ impl Config { } pub fn config() -> Result> { - let cd = env::current_dir().chain_err( - || "couldn't get the current directory", - )?; + let cd = env::current_dir().chain_err(|| "couldn't get the current directory")?; if let Some(p) = util::search(&cd, ".cargo/config") { - Ok(Some( - Config { table: util::parse(&p.join(".cargo/config"))? }, - )) + Ok(Some(Config { + table: util::parse(&p.join(".cargo/config"))?, + })) } else { Ok(None) } @@ -237,9 +221,9 @@ pub struct Toml { impl Toml { /// `profile.release` part of `Cargo.toml` pub fn profile(&self) -> Option { - self.table.lookup("profile.release").map( - |t| Profile { table: t }, - ) + self.table + .lookup("profile.release") + .map(|t| Profile { table: t }) } } @@ -258,13 +242,9 @@ impl Root { } pub fn root() -> Result> { - let cd = env::current_dir().chain_err( - || "couldn't get the current directory", - )?; + let cd = env::current_dir().chain_err(|| "couldn't get the current directory")?; - Ok( - util::search(&cd, "Cargo.toml").map(|p| Root { path: p.to_owned() }), - ) + Ok(util::search(&cd, "Cargo.toml").map(|p| Root { path: p.to_owned() })) } #[derive(Clone, Copy, PartialEq)] diff --git a/src/cli.rs b/src/cli.rs index 96a4a0b..1d24a07 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -22,9 +22,9 @@ impl Args { } pub fn verbose(&self) -> bool { - self.all.iter().any(|a| { - a == "--verbose" || a == "-v" || a == "-vv" - }) + self.all + .iter() + .any(|a| a == "--verbose" || a == "-v" || a == "-vv") } pub fn version(&self) -> bool { diff --git a/src/extensions.rs b/src/extensions.rs index b5375f4..10d0293 100644 --- a/src/extensions.rs +++ b/src/extensions.rs @@ -32,9 +32,8 @@ impl CommandExt for Command { writeln!(io::stderr(), "+ {:?}", self).ok(); } - self.status().chain_err( - || format!("couldn't execute `{:?}`", self), - ) + self.status() + .chain_err(|| format!("couldn't execute `{:?}`", self)) } /// Runs the command to completion and returns its stdout @@ -43,16 +42,12 @@ impl CommandExt for Command { writeln!(io::stderr(), "+ {:?}", self).ok(); } - let out = self.output().chain_err( - || format!("couldn't execute `{:?}`", self), - )?; + let out = self.output() + .chain_err(|| format!("couldn't execute `{:?}`", self))?; if out.status.success() { - Ok( - String::from_utf8(out.stdout).chain_err(|| { - format!("`{:?}` output was not UTF-8", self) - })?, - ) + Ok(String::from_utf8(out.stdout) + .chain_err(|| format!("`{:?}` output was not UTF-8", self))?) } else { Err(format!( "`{:?}` failed with exit code: {:?}", diff --git a/src/flock.rs b/src/flock.rs index 501e6be..2224020 100644 --- a/src/flock.rs +++ b/src/flock.rs @@ -96,16 +96,14 @@ impl Filesystem { ) -> io::Result { let path = self.path.join(path); - let f = opts.open(&path).or_else( - |e| if e.kind() == io::ErrorKind::NotFound && - state == State::Exclusive - { + let f = opts.open(&path).or_else(|e| { + if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive { create_dir_all(path.parent().unwrap())?; opts.open(&path) } else { Err(e) - }, - )?; + } + })?; match state { State::Exclusive => { @@ -117,12 +115,7 @@ impl Filesystem { )?; } State::Shared => { - acquire( - msg, - &path, - &|| f.try_lock_shared(), - &|| f.lock_shared(), - )?; + acquire(msg, &path, &|| f.try_lock_shared(), &|| f.lock_shared())?; } } @@ -180,14 +173,13 @@ fn acquire( match try() { Ok(_) => return Ok(()), #[cfg(target_os = "macos")] - Err(ref e) if e.raw_os_error() == Some(::libc::ENOTSUP) => { + Err(ref e) if e.raw_os_error() == Some(::libc::ENOTSUP) => + { return Ok(()) } - Err(e) => { - if e.raw_os_error() != fs2::lock_contended_error().raw_os_error() { - return Err(e); - } - } + Err(e) => if e.raw_os_error() != fs2::lock_contended_error().raw_os_error() { + return Err(e); + }, } writeln!( @@ -195,8 +187,7 @@ fn acquire( "{:>12} waiting for file lock on {}", "Blocking", msg - ) - .ok(); + ).ok(); block() } diff --git a/src/main.rs b/src/main.rs index 881cd86..2575d16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,7 @@ #[macro_use] extern crate error_chain; extern crate fs2; -#[cfg(any(all(target_os = "linux", not(target_env = "musl")), - target_os = "macos"))] +#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "macos"))] extern crate libc; extern crate rustc_version; extern crate serde_json; @@ -93,20 +92,14 @@ pub fn main() { writeln!(stderr, "{:?}", backtrace).ok(); } } else { - writeln!( - stderr, - "note: run with `RUST_BACKTRACE=1` for a backtrace" - ) - .ok(); + writeln!(stderr, "note: run with `RUST_BACKTRACE=1` for a backtrace").ok(); } process::exit(1) } - Ok(status) => { - if !status.success() { - process::exit(status.code().unwrap_or(1)) - } - } + Ok(status) => if !status.success() { + process::exit(status.code().unwrap_or(1)) + }, } } @@ -125,8 +118,7 @@ fn run() -> Result { io::stderr(), concat!("xargo ", env!("CARGO_PKG_VERSION"), "{}"), include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")) - ) - .ok(); + ).ok(); return cargo::run(&args, verbose); } @@ -140,21 +132,21 @@ fn run() -> Result { let src = match meta.channel { Channel::Dev => rustc::Src::from_env().ok_or( "The XARGO_RUST_SRC env variable must be set and point to the \ - Rust source directory when working with the 'dev' channel")?, - Channel::Nightly => { - if let Some(src) = rustc::Src::from_env() { - src - } else { - sysroot.src()? - } - } + Rust source directory when working with the 'dev' channel", + )?, + Channel::Nightly => if let Some(src) = rustc::Src::from_env() { + src + } else { + sysroot.src()? + }, Channel::Stable | Channel::Beta => { writeln!( io::stderr(), "WARNING: the sysroot can't be built for the {:?} channel. \ Switch to nightly.", - meta.channel).ok(); - return cargo::run(&args, verbose) + meta.channel + ).ok(); + return cargo::run(&args, verbose); } }; @@ -167,16 +159,12 @@ fn run() -> Result { } else if triple == meta.host { Some(CompilationMode::Native(meta.host.clone())) } else { - Target::new(triple, &cd, verbose)?.map( - CompilationMode::Cross, - ) + Target::new(triple, &cd, verbose)?.map(CompilationMode::Cross) } } else { if let Some(ref config) = config { if let Some(triple) = config.target()? { - Target::new(triple, &cd, verbose)?.map( - CompilationMode::Cross, - ) + Target::new(triple, &cd, verbose)?.map(CompilationMode::Cross) } else { Some(CompilationMode::Native(meta.host.clone())) } diff --git a/src/rustc.rs b/src/rustc.rs index d1c3613..3e86816 100644 --- a/src/rustc.rs +++ b/src/rustc.rs @@ -13,12 +13,12 @@ use walkdir::WalkDir; use CurrentDirectory; use errors::*; use extensions::CommandExt; -use {util, rustc}; +use {rustc, util}; fn command() -> Command { - env::var_os("RUSTC").map(Command::new).unwrap_or_else(|| { - Command::new("rustc") - }) + env::var_os("RUSTC") + .map(Command::new) + .unwrap_or_else(|| Command::new("rustc")) } /// `rustc --print target-list` @@ -34,7 +34,11 @@ pub fn sysroot(verbose: bool) -> Result { command() .args(&["--print", "sysroot"]) .run_and_get_stdout(verbose) - .map(|l| Sysroot { path: PathBuf::from(l.trim()) }) + .map(|l| { + Sysroot { + path: PathBuf::from(l.trim()), + } + }) } /// Path to Rust source pub struct Src { @@ -43,7 +47,11 @@ pub struct Src { impl Src { pub fn from_env() -> Option { - env::var_os("XARGO_RUST_SRC").map(|s| Src { path: PathBuf::from(s) }) + env::var_os("XARGO_RUST_SRC").map(|s| { + Src { + path: PathBuf::from(s), + } + }) } pub fn path(&self) -> &Path { @@ -67,7 +75,9 @@ impl Sysroot { let src = self.path().join("lib/rustlib/src"); if src.join("rust/src/libstd/Cargo.toml").is_file() { - return Ok(Src { path: src.join("rust/src") }); + return Ok(Src { + path: src.join("rust/src"), + }); } if src.exists() { @@ -81,7 +91,9 @@ impl Sysroot { if let Some(std) = toml.parent() { if let Some(src) = std.parent() { if std.file_name() == Some(OsStr::new("libstd")) { - return Ok(Src { path: src.to_owned() }); + return Ok(Src { + path: src.to_owned(), + }); } } } @@ -103,11 +115,7 @@ pub enum Target { } impl Target { - pub fn new( - triple: &str, - cd: &CurrentDirectory, - verbose: bool, - ) -> Result> { + pub fn new(triple: &str, cd: &CurrentDirectory, verbose: bool) -> Result> { let triple = triple.to_owned(); if rustc::targets(verbose)?.iter().any(|t| t == &triple) { diff --git a/src/sysroot.rs b/src/sysroot.rs index c9828b9..21e495c 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -47,15 +47,13 @@ version = "0.0.0" "#; let rustlib = home.lock_rw(cmode.triple())?; - rustlib.remove_siblings().chain_err(|| { - format!("couldn't clear {}", rustlib.path().display()) - })?; + rustlib + .remove_siblings() + .chain_err(|| format!("couldn't clear {}", rustlib.path().display()))?; let dst = rustlib.parent().join("lib"); util::mkdir(&dst)?; for (_, stage) in blueprint.stages { - let td = TempDir::new("xargo").chain_err( - || "couldn't create a temporary directory", - )?; + let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?; let td = td.path(); let mut stoml = TOML.to_owned(); @@ -72,9 +70,7 @@ version = "0.0.0" // Recent rust-src comes with a lockfile for libstd. Use it. let lockfile = src.path().join("Cargo.lock"); if lockfile.exists() { - fs::copy(lockfile, &td.join("Cargo.lock")).chain_err( - || "couldn't copy lock file", - )?; + fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(|| "couldn't copy lock file")?; } } util::write(&td.join("Cargo.toml"), &stoml)?; @@ -123,7 +119,6 @@ version = "0.0.0" .join("deps"), &dst, )?; - } // Create hash file @@ -192,13 +187,21 @@ pub fn update( let ctoml = cargo::toml(root)?; let xtoml = xargo::toml(root)?; - let blueprint = - Blueprint::from(xtoml.as_ref(), cmode.triple(), root, &src)?; + let blueprint = Blueprint::from(xtoml.as_ref(), cmode.triple(), root, &src)?; let hash = hash(cmode, &blueprint, rustflags, &ctoml, meta)?; if old_hash(cmode, home)? != Some(hash) { - build(cmode, blueprint, &ctoml, home, rustflags, src, hash, verbose)?; + build( + cmode, + blueprint, + &ctoml, + home, + rustflags, + src, + hash, + verbose, + )?; } // copy host artifacts into the sysroot, if necessary @@ -216,15 +219,16 @@ pub fn update( } } - lock.remove_siblings().chain_err(|| { - format!("couldn't clear {}", lock.path().display()) - })?; + lock.remove_siblings() + .chain_err(|| format!("couldn't clear {}", lock.path().display()))?; let dst = lock.parent().join("lib"); util::mkdir(&dst)?; util::cp_r( - &sysroot.path().join("lib/rustlib").join(&meta.host).join( - "lib", - ), + &sysroot + .path() + .join("lib/rustlib") + .join(&meta.host) + .join("lib"), &dst, )?; @@ -248,28 +252,26 @@ pub struct Blueprint { impl Blueprint { fn new() -> Self { - Blueprint { stages: BTreeMap::new() } + Blueprint { + stages: BTreeMap::new(), + } } - fn from( - toml: Option<&xargo::Toml>, - target: &str, - root: &Root, - src: &Src, - ) -> Result { + fn from(toml: Option<&xargo::Toml>, target: &str, root: &Root, src: &Src) -> Result { let deps = match ( toml.and_then(|t| t.dependencies()), toml.and_then(|t| t.target_dependencies(target)), ) { (Some(value), Some(tvalue)) => { - let mut deps = value.as_table().cloned().ok_or_else( - || format!("Xargo.toml: `dependencies` must be a table"), - )?; + let mut deps = value + .as_table() + .cloned() + .ok_or_else(|| format!("Xargo.toml: `dependencies` must be a table"))?; let more_deps = tvalue.as_table().ok_or_else(|| { format!( "Xargo.toml: `target.{}.dependencies` must be \ - a table", + a table", target ) })?; @@ -277,8 +279,8 @@ impl Blueprint { if deps.insert(k.to_owned(), v.clone()).is_some() { Err(format!( "found duplicate dependency name {}, \ - but all dependencies must have a \ - unique name", + but all dependencies must have a \ + unique name", k ))? } @@ -286,18 +288,15 @@ impl Blueprint { deps } - (Some(value), None) | - (None, Some(value)) => { - if let Some(table) = value.as_table() { - table.clone() - } else { - Err(format!( - "Xargo.toml: target.{}.dependencies must be \ - a table", - target - ))? - } - } + (Some(value), None) | (None, Some(value)) => if let Some(table) = value.as_table() { + table.clone() + } else { + Err(format!( + "Xargo.toml: target.{}.dependencies must be \ + a table", + target + ))? + }, (None, None) => { // If no dependencies were listed, we assume `core` as the // only dependency @@ -311,37 +310,23 @@ impl Blueprint { for (k, v) in deps { if let Value::Table(mut map) = v { let stage = if let Some(value) = map.remove("stage") { - value.as_integer().ok_or_else(|| { - format!( - "dependencies.{}.stage must be an integer", - k - ) - })? + value + .as_integer() + .ok_or_else(|| format!("dependencies.{}.stage must be an integer", k))? } else { 0 }; if let Some(path) = map.get_mut("path") { - let p = PathBuf::from( - path.as_str().ok_or_else(|| { - format!( - "dependencies.{}.path must be a string", - k - ) - })?, - ); + let p = PathBuf::from(path.as_str() + .ok_or_else(|| format!("dependencies.{}.path must be a string", k))?); if !p.is_absolute() { *path = Value::String( root.path() .join(&p) .canonicalize() - .chain_err(|| { - format!( - "couldn't canonicalize {}", - p.display() - ) - })? + .chain_err(|| format!("couldn't canonicalize {}", p.display()))? .display() .to_string(), ); @@ -349,10 +334,7 @@ impl Blueprint { } if !map.contains_key("path") && !map.contains_key("git") { - let path = src.path() - .join(format!("lib{}", k)) - .display() - .to_string(); + let path = src.path().join(format!("lib{}", k)).display().to_string(); map.insert("path".to_owned(), Value::String(path)); } @@ -361,7 +343,7 @@ impl Blueprint { } else { Err(format!( "Xargo.toml: target.{}.dependencies.{} must be \ - a table", + a table", target, k ))? diff --git a/src/util.rs b/src/util.rs index 0be65f6..6adef19 100644 --- a/src/util.rs +++ b/src/util.rs @@ -56,18 +56,14 @@ pub fn cp_r(src: &Path, dst: &Path) -> Result<()> { } pub fn mkdir(path: &Path) -> Result<()> { - fs::create_dir(path).chain_err(|| { - format!("couldn't create directory {}", path.display()) - }) + fs::create_dir(path).chain_err(|| format!("couldn't create directory {}", path.display())) } /// Parses `path` as TOML pub fn parse(path: &Path) -> Result { - Ok(Value::Table( - Parser::new(&read(path)?).parse().ok_or_else(|| { - format!("{} is not valid TOML", path.display()) - })?, - )) + Ok(Value::Table(Parser::new(&read(path)?) + .parse() + .ok_or_else(|| format!("{} is not valid TOML", path.display()))?)) } pub fn read(path: &Path) -> Result { diff --git a/src/xargo.rs b/src/xargo.rs index 645e675..ee92406 100644 --- a/src/xargo.rs +++ b/src/xargo.rs @@ -93,7 +93,9 @@ pub fn home(cmode: &CompilationMode) -> Result { p.push("HOST"); } - Ok(Home { path: Filesystem::new(p) }) + Ok(Home { + path: Filesystem::new(p), + }) } pub struct Toml { @@ -108,9 +110,8 @@ impl Toml { /// Returns the `target.{}.dependencies` part of `Xargo.toml` pub fn target_dependencies(&self, target: &str) -> Option<&Value> { - self.table.lookup( - &format!("target.{}.dependencies", target), - ) + self.table + .lookup(&format!("target.{}.dependencies", target)) } } diff --git a/tests/smoke.rs b/tests/smoke.rs index b973e36..093a5ae 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -4,11 +4,11 @@ #[macro_use] extern crate error_chain; +#[macro_use] +extern crate lazy_static; extern crate parking_lot; extern crate rustc_version; extern crate tempdir; -#[macro_use] -extern crate lazy_static; use std::fs::OpenOptions; use std::io::Write; @@ -41,9 +41,7 @@ fn home() -> Result { } else { Ok( env::home_dir() - .ok_or_else( - || "couldn't find your home directory. Is $HOME set?", - )? + .ok_or_else(|| "couldn't find your home directory. Is $HOME set?")? .join(".xargo"), ) } @@ -53,9 +51,7 @@ fn cleanup(target: &str) -> Result<()> { let p = home()?.join("lib/rustlib").join(target); if p.exists() { - fs::remove_dir_all(&p).chain_err(|| { - format!("couldn't clean sysroot for {}", target) - }) + fs::remove_dir_all(&p).chain_err(|| format!("couldn't clean sysroot for {}", target)) } else { Ok(()) } @@ -64,9 +60,7 @@ fn cleanup(target: &str) -> Result<()> { fn exists(krate: &str, target: &str) -> Result { let p = home()?.join("lib/rustlib").join(target).join("lib"); - for e in fs::read_dir(&p).chain_err(|| { - format!("couldn't read the directory {}", p.display()) - })? + for e in fs::read_dir(&p).chain_err(|| format!("couldn't read the directory {}", p.display()))? { let e = e.chain_err(|| { format!( @@ -95,9 +89,8 @@ fn mkdir(path: &Path) -> Result<()> { fn sysroot_was_built(stderr: &str, target: &str) -> bool { stderr.lines().filter(|l| l.starts_with("+")).any(|l| { - l.contains("cargo") && l.contains("build") && - l.contains("--target") && l.contains(target) && - l.contains("-p") && l.contains("core") + l.contains("cargo") && l.contains("build") && l.contains("--target") && l.contains(target) + && l.contains("-p") && l.contains("core") }) } @@ -120,9 +113,7 @@ fn write(path: &Path, append: bool, contents: &str) -> Result<()> { } fn xargo() -> Result { - let mut p = env::current_exe().chain_err( - || "couldn't get path to current executable", - )?; + let mut p = env::current_exe().chain_err(|| "couldn't get path to current executable")?; p.pop(); p.pop(); p.push("xargo"); @@ -136,9 +127,8 @@ trait CommandExt { impl CommandExt for Command { fn run(&mut self) -> Result<()> { - let status = self.status().chain_err( - || format!("couldn't execute `{:?}`", self), - )?; + let status = self.status() + .chain_err(|| format!("couldn't execute `{:?}`", self))?; if status.success() { Ok(()) @@ -152,16 +142,12 @@ impl CommandExt for Command { } fn run_and_get_stderr(&mut self) -> Result { - let out = self.output().chain_err( - || format!("couldn't execute `{:?}`", self), - )?; + let out = self.output() + .chain_err(|| format!("couldn't execute `{:?}`", self))?; if out.status.success() { - Ok( - String::from_utf8(out.stderr).chain_err(|| { - format!("`{:?}` output was not UTF-8", self) - })?, - ) + Ok(String::from_utf8(out.stderr) + .chain_err(|| format!("`{:?}` output was not UTF-8", self))?) } else { Err(format!( "`{:?}` failed with exit code: {:?}", @@ -193,9 +179,7 @@ impl Project { } "#; - let td = TempDir::new("xargo").chain_err( - || "couldn't create a temporary directory", - )?; + let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?; xargo()? .args(&["init", "--lib", "--vcs", "none", "--name", name]) @@ -267,9 +251,7 @@ fn hcleanup(triple: &str) -> Result<()> { let p = home()?.join("HOST/lib/rustlib").join(triple); if p.exists() { - fs::remove_dir_all(&p).chain_err(|| { - format!("couldn't clean sysroot for {}", triple) - }) + fs::remove_dir_all(&p).chain_err(|| format!("couldn't clean sysroot for {}", triple)) } else { Ok(()) } @@ -290,9 +272,7 @@ impl HProject { let guard = ONCE.lock(); - let td = TempDir::new("xargo").chain_err( - || "couldn't create a temporary directory", - )?; + let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?; xargo()? .args(&["init", "--lib", "--vcs", "none", "--name", "host"]) @@ -569,10 +549,12 @@ rustflags = ["--cfg", "xargo"] let stderr = project.build_and_get_stderr(Some(TARGET))?; - assert!(stderr + assert!( + stderr .lines() .filter(|l| !l.starts_with("+") && l.contains("rustc")) - .all(|l| l.contains("--cfg") && l.contains("xargo"))); + .all(|l| l.contains("--cfg") && l.contains("xargo")) + ); Ok(()) } @@ -599,10 +581,12 @@ panic = "abort" let stderr = project.build_and_get_stderr(Some(TARGET))?; - assert!(stderr + assert!( + stderr .lines() .filter(|l| !l.starts_with("+") && l.contains("--release")) - .all(|l| l.contains("-C") && l.contains("panic=abort"))); + .all(|l| l.contains("-C") && l.contains("panic=abort")) + ); Ok(()) } From 66cce2b89a1343ca21e633237d62a8282cca5683 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 4 Nov 2017 20:05:15 +0100 Subject: [PATCH 2/2] use recent nightly for macOS --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ebc88d..391cfa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,13 +27,9 @@ matrix: rust: nightly - env: TARGET=i686-apple-darwin os: osx - # old nightly to work around rust-lang/cargo#4699 - rust: nightly-2017-10-10 - env: TARGET=x86_64-apple-darwin os: osx rust: nightly - # old nightly to work around rust-lang/cargo#4699 - rust: nightly-2017-10-10 install: - bash ci/install.sh