From 1f1a1e6595cb9472927cd91d523982047832aa7a Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 23 Nov 2015 15:32:40 +1300 Subject: rustfmt: liballoc, liballoc_*, libarena --- src/liballoc/arc.rs | 37 +++++++++++++++++++------------------ src/liballoc/boxed.rs | 14 ++++++-------- src/liballoc/boxed_test.rs | 3 +-- src/liballoc/heap.rs | 2 +- src/liballoc/rc.rs | 20 ++++++++++---------- 5 files changed, 37 insertions(+), 39 deletions(-) (limited to 'src/liballoc') diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 7863f101811..77ef8a50619 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -131,11 +131,12 @@ pub struct Arc { } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Send for Arc { } +unsafe impl Send for Arc {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Sync for Arc { } +unsafe impl Sync for Arc {} -#[cfg(not(stage0))] // remove cfg after new snapshot +// remove cfg after new snapshot +#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Arc {} @@ -152,11 +153,12 @@ pub struct Weak { } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Send for Weak { } +unsafe impl Send for Weak {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Sync for Weak { } +unsafe impl Sync for Weak {} -#[cfg(not(stage0))] // remove cfg after new snapshot +// remove cfg after new snapshot +#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Weak {} @@ -226,7 +228,7 @@ impl Arc { pub fn try_unwrap(this: Self) -> Result { // See `drop` for why all these atomics are like this if this.inner().strong.compare_and_swap(1, 0, Release) != 1 { - return Err(this) + return Err(this); } atomic::fence(Acquire); @@ -265,7 +267,7 @@ impl Arc { // check if the weak counter is currently "locked"; if so, spin. if cur == usize::MAX { - continue + continue; } // NOTE: this code currently ignores the possibility of overflow @@ -276,7 +278,7 @@ impl Arc { // synchronize with the write coming from `is_unique`, so that the // events prior to that write happen before this read. if this.inner().weak.compare_and_swap(cur, cur + 1, Acquire) == cur { - return Weak { _ptr: this._ptr } + return Weak { _ptr: this._ptr }; } } } @@ -568,14 +570,14 @@ impl Drop for Arc { let ptr = *self._ptr; // if ptr.is_null() { return } if ptr as *mut u8 as usize == 0 || ptr as *mut u8 as usize == mem::POST_DROP_USIZE { - return + return; } // Because `fetch_sub` is already atomic, we do not need to synchronize // with other threads unless we are going to delete the object. This // same logic applies to the below `fetch_sub` to the `weak` count. if self.inner().strong.fetch_sub(1, Release) != 1 { - return + return; } // This fence is needed to prevent reordering of use of the data and @@ -634,13 +636,13 @@ impl Weak { // confirmed via the CAS below. let n = inner.strong.load(Relaxed); if n == 0 { - return None + return None; } // Relaxed is valid for the same reason it is on Arc's Clone impl let old = inner.strong.compare_and_swap(n, n + 1, Relaxed); if old == n { - return Some(Arc { _ptr: self._ptr }) + return Some(Arc { _ptr: self._ptr }); } } } @@ -682,7 +684,7 @@ impl Clone for Weak { } } - return Weak { _ptr: self._ptr } + return Weak { _ptr: self._ptr }; } } @@ -718,7 +720,7 @@ impl Drop for Weak { // see comments above for why this check is here if ptr as *mut u8 as usize == 0 || ptr as *mut u8 as usize == mem::POST_DROP_USIZE { - return + return; } // If we find out that we were the last weak pointer, then its time to @@ -928,8 +930,7 @@ mod tests { struct Canary(*mut atomic::AtomicUsize); - impl Drop for Canary - { + impl Drop for Canary { fn drop(&mut self) { unsafe { match *self { @@ -943,7 +944,7 @@ mod tests { #[test] fn manually_share_arc() { - let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arc_v = Arc::new(v); let (tx, rx) = channel(); diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 65c66ebe768..804c593467e 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -88,8 +88,7 @@ use core::convert::From; #[unstable(feature = "box_heap", reason = "may be renamed; uncertain about custom allocator design", issue = "27779")] -pub const HEAP: ExchangeHeapSingleton = - ExchangeHeapSingleton { _force_singleton: () }; +pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () }; /// This the singleton type used solely for `boxed::HEAP`. #[unstable(feature = "box_heap", @@ -238,7 +237,7 @@ impl Box { } } -impl Box { +impl Box { /// Constructs a box from the raw pointer. /// /// After this function call, pointer is owned by resulting box. @@ -535,8 +534,7 @@ pub trait FnBox { } #[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")] -impl FnBox for F - where F: FnOnce +impl FnBox for F where F: FnOnce { type Output = F::Output; @@ -546,7 +544,7 @@ impl FnBox for F } #[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")] -impl<'a,A,R> FnOnce for Box+'a> { +impl<'a, A, R> FnOnce for Box + 'a> { type Output = R; extern "rust-call" fn call_once(self, args: A) -> R { @@ -555,7 +553,7 @@ impl<'a,A,R> FnOnce for Box+'a> { } #[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")] -impl<'a,A,R> FnOnce for Box+Send+'a> { +impl<'a, A, R> FnOnce for Box + Send + 'a> { type Output = R; extern "rust-call" fn call_once(self, args: A) -> R { @@ -564,7 +562,7 @@ impl<'a,A,R> FnOnce for Box+Send+'a> { } #[unstable(feature = "coerce_unsized", issue = "27732")] -impl, U: ?Sized> CoerceUnsized> for Box {} +impl, U: ?Sized> CoerceUnsized> for Box {} #[stable(feature = "box_slice_clone", since = "1.3.0")] impl Clone for Box<[T]> { diff --git a/src/liballoc/boxed_test.rs b/src/liballoc/boxed_test.rs index 7f3dadcf24d..e7da6d04d3f 100644 --- a/src/liballoc/boxed_test.rs +++ b/src/liballoc/boxed_test.rs @@ -74,8 +74,7 @@ fn test_show() { #[test] fn deref() { - fn homura>(_: T) { - } + fn homura>(_: T) {} homura(Box::new(765)); } diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 6961702cbc0..7e7e3c619cb 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -18,7 +18,7 @@ use core::{isize, usize}; #[allow(improper_ctypes)] -extern { +extern "C" { #[allocator] fn __rust_allocate(size: usize, align: usize) -> *mut u8; fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize); diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 7abdc447ee5..a77e4f06338 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -196,9 +196,10 @@ impl !marker::Send for Rc {} #[stable(feature = "rust1", since = "1.0.0")] impl !marker::Sync for Rc {} -#[cfg(not(stage0))] // remove cfg after new snapshot +// remove cfg after new snapshot +#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] -impl, U: ?Sized> CoerceUnsized> for Rc {} +impl, U: ?Sized> CoerceUnsized> for Rc {} impl Rc { /// Constructs a new `Rc`. @@ -482,7 +483,6 @@ impl Drop for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Rc { - /// Makes a clone of the `Rc`. /// /// When you clone an `Rc`, it will create another pointer to the data and @@ -678,21 +678,21 @@ impl Ord for Rc { } #[stable(feature = "rust1", since = "1.0.0")] -impl Hash for Rc { +impl Hash for Rc { fn hash(&self, state: &mut H) { (**self).hash(state); } } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Display for Rc { +impl fmt::Display for Rc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for Rc { +impl fmt::Debug for Rc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } @@ -731,9 +731,10 @@ impl !marker::Send for Weak {} #[stable(feature = "rust1", since = "1.0.0")] impl !marker::Sync for Weak {} -#[cfg(not(stage0))] // remove cfg after new snapshot +// remove cfg after new snapshot +#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] -impl, U: ?Sized> CoerceUnsized> for Weak {} +impl, U: ?Sized> CoerceUnsized> for Weak {} impl Weak { /// Upgrades a weak reference to a strong reference. @@ -810,7 +811,6 @@ impl Drop for Weak { #[stable(feature = "rc_weak", since = "1.4.0")] impl Clone for Weak { - /// Makes a clone of the `Weak`. /// /// This increases the weak reference count. @@ -832,7 +832,7 @@ impl Clone for Weak { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for Weak { +impl fmt::Debug for Weak { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "(Weak)") } -- cgit 1.4.1-3-g733a5