rust/library/std/src/sync
Matthias Krüger d5f930fe76
Rollup merge of #139164 - xizheyin:issue-139034, r=joboet
std: improve documentation for get_mut() methods regarding forgotten guards

Fixes #139034

This PR improves the documentation for `get_mut()` methods in `Mutex`, `RefCell`, and `RwLock` to clarify their behavior when lock guards are forgotten (e.g., via std::mem::forget).

The current documentation for these methods states that a mutable borrow "statically guarantees no locks exist", which is not entirely accurate. While a mutable borrow prevents new locks from being created, it does not clear or detect previously abandoned locks through `forget()`. This can lead to counterintuitive behavior:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=e68cefec12dcd435daf2237c16824ed3
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=81263ad652c752afd63c903113d3082c
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=311baa4edb3abf82a25c8d7bf21a4a52

r? libs
2025-04-09 20:23:09 +02:00
..
mpmc Use faster thread_local in current_thread_id() 2025-02-21 13:09:16 +00:00
poison std: clarify RwLock::get_mut more clearly 2025-04-03 19:25:47 +08:00
barrier.rs Move std::sync unit tests to integration tests 2025-01-26 10:28:05 +00:00
lazy_lock.rs Move std::sync unit tests to integration tests 2025-01-26 10:28:05 +00:00
mod.rs Implement UniqueArc 2025-03-22 15:14:49 +08:00
mpsc.rs Move std::sync unit tests to integration tests 2025-01-26 10:28:05 +00:00
once_lock.rs update version placeholders 2025-02-18 08:50:21 -08:00
poison.rs Move some things to std::sync::poison and reexport them in std::sync 2025-01-02 15:21:41 +03:00
reentrant_lock.rs Move std::sync unit tests to integration tests 2025-01-26 10:28:05 +00:00