Skip to content

Commit 11f66f4

Browse files
authored
chore: replace ready! with std::task::ready! (#6804)
1 parent 479a56a commit 11f66f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+92
-123
lines changed

tests-integration/tests/process_stdio.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use futures::future::{self, FutureExt};
1010
use std::env;
1111
use std::io;
1212
use std::process::{ExitStatus, Stdio};
13+
use std::task::ready;
1314

1415
fn cat() -> Command {
1516
let mut cmd = Command::new(env!("CARGO_BIN_EXE_test-cat"));
@@ -211,7 +212,7 @@ async fn vectored_writes() {
211212
if vectored == 0 {
212213
return std::task::Poll::Ready(std::io::Result::Ok(()));
213214
}
214-
let n = futures::ready!(Pin::new(&mut stdin).poll_write_vectored(cx, &slices))?;
215+
let n = ready!(Pin::new(&mut stdin).poll_write_vectored(cx, &slices))?;
215216
writes_completed += 1;
216217
input.advance(n);
217218
})

tokio-stream/src/macros.rs

-9
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,3 @@ macro_rules! cfg_signal {
5757
)*
5858
}
5959
}
60-
61-
macro_rules! ready {
62-
($e:expr $(,)?) => {
63-
match $e {
64-
std::task::Poll::Ready(t) => t,
65-
std::task::Poll::Pending => return std::task::Poll::Pending,
66-
}
67-
};
68-
}

tokio-stream/src/stream_ext/all.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::Stream;
33
use core::future::Future;
44
use core::marker::PhantomPinned;
55
use core::pin::Pin;
6-
use core::task::{Context, Poll};
6+
use core::task::{ready, Context, Poll};
77
use pin_project_lite::pin_project;
88

99
pin_project! {
@@ -42,7 +42,7 @@ where
4242

4343
// Take a maximum of 32 items from the stream before yielding.
4444
for _ in 0..32 {
45-
match futures_core::ready!(stream.as_mut().poll_next(cx)) {
45+
match ready!(stream.as_mut().poll_next(cx)) {
4646
Some(v) => {
4747
if !(me.f)(v) {
4848
return Poll::Ready(false);

tokio-stream/src/stream_ext/any.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::Stream;
33
use core::future::Future;
44
use core::marker::PhantomPinned;
55
use core::pin::Pin;
6-
use core::task::{Context, Poll};
6+
use core::task::{ready, Context, Poll};
77
use pin_project_lite::pin_project;
88

99
pin_project! {
@@ -42,7 +42,7 @@ where
4242

4343
// Take a maximum of 32 items from the stream before yielding.
4444
for _ in 0..32 {
45-
match futures_core::ready!(stream.as_mut().poll_next(cx)) {
45+
match ready!(stream.as_mut().poll_next(cx)) {
4646
Some(v) => {
4747
if (me.f)(v) {
4848
return Poll::Ready(true);

tokio-stream/src/stream_ext/chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::stream_ext::Fuse;
22
use crate::Stream;
33

44
use core::pin::Pin;
5-
use core::task::{Context, Poll};
5+
use core::task::{ready, Context, Poll};
66
use pin_project_lite::pin_project;
77

88
pin_project! {

tokio-stream/src/stream_ext/chunks_timeout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tokio::time::{sleep, Sleep};
44

55
use core::future::Future;
66
use core::pin::Pin;
7-
use core::task::{Context, Poll};
7+
use core::task::{ready, Context, Poll};
88
use pin_project_lite::pin_project;
99
use std::time::Duration;
1010

tokio-stream/src/stream_ext/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::future::Future;
44
use core::marker::PhantomPinned;
55
use core::mem;
66
use core::pin::Pin;
7-
use core::task::{Context, Poll};
7+
use core::task::{ready, Context, Poll};
88
use pin_project_lite::pin_project;
99

1010
// Do not export this struct until `FromStream` can be unsealed.

tokio-stream/src/stream_ext/filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::Stream;
22

33
use core::fmt;
44
use core::pin::Pin;
5-
use core::task::{Context, Poll};
5+
use core::task::{ready, Context, Poll};
66
use pin_project_lite::pin_project;
77

88
pin_project! {

tokio-stream/src/stream_ext/filter_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::Stream;
22

33
use core::fmt;
44
use core::pin::Pin;
5-
use core::task::{Context, Poll};
5+
use core::task::{ready, Context, Poll};
66
use pin_project_lite::pin_project;
77

88
pin_project! {

tokio-stream/src/stream_ext/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::Stream;
33
use core::future::Future;
44
use core::marker::PhantomPinned;
55
use core::pin::Pin;
6-
use core::task::{Context, Poll};
6+
use core::task::{ready, Context, Poll};
77
use pin_project_lite::pin_project;
88

99
pin_project! {

tokio-stream/src/stream_ext/fuse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::Stream;
22

33
use pin_project_lite::pin_project;
44
use std::pin::Pin;
5-
use std::task::{Context, Poll};
5+
use std::task::{ready, Context, Poll};
66

77
pin_project! {
88
/// Stream returned by [`fuse()`][super::StreamExt::fuse].

tokio-stream/src/stream_ext/skip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::Stream;
22

33
use core::fmt;
44
use core::pin::Pin;
5-
use core::task::{Context, Poll};
5+
use core::task::{ready, Context, Poll};
66
use pin_project_lite::pin_project;
77

88
pin_project! {

tokio-stream/src/stream_ext/skip_while.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::Stream;
22

33
use core::fmt;
44
use core::pin::Pin;
5-
use core::task::{Context, Poll};
5+
use core::task::{ready, Context, Poll};
66
use pin_project_lite::pin_project;
77

88
pin_project! {

tokio-stream/src/stream_ext/throttle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tokio::time::{Duration, Instant, Sleep};
55

66
use std::future::Future;
77
use std::pin::Pin;
8-
use std::task::{self, Poll};
8+
use std::task::{self, ready, Poll};
99

1010
use pin_project_lite::pin_project;
1111

tokio-stream/src/stream_ext/timeout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tokio::time::{Instant, Sleep};
44

55
use core::future::Future;
66
use core::pin::Pin;
7-
use core::task::{Context, Poll};
7+
use core::task::{ready, Context, Poll};
88
use pin_project_lite::pin_project;
99
use std::fmt;
1010
use std::time::Duration;

tokio-stream/src/stream_ext/timeout_repeating.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{Elapsed, Stream};
33
use tokio::time::Interval;
44

55
use core::pin::Pin;
6-
use core::task::{Context, Poll};
6+
use core::task::{ready, Context, Poll};
77
use pin_project_lite::pin_project;
88

99
pin_project! {

tokio-stream/src/stream_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{poll_fn, Stream};
33
use std::borrow::Borrow;
44
use std::hash::Hash;
55
use std::pin::Pin;
6-
use std::task::{Context, Poll};
6+
use std::task::{ready, Context, Poll};
77

88
/// Combine many streams into one, indexing each source stream with a unique
99
/// key.

tokio-stream/src/wrappers/broadcast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use futures_core::Stream;
66
use tokio_util::sync::ReusableBoxFuture;
77

88
use std::fmt;
9-
use std::task::{Context, Poll};
9+
use std::task::{ready, Context, Poll};
1010

1111
/// A wrapper around [`tokio::sync::broadcast::Receiver`] that implements [`Stream`].
1212
///

tokio-stream/src/wrappers/watch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use futures_core::Stream;
55
use tokio_util::sync::ReusableBoxFuture;
66

77
use std::fmt;
8-
use std::task::{Context, Poll};
8+
use std::task::{ready, Context, Poll};
99
use tokio::sync::watch::error::RecvError;
1010

1111
/// A wrapper around [`tokio::sync::watch::Receiver`] that implements [`Stream`].

tokio-test/src/io.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ use tokio::sync::mpsc;
2323
use tokio::time::{self, Duration, Instant, Sleep};
2424
use tokio_stream::wrappers::UnboundedReceiverStream;
2525

26-
use futures_core::{ready, Stream};
26+
use futures_core::Stream;
2727
use std::collections::VecDeque;
2828
use std::fmt;
2929
use std::future::Future;
3030
use std::pin::Pin;
3131
use std::sync::Arc;
32-
use std::task::{self, Poll, Waker};
32+
use std::task::{self, ready, Poll, Waker};
3333
use std::{cmp, io};
3434

3535
/// An I/O object that follows a predefined script.

tokio-test/src/stream_mock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
3737
use std::collections::VecDeque;
3838
use std::pin::Pin;
39-
use std::task::Poll;
39+
use std::task::{ready, Poll};
4040
use std::time::Duration;
4141

42-
use futures_core::{ready, Stream};
42+
use futures_core::Stream;
4343
use std::future::Future;
4444
use tokio::time::{sleep_until, Instant, Sleep};
4545

tokio-util/src/codec/framed_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ use futures_core::Stream;
55
use tokio::io::{AsyncRead, AsyncWrite};
66

77
use bytes::BytesMut;
8-
use futures_core::ready;
98
use futures_sink::Sink;
109
use pin_project_lite::pin_project;
1110
use std::borrow::{Borrow, BorrowMut};
1211
use std::io;
1312
use std::pin::Pin;
14-
use std::task::{Context, Poll};
13+
use std::task::{ready, Context, Poll};
1514

1615
pin_project! {
1716
#[derive(Debug)]

tokio-util/src/compat.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//! Compatibility between the `tokio::io` and `futures-io` versions of the
22
//! `AsyncRead` and `AsyncWrite` traits.
3-
use futures_core::ready;
43
use pin_project_lite::pin_project;
54
use std::io;
65
use std::pin::Pin;
7-
use std::task::{Context, Poll};
6+
use std::task::{ready, Context, Poll};
87

98
pin_project! {
109
/// A compatibility layer that allows conversion between the

tokio-util/src/io/inspect.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use futures_core::ready;
21
use pin_project_lite::pin_project;
32
use std::io::{IoSlice, Result};
43
use std::pin::Pin;
5-
use std::task::{Context, Poll};
4+
use std::task::{ready, Context, Poll};
65

76
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
87

tokio-util/src/io/sink_writer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use futures_core::ready;
21
use futures_sink::Sink;
32

43
use futures_core::stream::Stream;
54
use pin_project_lite::pin_project;
65
use std::io;
76
use std::pin::Pin;
8-
use std::task::{Context, Poll};
7+
use std::task::{ready, Context, Poll};
98
use tokio::io::{AsyncRead, AsyncWrite};
109

1110
pin_project! {

tokio-util/src/sync/poll_semaphore.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use futures_core::{ready, Stream};
1+
use futures_core::Stream;
22
use std::fmt;
33
use std::pin::Pin;
44
use std::sync::Arc;
5-
use std::task::{Context, Poll};
5+
use std::task::{ready, Context, Poll};
66
use tokio::sync::{AcquireError, OwnedSemaphorePermit, Semaphore, TryAcquireError};
77

88
use super::ReusableBoxFuture;

tokio-util/src/time/delay_queue.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
use crate::time::wheel::{self, Wheel};
88

9-
use futures_core::ready;
109
use tokio::time::{sleep_until, Duration, Instant, Sleep};
1110

1211
use core::ops::{Index, IndexMut};
@@ -19,7 +18,7 @@ use std::fmt::Debug;
1918
use std::future::Future;
2019
use std::marker::PhantomData;
2120
use std::pin::Pin;
22-
use std::task::{self, Poll, Waker};
21+
use std::task::{self, ready, Poll, Waker};
2322

2423
/// A queue of delayed elements.
2524
///
@@ -74,9 +73,8 @@ use std::task::{self, Poll, Waker};
7473
/// ```rust,no_run
7574
/// use tokio_util::time::{DelayQueue, delay_queue};
7675
///
77-
/// use futures::ready;
7876
/// use std::collections::HashMap;
79-
/// use std::task::{Context, Poll};
77+
/// use std::task::{ready, Context, Poll};
8078
/// use std::time::Duration;
8179
/// # type CacheKey = String;
8280
/// # type Value = String;

tokio-util/src/udp/frame.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ use futures_core::Stream;
44
use tokio::{io::ReadBuf, net::UdpSocket};
55

66
use bytes::{BufMut, BytesMut};
7-
use futures_core::ready;
87
use futures_sink::Sink;
98
use std::pin::Pin;
10-
use std::task::{Context, Poll};
9+
use std::task::{ready, Context, Poll};
1110
use std::{
1211
borrow::Borrow,
1312
net::{Ipv4Addr, SocketAddr, SocketAddrV4},

tokio-util/src/util/poll_buf.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
22

33
use bytes::{Buf, BufMut};
4-
use futures_core::ready;
54
use std::io::{self, IoSlice};
65
use std::mem::MaybeUninit;
76
use std::pin::Pin;
8-
use std::task::{Context, Poll};
7+
use std::task::{ready, Context, Poll};
98

109
/// Try to read data from an `AsyncRead` into an implementer of the [`BufMut`] trait.
1110
///

tokio/src/fs/file.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use std::io::{self, Seek, SeekFrom};
1414
use std::path::Path;
1515
use std::pin::Pin;
1616
use std::sync::Arc;
17-
use std::task::Context;
18-
use std::task::Poll;
17+
use std::task::{ready, Context, Poll};
1918

2019
#[cfg(test)]
2120
use super::mocks::JoinHandle;

tokio/src/fs/read_dir.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use std::io;
88
use std::path::{Path, PathBuf};
99
use std::pin::Pin;
1010
use std::sync::Arc;
11-
use std::task::Context;
12-
use std::task::Poll;
11+
use std::task::{ready, Context, Poll};
1312

1413
#[cfg(test)]
1514
use super::mocks::spawn_blocking;

tokio/src/future/maybe_done.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use pin_project_lite::pin_project;
44
use std::future::{Future, IntoFuture};
55
use std::pin::Pin;
6-
use std::task::{Context, Poll};
6+
use std::task::{ready, Context, Poll};
77

88
pin_project! {
99
/// A future that may have completed.

tokio/src/io/async_fd.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::error::Error;
77
use std::fmt;
88
use std::io;
99
use std::os::unix::io::{AsRawFd, RawFd};
10-
use std::{task::Context, task::Poll};
10+
use std::task::{ready, Context, Poll};
1111

1212
/// Associates an IO object backed by a Unix file descriptor with the tokio
1313
/// reactor, allowing for readiness to be polled. The file descriptor must be of
@@ -71,11 +71,10 @@ use std::{task::Context, task::Poll};
7171
/// and using the IO traits [`AsyncRead`] and [`AsyncWrite`].
7272
///
7373
/// ```no_run
74-
/// use futures::ready;
7574
/// use std::io::{self, Read, Write};
7675
/// use std::net::TcpStream;
7776
/// use std::pin::Pin;
78-
/// use std::task::{Context, Poll};
77+
/// use std::task::{ready, Context, Poll};
7978
/// use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
8079
/// use tokio::io::unix::AsyncFd;
8180
///

0 commit comments

Comments
 (0)