Skip to content

Commit 8a281f9

Browse files
committed
Auto merge of #107060 - ibraheemdev:poll-ready, r=joshtriplett
Remove unstable `Poll::ready` Based on the discussion in #89780, this API is problematic and would likely require changes over an edition. Now that `task::ready!` is stabilized, this seems unlikely to happen, so I think we should just go ahead and remove it. ACP: rust-lang/libs-team#214
2 parents 17a6810 + 4fbca2e commit 8a281f9

File tree

4 files changed

+3
-95
lines changed

4 files changed

+3
-95
lines changed

library/core/src/future/join.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::cell::UnsafeCell;
44
use crate::future::{poll_fn, Future};
55
use crate::mem;
66
use crate::pin::Pin;
7-
use crate::task::{Context, Poll};
7+
use crate::task::{ready, Context, Poll};
88

99
/// Polls multiple futures simultaneously, returning a tuple
1010
/// of all results once complete.
@@ -118,7 +118,7 @@ macro join_internal {
118118
fut
119119
})
120120
};
121-
// Despite how tempting it may be to `let () = fut.poll(cx).ready()?;`
121+
// Despite how tempting it may be to `let () = ready!(fut.poll(cx));`
122122
// doing so would defeat the point of `join!`: to start polling eagerly all
123123
// of the futures, to allow parallelizing the waits.
124124
done &= fut.poll(cx).is_ready();
@@ -180,7 +180,7 @@ impl<F: Future> Future for MaybeDone<F> {
180180
// Do not mix match ergonomics with unsafe.
181181
match *self.as_mut().get_unchecked_mut() {
182182
MaybeDone::Future(ref mut f) => {
183-
let val = Pin::new_unchecked(f).poll(cx).ready()?;
183+
let val = ready!(Pin::new_unchecked(f).poll(cx));
184184
self.set(Self::Done(val));
185185
}
186186
MaybeDone::Done(_) => {}

library/core/src/task/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ pub use self::wake::{Context, RawWaker, RawWakerVTable, Waker};
1313
mod ready;
1414
#[stable(feature = "ready_macro", since = "1.64.0")]
1515
pub use ready::ready;
16-
#[unstable(feature = "poll_ready", issue = "89780")]
17-
pub use ready::Ready;

library/core/src/task/poll.rs

-33
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::convert;
44
use crate::ops::{self, ControlFlow};
55
use crate::result::Result;
6-
use crate::task::Ready;
76

87
/// Indicates whether a value is available or if the current task has been
98
/// scheduled to receive a wakeup instead.
@@ -95,38 +94,6 @@ impl<T> Poll<T> {
9594
pub const fn is_pending(&self) -> bool {
9695
!self.is_ready()
9796
}
98-
99-
/// Extracts the successful type of a [`Poll<T>`].
100-
///
101-
/// When combined with the `?` operator, this function will
102-
/// propagate any [`Poll::Pending`] values to the caller, and
103-
/// extract the `T` from [`Poll::Ready`].
104-
///
105-
/// # Examples
106-
///
107-
/// ```rust
108-
/// #![feature(poll_ready)]
109-
///
110-
/// use std::task::{Context, Poll};
111-
/// use std::future::{self, Future};
112-
/// use std::pin::Pin;
113-
///
114-
/// pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> {
115-
/// let mut fut = future::ready(42);
116-
/// let fut = Pin::new(&mut fut);
117-
///
118-
/// let num = fut.poll(cx).ready()?;
119-
/// # let _ = num; // to silence unused warning
120-
/// // ... use num
121-
///
122-
/// Poll::Ready(())
123-
/// }
124-
/// ```
125-
#[inline]
126-
#[unstable(feature = "poll_ready", issue = "89780")]
127-
pub fn ready(self) -> Ready<T> {
128-
Ready(self)
129-
}
13097
}
13198

13299
impl<T, E> Poll<Result<T, E>> {

library/core/src/task/ready.rs

-57
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
use core::convert;
2-
use core::fmt;
3-
use core::ops::{ControlFlow, FromResidual, Try};
4-
use core::task::Poll;
5-
61
/// Extracts the successful type of a [`Poll<T>`].
72
///
83
/// This macro bakes in propagation of [`Pending`] signals by returning early.
@@ -60,55 +55,3 @@ pub macro ready($e:expr) {
6055
}
6156
}
6257
}
63-
64-
/// Extracts the successful type of a [`Poll<T>`].
65-
///
66-
/// See [`Poll::ready`] for details.
67-
#[unstable(feature = "poll_ready", issue = "89780")]
68-
pub struct Ready<T>(pub(crate) Poll<T>);
69-
70-
#[unstable(feature = "poll_ready", issue = "89780")]
71-
impl<T> Try for Ready<T> {
72-
type Output = T;
73-
type Residual = Ready<convert::Infallible>;
74-
75-
#[inline]
76-
fn from_output(output: Self::Output) -> Self {
77-
Ready(Poll::Ready(output))
78-
}
79-
80-
#[inline]
81-
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
82-
match self.0 {
83-
Poll::Ready(v) => ControlFlow::Continue(v),
84-
Poll::Pending => ControlFlow::Break(Ready(Poll::Pending)),
85-
}
86-
}
87-
}
88-
89-
#[unstable(feature = "poll_ready", issue = "89780")]
90-
impl<T> FromResidual for Ready<T> {
91-
#[inline]
92-
fn from_residual(residual: Ready<convert::Infallible>) -> Self {
93-
match residual.0 {
94-
Poll::Pending => Ready(Poll::Pending),
95-
}
96-
}
97-
}
98-
99-
#[unstable(feature = "poll_ready", issue = "89780")]
100-
impl<T> FromResidual<Ready<convert::Infallible>> for Poll<T> {
101-
#[inline]
102-
fn from_residual(residual: Ready<convert::Infallible>) -> Self {
103-
match residual.0 {
104-
Poll::Pending => Poll::Pending,
105-
}
106-
}
107-
}
108-
109-
#[unstable(feature = "poll_ready", issue = "89780")]
110-
impl<T> fmt::Debug for Ready<T> {
111-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
112-
f.debug_tuple("Ready").finish()
113-
}
114-
}

0 commit comments

Comments
 (0)