Format the world
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index c217291..2ff3613 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs
@@ -360,7 +360,10 @@ /// assert_eq!(lock.into_inner().unwrap(), "modified"); /// ``` #[stable(feature = "rwlock_into_inner", since = "1.6.0")] - pub fn into_inner(self) -> LockResult<T> where T: Sized { + pub fn into_inner(self) -> LockResult<T> + where + T: Sized, + { // We know statically that there are no outstanding references to // `self` so there's no need to lock the inner lock. // @@ -426,7 +429,7 @@ Ok(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), Err(TryLockError::Poisoned(err)) => { f.debug_struct("RwLock").field("data", &&**err.get_ref()).finish() - }, + } Err(TryLockError::WouldBlock) => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { @@ -461,24 +464,16 @@ } impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { - unsafe fn new(lock: &'rwlock RwLock<T>) - -> LockResult<RwLockReadGuard<'rwlock, T>> { - poison::map_result(lock.poison.borrow(), |_| { - RwLockReadGuard { - lock: lock, - } - }) + unsafe fn new(lock: &'rwlock RwLock<T>) -> LockResult<RwLockReadGuard<'rwlock, T>> { + poison::map_result(lock.poison.borrow(), |_| RwLockReadGuard { lock: lock }) } } impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { - unsafe fn new(lock: &'rwlock RwLock<T>) - -> LockResult<RwLockWriteGuard<'rwlock, T>> { - poison::map_result(lock.poison.borrow(), |guard| { - RwLockWriteGuard { - lock: lock, - poison: guard, - } + unsafe fn new(lock: &'rwlock RwLock<T>) -> LockResult<RwLockWriteGuard<'rwlock, T>> { + poison::map_result(lock.poison.borrow(), |guard| RwLockWriteGuard { + lock: lock, + poison: guard, }) } } @@ -486,9 +481,7 @@ #[stable(feature = "std_debug", since = "1.16.0")] impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RwLockReadGuard") - .field("lock", &self.lock) - .finish() + f.debug_struct("RwLockReadGuard").field("lock", &self.lock).finish() } } @@ -502,9 +495,7 @@ #[stable(feature = "std_debug", since = "1.16.0")] impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RwLockWriteGuard") - .field("lock", &self.lock) - .finish() + f.debug_struct("RwLockWriteGuard").field("lock", &self.lock).finish() } } @@ -543,7 +534,9 @@ #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> Drop for RwLockReadGuard<'_, T> { fn drop(&mut self) { - unsafe { self.lock.inner.read_unlock(); } + unsafe { + self.lock.inner.read_unlock(); + } } } @@ -551,17 +544,19 @@ impl<T: ?Sized> Drop for RwLockWriteGuard<'_, T> { fn drop(&mut self) { self.lock.poison.done(&self.poison); - unsafe { self.lock.inner.write_unlock(); } + unsafe { + self.lock.inner.write_unlock(); + } } } #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use rand::{self, Rng}; - use crate::sync::mpsc::channel; - use crate::thread; - use crate::sync::{Arc, RwLock, TryLockError}; use crate::sync::atomic::{AtomicUsize, Ordering}; + use crate::sync::mpsc::channel; + use crate::sync::{Arc, RwLock, TryLockError}; + use crate::thread; + use rand::{self, Rng}; #[derive(Eq, PartialEq, Debug)] struct NonCopy(i32); @@ -609,7 +604,8 @@ let _: Result<(), _> = thread::spawn(move || { let _lock = arc2.write().unwrap(); panic!(); - }).join(); + }) + .join(); assert!(arc.read().is_err()); } @@ -621,7 +617,8 @@ let _: Result<(), _> = thread::spawn(move || { let _lock = arc2.write().unwrap(); panic!(); - }).join(); + }) + .join(); assert!(arc.write().is_err()); assert!(arc.is_poisoned()); } @@ -633,7 +630,8 @@ let _: Result<(), _> = thread::spawn(move || { let _lock = arc2.read().unwrap(); panic!(); - }).join(); + }) + .join(); let lock = arc.read().unwrap(); assert_eq!(*lock, 1); } @@ -644,7 +642,8 @@ let _: Result<(), _> = thread::spawn(move || { let _lock = arc2.read().unwrap(); panic!() - }).join(); + }) + .join(); let lock = arc.write().unwrap(); assert_eq!(*lock, 1); } @@ -703,7 +702,8 @@ } let _u = Unwinder { i: arc2 }; panic!(); - }).join(); + }) + .join(); let lock = arc.read().unwrap(); assert_eq!(*lock, 2); } @@ -766,7 +766,8 @@ let _ = thread::spawn(move || { let _lock = m2.write().unwrap(); panic!("test panic in inner thread to poison RwLock"); - }).join(); + }) + .join(); assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().into_inner() { @@ -789,7 +790,8 @@ let _ = thread::spawn(move || { let _lock = m2.write().unwrap(); panic!("test panic in inner thread to poison RwLock"); - }).join(); + }) + .join(); assert!(m.is_poisoned()); match Arc::try_unwrap(m).unwrap().get_mut() {