Skip to content

Commit 3fadc60

Browse files
committed
Don't use mut in Windows Mutex.
1 parent 1016deb commit 3fadc60

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

library/std/src/sys/windows/mutex.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Mutex {
6464
match kind() {
6565
Kind::SRWLock => c::AcquireSRWLockExclusive(raw(self)),
6666
Kind::CriticalSection => {
67-
let inner = &mut *self.inner();
67+
let inner = &*self.inner();
6868
inner.remutex.lock();
6969
if inner.held.replace(true) {
7070
// It was already locked, so we got a recursive lock which we do not want.
@@ -78,7 +78,7 @@ impl Mutex {
7878
match kind() {
7979
Kind::SRWLock => c::TryAcquireSRWLockExclusive(raw(self)) != 0,
8080
Kind::CriticalSection => {
81-
let inner = &mut *self.inner();
81+
let inner = &*self.inner();
8282
if !inner.remutex.try_lock() {
8383
false
8484
} else if inner.held.replace(true) {
@@ -95,7 +95,7 @@ impl Mutex {
9595
match kind() {
9696
Kind::SRWLock => c::ReleaseSRWLockExclusive(raw(self)),
9797
Kind::CriticalSection => {
98-
let inner = &mut *(self.lock.load(Ordering::SeqCst) as *mut Inner);
98+
let inner = &*(self.lock.load(Ordering::SeqCst) as *const Inner);
9999
inner.held.set(false);
100100
inner.remutex.unlock();
101101
}
@@ -106,17 +106,15 @@ impl Mutex {
106106
Kind::SRWLock => {}
107107
Kind::CriticalSection => match self.lock.load(Ordering::SeqCst) {
108108
0 => {}
109-
n => {
110-
Box::from_raw(n as *mut Inner).remutex.destroy();
111-
}
109+
n => Box::from_raw(n as *mut Inner).remutex.destroy(),
112110
},
113111
}
114112
}
115113

116-
unsafe fn inner(&self) -> *mut Inner {
114+
unsafe fn inner(&self) -> *const Inner {
117115
match self.lock.load(Ordering::SeqCst) {
118116
0 => {}
119-
n => return n as *mut _,
117+
n => return n as *const _,
120118
}
121119
let inner = box Inner { remutex: ReentrantMutex::uninitialized(), held: Cell::new(false) };
122120
inner.remutex.init();
@@ -125,7 +123,7 @@ impl Mutex {
125123
0 => inner,
126124
n => {
127125
Box::from_raw(inner).remutex.destroy();
128-
n as *mut _
126+
n as *const _
129127
}
130128
}
131129
}

0 commit comments

Comments
 (0)