diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-03 07:03:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-03 07:03:42 +0200 |
| commit | 55f7571a7e241830abfd16ac09153470468793b6 (patch) | |
| tree | 43d0cd47672a6277e2f20b1cf5ae5fd140f4dcba /compiler/rustc_interface/src | |
| parent | 99426c570eebec8dcba2eaa8f5057265346aaedc (diff) | |
| parent | 200d742984ddd7eb1c96db09882217fcb1a1a146 (diff) | |
| download | rust-55f7571a7e241830abfd16ac09153470468793b6.tar.gz rust-55f7571a7e241830abfd16ac09153470468793b6.zip | |
Rollup merge of #140715 - lukaslueg:oncecellsyncdocs, r=tgross35
Clarify &mut-methods' docs on sync::OnceLock Three small changes to the docs of `sync::OnceLock`: * The docs for `OnceLock::take()` used to [say](https://doc.rust-lang.org/std/sync/struct.OnceLock.html#method.take) "**Safety** is guaranteed by requiring a mutable reference." (emphasis mine). While technically correct, imho its not necessary to even mention safety - as opposed to unsafety - here: Safety never comes up wrt `OnceLock`, as there is (currently) no way to interact with a `OnceLock` in an unsafe way; there are no unsafe methods on `OnceLock`, so there is "safety" guarantee required anywhere. What we simply meant to say is "**Synchronization** is guaranteed...". * I've add that phrase to the other methods of `OnceLock` which take a `&mut self`, to highlight the fact that having a `&mut OnceLock` guarantees that synchronization with other threads is not required. This is the same as with [`Mutex::get_mut()`](https://doc.rust-lang.org/std/sync/struct.Mutex.html#method.get_mut), [`Cell::get_mut()`](https://doc.rust-lang.org/std/cell/struct.Cell.html#method.get_mut), and others. * In that spirit, the half-sentence "or being initialized" was removed from `get_mut()`, as there is no way that the `OnceLock` is being initialized while we are holding `&mut` to it. Probably a copy&paste from `.get()`
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions
