Run rustfmt on liballoc.
This commit is contained in:
parent
81b3b27cf5
commit
5dcd406188
4 changed files with 39 additions and 25 deletions
|
@ -307,9 +307,7 @@ impl<T: ?Sized> Arc<T> {
|
||||||
|
|
||||||
if self.inner().weak.fetch_sub(1, Release) == 1 {
|
if self.inner().weak.fetch_sub(1, Release) == 1 {
|
||||||
atomic::fence(Acquire);
|
atomic::fence(Acquire);
|
||||||
deallocate(ptr as *mut u8,
|
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
|
||||||
size_of_val(&*ptr),
|
|
||||||
align_of_val(&*ptr))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,11 +720,7 @@ impl<T: ?Sized> Drop for Weak<T> {
|
||||||
// ref, which can only happen after the lock is released.
|
// ref, which can only happen after the lock is released.
|
||||||
if self.inner().weak.fetch_sub(1, Release) == 1 {
|
if self.inner().weak.fetch_sub(1, Release) == 1 {
|
||||||
atomic::fence(Acquire);
|
atomic::fence(Acquire);
|
||||||
unsafe {
|
unsafe { deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) }
|
||||||
deallocate(ptr as *mut u8,
|
|
||||||
size_of_val(&*ptr),
|
|
||||||
align_of_val(&*ptr))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1152,5 +1146,7 @@ impl<T: ?Sized> borrow::Borrow<T> for Arc<T> {
|
||||||
|
|
||||||
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
||||||
impl<T: ?Sized> AsRef<T> for Arc<T> {
|
impl<T: ?Sized> AsRef<T> for Arc<T> {
|
||||||
fn as_ref(&self) -> &T { &**self }
|
fn as_ref(&self) -> &T {
|
||||||
|
&**self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,12 @@ fn make_place<T>() -> IntermediateBox<T> {
|
||||||
p
|
p
|
||||||
};
|
};
|
||||||
|
|
||||||
IntermediateBox { ptr: p, size: size, align: align, marker: marker::PhantomData }
|
IntermediateBox {
|
||||||
|
ptr: p,
|
||||||
|
size: size,
|
||||||
|
align: align,
|
||||||
|
marker: marker::PhantomData,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> BoxPlace<T> for IntermediateBox<T> {
|
impl<T> BoxPlace<T> for IntermediateBox<T> {
|
||||||
|
@ -538,7 +543,10 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
|
||||||
#[stable(feature = "box_slice_clone", since = "1.3.0")]
|
#[stable(feature = "box_slice_clone", since = "1.3.0")]
|
||||||
impl<T: Clone> Clone for Box<[T]> {
|
impl<T: Clone> Clone for Box<[T]> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
let mut new = BoxBuilder { data: RawVec::with_capacity(self.len()), len: 0 };
|
let mut new = BoxBuilder {
|
||||||
|
data: RawVec::with_capacity(self.len()),
|
||||||
|
len: 0,
|
||||||
|
};
|
||||||
|
|
||||||
let mut target = new.data.ptr();
|
let mut target = new.data.ptr();
|
||||||
|
|
||||||
|
@ -597,10 +605,14 @@ impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> {
|
||||||
|
|
||||||
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
||||||
impl<T: ?Sized> AsRef<T> for Box<T> {
|
impl<T: ?Sized> AsRef<T> for Box<T> {
|
||||||
fn as_ref(&self) -> &T { &**self }
|
fn as_ref(&self) -> &T {
|
||||||
|
&**self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
||||||
impl<T: ?Sized> AsMut<T> for Box<T> {
|
impl<T: ?Sized> AsMut<T> for Box<T> {
|
||||||
fn as_mut(&mut self) -> &mut T { &mut **self }
|
fn as_mut(&mut self) -> &mut T {
|
||||||
|
&mut **self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,10 @@ impl<T> RawVec<T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
|
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
|
||||||
RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: cap }
|
RawVec {
|
||||||
|
ptr: Unique::new(heap::EMPTY as *mut T),
|
||||||
|
cap: cap,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +105,10 @@ impl<T> RawVec<T> {
|
||||||
ptr
|
ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
RawVec { ptr: Unique::new(ptr as *mut _), cap: cap }
|
RawVec {
|
||||||
|
ptr: Unique::new(ptr as *mut _),
|
||||||
|
cap: cap,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +120,10 @@ impl<T> RawVec<T> {
|
||||||
/// capacity cannot exceed `isize::MAX` (only a concern on 32-bit systems).
|
/// capacity cannot exceed `isize::MAX` (only a concern on 32-bit systems).
|
||||||
/// If the ptr and capacity come from a RawVec, then this is guaranteed.
|
/// If the ptr and capacity come from a RawVec, then this is guaranteed.
|
||||||
pub unsafe fn from_raw_parts(ptr: *mut T, cap: usize) -> Self {
|
pub unsafe fn from_raw_parts(ptr: *mut T, cap: usize) -> Self {
|
||||||
RawVec { ptr: Unique::new(ptr), cap: cap }
|
RawVec {
|
||||||
|
ptr: Unique::new(ptr),
|
||||||
|
cap: cap,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a `Box<[T]>` into a `RawVec<T>`.
|
/// Converts a `Box<[T]>` into a `RawVec<T>`.
|
||||||
|
@ -398,8 +407,7 @@ impl<T> RawVec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This check is my waterloo; it's the only thing Vec wouldn't have to do.
|
// This check is my waterloo; it's the only thing Vec wouldn't have to do.
|
||||||
assert!(self.cap >= amount,
|
assert!(self.cap >= amount, "Tried to shrink to a larger capacity");
|
||||||
"Tried to shrink to a larger capacity");
|
|
||||||
|
|
||||||
if amount == 0 {
|
if amount == 0 {
|
||||||
mem::replace(self, RawVec::new());
|
mem::replace(self, RawVec::new());
|
||||||
|
|
|
@ -467,9 +467,7 @@ impl<T: ?Sized> Drop for Rc<T> {
|
||||||
self.dec_weak();
|
self.dec_weak();
|
||||||
|
|
||||||
if self.weak() == 0 {
|
if self.weak() == 0 {
|
||||||
deallocate(ptr as *mut u8,
|
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
|
||||||
size_of_val(&*ptr),
|
|
||||||
align_of_val(&*ptr))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -788,9 +786,7 @@ impl<T: ?Sized> Drop for Weak<T> {
|
||||||
// the weak count starts at 1, and will only go to zero if all
|
// the weak count starts at 1, and will only go to zero if all
|
||||||
// the strong pointers have disappeared.
|
// the strong pointers have disappeared.
|
||||||
if self.weak() == 0 {
|
if self.weak() == 0 {
|
||||||
deallocate(ptr as *mut u8,
|
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
|
||||||
size_of_val(&*ptr),
|
|
||||||
align_of_val(&*ptr))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1121,5 +1117,7 @@ impl<T: ?Sized> borrow::Borrow<T> for Rc<T> {
|
||||||
|
|
||||||
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
|
||||||
impl<T: ?Sized> AsRef<T> for Rc<T> {
|
impl<T: ?Sized> AsRef<T> for Rc<T> {
|
||||||
fn as_ref(&self) -> &T { &**self }
|
fn as_ref(&self) -> &T {
|
||||||
|
&**self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue