Skip to content

Commit 459f772

Browse files
committed
Better function calls
1 parent 06812c2 commit 459f772

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

src/liballoc/arc.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ impl<T: ?Sized> Arc<T> {
307307

308308
if self.inner().weak.fetch_sub(1, Release) == 1 {
309309
atomic::fence(Acquire);
310-
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
310+
deallocate(ptr as *mut u8,
311+
size_of_val(&*ptr),
312+
align_of_val(&*ptr))
311313
}
312314
}
313315
}
@@ -719,7 +721,11 @@ impl<T: ?Sized> Drop for Weak<T> {
719721
// ref, which can only happen after the lock is released.
720722
if self.inner().weak.fetch_sub(1, Release) == 1 {
721723
atomic::fence(Acquire);
722-
unsafe { deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) }
724+
unsafe {
725+
deallocate(ptr as *mut u8,
726+
size_of_val(&*ptr),
727+
align_of_val(&*ptr))
728+
}
723729
}
724730
}
725731
}

src/liballoc/heap.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ extern {
3434
#[inline(always)]
3535
fn check_size_and_alignment(size: usize, align: usize) {
3636
debug_assert!(size != 0);
37-
debug_assert!(size <= isize::MAX as usize, "Tried to allocate too much: {} bytes", size);
38-
debug_assert!(usize::is_power_of_two(align), "Invalid alignment of allocation: {}", align);
37+
debug_assert!(size <= isize::MAX as usize,
38+
"Tried to allocate too much: {} bytes",
39+
size);
40+
debug_assert!(usize::is_power_of_two(align),
41+
"Invalid alignment of allocation: {}",
42+
align);
3943
}
4044

4145
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`

src/liballoc/raw_vec.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ impl<T> RawVec<T> {
274274
let ptr = if self.cap == 0 {
275275
heap::allocate(new_alloc_size, align)
276276
} else {
277-
heap::reallocate(self.ptr() as *mut _, self.cap * elem_size, new_alloc_size, align)
277+
heap::reallocate(self.ptr() as *mut _,
278+
self.cap * elem_size,
279+
new_alloc_size,
280+
align)
278281
};
279282

280283
// If allocate or reallocate fail, we'll get `null` back
@@ -358,7 +361,10 @@ impl<T> RawVec<T> {
358361
let ptr = if self.cap == 0 {
359362
heap::allocate(new_alloc_size, align)
360363
} else {
361-
heap::reallocate(self.ptr() as *mut _, self.cap * elem_size, new_alloc_size, align)
364+
heap::reallocate(self.ptr() as *mut _,
365+
self.cap * elem_size,
366+
new_alloc_size,
367+
align)
362368
};
363369

364370
// If allocate or reallocate fail, we'll get `null` back
@@ -392,7 +398,8 @@ impl<T> RawVec<T> {
392398
}
393399

394400
// This check is my waterloo; it's the only thing Vec wouldn't have to do.
395-
assert!(self.cap >= amount, "Tried to shrink to a larger capacity");
401+
assert!(self.cap >= amount,
402+
"Tried to shrink to a larger capacity");
396403

397404
if amount == 0 {
398405
mem::replace(self, RawVec::new());
@@ -466,6 +473,7 @@ impl<T> Drop for RawVec<T> {
466473
#[inline]
467474
fn alloc_guard(alloc_size: usize) {
468475
if core::usize::BITS < 64 {
469-
assert!(alloc_size <= ::core::isize::MAX as usize, "capacity overflow");
476+
assert!(alloc_size <= ::core::isize::MAX as usize,
477+
"capacity overflow");
470478
}
471479
}

src/liballoc/rc.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ impl<T: ?Sized> Drop for Rc<T> {
466466
self.dec_weak();
467467

468468
if self.weak() == 0 {
469-
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
469+
deallocate(ptr as *mut u8,
470+
size_of_val(&*ptr),
471+
align_of_val(&*ptr))
470472
}
471473
}
472474
}
@@ -785,7 +787,9 @@ impl<T: ?Sized> Drop for Weak<T> {
785787
// the weak count starts at 1, and will only go to zero if all
786788
// the strong pointers have disappeared.
787789
if self.weak() == 0 {
788-
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
790+
deallocate(ptr as *mut u8,
791+
size_of_val(&*ptr),
792+
align_of_val(&*ptr))
789793
}
790794
}
791795
}

0 commit comments

Comments
 (0)