Skip to content

Commit

Permalink
Auto merge of #133089 - eholk:stabilize-noop-waker, r=dtolnay
Browse files Browse the repository at this point in the history
Stabilize noop_waker

Tracking Issue: #98286

This is a handy feature that's been used widely in tests and example async code and it'd be nice to make it available to users.

cc `@rust-lang/wg-async`
  • Loading branch information
bors committed Dec 6, 2024
2 parents cdeddae + 72ce1ab commit 8dc8377
Show file tree
Hide file tree
Showing 46 changed files with 104 additions and 132 deletions.
1 change: 0 additions & 1 deletion library/alloc/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
///
/// ```rust
/// #![feature(local_waker)]
/// #![feature(noop_waker)]
/// use std::task::{LocalWake, ContextBuilder, LocalWaker, Waker};
/// use std::future::Future;
/// use std::pin::Pin;
Expand Down
13 changes: 5 additions & 8 deletions library/core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ impl RawWaker {
RawWaker { data, vtable }
}

#[unstable(feature = "noop_waker", issue = "98286")]
#[stable(feature = "noop_waker", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "noop_waker", since = "CURRENT_RUSTC_VERSION")]
const NOOP: RawWaker = {
const VTABLE: RawWakerVTable = RawWakerVTable::new(
// Cloning just returns a new no-op raw waker
Expand Down Expand Up @@ -283,7 +284,6 @@ impl fmt::Debug for Context<'_> {
/// # Examples
/// ```
/// #![feature(local_waker)]
/// #![feature(noop_waker)]
/// use std::task::{ContextBuilder, LocalWaker, Waker, Poll};
/// use std::future::Future;
///
Expand Down Expand Up @@ -555,8 +555,6 @@ impl Waker {
/// # Examples
///
/// ```
/// #![feature(noop_waker)]
///
/// use std::future::Future;
/// use std::task;
///
Expand All @@ -567,7 +565,8 @@ impl Waker {
/// ```
#[inline]
#[must_use]
#[unstable(feature = "noop_waker", issue = "98286")]
#[stable(feature = "noop_waker", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "noop_waker", since = "CURRENT_RUSTC_VERSION")]
pub const fn noop() -> &'static Waker {
const WAKER: &Waker = &Waker { waker: RawWaker::NOOP };
WAKER
Expand Down Expand Up @@ -850,8 +849,6 @@ impl LocalWaker {
///
/// ```
/// #![feature(local_waker)]
/// #![feature(noop_waker)]
///
/// use std::future::Future;
/// use std::task::{ContextBuilder, LocalWaker, Waker, Poll};
///
Expand All @@ -864,7 +861,7 @@ impl LocalWaker {
/// ```
#[inline]
#[must_use]
#[unstable(feature = "noop_waker", issue = "98286")]
#[unstable(feature = "local_waker", issue = "118959")]
pub const fn noop() -> &'static LocalWaker {
const WAKER: &LocalWaker = &LocalWaker { waker: RawWaker::NOOP };
WAKER
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#![feature(maybe_uninit_write_slice)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(noop_waker)]
#![feature(num_midpoint_signed)]
#![feature(numfmt)]
#![feature(pattern)]
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/pass/async-closure-captures.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Same as rustc's `tests/ui/async-await/async-closures/captures.rs`, keep in sync

#![feature(async_closure, noop_waker, async_trait_bounds)]
#![feature(async_closure, async_trait_bounds)]

use std::future::Future;
use std::pin::pin;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/pass/async-closure-drop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_closure, noop_waker, async_trait_bounds)]
#![feature(async_closure, async_trait_bounds)]

use std::future::Future;
use std::pin::pin;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/pass/async-closure.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_closure, noop_waker, async_fn_traits)]
#![feature(async_closure, async_fn_traits)]
#![allow(unused)]

use std::future::Future;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/pass/async-drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// please consider modifying rustc's async drop test at
// `tests/ui/async-await/async-drop.rs`.

#![feature(async_drop, impl_trait_in_assoc_type, noop_waker, async_closure)]
#![feature(async_drop, impl_trait_in_assoc_type, async_closure)]
#![allow(incomplete_features, dead_code)]

// FIXME(zetanumbers): consider AsyncDestruct::async_drop cleanup tests
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/async-fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(never_type)]
#![feature(noop_waker)]

use std::future::Future;

Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/dyn-star.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(dyn_star)]
#![allow(incomplete_features)]
#![feature(custom_inner_attributes)]
#![feature(noop_waker)]
// rustfmt destroys `dyn* Trait` syntax
#![rustfmt::skip]

Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/future-self-referential.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
#![feature(noop_waker)]

use std::future::*;
use std::marker::PhantomPinned;
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/tests/pass/issues/issue-miri-2068.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(noop_waker)]

use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll, Waker};
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/move-data-across-await-point.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(noop_waker)]
use std::future::Future;
use std::ptr;

Expand Down
Loading

0 comments on commit 8dc8377

Please sign in to comment.