Skip to content

Commit fef1725

Browse files
authored
Rollup merge of #81050 - yoshuawuyts:stabilize-task-ready, r=m-ou-se
Stabilize core::task::ready! _Tracking issue: https://github.com/rust-lang/rust/issues/70922_ This PR stabilizes the `task::ready!` macro. Similar to #80886, this PR was waiting on #74355 to be fixed. The `task::ready!` API has existed in the futures ecosystem for several years, and was added on nightly last year in #70817. The motivation for this macro is the same as it was back then: virtually every single manual future implementation makes use of this; so much so that it's one of the few things included in the [futures-core](https://docs.rs/futures-core/0.3.12/futures_core) library. r? ``@tmandry`` cc/ ``@rust-lang/wg-async-foundations`` ``@rust-lang/libs`` ## Example ```rust use core::task::{Context, Poll}; use core::future::Future; use core::pin::Pin; async fn get_num() -> usize { 42 } pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> { let mut f = get_num(); let f = unsafe { Pin::new_unchecked(&mut f) }; let num = ready!(f.poll(cx)); // ... use num Poll::Ready(()) } ```
2 parents a28109a + 18cc06c commit fef1725

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

library/core/src/task/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ mod wake;
1111
pub use self::wake::{Context, RawWaker, RawWakerVTable, Waker};
1212

1313
mod ready;
14-
#[unstable(feature = "ready_macro", issue = "70922")]
14+
#[stable(feature = "ready_macro", since = "1.56.0")]
1515
pub use ready::ready;

library/core/src/task/ready.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
/// # Examples
99
///
1010
/// ```
11-
/// #![feature(ready_macro)]
12-
///
1311
/// use std::task::{ready, Context, Poll};
1412
/// use std::future::{self, Future};
1513
/// use std::pin::Pin;
@@ -29,8 +27,6 @@
2927
/// The `ready!` call expands to:
3028
///
3129
/// ```
32-
/// # #![feature(ready_macro)]
33-
/// #
3430
/// # use std::task::{Context, Poll};
3531
/// # use std::future::{self, Future};
3632
/// # use std::pin::Pin;
@@ -49,7 +45,7 @@
4945
/// # Poll::Ready(())
5046
/// # }
5147
/// ```
52-
#[unstable(feature = "ready_macro", issue = "70922")]
48+
#[stable(feature = "ready_macro", since = "1.56.0")]
5349
#[rustc_macro_transparency = "semitransparent"]
5450
pub macro ready($e:expr) {
5551
match $e {

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@
304304
#![feature(pin_static_ref)]
305305
#![feature(prelude_import)]
306306
#![feature(ptr_internals)]
307-
#![feature(ready_macro)]
308307
#![feature(rustc_attrs)]
309308
#![feature(rustc_private)]
310309
#![feature(shrink_to)]

0 commit comments

Comments
 (0)