]> git.lizzy.rs Git - rust.git/commitdiff
Remove unneeded `T: Send + Sync` bounds from `Arc`.
authorHuon Wilson <dbau.pp+github@gmail.com>
Sun, 8 Mar 2015 10:59:08 +0000 (21:59 +1100)
committerHuon Wilson <dbau.pp+github@gmail.com>
Sun, 8 Mar 2015 10:59:08 +0000 (21:59 +1100)
The requirement `T: Send + Sync` only matters if the `Arc` crosses
thread boundaries, and that is adequately controlled by the impls of
`Send`/`Sync` for `Arc` itself. If `T` doesn't satisfy the bounds, then
the `Arc` cannot cross thread boundaries and so everything is still
safe (`Arc` just acts like an expensive `Rc`).

src/liballoc/arc.rs

index dc1938cac1ada7b51f3d12e264d9e85245f9773d..ce25f907ec2cc4cb84c4d6c3666c8c18cb41ddc4 100644 (file)
@@ -265,7 +265,7 @@ fn deref(&self) -> &T {
     }
 }
 
-impl<T: Send + Sync + Clone> Arc<T> {
+impl<T: Clone> Arc<T> {
     /// Make a mutable reference from the given `Arc<T>`.
     ///
     /// This is also referred to as a copy-on-write operation because the inner data is cloned if
@@ -300,7 +300,7 @@ pub fn make_unique(&mut self) -> &mut T {
 
 #[unsafe_destructor]
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Sync + Send> Drop for Arc<T> {
+impl<T> Drop for Arc<T> {
     /// Drops the `Arc<T>`.
     ///
     /// This will decrement the strong reference count. If the strong reference count becomes zero
@@ -367,7 +367,7 @@ fn drop(&mut self) {
 
 #[unstable(feature = "alloc",
            reason = "Weak pointers may not belong in this module.")]
-impl<T: Sync + Send> Weak<T> {
+impl<T> Weak<T> {
     /// Upgrades a weak reference to a strong reference.
     ///
     /// Upgrades the `Weak<T>` reference to an `Arc<T>`, if possible.
@@ -406,7 +406,7 @@ fn inner(&self) -> &ArcInner<T> {
 
 #[unstable(feature = "alloc",
            reason = "Weak pointers may not belong in this module.")]
-impl<T: Sync + Send> Clone for Weak<T> {
+impl<T> Clone for Weak<T> {
     /// Makes a clone of the `Weak<T>`.
     ///
     /// This increases the weak reference count.
@@ -430,7 +430,7 @@ fn clone(&self) -> Weak<T> {
 
 #[unsafe_destructor]
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Sync + Send> Drop for Weak<T> {
+impl<T> Drop for Weak<T> {
     /// Drops the `Weak<T>`.
     ///
     /// This will decrement the weak reference count.