about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-11-25 20:40:27 +0000
committerbors <bors@rust-lang.org>2015-11-25 20:40:27 +0000
commitbef2af620187350a49c840099760f24acd21c861 (patch)
tree9deb3089b49e1c4d2b88792ccdcda017619a2c96 /src/liballoc
parent1bb91be05f3e947364de8f6781124003ce2404ab (diff)
parent5fb6531903c4e425f48a859463bee20cfcc7f7c5 (diff)
downloadrust-bef2af620187350a49c840099760f24acd21c861.tar.gz
rust-bef2af620187350a49c840099760f24acd21c861.zip
Auto merge of #30017 - nrc:fmt, r=brson
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs37
-rw-r--r--src/liballoc/boxed.rs14
-rw-r--r--src/liballoc/boxed_test.rs3
-rw-r--r--src/liballoc/heap.rs2
-rw-r--r--src/liballoc/rc.rs20
5 files changed, 37 insertions, 39 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index 45a47ae075e..f8483a8ed9b 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -131,11 +131,12 @@ pub struct Arc<T: ?Sized> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> { }
+unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> {}
 #[stable(feature = "rust1", since = "1.0.0")]
-unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> { }
+unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> {}
 
-#[cfg(not(stage0))] // remove cfg after new snapshot
+// remove cfg after new snapshot
+#[cfg(not(stage0))]
 #[unstable(feature = "coerce_unsized", issue = "27732")]
 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
 
@@ -152,11 +153,12 @@ pub struct Weak<T: ?Sized> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> { }
+unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> {}
 #[stable(feature = "rust1", since = "1.0.0")]
-unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> { }
+unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> {}
 
-#[cfg(not(stage0))] // remove cfg after new snapshot
+// remove cfg after new snapshot
+#[cfg(not(stage0))]
 #[unstable(feature = "coerce_unsized", issue = "27732")]
 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
 
@@ -226,7 +228,7 @@ impl<T> Arc<T> {
     pub fn try_unwrap(this: Self) -> Result<T, Self> {
         // 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<T: ?Sized> Arc<T> {
 
             // 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<T: ?Sized> Arc<T> {
             // 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<T: ?Sized> Drop for Arc<T> {
         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,7 +636,7 @@ impl<T: ?Sized> Weak<T> {
             // confirmed via the CAS below.
             let n = inner.strong.load(Relaxed);
             if n == 0 {
-                return None
+                return None;
             }
 
             // See comments in `Arc::clone` for why we do this (for `mem::forget`).
@@ -645,7 +647,7 @@ impl<T: ?Sized> Weak<T> {
             // 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 });
             }
         }
     }
@@ -687,7 +689,7 @@ impl<T: ?Sized> Clone for Weak<T> {
             }
         }
 
-        return Weak { _ptr: self._ptr }
+        return Weak { _ptr: self._ptr };
     }
 }
 
@@ -723,7 +725,7 @@ impl<T: ?Sized> Drop for Weak<T> {
 
         // 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
@@ -933,8 +935,7 @@ mod tests {
 
     struct Canary(*mut atomic::AtomicUsize);
 
-    impl Drop for Canary
-    {
+    impl Drop for Canary {
         fn drop(&mut self) {
             unsafe {
                 match *self {
@@ -948,7 +949,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<T> Box<T> {
     }
 }
 
-impl<T : ?Sized> Box<T> {
+impl<T: ?Sized> Box<T> {
     /// Constructs a box from the raw pointer.
     ///
     /// After this function call, pointer is owned by resulting box.
@@ -535,8 +534,7 @@ pub trait FnBox<A> {
 }
 
 #[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
-impl<A,F> FnBox<A> for F
-    where F: FnOnce<A>
+impl<A, F> FnBox<A> for F where F: FnOnce<A>
 {
     type Output = F::Output;
 
@@ -546,7 +544,7 @@ impl<A,F> FnBox<A> for F
 }
 
 #[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
-impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+'a> {
+impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
     type Output = R;
 
     extern "rust-call" fn call_once(self, args: A) -> R {
@@ -555,7 +553,7 @@ impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+'a> {
 }
 
 #[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
-impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+Send+'a> {
+impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
     type Output = R;
 
     extern "rust-call" fn call_once(self, args: A) -> R {
@@ -564,7 +562,7 @@ impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+Send+'a> {
 }
 
 #[unstable(feature = "coerce_unsized", issue = "27732")]
-impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
+impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
 
 #[stable(feature = "box_slice_clone", since = "1.3.0")]
 impl<T: Clone> 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: Deref<Target = i32>>(_: T) {
-    }
+    fn homura<T: Deref<Target = i32>>(_: 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 0ea5ecfda79..404c7522403 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -196,9 +196,10 @@ impl<T: ?Sized> !marker::Send for Rc<T> {}
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> !marker::Sync for Rc<T> {}
 
-#[cfg(not(stage0))] // remove cfg after new snapshot
+// remove cfg after new snapshot
+#[cfg(not(stage0))]
 #[unstable(feature = "coerce_unsized", issue = "27732")]
-impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
+impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
 
 impl<T> Rc<T> {
     /// Constructs a new `Rc<T>`.
@@ -482,7 +483,6 @@ impl<T: ?Sized> Drop for Rc<T> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> Clone for Rc<T> {
-
     /// Makes a clone of the `Rc<T>`.
     ///
     /// When you clone an `Rc<T>`, it will create another pointer to the data and
@@ -678,21 +678,21 @@ impl<T: ?Sized + Ord> Ord for Rc<T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized+Hash> Hash for Rc<T> {
+impl<T: ?Sized + Hash> Hash for Rc<T> {
     fn hash<H: Hasher>(&self, state: &mut H) {
         (**self).hash(state);
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized+fmt::Display> fmt::Display for Rc<T> {
+impl<T: ?Sized + fmt::Display> fmt::Display for Rc<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fmt::Display::fmt(&**self, f)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized+fmt::Debug> fmt::Debug for Rc<T> {
+impl<T: ?Sized + fmt::Debug> fmt::Debug for Rc<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fmt::Debug::fmt(&**self, f)
     }
@@ -731,9 +731,10 @@ impl<T: ?Sized> !marker::Send for Weak<T> {}
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> !marker::Sync for Weak<T> {}
 
-#[cfg(not(stage0))] // remove cfg after new snapshot
+// remove cfg after new snapshot
+#[cfg(not(stage0))]
 #[unstable(feature = "coerce_unsized", issue = "27732")]
-impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
+impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
 
 impl<T: ?Sized> Weak<T> {
     /// Upgrades a weak reference to a strong reference.
@@ -810,7 +811,6 @@ impl<T: ?Sized> Drop for Weak<T> {
 
 #[stable(feature = "rc_weak", since = "1.4.0")]
 impl<T: ?Sized> Clone for Weak<T> {
-
     /// Makes a clone of the `Weak<T>`.
     ///
     /// This increases the weak reference count.
@@ -832,7 +832,7 @@ impl<T: ?Sized> Clone for Weak<T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized+fmt::Debug> fmt::Debug for Weak<T> {
+impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "(Weak)")
     }