Skip to content

Commit 54e320d

Browse files
committed
run rustfmt on various folders
1 parent 6dc035e commit 54e320d

File tree

5 files changed

+26
-39
lines changed

5 files changed

+26
-39
lines changed

src/build_helper/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ pub fn run_silent(cmd: &mut Command) {
2525
};
2626
if !status.success() {
2727
fail(&format!("command did not execute successfully: {:?}\n\
28-
expected success, got: {}", cmd, status));
28+
expected success, got: {}",
29+
cmd,
30+
status));
2931
}
3032
}
3133

@@ -65,7 +67,9 @@ pub fn output(cmd: &mut Command) -> String {
6567
};
6668
if !output.status.success() {
6769
panic!("command did not execute successfully: {:?}\n\
68-
expected success, got: {}", cmd, output.status);
70+
expected success, got: {}",
71+
cmd,
72+
output.status);
6973
}
7074
String::from_utf8(output.stdout).unwrap()
7175
}

src/liballoc/raw_vec.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ impl<T> RawVec<T> {
5757
pub fn new() -> Self {
5858
unsafe {
5959
// !0 is usize::MAX. This branch should be stripped at compile time.
60-
let cap = if mem::size_of::<T>() == 0 {
61-
!0
62-
} else {
63-
0
64-
};
60+
let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
6561

6662
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
6763
RawVec {
@@ -209,11 +205,7 @@ impl<T> RawVec<T> {
209205

210206
let (new_cap, ptr) = if self.cap == 0 {
211207
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
212-
let new_cap = if elem_size > (!0) / 8 {
213-
1
214-
} else {
215-
4
216-
};
208+
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
217209
let ptr = heap::allocate(new_cap * elem_size, align);
218210
(new_cap, ptr)
219211
} else {
@@ -347,7 +339,7 @@ impl<T> RawVec<T> {
347339
let elem_size = mem::size_of::<T>();
348340
// Nothing we can really do about these checks :(
349341
let required_cap = used_cap.checked_add(needed_extra_cap)
350-
.expect("capacity overflow");
342+
.expect("capacity overflow");
351343
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
352344
let double_cap = self.cap * 2;
353345
// `double_cap` guarantees exponential growth.

src/liballoc_jemalloc/build.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ fn main() {
3535
// that the feature set used by std is the same across all
3636
// targets, which means we have to build the alloc_jemalloc crate
3737
// for targets like emscripten, even if we don't use it.
38-
if target.contains("rumprun") ||
39-
target.contains("bitrig") ||
40-
target.contains("openbsd") ||
41-
target.contains("msvc") ||
42-
target.contains("emscripten")
43-
{
38+
if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") ||
39+
target.contains("msvc") || target.contains("emscripten") {
4440
println!("cargo:rustc-cfg=dummy_jemalloc");
4541
return;
4642
}
@@ -64,16 +60,16 @@ fn main() {
6460
// only msvc returns None for ar so unwrap is okay
6561
let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
6662
let cflags = compiler.args()
67-
.iter()
68-
.map(|s| s.to_str().unwrap())
69-
.collect::<Vec<_>>()
70-
.join(" ");
63+
.iter()
64+
.map(|s| s.to_str().unwrap())
65+
.collect::<Vec<_>>()
66+
.join(" ");
7167

7268
let mut stack = src_dir.join("../jemalloc")
73-
.read_dir()
74-
.unwrap()
75-
.map(|e| e.unwrap())
76-
.collect::<Vec<_>>();
69+
.read_dir()
70+
.unwrap()
71+
.map(|e| e.unwrap())
72+
.collect::<Vec<_>>();
7773
while let Some(entry) = stack.pop() {
7874
let path = entry.path();
7975
if entry.file_type().unwrap().is_dir() {
@@ -155,10 +151,10 @@ fn main() {
155151

156152
run(&mut cmd);
157153
run(Command::new("make")
158-
.current_dir(&build_dir)
159-
.arg("build_lib_static")
160-
.arg("-j")
161-
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
154+
.current_dir(&build_dir)
155+
.arg("build_lib_static")
156+
.arg("-j")
157+
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
162158

163159
if target.contains("windows") {
164160
println!("cargo:rustc-link-lib=static=jemalloc");

src/liballoc_system/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ mod imp {
221221
HEAP_REALLOC_IN_PLACE_ONLY,
222222
ptr as LPVOID,
223223
size as SIZE_T) as *mut u8;
224-
if new.is_null() {
225-
old_size
226-
} else {
227-
size
228-
}
224+
if new.is_null() { old_size } else { size }
229225
} else {
230226
old_size
231227
}

src/libarena/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ mod tests {
302302

303303
let arena = Wrap(TypedArena::new());
304304

305-
let result = arena.alloc_outer(|| {
306-
Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }
307-
});
305+
let result =
306+
arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) });
308307

309308
assert_eq!(result.inner.value, 10);
310309
}

0 commit comments

Comments
 (0)