Skip to content

Commit 0b6ec57

Browse files
committed
make mutex_unlock infallible
1 parent 67ad304 commit 0b6ec57

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/shims/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn release_cond_mutex_and_block<'mir, 'tcx: 'mir>(
316316
active_thread: ThreadId,
317317
mutex: MutexId,
318318
) -> InterpResult<'tcx> {
319-
if let Some(old_locked_count) = ecx.mutex_unlock(mutex, active_thread)? {
319+
if let Some(old_locked_count) = ecx.mutex_unlock(mutex, active_thread) {
320320
if old_locked_count != 1 {
321321
throw_unsup_format!("awaiting on a lock acquired multiple times is not supported");
322322
}
@@ -486,7 +486,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
486486
let id = mutex_get_or_create_id(this, mutex_op)?;
487487
let active_thread = this.get_active_thread();
488488

489-
if let Some(_old_locked_count) = this.mutex_unlock(id, active_thread)? {
489+
if let Some(_old_locked_count) = this.mutex_unlock(id, active_thread) {
490490
// The mutex was locked by the current thread.
491491
Ok(0)
492492
} else {

src/sync.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
153153
&mut self,
154154
id: MutexId,
155155
expected_owner: ThreadId,
156-
) -> InterpResult<'tcx, Option<usize>> {
156+
) -> Option<usize> {
157157
let this = self.eval_context_mut();
158158
let mutex = &mut this.machine.threads.sync.mutexes[id];
159159
if let Some(current_owner) = mutex.owner {
160160
// Mutex is locked.
161161
if current_owner != expected_owner {
162162
// Only the owner can unlock the mutex.
163-
return Ok(None);
163+
return None;
164164
}
165165
let old_lock_count = mutex.lock_count;
166166
mutex.lock_count = old_lock_count
@@ -172,10 +172,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
172172
// to another thread.
173173
this.mutex_dequeue_and_lock(id);
174174
}
175-
Ok(Some(old_lock_count))
175+
Some(old_lock_count)
176176
} else {
177177
// Mutex is unlocked.
178-
Ok(None)
178+
None
179179
}
180180
}
181181

0 commit comments

Comments
 (0)