From 49697ae38bb724fd4eff97c64e73a83b9c1a28df Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 6 Dec 2019 17:28:04 +0100 Subject: [PATCH] get rid of __ in field names --- src/libstd/sync/mutex.rs | 22 ++++++++++------------ src/libstd/sync/rwlock.rs | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 87c2318a9377c..e90da69906009 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -143,10 +143,8 @@ unsafe impl Sync for Mutex { } #[must_use = "if unused the Mutex will immediately unlock"] #[stable(feature = "rust1", since = "1.0.0")] pub struct MutexGuard<'a, T: ?Sized + 'a> { - // funny underscores due to how Deref/DerefMut currently work (they - // disregard field privacy). - __lock: &'a Mutex, - __poison: poison::Guard, + lock: &'a Mutex, + poison: poison::Guard, } #[stable(feature = "rust1", since = "1.0.0")] @@ -417,8 +415,8 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { unsafe fn new(lock: &'mutex Mutex) -> LockResult> { poison::map_result(lock.poison.borrow(), |guard| { MutexGuard { - __lock: lock, - __poison: guard, + lock: lock, + poison: guard, } }) } @@ -429,14 +427,14 @@ impl Deref for MutexGuard<'_, T> { type Target = T; fn deref(&self) -> &T { - unsafe { &*self.__lock.data.get() } + unsafe { &*self.lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] impl DerefMut for MutexGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { - unsafe { &mut *self.__lock.data.get() } + unsafe { &mut *self.lock.data.get() } } } @@ -445,8 +443,8 @@ impl Drop for MutexGuard<'_, T> { #[inline] fn drop(&mut self) { unsafe { - self.__lock.poison.done(&self.__poison); - self.__lock.inner.raw_unlock(); + self.lock.poison.done(&self.poison); + self.lock.inner.raw_unlock(); } } } @@ -466,11 +464,11 @@ impl fmt::Display for MutexGuard<'_, T> { } pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex { - &guard.__lock.inner + &guard.lock.inner } pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag { - &guard.__lock.poison + &guard.lock.poison } #[cfg(all(test, not(target_os = "emscripten")))] diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index b1b56f321fc6b..c217291a42e48 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -87,7 +87,7 @@ unsafe impl Sync for RwLock {} #[must_use = "if unused the RwLock will immediately unlock"] #[stable(feature = "rust1", since = "1.0.0")] pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { - __lock: &'a RwLock, + lock: &'a RwLock, } #[stable(feature = "rust1", since = "1.0.0")] @@ -108,8 +108,8 @@ unsafe impl Sync for RwLockReadGuard<'_, T> {} #[must_use = "if unused the RwLock will immediately unlock"] #[stable(feature = "rust1", since = "1.0.0")] pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { - __lock: &'a RwLock, - __poison: poison::Guard, + lock: &'a RwLock, + poison: poison::Guard, } #[stable(feature = "rust1", since = "1.0.0")] @@ -465,7 +465,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { -> LockResult> { poison::map_result(lock.poison.borrow(), |_| { RwLockReadGuard { - __lock: lock, + lock: lock, } }) } @@ -476,8 +476,8 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { -> LockResult> { poison::map_result(lock.poison.borrow(), |guard| { RwLockWriteGuard { - __lock: lock, - __poison: guard, + lock: lock, + poison: guard, } }) } @@ -487,7 +487,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { impl fmt::Debug for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RwLockReadGuard") - .field("lock", &self.__lock) + .field("lock", &self.lock) .finish() } } @@ -503,7 +503,7 @@ impl fmt::Display for RwLockReadGuard<'_, T> { impl fmt::Debug for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RwLockWriteGuard") - .field("lock", &self.__lock) + .field("lock", &self.lock) .finish() } } @@ -520,7 +520,7 @@ impl Deref for RwLockReadGuard<'_, T> { type Target = T; fn deref(&self) -> &T { - unsafe { &*self.__lock.data.get() } + unsafe { &*self.lock.data.get() } } } @@ -529,29 +529,29 @@ impl Deref for RwLockWriteGuard<'_, T> { type Target = T; fn deref(&self) -> &T { - unsafe { &*self.__lock.data.get() } + unsafe { &*self.lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] impl DerefMut for RwLockWriteGuard<'_, T> { fn deref_mut(&mut self) -> &mut T { - unsafe { &mut *self.__lock.data.get() } + unsafe { &mut *self.lock.data.get() } } } #[stable(feature = "rust1", since = "1.0.0")] impl Drop for RwLockReadGuard<'_, T> { fn drop(&mut self) { - unsafe { self.__lock.inner.read_unlock(); } + unsafe { self.lock.inner.read_unlock(); } } } #[stable(feature = "rust1", since = "1.0.0")] impl Drop for RwLockWriteGuard<'_, T> { fn drop(&mut self) { - self.__lock.poison.done(&self.__poison); - unsafe { self.__lock.inner.write_unlock(); } + self.lock.poison.done(&self.poison); + unsafe { self.lock.inner.write_unlock(); } } }