From 54e320d4bce4a397d165739fda8329a0567b35c4 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Sun, 16 Oct 2016 15:41:01 +0530 Subject: [PATCH] run rustfmt on various folders --- src/build_helper/lib.rs | 8 ++++++-- src/liballoc/raw_vec.rs | 14 +++----------- src/liballoc_jemalloc/build.rs | 32 ++++++++++++++------------------ src/liballoc_system/lib.rs | 6 +----- src/libarena/lib.rs | 5 ++--- 5 files changed, 26 insertions(+), 39 deletions(-) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 838cc4f07a9a1..38844fb6c9ef0 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -25,7 +25,9 @@ pub fn run_silent(cmd: &mut Command) { }; if !status.success() { fail(&format!("command did not execute successfully: {:?}\n\ - expected success, got: {}", cmd, status)); + expected success, got: {}", + cmd, + status)); } } @@ -65,7 +67,9 @@ pub fn output(cmd: &mut Command) -> String { }; if !output.status.success() { panic!("command did not execute successfully: {:?}\n\ - expected success, got: {}", cmd, output.status); + expected success, got: {}", + cmd, + output.status); } String::from_utf8(output.stdout).unwrap() } diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index e153507956b9f..f23ea0ea8bf71 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -57,11 +57,7 @@ impl RawVec { pub fn new() -> Self { unsafe { // !0 is usize::MAX. This branch should be stripped at compile time. - let cap = if mem::size_of::() == 0 { - !0 - } else { - 0 - }; + let cap = if mem::size_of::() == 0 { !0 } else { 0 }; // heap::EMPTY doubles as "unallocated" and "zero-sized allocation" RawVec { @@ -209,11 +205,7 @@ impl RawVec { let (new_cap, ptr) = if self.cap == 0 { // skip to 4 because tiny Vec's are dumb; but not if that would cause overflow - let new_cap = if elem_size > (!0) / 8 { - 1 - } else { - 4 - }; + let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 }; let ptr = heap::allocate(new_cap * elem_size, align); (new_cap, ptr) } else { @@ -347,7 +339,7 @@ impl RawVec { let elem_size = mem::size_of::(); // Nothing we can really do about these checks :( let required_cap = used_cap.checked_add(needed_extra_cap) - .expect("capacity overflow"); + .expect("capacity overflow"); // Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`. let double_cap = self.cap * 2; // `double_cap` guarantees exponential growth. diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index 028d742cc832e..369db8e75a398 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -35,12 +35,8 @@ fn main() { // that the feature set used by std is the same across all // targets, which means we have to build the alloc_jemalloc crate // for targets like emscripten, even if we don't use it. - if target.contains("rumprun") || - target.contains("bitrig") || - target.contains("openbsd") || - target.contains("msvc") || - target.contains("emscripten") - { + if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") || + target.contains("msvc") || target.contains("emscripten") { println!("cargo:rustc-cfg=dummy_jemalloc"); return; } @@ -64,16 +60,16 @@ fn main() { // only msvc returns None for ar so unwrap is okay let ar = build_helper::cc2ar(compiler.path(), &target).unwrap(); let cflags = compiler.args() - .iter() - .map(|s| s.to_str().unwrap()) - .collect::>() - .join(" "); + .iter() + .map(|s| s.to_str().unwrap()) + .collect::>() + .join(" "); let mut stack = src_dir.join("../jemalloc") - .read_dir() - .unwrap() - .map(|e| e.unwrap()) - .collect::>(); + .read_dir() + .unwrap() + .map(|e| e.unwrap()) + .collect::>(); while let Some(entry) = stack.pop() { let path = entry.path(); if entry.file_type().unwrap().is_dir() { @@ -155,10 +151,10 @@ fn main() { run(&mut cmd); run(Command::new("make") - .current_dir(&build_dir) - .arg("build_lib_static") - .arg("-j") - .arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set"))); + .current_dir(&build_dir) + .arg("build_lib_static") + .arg("-j") + .arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set"))); if target.contains("windows") { println!("cargo:rustc-link-lib=static=jemalloc"); diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index dacafe771edc2..b380ba180f40e 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -221,11 +221,7 @@ mod imp { HEAP_REALLOC_IN_PLACE_ONLY, ptr as LPVOID, size as SIZE_T) as *mut u8; - if new.is_null() { - old_size - } else { - size - } + if new.is_null() { old_size } else { size } } else { old_size } diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 4986c9850d7c7..72785b9cc831e 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -302,9 +302,8 @@ mod tests { let arena = Wrap(TypedArena::new()); - let result = arena.alloc_outer(|| { - Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) } - }); + let result = + arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }); assert_eq!(result.inner.value, 10); }