rust/library/std
Ralf Jung b670b86353
Rollup merge of #76936 - danielhenrymantilla:unsafecell_get_mut, r=RalfJung
Add non-`unsafe` `.get_mut()` for `Unsafecell`

  - Tracking issue: https://github.com/rust-lang/rust/issues/76943

As discussed in: https://internals.rust-lang.org/t/add-non-unsafe-get-mut-for-unsafecell/12407

  - ### [Rendered documentation](https://modest-dubinsky-1f9f47.netlify.app/core/cell/struct.unsafecell)

This PR tries to move the sound `&mut UnsafeCell<T> -> &mut T` projection that all the "downstream" constructions were already relying on, up to the root abstraction, where it rightfully belongs, and officially blessing it.

  - this **helps reduce the amount of `unsafe` snippets out there** (_c.f._, the second commit of this PR: 09503fd1b3)

The fact that this getter is now expose for `UnsafeCell<T>` itself, will also help convey the idea that **`UnsafeCell` is not magical _w.r.t._ `&mut` accesses**, contrary to what some people incorrectly think.

  - Even the standard library itself at some point had such a confusion, _c.f._ this comment where there is a mention of multi-threaded (and thus _shared_) access despite dealing with exclusive references over unique ownership: 59fb88d061/library/core/src/cell.rs (L498-L499)

r? @RalfJung
2020-09-21 10:40:37 +02:00
..
benches
src Rollup merge of #76936 - danielhenrymantilla:unsafecell_get_mut, r=RalfJung 2020-09-21 10:40:37 +02:00
tests
build.rs [AVR] Rename the last few remaining references from 'avr-unknown-unknown' to 'avr-unknown-gnu-atmega328' 2020-08-24 18:45:24 +12:00
Cargo.toml Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O 2020-09-10 16:27:28 +02:00