Skip to content

Commit c0dc2cb

Browse files
committedOct 14, 2015
Auto merge of #29026 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #28988, #28989, #28990, #28997, #29007, #29015 - Failed merges: #28906
2 parents ec4362d + 1537545 commit c0dc2cb

File tree

7 files changed

+124
-114
lines changed

7 files changed

+124
-114
lines changed
 

‎src/doc/trpl/error-handling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ for pop in search(&data_file, &city) {
18981898

18991899
In this piece of code, we take `file` (which has the type
19001900
`Option<String>`), and convert it to a type that `search` can use, in
1901-
this case, `&Option<AsRef<Path>>`. Do do this, we take a reference of
1901+
this case, `&Option<AsRef<Path>>`. To do this, we take a reference of
19021902
file, and map `Path::new` onto it. In this case, `as_ref()` converts
19031903
the `Option<String>` into an `Option<&str>`, and from there, we can
19041904
execute `Path::new` to the content of the optional, and return the

‎src/doc/trpl/iterators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ own iterator involves implementing the `Iterator` trait. While doing that is
4444
outside of the scope of this guide, Rust provides a number of useful iterators
4545
to accomplish various tasks. But first, a few notes about limitations of ranges.
4646

47-
Ranges are very primitive, and we often can use better alternatives. Consider
47+
Ranges are very primitive, and we often can use better alternatives. Consider the
4848
following Rust anti-pattern: using ranges to emulate a C-style `for` loop. Let’s
4949
suppose you needed to iterate over the contents of a vector. You may be tempted
5050
to write this:

‎src/doc/trpl/lifetimes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% Lifetimes
22

3-
This guide is one of three presenting Rust’s ownership system. This is one of
3+
This guide is three of three presenting Rust’s ownership system. This is one of
44
Rust’s most unique and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own chapter:

‎src/doc/trpl/references-and-borrowing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% References and Borrowing
22

3-
This guide is one of three presenting Rust’s ownership system. This is one of
3+
This guide is two of three presenting Rust’s ownership system. This is one of
44
Rust’s most unique and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own

‎src/liballoc_jemalloc/lib.rs

+22-11
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ use libc::{c_int, c_void, size_t};
4343
extern {
4444
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
4545
fn je_rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
46-
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t,
47-
flags: c_int) -> size_t;
46+
fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
4847
fn je_sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
4948
fn je_nallocx(size: size_t, flags: c_int) -> size_t;
5049
}
@@ -63,40 +62,52 @@ const MIN_ALIGN: usize = 8;
6362
const MIN_ALIGN: usize = 16;
6463

6564
// MALLOCX_ALIGN(a) macro
66-
fn mallocx_align(a: usize) -> c_int { a.trailing_zeros() as c_int }
65+
fn mallocx_align(a: usize) -> c_int {
66+
a.trailing_zeros() as c_int
67+
}
6768

6869
fn align_to_flags(align: usize) -> c_int {
69-
if align <= MIN_ALIGN { 0 } else { mallocx_align(align) }
70+
if align <= MIN_ALIGN {
71+
0
72+
} else {
73+
mallocx_align(align)
74+
}
7075
}
7176

7277
#[no_mangle]
73-
pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
78+
pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
7479
let flags = align_to_flags(align);
7580
unsafe { je_mallocx(size as size_t, flags) as *mut u8 }
7681
}
7782

7883
#[no_mangle]
79-
pub extern fn __rust_reallocate(ptr: *mut u8, _old_size: usize, size: usize,
80-
align: usize) -> *mut u8 {
84+
pub extern "C" fn __rust_reallocate(ptr: *mut u8,
85+
_old_size: usize,
86+
size: usize,
87+
align: usize)
88+
-> *mut u8 {
8189
let flags = align_to_flags(align);
8290
unsafe { je_rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
8391
}
8492

8593
#[no_mangle]
86-
pub extern fn __rust_reallocate_inplace(ptr: *mut u8, _old_size: usize,
87-
size: usize, align: usize) -> usize {
94+
pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8,
95+
_old_size: usize,
96+
size: usize,
97+
align: usize)
98+
-> usize {
8899
let flags = align_to_flags(align);
89100
unsafe { je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
90101
}
91102

92103
#[no_mangle]
93-
pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
104+
pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
94105
let flags = align_to_flags(align);
95106
unsafe { je_sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
96107
}
97108

98109
#[no_mangle]
99-
pub extern fn __rust_usable_size(size: usize, align: usize) -> usize {
110+
pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
100111
let flags = align_to_flags(align);
101112
unsafe { je_nallocx(size as size_t, flags) as usize }
102113
}

‎src/liballoc_system/lib.rs

+48-29
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,35 @@ const MIN_ALIGN: usize = 8;
3939
const MIN_ALIGN: usize = 16;
4040

4141
#[no_mangle]
42-
pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
42+
pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
4343
unsafe { imp::allocate(size, align) }
4444
}
4545

4646
#[no_mangle]
47-
pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
47+
pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
4848
unsafe { imp::deallocate(ptr, old_size, align) }
4949
}
5050

5151
#[no_mangle]
52-
pub extern fn __rust_reallocate(ptr: *mut u8, old_size: usize, size: usize,
53-
align: usize) -> *mut u8 {
52+
pub extern "C" fn __rust_reallocate(ptr: *mut u8,
53+
old_size: usize,
54+
size: usize,
55+
align: usize)
56+
-> *mut u8 {
5457
unsafe { imp::reallocate(ptr, old_size, size, align) }
5558
}
5659

5760
#[no_mangle]
58-
pub extern fn __rust_reallocate_inplace(ptr: *mut u8, old_size: usize,
59-
size: usize, align: usize) -> usize {
61+
pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8,
62+
old_size: usize,
63+
size: usize,
64+
align: usize)
65+
-> usize {
6066
unsafe { imp::reallocate_inplace(ptr, old_size, size, align) }
6167
}
6268

6369
#[no_mangle]
64-
pub extern fn __rust_usable_size(size: usize, align: usize) -> usize {
70+
pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
6571
imp::usable_size(size, align)
6672
}
6773

@@ -80,7 +86,8 @@ mod imp {
8086
#[cfg(not(target_os = "android"))]
8187
fn posix_memalign(memptr: *mut *mut libc::c_void,
8288
align: libc::size_t,
83-
size: libc::size_t) -> libc::c_int;
89+
size: libc::size_t)
90+
-> libc::c_int;
8491
}
8592

8693
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
@@ -94,9 +101,7 @@ mod imp {
94101
#[cfg(not(target_os = "android"))]
95102
unsafe fn more_aligned_malloc(size: usize, align: usize) -> *mut u8 {
96103
let mut out = ptr::null_mut();
97-
let ret = posix_memalign(&mut out,
98-
align as libc::size_t,
99-
size as libc::size_t);
104+
let ret = posix_memalign(&mut out, align as libc::size_t, size as libc::size_t);
100105
if ret != 0 {
101106
ptr::null_mut()
102107
} else {
@@ -107,8 +112,7 @@ mod imp {
107112
}
108113
}
109114

110-
pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize,
111-
align: usize) -> *mut u8 {
115+
pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
112116
if align <= MIN_ALIGN {
113117
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
114118
} else {
@@ -119,8 +123,11 @@ mod imp {
119123
}
120124
}
121125

122-
pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize,
123-
_align: usize) -> usize {
126+
pub unsafe fn reallocate_inplace(_ptr: *mut u8,
127+
old_size: usize,
128+
_size: usize,
129+
_align: usize)
130+
-> usize {
124131
old_size
125132
}
126133

@@ -141,8 +148,7 @@ mod imp {
141148
extern "system" {
142149
fn GetProcessHeap() -> HANDLE;
143150
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
144-
fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID,
145-
dwBytes: SIZE_T) -> LPVOID;
151+
fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID;
146152
fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
147153
}
148154

@@ -165,32 +171,45 @@ mod imp {
165171
if align <= MIN_ALIGN {
166172
HeapAlloc(GetProcessHeap(), 0, size as SIZE_T) as *mut u8
167173
} else {
168-
let ptr = HeapAlloc(GetProcessHeap(), 0,
169-
(size + align) as SIZE_T) as *mut u8;
170-
if ptr.is_null() { return ptr }
174+
let ptr = HeapAlloc(GetProcessHeap(), 0, (size + align) as SIZE_T) as *mut u8;
175+
if ptr.is_null() {
176+
return ptr
177+
}
171178
align_ptr(ptr, align)
172179
}
173180
}
174181

175-
pub unsafe fn reallocate(ptr: *mut u8, _old_size: usize, size: usize,
176-
align: usize) -> *mut u8 {
182+
pub unsafe fn reallocate(ptr: *mut u8, _old_size: usize, size: usize, align: usize) -> *mut u8 {
177183
if align <= MIN_ALIGN {
178184
HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, size as SIZE_T) as *mut u8
179185
} else {
180186
let header = get_header(ptr);
181-
let new = HeapReAlloc(GetProcessHeap(), 0, header.0 as LPVOID,
187+
let new = HeapReAlloc(GetProcessHeap(),
188+
0,
189+
header.0 as LPVOID,
182190
(size + align) as SIZE_T) as *mut u8;
183-
if new.is_null() { return new }
191+
if new.is_null() {
192+
return new
193+
}
184194
align_ptr(new, align)
185195
}
186196
}
187197

188-
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: usize, size: usize,
189-
align: usize) -> usize {
198+
pub unsafe fn reallocate_inplace(ptr: *mut u8,
199+
old_size: usize,
200+
size: usize,
201+
align: usize)
202+
-> usize {
190203
if align <= MIN_ALIGN {
191-
let new = HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY,
192-
ptr as LPVOID, size as SIZE_T) as *mut u8;
193-
if new.is_null() { old_size } else { size }
204+
let new = HeapReAlloc(GetProcessHeap(),
205+
HEAP_REALLOC_IN_PLACE_ONLY,
206+
ptr as LPVOID,
207+
size as SIZE_T) as *mut u8;
208+
if new.is_null() {
209+
old_size
210+
} else {
211+
size
212+
}
194213
} else {
195214
old_size
196215
}

‎src/libarena/lib.rs

+50-70
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct Arena<'longer_than_self> {
105105
head: RefCell<Chunk>,
106106
copy_head: RefCell<Chunk>,
107107
chunks: RefCell<Vec<Chunk>>,
108-
_marker: marker::PhantomData<*mut &'longer_than_self()>,
108+
_marker: marker::PhantomData<*mut &'longer_than_self ()>,
109109
}
110110

111111
impl<'a> Arena<'a> {
@@ -197,7 +197,7 @@ fn un_bitpack_tydesc_ptr(p: usize) -> (*const TyDesc, bool) {
197197
struct TyDesc {
198198
drop_glue: fn(*const i8),
199199
size: usize,
200-
align: usize
200+
align: usize,
201201
}
202202

203203
trait AllTypes { fn dummy(&self) { } }
@@ -224,8 +224,7 @@ impl<'longer_than_self> Arena<'longer_than_self> {
224224
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
225225
self.chunks.borrow_mut().push(self.copy_head.borrow().clone());
226226

227-
*self.copy_head.borrow_mut() =
228-
chunk((new_min_chunk_size + 1).next_power_of_two(), true);
227+
*self.copy_head.borrow_mut() = chunk((new_min_chunk_size + 1).next_power_of_two(), true);
229228

230229
self.alloc_copy_inner(n_bytes, align)
231230
}
@@ -242,38 +241,32 @@ impl<'longer_than_self> Arena<'longer_than_self> {
242241
let copy_head = self.copy_head.borrow();
243242
copy_head.fill.set(end);
244243

245-
unsafe {
246-
copy_head.as_ptr().offset(start as isize)
247-
}
244+
unsafe { copy_head.as_ptr().offset(start as isize) }
248245
}
249246

250247
#[inline]
251248
fn alloc_copy<T, F>(&self, op: F) -> &mut T where F: FnOnce() -> T {
252249
unsafe {
253-
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
254-
mem::align_of::<T>());
250+
let ptr = self.alloc_copy_inner(mem::size_of::<T>(), mem::align_of::<T>());
255251
let ptr = ptr as *mut T;
256252
ptr::write(&mut (*ptr), op());
257253
&mut *ptr
258254
}
259255
}
260256

261257
// Functions for the non-POD part of the arena
262-
fn alloc_noncopy_grow(&self, n_bytes: usize,
263-
align: usize) -> (*const u8, *const u8) {
258+
fn alloc_noncopy_grow(&self, n_bytes: usize, align: usize) -> (*const u8, *const u8) {
264259
// Allocate a new chunk.
265260
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
266261
self.chunks.borrow_mut().push(self.head.borrow().clone());
267262

268-
*self.head.borrow_mut() =
269-
chunk((new_min_chunk_size + 1).next_power_of_two(), false);
263+
*self.head.borrow_mut() = chunk((new_min_chunk_size + 1).next_power_of_two(), false);
270264

271265
self.alloc_noncopy_inner(n_bytes, align)
272266
}
273267

274268
#[inline]
275-
fn alloc_noncopy_inner(&self, n_bytes: usize,
276-
align: usize) -> (*const u8, *const u8) {
269+
fn alloc_noncopy_inner(&self, n_bytes: usize, align: usize) -> (*const u8, *const u8) {
277270
// Be careful to not maintain any `head` borrows active, because
278271
// `alloc_noncopy_grow` borrows it mutably.
279272
let (start, end, tydesc_start, head_capacity) = {
@@ -297,24 +290,23 @@ impl<'longer_than_self> Arena<'longer_than_self> {
297290

298291
unsafe {
299292
let buf = head.as_ptr();
300-
(buf.offset(tydesc_start as isize), buf.offset(start as isize))
293+
(buf.offset(tydesc_start as isize),
294+
buf.offset(start as isize))
301295
}
302296
}
303297

304298
#[inline]
305299
fn alloc_noncopy<T, F>(&self, op: F) -> &mut T where F: FnOnce() -> T {
306300
unsafe {
307301
let tydesc = get_tydesc::<T>();
308-
let (ty_ptr, ptr) =
309-
self.alloc_noncopy_inner(mem::size_of::<T>(),
310-
mem::align_of::<T>());
302+
let (ty_ptr, ptr) = self.alloc_noncopy_inner(mem::size_of::<T>(), mem::align_of::<T>());
311303
let ty_ptr = ty_ptr as *mut usize;
312304
let ptr = ptr as *mut T;
313305
// Write in our tydesc along with a bit indicating that it
314306
// has *not* been initialized yet.
315307
*ty_ptr = bitpack_tydesc_ptr(tydesc, false);
316308
// Actually initialize it
317-
ptr::write(&mut(*ptr), op());
309+
ptr::write(&mut (*ptr), op());
318310
// Now that we are done, update the tydesc to indicate that
319311
// the object is there.
320312
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
@@ -358,10 +350,10 @@ fn test_arena_destructors_fail() {
358350
for i in 0..10 {
359351
// Arena allocate something with drop glue to make sure it
360352
// doesn't leak.
361-
arena.alloc(|| { Rc::new(i) });
353+
arena.alloc(|| Rc::new(i));
362354
// Allocate something with funny size and alignment, to keep
363355
// things interesting.
364-
arena.alloc(|| { [0u8, 1, 2] });
356+
arena.alloc(|| [0u8, 1, 2]);
365357
}
366358
// Now, panic while allocating
367359
arena.alloc::<Rc<i32>, _>(|| {
@@ -409,12 +401,13 @@ fn calculate_size<T>(capacity: usize) -> usize {
409401

410402
impl<T> TypedArenaChunk<T> {
411403
#[inline]
412-
unsafe fn new(next: *mut TypedArenaChunk<T>, capacity: usize)
413-
-> *mut TypedArenaChunk<T> {
404+
unsafe fn new(next: *mut TypedArenaChunk<T>, capacity: usize) -> *mut TypedArenaChunk<T> {
414405
let size = calculate_size::<T>(capacity);
415-
let chunk = allocate(size, mem::align_of::<TypedArenaChunk<T>>())
416-
as *mut TypedArenaChunk<T>;
417-
if chunk.is_null() { alloc::oom() }
406+
let chunk =
407+
allocate(size, mem::align_of::<TypedArenaChunk<T>>()) as *mut TypedArenaChunk<T>;
408+
if chunk.is_null() {
409+
alloc::oom()
410+
}
418411
(*chunk).next = next;
419412
(*chunk).capacity = capacity;
420413
chunk
@@ -437,7 +430,8 @@ impl<T> TypedArenaChunk<T> {
437430
let next = self.next;
438431
let size = calculate_size::<T>(self.capacity);
439432
let self_ptr: *mut TypedArenaChunk<T> = self;
440-
deallocate(self_ptr as *mut u8, size,
433+
deallocate(self_ptr as *mut u8,
434+
size,
441435
mem::align_of::<TypedArenaChunk<T>>());
442436
if !next.is_null() {
443437
let capacity = (*next).capacity;
@@ -449,9 +443,7 @@ impl<T> TypedArenaChunk<T> {
449443
#[inline]
450444
fn start(&self) -> *const u8 {
451445
let this: *const TypedArenaChunk<T> = self;
452-
unsafe {
453-
round_up(this.offset(1) as usize, mem::align_of::<T>()) as *const u8
454-
}
446+
unsafe { round_up(this.offset(1) as usize, mem::align_of::<T>()) as *const u8 }
455447
}
456448

457449
// Returns a pointer to the end of the allocated space.
@@ -545,22 +537,29 @@ mod tests {
545537

546538
#[test]
547539
fn test_arena_alloc_nested() {
548-
struct Inner { value: u8 }
549-
struct Outer<'a> { inner: &'a Inner }
550-
enum EI<'e> { I(Inner), O(Outer<'e>) }
540+
struct Inner {
541+
value: u8,
542+
}
543+
struct Outer<'a> {
544+
inner: &'a Inner,
545+
}
546+
enum EI<'e> {
547+
I(Inner),
548+
O(Outer<'e>),
549+
}
551550

552551
struct Wrap<'a>(TypedArena<EI<'a>>);
553552

554553
impl<'a> Wrap<'a> {
555-
fn alloc_inner<F:Fn() -> Inner>(&self, f: F) -> &Inner {
554+
fn alloc_inner<F: Fn() -> Inner>(&self, f: F) -> &Inner {
556555
let r: &EI = self.0.alloc(EI::I(f()));
557556
if let &EI::I(ref i) = r {
558557
i
559558
} else {
560559
panic!("mismatch");
561560
}
562561
}
563-
fn alloc_outer<F:Fn() -> Outer<'a>>(&self, f: F) -> &Outer {
562+
fn alloc_outer<F: Fn() -> Outer<'a>>(&self, f: F) -> &Outer {
564563
let r: &EI = self.0.alloc(EI::O(f()));
565564
if let &EI::O(ref o) = r {
566565
o
@@ -572,8 +571,9 @@ mod tests {
572571

573572
let arena = Wrap(TypedArena::new());
574573

575-
let result = arena.alloc_outer(|| Outer {
576-
inner: arena.alloc_inner(|| Inner { value: 10 }) });
574+
let result = arena.alloc_outer(|| {
575+
Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }
576+
});
577577

578578
assert_eq!(result.inner.value, 10);
579579
}
@@ -582,49 +582,27 @@ mod tests {
582582
pub fn test_copy() {
583583
let arena = TypedArena::new();
584584
for _ in 0..100000 {
585-
arena.alloc(Point {
586-
x: 1,
587-
y: 2,
588-
z: 3,
589-
});
585+
arena.alloc(Point { x: 1, y: 2, z: 3 });
590586
}
591587
}
592588

593589
#[bench]
594590
pub fn bench_copy(b: &mut Bencher) {
595591
let arena = TypedArena::new();
596-
b.iter(|| {
597-
arena.alloc(Point {
598-
x: 1,
599-
y: 2,
600-
z: 3,
601-
})
602-
})
592+
b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 }))
603593
}
604594

605595
#[bench]
606596
pub fn bench_copy_nonarena(b: &mut Bencher) {
607597
b.iter(|| {
608-
let _: Box<_> = box Point {
609-
x: 1,
610-
y: 2,
611-
z: 3,
612-
};
598+
let _: Box<_> = box Point { x: 1, y: 2, z: 3 };
613599
})
614600
}
615601

616602
#[bench]
617603
pub fn bench_copy_old_arena(b: &mut Bencher) {
618604
let arena = Arena::new();
619-
b.iter(|| {
620-
arena.alloc(|| {
621-
Point {
622-
x: 1,
623-
y: 2,
624-
z: 3,
625-
}
626-
})
627-
})
605+
b.iter(|| arena.alloc(|| Point { x: 1, y: 2, z: 3 }))
628606
}
629607

630608
#[allow(dead_code)]
@@ -639,7 +617,7 @@ mod tests {
639617
for _ in 0..100000 {
640618
arena.alloc(Noncopy {
641619
string: "hello world".to_string(),
642-
array: vec!( 1, 2, 3, 4, 5 ),
620+
array: vec!(1, 2, 3, 4, 5),
643621
});
644622
}
645623
}
@@ -650,7 +628,7 @@ mod tests {
650628
b.iter(|| {
651629
arena.alloc(Noncopy {
652630
string: "hello world".to_string(),
653-
array: vec!( 1, 2, 3, 4, 5 ),
631+
array: vec!(1, 2, 3, 4, 5),
654632
})
655633
})
656634
}
@@ -660,7 +638,7 @@ mod tests {
660638
b.iter(|| {
661639
let _: Box<_> = box Noncopy {
662640
string: "hello world".to_string(),
663-
array: vec!( 1, 2, 3, 4, 5 ),
641+
array: vec!(1, 2, 3, 4, 5),
664642
};
665643
})
666644
}
@@ -669,9 +647,11 @@ mod tests {
669647
pub fn bench_noncopy_old_arena(b: &mut Bencher) {
670648
let arena = Arena::new();
671649
b.iter(|| {
672-
arena.alloc(|| Noncopy {
673-
string: "hello world".to_string(),
674-
array: vec!( 1, 2, 3, 4, 5 ),
650+
arena.alloc(|| {
651+
Noncopy {
652+
string: "hello world".to_string(),
653+
array: vec!(1, 2, 3, 4, 5),
654+
}
675655
})
676656
})
677657
}

0 commit comments

Comments
 (0)
Please sign in to comment.