]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #74304 - yoshuawuyts:stabilize-wake, r=KodrAus
authorMara Bos <m-ou.se@m-ou.se>
Thu, 4 Feb 2021 20:10:31 +0000 (21:10 +0100)
committerGitHub <noreply@github.com>
Thu, 4 Feb 2021 20:10:31 +0000 (21:10 +0100)
commitd20d09712550c820c2d67a9b3ed2a3f9debb9393
treef4c3ecc3ca708198a103fee5bcc6e631ee73e91c
parent822ebfd2c43fbe466da8ae34ffe3ce6cba2e8336
parent2c8bf1db549d1e70af53b7ff8b8afb80187827e2
Rollup merge of #74304 - yoshuawuyts:stabilize-wake, r=KodrAus

Stabilize the Wake trait

This PR proposes stabilizing the `wake_trait` feature, tracking issue https://github.com/rust-lang/rust/issues/69912.

## Motivation

The surface area this trait introduces is small, and it has been on nightly for 4 months without any reported issues. Given the surface area of this trait is small and only serves to provide a safe interface around the already stable [`std::task::RawWakerVTable`](https://doc.rust-lang.org/std/task/struct.RawWaker.html) it seems unlikely this trait will require any further changes. So I'm proposing we stabilize this.

Personally I would love to have this available on stable, since it would enable cleaning up some runtime internals by removing the tedious pointer required to construct a [`RawWakerVTable`](https://doc.rust-lang.org/std/task/struct.RawWakerVTable.html). I believe the intent was always to introduce a `Wake` counterpart to `RawWaker` in order to safely construct `Waker` instances. And the `Wake` trait feels like it does that job as intended.

## Implementation notes

This PR itself fixes a link in the docs, and introduces an example of how to use the trait: a minimal `block_on` example that runs a future to completion on the current thread. It doesn't include fancier features such as support for nesting, but is intended to serve as a teaching device for both `task::Wake` and futures alike.