OnceLock::get_mut_or_init should not be called concurrently #128429
Closed
Description
Location
https://doc.rust-lang.org/std/sync/struct.OnceLock.html#method.get_mut_or_init
Summary
The current docs state that
Many threads may call `get_mut_or_init` concurrently with different initializing functions, but it is guaranteed that only one function will be executed.
However, as the method takes a mutable reference, no concurrent calls to this method can occur. If this method was indeed called from several threads, they would need to use external synchronisation to make the access exclusive and not-concurrent. It seems that this text was copy-pasted from the get_or_init
sibling method.