about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-06-04 08:25:46 +0100
committerGitHub <noreply@github.com>2024-06-04 08:25:46 +0100
commitd5a04221efa2cc1ec2833411f9a3f0c51a30d9a5 (patch)
treef333a7a336ca6e14146c6b1e587c1e2030e1d78a /compiler/rustc_codegen_llvm/src
parentaa13b892c7b02436174191142fabc89a2b3e1e00 (diff)
parent65dffc1990f91b470f23175ef243bdd5e0b5313a (diff)
downloadrust-d5a04221efa2cc1ec2833411f9a3f0c51a30d9a5.tar.gz
rust-d5a04221efa2cc1ec2833411f9a3f0c51a30d9a5.zip
Rollup merge of #125504 - mqudsi:once_nominal, r=cuviper
Change pedantically incorrect OnceCell/OnceLock wording

While the semantic intent of a OnceCell/OnceLock is that it can only be written to once (upon init), the fact of the matter is that both these types offer a `take(&mut self) -> Option<T>` mechanism that, when successful, resets the cell to its initial state, thereby [technically allowing it to be written to again](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=415c023a6ae1ef35f371a2d3bb1aa735)

Despite the fact that this can only happen with a mutable reference (generally only used during the construction of the OnceCell/OnceLock), it would be incorrect to say that the type itself as a whole *categorically* prevents being initialized or written to more than once (since it is possible to imagine an identical type only without the `take()` method that actually fulfills that contract).

To clarify, change "that cannot be.." to "that nominally cannot.." and add a note to OnceCell about what can be done with an `&mut Self` reference.

```@rustbot``` label +A-rustdocs
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions