Skip to content

Commit 94a7ea2

Browse files
committedSep 12, 2020
Auto merge of rust-lang#74328 - yoshuawuyts:stabilize-future-readiness-fns, r=sfackler
Stabilize core::future::{pending,ready} This PR stabilizes `core::future::{pending,ready}`, tracking issue rust-lang#70921. ## Motivation These functions have been on nightly for three months now, and have lived as part of the futures ecosystem for several years. In that time these functions have undergone several iterations, with [the `async-std` impls](https://docs.rs/async-std/1.6.2/async_std/future/index.html) probably diverging the most (using `async fn`, which in hindsight was a mistake). It seems the space around these functions has been _thoroughly_ explored over the last couple of years, and the ecosystem has settled on the current shape of the functions. It seems highly unlikely we'd want to make any further changes to these functions, so I propose we stabilize. ## Implementation notes This stabilization PR was fairly straightforward; this feature has already thoroughly been reviewed by the libs team already in rust-lang#70834. So all this PR does is remove the feature gate.
2 parents 12c10e3 + 688f447 commit 94a7ea2

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed
 

‎library/core/src/future/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pub use self::future::Future;
2121
#[unstable(feature = "into_future", issue = "67644")]
2222
pub use into_future::IntoFuture;
2323

24-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
24+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
2525
pub use pending::{pending, Pending};
26-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
26+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
2727
pub use ready::{ready, Ready};
2828

2929
#[unstable(feature = "future_poll_fn", issue = "72302")]

‎library/core/src/future/pending.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::fmt::{self, Debug};
12
use crate::future::Future;
23
use crate::marker;
34
use crate::pin::Pin;
@@ -10,8 +11,7 @@ use crate::task::{Context, Poll};
1011
/// documentation for more.
1112
///
1213
/// [`pending`]: fn.pending.html
13-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
14-
#[derive(Debug)]
14+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
1515
#[must_use = "futures do nothing unless you `.await` or poll them"]
1616
pub struct Pending<T> {
1717
_data: marker::PhantomData<T>,
@@ -23,7 +23,6 @@ pub struct Pending<T> {
2323
/// # Examples
2424
///
2525
/// ```no_run
26-
/// #![feature(future_readiness_fns)]
2726
/// use core::future;
2827
///
2928
/// # async fn run() {
@@ -32,12 +31,12 @@ pub struct Pending<T> {
3231
/// unreachable!();
3332
/// # }
3433
/// ```
35-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
34+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
3635
pub fn pending<T>() -> Pending<T> {
3736
Pending { _data: marker::PhantomData }
3837
}
3938

40-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
39+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
4140
impl<T> Future for Pending<T> {
4241
type Output = T;
4342

@@ -46,10 +45,17 @@ impl<T> Future for Pending<T> {
4645
}
4746
}
4847

49-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
48+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
5049
impl<T> Unpin for Pending<T> {}
5150

52-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
51+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
52+
impl<T> Debug for Pending<T> {
53+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54+
f.debug_struct("Pending").finish()
55+
}
56+
}
57+
58+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
5359
impl<T> Clone for Pending<T> {
5460
fn clone(&self) -> Self {
5561
pending()

‎library/core/src/future/ready.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ use crate::task::{Context, Poll};
88
/// documentation for more.
99
///
1010
/// [`ready`]: fn.ready.html
11-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
11+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
1212
#[derive(Debug, Clone)]
1313
#[must_use = "futures do nothing unless you `.await` or poll them"]
1414
pub struct Ready<T>(Option<T>);
1515

16-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
16+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
1717
impl<T> Unpin for Ready<T> {}
1818

19-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
19+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
2020
impl<T> Future for Ready<T> {
2121
type Output = T;
2222

@@ -28,18 +28,21 @@ impl<T> Future for Ready<T> {
2828

2929
/// Creates a future that is immediately ready with a value.
3030
///
31+
/// Futures created through this function are functionally similar to those
32+
/// created through `async {}`. The main difference is that futures created
33+
/// through this function are named and implement `Unpin`.
34+
///
3135
/// # Examples
3236
///
3337
/// ```
34-
/// #![feature(future_readiness_fns)]
3538
/// use core::future;
3639
///
3740
/// # async fn run() {
3841
/// let a = future::ready(1);
3942
/// assert_eq!(a.await, 1);
4043
/// # }
4144
/// ```
42-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
45+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
4346
pub fn ready<T>(t: T) -> Ready<T> {
4447
Ready(Some(t))
4548
}

‎library/core/src/task/ready.rs

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/// # Examples
66
///
77
/// ```
8-
/// #![feature(future_readiness_fns)]
98
/// #![feature(ready_macro)]
109
///
1110
/// use core::task::{ready, Context, Poll};
@@ -27,7 +26,6 @@
2726
/// The `ready!` call expands to:
2827
///
2928
/// ```
30-
/// # #![feature(future_readiness_fns)]
3129
/// # #![feature(ready_macro)]
3230
/// #
3331
/// # use core::task::{Context, Poll};

‎library/std/src/future.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use core::future::Future;
99
pub use core::future::{from_generator, get_context, ResumeTy};
1010

1111
#[doc(inline)]
12-
#[unstable(feature = "future_readiness_fns", issue = "70921")]
12+
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
1313
pub use core::future::{pending, ready, Pending, Ready};
1414

1515
#[doc(inline)]

‎library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@
258258
#![feature(external_doc)]
259259
#![feature(fn_traits)]
260260
#![feature(format_args_nl)]
261-
#![feature(future_readiness_fns)]
262261
#![feature(gen_future)]
263262
#![feature(generator_trait)]
264263
#![feature(global_asm)]

0 commit comments

Comments
 (0)
Please sign in to comment.