Skip to content

Commit

Permalink
Remove workaround for deref issue that no longer exists.
Browse files Browse the repository at this point in the history
The double underscores were used to work around issue rust-lang#12808, which was
solved in 2016.
  • Loading branch information
m-ou-se committed Sep 24, 2020
1 parent 4eff9b0 commit 13dc237
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions library/std/src/sys_common/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ impl<T> RefUnwindSafe for ReentrantMutex<T> {}
/// guarded data.
#[must_use = "if unused the ReentrantMutex will immediately unlock"]
pub struct ReentrantMutexGuard<'a, T: 'a> {
// funny underscores due to how Deref currently works (it disregards field
// privacy).
__lock: &'a ReentrantMutex<T>,
lock: &'a ReentrantMutex<T>,
}

impl<T> !marker::Send for ReentrantMutexGuard<'_, T> {}
Expand Down Expand Up @@ -129,23 +127,23 @@ impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {

impl<'mutex, T> ReentrantMutexGuard<'mutex, T> {
fn new(lock: &'mutex ReentrantMutex<T>) -> ReentrantMutexGuard<'mutex, T> {
ReentrantMutexGuard { __lock: lock }
ReentrantMutexGuard { lock }
}
}

impl<T> Deref for ReentrantMutexGuard<'_, T> {
type Target = T;

fn deref(&self) -> &T {
&self.__lock.data
&self.lock.data
}
}

impl<T> Drop for ReentrantMutexGuard<'_, T> {
#[inline]
fn drop(&mut self) {
unsafe {
self.__lock.inner.unlock();
self.lock.inner.unlock();
}
}
}

0 comments on commit 13dc237

Please sign in to comment.