diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 6f0febd61e8..7b5076acbca 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -121,6 +121,8 @@ pub struct Mutex { data: UnsafeCell, } +// these are the only places where `T: Send` matters; all other +// functionality works fine on a single thread. unsafe impl Send for Mutex { } unsafe impl Sync for Mutex { } @@ -179,7 +181,7 @@ impl<'a, T> !marker::Send for MutexGuard<'a, T> {} poison: poison::FLAG_INIT, }; -impl Mutex { +impl Mutex { /// Creates a new mutex in an unlocked state ready for use. #[stable(feature = "rust1", since = "1.0.0")] pub fn new(t: T) -> Mutex { @@ -242,7 +244,7 @@ pub fn is_poisoned(&self) -> bool { #[unsafe_destructor] #[stable(feature = "rust1", since = "1.0.0")] -impl Drop for Mutex { +impl Drop for Mutex { 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 @@ -252,7 +254,7 @@ fn drop(&mut self) { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for Mutex { +impl fmt::Debug for Mutex { 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 e9ff6c0bf9d..d32eae15a1b 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -129,7 +129,7 @@ pub struct RwLockWriteGuard<'a, T: 'a> { impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {} -impl RwLock { +impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// /// # Examples @@ -257,7 +257,7 @@ fn drop(&mut self) { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for RwLock { +impl fmt::Debug for RwLock { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.try_read() { Ok(guard) => write!(f, "RwLock {{ data: {:?} }}", *guard),