diff options
| author | bors <bors@rust-lang.org> | 2025-04-09 21:35:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-09 21:35:22 +0000 |
| commit | 51548ce71fe80b5ca7aef00e6f1bf2491df98c79 (patch) | |
| tree | 29b433265de973052eb7b54582906227dad45705 /library/std/src | |
| parent | 934880f586f6ac1f952c7090e2a943fcd7775e7b (diff) | |
| parent | 7aab307541051ea59bde1bb3f0375463c345b9aa (diff) | |
| download | rust-51548ce71fe80b5ca7aef00e6f1bf2491df98c79.tar.gz rust-51548ce71fe80b5ca7aef00e6f1bf2491df98c79.zip | |
Auto merge of #139595 - matthiaskrgr:rollup-kaa8aim, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #138470 (Test interaction between RFC 2229 migration and use closures) - #138628 (Add more ergonomic clone tests) - #139164 (std: improve documentation for get_mut() methods regarding forgotten guards) - #139488 (Add missing regression GUI test) - #139489 (compiletest: Add directive `dont-require-annotations`) - #139513 (Report higher-ranked trait error when higher-ranked projection goal fails in new solver) - #139521 (triagebot: roll compiler reviewers for rustc/unstable book) - #139532 (Update `u8`-to-and-from-`i8` suggestions.) - #139551 (report call site of inlined scopes for large assignment lints) - #139575 (Remove redundant words) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sync/poison/mutex.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sync/poison/rwlock.rs | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/library/std/src/sync/poison/mutex.rs b/library/std/src/sync/poison/mutex.rs index 9362c764173..adb74bb6f3d 100644 --- a/library/std/src/sync/poison/mutex.rs +++ b/library/std/src/sync/poison/mutex.rs @@ -582,7 +582,9 @@ impl<T: ?Sized> Mutex<T> { /// Returns a mutable reference to the underlying data. /// /// Since this call borrows the `Mutex` mutably, no actual locking needs to - /// take place -- the mutable borrow statically guarantees no locks exist. + /// take place -- the mutable borrow statically guarantees no new locks can be acquired + /// while this reference exists. Note that this method does not clear any previous abandoned locks + /// (e.g., via [`forget()`] on a [`MutexGuard`]). /// /// # Errors /// @@ -599,6 +601,8 @@ impl<T: ?Sized> Mutex<T> { /// *mutex.get_mut().unwrap() = 10; /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` + /// + /// [`forget()`]: mem::forget #[stable(feature = "mutex_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { let data = self.data.get_mut(); diff --git a/library/std/src/sync/poison/rwlock.rs b/library/std/src/sync/poison/rwlock.rs index f9d9321f5f2..a2abd4f692e 100644 --- a/library/std/src/sync/poison/rwlock.rs +++ b/library/std/src/sync/poison/rwlock.rs @@ -608,7 +608,9 @@ impl<T: ?Sized> RwLock<T> { /// Returns a mutable reference to the underlying data. /// /// Since this call borrows the `RwLock` mutably, no actual locking needs to - /// take place -- the mutable borrow statically guarantees no locks exist. + /// take place -- the mutable borrow statically guarantees no new locks can be acquired + /// while this reference exists. Note that this method does not clear any previously abandoned locks + /// (e.g., via [`forget()`] on a [`RwLockReadGuard`] or [`RwLockWriteGuard`]). /// /// # Errors /// |
