Skip to content

Commit

Permalink
Rollup merge of #77164 - fusion-engineering-forks:no-more-funny-under…
Browse files Browse the repository at this point in the history
…scores, r=Mark-Simulacrum

Remove workaround for deref issue that no longer exists.

The double underscores were used to work around issue #12808, which was solved in 2016.
  • Loading branch information
jonas-schievink authored Sep 25, 2020
2 parents b8d158b + 13dc237 commit fc4dc5f
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 fc4dc5f

Please sign in to comment.