Skip to content

Commit ed7c567

Browse files
committed
Auto merge of #33034 - tbu-:pr_doc_mutex_lock, r=nagisa
Add a comment about locking a `Mutex` multiple times Fixes #32260.
2 parents 412e6f7 + df748bf commit ed7c567

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libstd/sync/mutex.rs

+9
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,19 @@ impl<T: ?Sized> Mutex<T> {
205205
/// held. An RAII guard is returned to allow scoped unlock of the lock. When
206206
/// the guard goes out of scope, the mutex will be unlocked.
207207
///
208+
/// The exact behavior on locking a mutex in the thread which already holds
209+
/// the lock is left unspecified, however, this function will not return on
210+
/// the second call, it might e.g. panic or deadlock.
211+
///
208212
/// # Errors
209213
///
210214
/// If another user of this mutex panicked while holding the mutex, then
211215
/// this call will return an error once the mutex is acquired.
216+
///
217+
/// # Panics
218+
///
219+
/// This function might panic when called if the lock is already held by
220+
/// the current thread.
212221
#[stable(feature = "rust1", since = "1.0.0")]
213222
pub fn lock(&self) -> LockResult<MutexGuard<T>> {
214223
unsafe {

0 commit comments

Comments
 (0)