diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 18:38:19 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 18:38:19 -0700 |
| commit | d49b67e255db86a5df952b33f4140150fc12bf4d (patch) | |
| tree | f1f6284c449bd17747d0ccbf74f15994bce52dd2 /src/libstd | |
| parent | f92e7abefd0231f80d16062e5ff6aaf8cc3bc861 (diff) | |
| parent | 0f6b43aa8f288d3d12adc8747fb5060956d7f0e5 (diff) | |
| download | rust-d49b67e255db86a5df952b33f4140150fc12bf4d.tar.gz rust-d49b67e255db86a5df952b33f4140150fc12bf4d.zip | |
rollup merge of #23176: huonw/rm-bounds
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 24 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/mpsc_queue.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/oneshot.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/shared.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/spsc_queue.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/stream.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/sync.rs | 12 | ||||
| -rw-r--r-- | src/libstd/sync/mutex.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sync/rwlock.rs | 4 |
9 files changed, 36 insertions, 34 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index e14f32865fa..b436e49feab 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -488,7 +488,7 @@ impl<T:Send> UnsafeFlavor<T> for Receiver<T> { /// println!("{:?}", rx.recv().unwrap()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) { +pub fn channel<T>() -> (Sender<T>, Receiver<T>) { let a = Arc::new(UnsafeCell::new(oneshot::Packet::new())); (Sender::new(Flavor::Oneshot(a.clone())), Receiver::new(Flavor::Oneshot(a))) } @@ -528,7 +528,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) { /// assert_eq!(rx.recv().unwrap(), 2); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -pub fn sync_channel<T: Send>(bound: usize) -> (SyncSender<T>, Receiver<T>) { +pub fn sync_channel<T>(bound: usize) -> (SyncSender<T>, Receiver<T>) { let a = Arc::new(UnsafeCell::new(sync::Packet::new(bound))); (SyncSender::new(a.clone()), Receiver::new(Flavor::Sync(a))) } @@ -537,7 +537,7 @@ pub fn sync_channel<T: Send>(bound: usize) -> (SyncSender<T>, Receiver<T>) { // Sender //////////////////////////////////////////////////////////////////////////////// -impl<T: Send> Sender<T> { +impl<T> Sender<T> { fn new(inner: Flavor<T>) -> Sender<T> { Sender { inner: UnsafeCell::new(inner), @@ -619,7 +619,7 @@ impl<T: Send> Sender<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Clone for Sender<T> { +impl<T> Clone for Sender<T> { fn clone(&self) -> Sender<T> { let (packet, sleeper, guard) = match *unsafe { self.inner() } { Flavor::Oneshot(ref p) => { @@ -665,7 +665,7 @@ impl<T: Send> Clone for Sender<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Sender<T> { +impl<T> Drop for Sender<T> { fn drop(&mut self) { match *unsafe { self.inner_mut() } { Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_chan(); }, @@ -680,7 +680,7 @@ impl<T: Send> Drop for Sender<T> { // SyncSender //////////////////////////////////////////////////////////////////////////////// -impl<T: Send> SyncSender<T> { +impl<T> SyncSender<T> { fn new(inner: Arc<UnsafeCell<sync::Packet<T>>>) -> SyncSender<T> { SyncSender { inner: inner } } @@ -720,7 +720,7 @@ impl<T: Send> SyncSender<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Clone for SyncSender<T> { +impl<T> Clone for SyncSender<T> { fn clone(&self) -> SyncSender<T> { unsafe { (*self.inner.get()).clone_chan(); } return SyncSender::new(self.inner.clone()); @@ -729,7 +729,7 @@ impl<T: Send> Clone for SyncSender<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for SyncSender<T> { +impl<T> Drop for SyncSender<T> { fn drop(&mut self) { unsafe { (*self.inner.get()).drop_chan(); } } @@ -739,7 +739,7 @@ impl<T: Send> Drop for SyncSender<T> { // Receiver //////////////////////////////////////////////////////////////////////////////// -impl<T: Send> Receiver<T> { +impl<T> Receiver<T> { fn new(inner: Flavor<T>) -> Receiver<T> { Receiver { inner: UnsafeCell::new(inner) } } @@ -858,7 +858,7 @@ impl<T: Send> Receiver<T> { } } -impl<T: Send> select::Packet for Receiver<T> { +impl<T> select::Packet for Receiver<T> { fn can_recv(&self) -> bool { loop { let new_port = match *unsafe { self.inner() } { @@ -945,7 +945,7 @@ impl<T: Send> select::Packet for Receiver<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: Send> Iterator for Iter<'a, T> { +impl<'a, T> Iterator for Iter<'a, T> { type Item = T; fn next(&mut self) -> Option<T> { self.rx.recv().ok() } @@ -953,7 +953,7 @@ impl<'a, T: Send> Iterator for Iter<'a, T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Receiver<T> { +impl<T> Drop for Receiver<T> { fn drop(&mut self) { match *unsafe { self.inner_mut() } { Flavor::Oneshot(ref mut p) => unsafe { (*p.get()).drop_port(); }, diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 1be8b0dd862..7866a85dc8f 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -89,7 +89,7 @@ impl<T> Node<T> { } } -impl<T: Send> Queue<T> { +impl<T> Queue<T> { /// Creates a new queue that is safe to share among multiple producers and /// one consumer. pub fn new() -> Queue<T> { @@ -140,7 +140,7 @@ impl<T: Send> Queue<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Queue<T> { +impl<T> Drop for Queue<T> { fn drop(&mut self) { unsafe { let mut cur = *self.tail.get(); diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index 13578ce0517..21f690f0ee4 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -88,7 +88,7 @@ enum MyUpgrade<T:Send> { GoUp(Receiver<T>), } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { pub fn new() -> Packet<T> { Packet { data: None, @@ -368,7 +368,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { assert_eq!(self.state.load(Ordering::SeqCst), DISCONNECTED); } diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index 80cbd076163..be973028577 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -64,7 +64,7 @@ pub enum Failure { Disconnected, } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { // Creation of a packet *must* be followed by a call to postinit_lock // and later by inherit_blocker pub fn new() -> Packet<T> { @@ -474,7 +474,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { // Note that this load is not only an assert for correctness about // disconnection, but also a proper fence before the read of diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index cd6d1ee05c7..278ac03cf03 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -78,7 +78,7 @@ unsafe impl<T: Send> Send for Queue<T> { } unsafe impl<T: Send> Sync for Queue<T> { } -impl<T: Send> Node<T> { +impl<T> Node<T> { fn new() -> *mut Node<T> { unsafe { boxed::into_raw(box Node { @@ -89,7 +89,7 @@ impl<T: Send> Node<T> { } } -impl<T: Send> Queue<T> { +impl<T> Queue<T> { /// Creates a new queue. /// /// This is unsafe as the type system doesn't enforce a single @@ -227,7 +227,7 @@ impl<T: Send> Queue<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Queue<T> { +impl<T> Drop for Queue<T> { fn drop(&mut self) { unsafe { let mut cur = *self.first.get(); diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs index a5a73314a6d..25b5f6f27ba 100644 --- a/src/libstd/sync/mpsc/stream.rs +++ b/src/libstd/sync/mpsc/stream.rs @@ -74,7 +74,7 @@ enum Message<T:Send> { GoUp(Receiver<T>), } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { pub fn new() -> Packet<T> { Packet { queue: unsafe { spsc::Queue::new(128) }, @@ -472,7 +472,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { // Note that this load is not only an assert for correctness about // disconnection, but also a proper fence before the read of diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 71236269487..8e49edc44b6 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -113,10 +113,10 @@ pub enum Failure { /// Atomically blocks the current thread, placing it into `slot`, unlocking `lock` /// in the meantime. This re-locks the mutex upon returning. -fn wait<'a, 'b, T: Send>(lock: &'a Mutex<State<T>>, - mut guard: MutexGuard<'b, State<T>>, - f: fn(SignalToken) -> Blocker) - -> MutexGuard<'a, State<T>> +fn wait<'a, 'b, T>(lock: &'a Mutex<State<T>>, + mut guard: MutexGuard<'b, State<T>>, + f: fn(SignalToken) -> Blocker) + -> MutexGuard<'a, State<T>> { let (wait_token, signal_token) = blocking::tokens(); match mem::replace(&mut guard.blocker, f(signal_token)) { @@ -136,7 +136,7 @@ fn wakeup<T>(token: SignalToken, guard: MutexGuard<State<T>>) { token.signal(); } -impl<T: Send> Packet<T> { +impl<T> Packet<T> { pub fn new(cap: usize) -> Packet<T> { Packet { channels: AtomicUsize::new(1), @@ -412,7 +412,7 @@ impl<T: Send> Packet<T> { } #[unsafe_destructor] -impl<T: Send> Drop for Packet<T> { +impl<T> Drop for Packet<T> { fn drop(&mut self) { assert_eq!(self.channels.load(Ordering::SeqCst), 0); let mut guard = self.lock.lock().unwrap(); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index b24cfbb6899..6a721aff89e 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -122,6 +122,8 @@ pub struct Mutex<T: Send> { data: UnsafeCell<T>, } +// these are the only places where `T: Send` matters; all other +// functionality works fine on a single thread. unsafe impl<T: Send> Send for Mutex<T> { } unsafe impl<T: Send> Sync for Mutex<T> { } @@ -181,7 +183,7 @@ pub const MUTEX_INIT: StaticMutex = StaticMutex { poison: poison::FLAG_INIT, }; -impl<T: Send> Mutex<T> { +impl<T> Mutex<T> { /// Creates a new mutex in an unlocked state ready for use. #[stable(feature = "rust1", since = "1.0.0")] pub fn new(t: T) -> Mutex<T> { @@ -244,7 +246,7 @@ impl<T: Send> Mutex<T> { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl<T: Send> Drop for Mutex<T> { +impl<T> Drop for Mutex<T> { fn drop(&mut self) { // This is actually safe b/c we know that there is no further usage of // this mutex (it's up to the user to arrange for a mutex to get @@ -254,7 +256,7 @@ impl<T: Send> Drop for Mutex<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: fmt::Debug + Send + 'static> fmt::Debug for Mutex<T> { +impl<T: fmt::Debug + 'static> fmt::Debug for Mutex<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_lock() { Ok(guard) => write!(f, "Mutex {{ data: {:?} }}", *guard), diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index a79ffaa0860..d70350bc7d6 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -130,7 +130,7 @@ pub struct RwLockWriteGuard<'a, T: 'a> { impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {} -impl<T: Send + Sync> RwLock<T> { +impl<T> RwLock<T> { /// Creates a new instance of an `RwLock<T>` which is unlocked. /// /// # Examples @@ -258,7 +258,7 @@ impl<T> Drop for RwLock<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: fmt::Debug + Send + Sync> fmt::Debug for RwLock<T> { +impl<T: fmt::Debug> fmt::Debug for RwLock<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_read() { Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", *guard), |
