未验证 提交 29847a4d 编写于 作者: M Mazdak Farrokhzad 提交者: GitHub

Rollup merge of #67094 - RalfJung:fields, r=Mark-Simulacrum

get rid of __ in field names

This old work-around should not be needed any more.
...@@ -143,10 +143,8 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { } ...@@ -143,10 +143,8 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
#[must_use = "if unused the Mutex will immediately unlock"] #[must_use = "if unused the Mutex will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct MutexGuard<'a, T: ?Sized + 'a> { pub struct MutexGuard<'a, T: ?Sized + 'a> {
// funny underscores due to how Deref/DerefMut currently work (they lock: &'a Mutex<T>,
// disregard field privacy). poison: poison::Guard,
__lock: &'a Mutex<T>,
__poison: poison::Guard,
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
...@@ -417,8 +415,8 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { ...@@ -417,8 +415,8 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> {
unsafe fn new(lock: &'mutex Mutex<T>) -> LockResult<MutexGuard<'mutex, T>> { unsafe fn new(lock: &'mutex Mutex<T>) -> LockResult<MutexGuard<'mutex, T>> {
poison::map_result(lock.poison.borrow(), |guard| { poison::map_result(lock.poison.borrow(), |guard| {
MutexGuard { MutexGuard {
__lock: lock, lock: lock,
__poison: guard, poison: guard,
} }
}) })
} }
...@@ -429,14 +427,14 @@ impl<T: ?Sized> Deref for MutexGuard<'_, T> { ...@@ -429,14 +427,14 @@ impl<T: ?Sized> Deref for MutexGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &T { fn deref(&self) -> &T {
unsafe { &*self.__lock.data.get() } unsafe { &*self.lock.data.get() }
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> DerefMut for MutexGuard<'_, T> { impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut 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<T: ?Sized> Drop for MutexGuard<'_, T> { ...@@ -445,8 +443,8 @@ impl<T: ?Sized> Drop for MutexGuard<'_, T> {
#[inline] #[inline]
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
self.__lock.poison.done(&self.__poison); self.lock.poison.done(&self.poison);
self.__lock.inner.raw_unlock(); self.lock.inner.raw_unlock();
} }
} }
} }
...@@ -466,11 +464,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -466,11 +464,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex { 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 { 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")))] #[cfg(all(test, not(target_os = "emscripten")))]
......
...@@ -87,7 +87,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {} ...@@ -87,7 +87,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
#[must_use = "if unused the RwLock will immediately unlock"] #[must_use = "if unused the RwLock will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
__lock: &'a RwLock<T>, lock: &'a RwLock<T>,
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
...@@ -108,8 +108,8 @@ unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {} ...@@ -108,8 +108,8 @@ unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {}
#[must_use = "if unused the RwLock will immediately unlock"] #[must_use = "if unused the RwLock will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
__lock: &'a RwLock<T>, lock: &'a RwLock<T>,
__poison: poison::Guard, poison: poison::Guard,
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
...@@ -465,7 +465,7 @@ unsafe fn new(lock: &'rwlock RwLock<T>) ...@@ -465,7 +465,7 @@ unsafe fn new(lock: &'rwlock RwLock<T>)
-> LockResult<RwLockReadGuard<'rwlock, T>> { -> LockResult<RwLockReadGuard<'rwlock, T>> {
poison::map_result(lock.poison.borrow(), |_| { poison::map_result(lock.poison.borrow(), |_| {
RwLockReadGuard { RwLockReadGuard {
__lock: lock, lock: lock,
} }
}) })
} }
...@@ -476,8 +476,8 @@ unsafe fn new(lock: &'rwlock RwLock<T>) ...@@ -476,8 +476,8 @@ unsafe fn new(lock: &'rwlock RwLock<T>)
-> LockResult<RwLockWriteGuard<'rwlock, T>> { -> LockResult<RwLockWriteGuard<'rwlock, T>> {
poison::map_result(lock.poison.borrow(), |guard| { poison::map_result(lock.poison.borrow(), |guard| {
RwLockWriteGuard { RwLockWriteGuard {
__lock: lock, lock: lock,
__poison: guard, poison: guard,
} }
}) })
} }
...@@ -487,7 +487,7 @@ unsafe fn new(lock: &'rwlock RwLock<T>) ...@@ -487,7 +487,7 @@ unsafe fn new(lock: &'rwlock RwLock<T>)
impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> { impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwLockReadGuard") f.debug_struct("RwLockReadGuard")
.field("lock", &self.__lock) .field("lock", &self.lock)
.finish() .finish()
} }
} }
...@@ -503,7 +503,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -503,7 +503,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> { impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwLockWriteGuard") f.debug_struct("RwLockWriteGuard")
.field("lock", &self.__lock) .field("lock", &self.lock)
.finish() .finish()
} }
} }
...@@ -520,7 +520,7 @@ impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> { ...@@ -520,7 +520,7 @@ impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &T { fn deref(&self) -> &T {
unsafe { &*self.__lock.data.get() } unsafe { &*self.lock.data.get() }
} }
} }
...@@ -529,29 +529,29 @@ impl<T: ?Sized> Deref for RwLockWriteGuard<'_, T> { ...@@ -529,29 +529,29 @@ impl<T: ?Sized> Deref for RwLockWriteGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &T { fn deref(&self) -> &T {
unsafe { &*self.__lock.data.get() } unsafe { &*self.lock.data.get() }
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> DerefMut for RwLockWriteGuard<'_, T> { impl<T: ?Sized> DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut 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")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for RwLockReadGuard<'_, T> { impl<T: ?Sized> Drop for RwLockReadGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { self.__lock.inner.read_unlock(); } unsafe { self.lock.inner.read_unlock(); }
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for RwLockWriteGuard<'_, T> { impl<T: ?Sized> Drop for RwLockWriteGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
self.__lock.poison.done(&self.__poison); self.lock.poison.done(&self.poison);
unsafe { self.__lock.inner.write_unlock(); } unsafe { self.lock.inner.write_unlock(); }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册