diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2018-07-11 12:38:40 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-11 12:38:40 -0600 |
| commit | b41105ba2656c7e70665737268828dc3a1820cf1 (patch) | |
| tree | 5a4a3246895836119349e1b219cf3f73401b8b35 /src/rustllvm/RustWrapper.cpp | |
| parent | 2d49909f45d1f6851f26a983190047f64ab6b559 (diff) | |
| parent | 0f3f292b4c7a15b656a925e7ebe5f2d3955b8553 (diff) | |
| download | rust-b41105ba2656c7e70665737268828dc3a1820cf1.tar.gz rust-b41105ba2656c7e70665737268828dc3a1820cf1.zip | |
Rollup merge of #52239 - CAD97:patch-1, r=alexcrichton
Remove sync::Once::call_once 'static bound
See https://internals.rust-lang.org/t/sync-once-per-instance/7918 for more context.
Suggested r is @alexcrichton, the one who added the `'static` bound back in 2014. I don't want to officially r? though, if the system would even let me. I'd rather let the system choose the appropriate member since it knows more than I do.
`git blame` history for `sync::Once::call_once`'s signature:
- [std: Second pass stabilization of sync](https://github.com/rust-lang/rust/commit/f3a7ec7028c76b3a1c6051131328f372b068e33a) (Dec 2014)
```diff
- pub fn doit<F>(&'static self, f: F) where F: FnOnce() {
+ #[stable]
+ pub fn call_once<F>(&'static self, f: F) where F: FnOnce() {
```
- [libstd: use unboxed closures](https://github.com/rust-lang/rust/commit/cdbb3ca9b776b066e2c93acfb60da8537d2b1c9b) (Dec 2014)
```diff
- pub fn doit(&'static self, f: ||) {
+ pub fn doit<F>(&'static self, f: F) where F: FnOnce() {
```
- [std: Rewrite the `sync` module](https://github.com/rust-lang/rust/commit/71d4e77db8ad4b6d821da7e5d5300134ac95974e) (Nov 2014)
```diff
- pub fn doit(&self, f: ||) {
+ pub fn doit(&'static self, f: ||) {
```
> ```text
> The second layer is the layer provided by `std::sync` which is intended to be
> the thinnest possible layer on top of `sys_common` which is entirely safe to
> use. There are a few concerns which need to be addressed when making these
> system primitives safe:
>
> * Once used, the OS primitives can never be **moved**. This means that they
> essentially need to have a stable address. The static primitives use
> `&'static self` to enforce this, and the non-static primitives all use a
> `Box` to provide this guarantee.
> ```
The author of this diff is @alexcrichton. `sync::Once` now contains only a pointer to (privately hidden) `Waiter`s, which are all stack-allocated. The `'static` bound to `sync::Once` is thus unnecessary to guarantee that any OS primitives are non-relocatable.
As the `'static` bound is not required for `sync::Once`'s operation, removing it is strictly more useful. As an example, it allows attaching a one-time operation to instances rather than only to global singletons.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
