diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-24 16:13:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-24 16:13:09 +0200 |
| commit | a7d993961f90e2b14e8bed96ba6ee22ce40e1805 (patch) | |
| tree | 2cd498d5e2030ac66b9c6ea438a3b3e88f209069 | |
| parent | 21caaba2bcf69c9003827b114ebcb86bb6740aa5 (diff) | |
| parent | d30b36efc528e7391357d8d2f599c6cf2e427fd2 (diff) | |
| download | rust-a7d993961f90e2b14e8bed96ba6ee22ce40e1805.tar.gz rust-a7d993961f90e2b14e8bed96ba6ee22ce40e1805.zip | |
Rollup merge of #62716 - RalfJung:unsafe-cell, r=Centril
state also in the intro that UnsafeCell has no effect on &mut Just to be extra sure.
| -rw-r--r-- | src/libcore/cell.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index f74e945b3cc..0aaf5269a3d 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1412,8 +1412,9 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> { /// If you have a reference `&SomeStruct`, then normally in Rust all fields of `SomeStruct` are /// immutable. The compiler makes optimizations based on the knowledge that `&T` is not mutably /// aliased or mutated, and that `&mut T` is unique. `UnsafeCell<T>` is the only core language -/// feature to work around this restriction. All other types that allow internal mutability, such as -/// `Cell<T>` and `RefCell<T>`, use `UnsafeCell` to wrap their internal data. +/// feature to work around the restriction that `&T` may not be mutated. All other types that +/// allow internal mutability, such as `Cell<T>` and `RefCell<T>`, use `UnsafeCell` to wrap their +/// internal data. There is *no* legal way to obtain aliasing `&mut`, not even with `UnsafeCell<T>`. /// /// The `UnsafeCell` API itself is technically very simple: it gives you a raw pointer `*mut T` to /// its contents. It is up to _you_ as the abstraction designer to use that raw pointer correctly. |
