Skip to content

Commit 12a0942

Browse files
committed
Run cargo fmt
1 parent b96ab72 commit 12a0942

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

test/src/lib.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ extern crate cfg_if;
88
extern crate rand;
99
extern crate wee_alloc;
1010

11-
use std::alloc::{Alloc, Layout};
1211
use quickcheck::{Arbitrary, Gen};
12+
use std::alloc::{Alloc, Layout};
1313
use std::f64;
1414
use std::fs;
1515
use std::io::Read;
@@ -162,7 +162,8 @@ impl Arbitrary for Operations {
162162
let prefixes =
163163
(0..self.0.len()).map(move |i| Operations(ops.iter().cloned().take(i).collect()));
164164

165-
let free_indices: Vec<_> = self.0
165+
let free_indices: Vec<_> = self
166+
.0
166167
.iter()
167168
.enumerate()
168169
.filter_map(|(i, op)| if let Free(_) = *op { Some(i) } else { None })
@@ -178,7 +179,8 @@ impl Arbitrary for Operations {
178179
)
179180
});
180181

181-
let alloc_indices: Vec<_> = self.0
182+
let alloc_indices: Vec<_> = self
183+
.0
182184
.iter()
183185
.enumerate()
184186
.filter_map(|(i, op)| if let Alloc(_) = *op { Some(i) } else { None })
@@ -433,7 +435,8 @@ fn allocate_size_zero() {
433435
.take(1000)
434436
.chain((0..1000).map(|i| Free(i)))
435437
.collect(),
436-
).run_single_threaded();
438+
)
439+
.run_single_threaded();
437440
}
438441

439442
#[test]
@@ -447,7 +450,8 @@ fn allocate_many_small() {
447450
.chain(iter::repeat(Alloc(256 * mem::size_of::<usize>())).take(100))
448451
.chain((0..100).map(|i| Free(i + 100)))
449452
.collect(),
450-
).run_single_threaded();
453+
)
454+
.run_single_threaded();
451455
}
452456

453457
#[test]
@@ -461,7 +465,8 @@ fn allocate_many_large() {
461465
.chain(iter::repeat(Alloc(1024 * mem::size_of::<usize>())).take(100))
462466
.chain((0..100).map(|i| Free(i + 100)))
463467
.collect(),
464-
).run_single_threaded();
468+
)
469+
.run_single_threaded();
465470
}
466471

467472
////////////////////////////////////////////////////////////////////////////////
@@ -475,7 +480,8 @@ fn smoke() {
475480
let mut a = &wee_alloc::WeeAlloc::INIT;
476481
unsafe {
477482
let layout = Layout::new::<u8>();
478-
let ptr = a.alloc(layout.clone())
483+
let ptr = a
484+
.alloc(layout.clone())
479485
.expect("Should be able to alloc a fresh Layout clone");
480486
{
481487
let ptr = ptr.as_ptr() as *mut u8;
@@ -484,7 +490,8 @@ fn smoke() {
484490
}
485491
a.dealloc(ptr, layout.clone());
486492

487-
let ptr = a.alloc(layout.clone())
493+
let ptr = a
494+
.alloc(layout.clone())
488495
.expect("Should be able to alloc from a second clone");
489496
{
490497
let ptr = ptr.as_ptr() as *mut u8;

trace-malloc-free/src/main.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ main!(|cli: Cli| {
4141

4242
let malloc_re = Regex::new(
4343
r#"^\-\-\d+\-\- (realloc\(0x0,\d+\))?malloc\((?P<size>\d+)\) = 0x(?P<ptr>\w+)$"#,
44-
).unwrap();
44+
)
45+
.unwrap();
4546

46-
let calloc_re = Regex::new(
47-
r#"^\-\-\d+\-\- calloc\((?P<num>\d+),(?P<size>\d+)\) = 0x(?P<ptr>\w+)$"#,
48-
).unwrap();
47+
let calloc_re =
48+
Regex::new(r#"^\-\-\d+\-\- calloc\((?P<num>\d+),(?P<size>\d+)\) = 0x(?P<ptr>\w+)$"#)
49+
.unwrap();
4950

50-
let realloc_re = Regex::new(
51-
r#"^\-\-\d+\-\- realloc\(0x(?P<orig>\w+),(?P<size>\d+)\) = 0x(?P<new>\w+)$"#,
52-
).unwrap();
51+
let realloc_re =
52+
Regex::new(r#"^\-\-\d+\-\- realloc\(0x(?P<orig>\w+),(?P<size>\d+)\) = 0x(?P<new>\w+)$"#)
53+
.unwrap();
5354

5455
// TODO: record the requested alignment and replay that as well.
55-
let memalign_re = Regex::new(
56-
r#"r#"^\-\-\d+\-\- memalign\(al \d+, size (?P<size>\d+)\) = 0x(?P<ptr>\w+)$"#,
57-
).unwrap();
56+
let memalign_re =
57+
Regex::new(r#"r#"^\-\-\d+\-\- memalign\(al \d+, size (?P<size>\d+)\) = 0x(?P<ptr>\w+)$"#)
58+
.unwrap();
5859

5960
let free_re = Regex::new(r#"^\-\-\d+\-\- free\(0x(?P<ptr>\w+)\)$"#).unwrap();
6061

wee_alloc/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ fn export_rerun_rules() {
3838
"./build.rs",
3939
"./src/lib.rs",
4040
"./src/imp_static_array.rs",
41-
].iter()
41+
]
42+
.iter()
4243
{
4344
println!("cargo:rerun-if-changed={}", path);
4445
}

wee_alloc/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,7 @@ impl<'a> AllocPolicy<'a> for LargeAllocPolicy {
777777
// free list with this new cell, make sure that we allocate enough to
778778
// fulfill the requested alignment, and still have the minimum cell size
779779
// left over.
780-
let size: Bytes = cmp::max(
781-
size.into(),
782-
(align + Self::MIN_CELL_SIZE) * Words(2),
783-
);
780+
let size: Bytes = cmp::max(size.into(), (align + Self::MIN_CELL_SIZE) * Words(2));
784781

785782
let pages: Pages = (size + size_of::<CellHeader>()).round_up_to();
786783
let new_pages = imp::alloc_pages(pages)?;
@@ -912,9 +909,7 @@ unsafe fn alloc_first_fit<'a>(
912909

913910
if let Some(allocated) = current.try_alloc(previous, size, align, policy) {
914911
assert_aligned_to(allocated.data(), align);
915-
return Some(unchecked_unwrap(
916-
NonNull::new(allocated.data() as *mut u8),
917-
));
912+
return Some(unchecked_unwrap(NonNull::new(allocated.data() as *mut u8)));
918913
}
919914

920915
None
@@ -1093,7 +1088,8 @@ impl<'a> WeeAlloc<'a> {
10931088
// immediately, whereas the consolidating with the next adjacent
10941089
// cell must be delayed, as explained above.
10951090

1096-
if let Some(prev) = free.header
1091+
if let Some(prev) = free
1092+
.header
10971093
.neighbors
10981094
.prev()
10991095
.and_then(|p| (*p).as_free_cell())
@@ -1108,7 +1104,8 @@ impl<'a> WeeAlloc<'a> {
11081104
return;
11091105
}
11101106

1111-
if let Some(next) = free.header
1107+
if let Some(next) = free
1108+
.header
11121109
.neighbors
11131110
.next()
11141111
.and_then(|n| (*n).as_free_cell())

0 commit comments

Comments
 (0)