diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index b40768a52b6b4..c833deb9dd549 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs @@ -247,7 +247,7 @@ fn raw_waker(waker: Arc) -> RawWaker { /// // cast the Rc into a `LocalWaker` /// let local_waker: LocalWaker = task.clone().into(); /// // Build the context using `ContextBuilder` -/// let mut cx = ContextBuilder::from_waker(Waker::noop()) +/// let mut cx = ContextBuilder::from_waker(Waker::NOOP) /// .local_waker(&local_waker) /// .build(); /// diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 1b43c46bda515..034656c6006e1 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -284,7 +284,7 @@ impl fmt::Debug for Context<'_> { /// use std::future::Future; /// /// let local_waker = LocalWaker::noop(); -/// let waker = Waker::noop(); +/// let waker = Waker::NOOP; /// /// let mut cx = ContextBuilder::from_waker(&waker) /// .local_waker(&local_waker) @@ -465,7 +465,7 @@ impl Waker { Waker { waker } } - /// Returns a reference to a `Waker` that does nothing when used. + /// A reference to a `Waker` that does nothing when used. /// /// This is mostly useful for writing tests that need a [`Context`] to poll /// some futures, but are not expecting those futures to wake the waker or @@ -481,18 +481,13 @@ impl Waker { /// use std::future::Future; /// use std::task; /// - /// let mut cx = task::Context::from_waker(task::Waker::noop()); + /// let mut cx = task::Context::from_waker(task::Waker::NOOP); /// /// let mut future = Box::pin(async { 10 }); /// assert_eq!(future.as_mut().poll(&mut cx), task::Poll::Ready(10)); /// ``` - #[inline] - #[must_use] #[unstable(feature = "noop_waker", issue = "98286")] - pub const fn noop() -> &'static Waker { - const WAKER: &Waker = &Waker { waker: RawWaker::NOOP }; - WAKER - } + pub const NOOP: &'static Waker = &Waker { waker: RawWaker::NOOP }; /// Get a reference to the underlying [`RawWaker`]. #[inline] @@ -697,7 +692,7 @@ impl LocalWaker { /// use std::future::Future; /// use std::task::{ContextBuilder, LocalWaker, Waker, Poll}; /// - /// let mut cx = ContextBuilder::from_waker(Waker::noop()) + /// let mut cx = ContextBuilder::from_waker(Waker::NOOP) /// .local_waker(LocalWaker::noop()) /// .build(); /// diff --git a/library/core/tests/async_iter/mod.rs b/library/core/tests/async_iter/mod.rs index 4f425d7286d09..397dd89ec7d49 100644 --- a/library/core/tests/async_iter/mod.rs +++ b/library/core/tests/async_iter/mod.rs @@ -7,7 +7,7 @@ fn into_async_iter() { let async_iter = async_iter::from_iter(0..3); let mut async_iter = pin!(async_iter.into_async_iter()); - let mut cx = &mut core::task::Context::from_waker(core::task::Waker::noop()); + let mut cx = &mut core::task::Context::from_waker(core::task::Waker::NOOP); assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(0))); assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(1)));