Skip to content

Commit 60c18c8

Browse files
committed
Auto merge of #28987 - ahmedcharles:liballoc, r=brson
2 parents 5c7dbf6 + 5dcd406 commit 60c18c8

File tree

4 files changed

+39
-25
lines changed

4 files changed

+39
-25
lines changed

src/liballoc/arc.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ 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,
311-
size_of_val(&*ptr),
312-
align_of_val(&*ptr))
310+
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
313311
}
314312
}
315313
}
@@ -722,11 +720,7 @@ impl<T: ?Sized> Drop for Weak<T> {
722720
// ref, which can only happen after the lock is released.
723721
if self.inner().weak.fetch_sub(1, Release) == 1 {
724722
atomic::fence(Acquire);
725-
unsafe {
726-
deallocate(ptr as *mut u8,
727-
size_of_val(&*ptr),
728-
align_of_val(&*ptr))
729-
}
723+
unsafe { deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) }
730724
}
731725
}
732726
}
@@ -1152,5 +1146,7 @@ impl<T: ?Sized> borrow::Borrow<T> for Arc<T> {
11521146

11531147
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
11541148
impl<T: ?Sized> AsRef<T> for Arc<T> {
1155-
fn as_ref(&self) -> &T { &**self }
1149+
fn as_ref(&self) -> &T {
1150+
&**self
1151+
}
11561152
}

src/liballoc/boxed.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ fn make_place<T>() -> IntermediateBox<T> {
161161
p
162162
};
163163

164-
IntermediateBox { ptr: p, size: size, align: align, marker: marker::PhantomData }
164+
IntermediateBox {
165+
ptr: p,
166+
size: size,
167+
align: align,
168+
marker: marker::PhantomData,
169+
}
165170
}
166171

167172
impl<T> BoxPlace<T> for IntermediateBox<T> {
@@ -538,7 +543,10 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
538543
#[stable(feature = "box_slice_clone", since = "1.3.0")]
539544
impl<T: Clone> Clone for Box<[T]> {
540545
fn clone(&self) -> Self {
541-
let mut new = BoxBuilder { data: RawVec::with_capacity(self.len()), len: 0 };
546+
let mut new = BoxBuilder {
547+
data: RawVec::with_capacity(self.len()),
548+
len: 0,
549+
};
542550

543551
let mut target = new.data.ptr();
544552

@@ -597,10 +605,14 @@ impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> {
597605

598606
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
599607
impl<T: ?Sized> AsRef<T> for Box<T> {
600-
fn as_ref(&self) -> &T { &**self }
608+
fn as_ref(&self) -> &T {
609+
&**self
610+
}
601611
}
602612

603613
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
604614
impl<T: ?Sized> AsMut<T> for Box<T> {
605-
fn as_mut(&mut self) -> &mut T { &mut **self }
615+
fn as_mut(&mut self) -> &mut T {
616+
&mut **self
617+
}
606618
}

src/liballoc/raw_vec.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ impl<T> RawVec<T> {
6565
};
6666

6767
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
68-
RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: cap }
68+
RawVec {
69+
ptr: Unique::new(heap::EMPTY as *mut T),
70+
cap: cap,
71+
}
6972
}
7073
}
7174

@@ -102,7 +105,10 @@ impl<T> RawVec<T> {
102105
ptr
103106
};
104107

105-
RawVec { ptr: Unique::new(ptr as *mut _), cap: cap }
108+
RawVec {
109+
ptr: Unique::new(ptr as *mut _),
110+
cap: cap,
111+
}
106112
}
107113
}
108114

@@ -114,7 +120,10 @@ impl<T> RawVec<T> {
114120
/// capacity cannot exceed `isize::MAX` (only a concern on 32-bit systems).
115121
/// If the ptr and capacity come from a RawVec, then this is guaranteed.
116122
pub unsafe fn from_raw_parts(ptr: *mut T, cap: usize) -> Self {
117-
RawVec { ptr: Unique::new(ptr), cap: cap }
123+
RawVec {
124+
ptr: Unique::new(ptr),
125+
cap: cap,
126+
}
118127
}
119128

120129
/// Converts a `Box<[T]>` into a `RawVec<T>`.
@@ -398,8 +407,7 @@ impl<T> RawVec<T> {
398407
}
399408

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

404412
if amount == 0 {
405413
mem::replace(self, RawVec::new());

src/liballoc/rc.rs

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

469469
if self.weak() == 0 {
470-
deallocate(ptr as *mut u8,
471-
size_of_val(&*ptr),
472-
align_of_val(&*ptr))
470+
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
473471
}
474472
}
475473
}
@@ -788,9 +786,7 @@ impl<T: ?Sized> Drop for Weak<T> {
788786
// the weak count starts at 1, and will only go to zero if all
789787
// the strong pointers have disappeared.
790788
if self.weak() == 0 {
791-
deallocate(ptr as *mut u8,
792-
size_of_val(&*ptr),
793-
align_of_val(&*ptr))
789+
deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
794790
}
795791
}
796792
}
@@ -1121,5 +1117,7 @@ impl<T: ?Sized> borrow::Borrow<T> for Rc<T> {
11211117

11221118
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
11231119
impl<T: ?Sized> AsRef<T> for Rc<T> {
1124-
fn as_ref(&self) -> &T { &**self }
1120+
fn as_ref(&self) -> &T {
1121+
&**self
1122+
}
11251123
}

0 commit comments

Comments
 (0)