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: https://github.com/rust-lang/rust/pull/76936/commits/09503fd1b30c83ca605546fa3f899721e41e68c6 )
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
Alexis Bourget
aaddcdb0d0
Fix nits
2020-09-20 18:37:05 +02:00
Daniel Henry-Mantilla
5886c38112
Replace unneeded unsafe calls to .get() with calls to .get_mut()
2020-09-20 18:06:03 +02:00
Alexis Bourget
b534d9f6e1
Fix broken link
2020-09-18 12:32:23 +02:00
Alexis Bourget
bffd2111f7
Finish moving to intra doc links for std::sync
2020-09-18 11:09:36 +02:00
Mara Bos
aa68aaa8e1
Mark Once::new as #[inline].
...
Without this, it was not inlined in SyncOnceCell::into_inner(), causing
unecessary checks and dead code.
2020-09-12 17:11:47 +02:00
bors
aa81d32165
Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus
...
Use Arc::clone and Rc::clone in documentation
This PR replaces uses of `x.clone()` by `Rc::clone(&x)` (or `Arc::clone(&x)`) to better match the documentation for those types.
@rustbot modify labels: T-doc
2020-09-06 12:34:31 +00:00
Lzu Tao
a4e926daee
std: move "mod tests/benches" to separate files
...
Also doing fmt inplace as requested.
2020-08-31 02:56:59 +00:00
Alexis Bourget
81e85ce76d
Move to Arc::clone(&x) over x.clone() in library/std
2020-08-30 21:59:43 +02:00
Lzu Tao
2c995d29f7
Prefer https link for wikipedia URLs
2020-08-23 10:02:42 +00:00
LeSeulArtichaut
f3a832f4b4
Use intra-doc-links in std::sync::*
2020-08-22 01:28:26 +02:00
liuzhenyu
3b4151c9f3
fix typos
2020-08-02 23:20:00 +08:00
mark
2c31b45ae8
mv std libs to library/
2020-07-27 19:51:13 -05:00