Skip to content

Commit

Permalink
chore: replace ready! with std::task::ready! (#6804)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaka authored Aug 29, 2024
1 parent 479a56a commit 11f66f4
Show file tree
Hide file tree
Showing 86 changed files with 92 additions and 123 deletions.
3 changes: 2 additions & 1 deletion tests-integration/tests/process_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use futures::future::{self, FutureExt};
use std::env;
use std::io;
use std::process::{ExitStatus, Stdio};
use std::task::ready;

fn cat() -> Command {
let mut cmd = Command::new(env!("CARGO_BIN_EXE_test-cat"));
Expand Down Expand Up @@ -211,7 +212,7 @@ async fn vectored_writes() {
if vectored == 0 {
return std::task::Poll::Ready(std::io::Result::Ok(()));
}
let n = futures::ready!(Pin::new(&mut stdin).poll_write_vectored(cx, &slices))?;
let n = ready!(Pin::new(&mut stdin).poll_write_vectored(cx, &slices))?;
writes_completed += 1;
input.advance(n);
})
Expand Down
9 changes: 0 additions & 9 deletions tokio-stream/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,3 @@ macro_rules! cfg_signal {
)*
}
}

macro_rules! ready {
($e:expr $(,)?) => {
match $e {
std::task::Poll::Ready(t) => t,
std::task::Poll::Pending => return std::task::Poll::Pending,
}
};
}
4 changes: 2 additions & 2 deletions tokio-stream/src/stream_ext/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::Stream;
use core::future::Future;
use core::marker::PhantomPinned;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down Expand Up @@ -42,7 +42,7 @@ where

// Take a maximum of 32 items from the stream before yielding.
for _ in 0..32 {
match futures_core::ready!(stream.as_mut().poll_next(cx)) {
match ready!(stream.as_mut().poll_next(cx)) {
Some(v) => {
if !(me.f)(v) {
return Poll::Ready(false);
Expand Down
4 changes: 2 additions & 2 deletions tokio-stream/src/stream_ext/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::Stream;
use core::future::Future;
use core::marker::PhantomPinned;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down Expand Up @@ -42,7 +42,7 @@ where

// Take a maximum of 32 items from the stream before yielding.
for _ in 0..32 {
match futures_core::ready!(stream.as_mut().poll_next(cx)) {
match ready!(stream.as_mut().poll_next(cx)) {
Some(v) => {
if (me.f)(v) {
return Poll::Ready(true);
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::stream_ext::Fuse;
use crate::Stream;

use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/chunks_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tokio::time::{sleep, Sleep};

use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;
use std::time::Duration;

Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::future::Future;
use core::marker::PhantomPinned;
use core::mem;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

// Do not export this struct until `FromStream` can be unsealed.
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Stream;

use core::fmt;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Stream;

use core::fmt;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::Stream;
use core::future::Future;
use core::marker::PhantomPinned;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Stream;

use pin_project_lite::pin_project;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

pin_project! {
/// Stream returned by [`fuse()`][super::StreamExt::fuse].
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Stream;

use core::fmt;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/skip_while.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Stream;

use core::fmt;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/throttle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tokio::time::{Duration, Instant, Sleep};

use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
use std::task::{self, ready, Poll};

use pin_project_lite::pin_project;

Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tokio::time::{Instant, Sleep};

use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;
use std::fmt;
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_ext/timeout_repeating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{Elapsed, Stream};
use tokio::time::Interval;

use core::pin::Pin;
use core::task::{Context, Poll};
use core::task::{ready, Context, Poll};
use pin_project_lite::pin_project;

pin_project! {
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/stream_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{poll_fn, Stream};
use std::borrow::Borrow;
use std::hash::Hash;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

/// Combine many streams into one, indexing each source stream with a unique
/// key.
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/wrappers/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use futures_core::Stream;
use tokio_util::sync::ReusableBoxFuture;

use std::fmt;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

/// A wrapper around [`tokio::sync::broadcast::Receiver`] that implements [`Stream`].
///
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/src/wrappers/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use futures_core::Stream;
use tokio_util::sync::ReusableBoxFuture;

use std::fmt;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};
use tokio::sync::watch::error::RecvError;

/// A wrapper around [`tokio::sync::watch::Receiver`] that implements [`Stream`].
Expand Down
4 changes: 2 additions & 2 deletions tokio-test/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ use tokio::sync::mpsc;
use tokio::time::{self, Duration, Instant, Sleep};
use tokio_stream::wrappers::UnboundedReceiverStream;

use futures_core::{ready, Stream};
use futures_core::Stream;
use std::collections::VecDeque;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{self, Poll, Waker};
use std::task::{self, ready, Poll, Waker};
use std::{cmp, io};

/// An I/O object that follows a predefined script.
Expand Down
4 changes: 2 additions & 2 deletions tokio-test/src/stream_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
use std::collections::VecDeque;
use std::pin::Pin;
use std::task::Poll;
use std::task::{ready, Poll};
use std::time::Duration;

use futures_core::{ready, Stream};
use futures_core::Stream;
use std::future::Future;
use tokio::time::{sleep_until, Instant, Sleep};

Expand Down
3 changes: 1 addition & 2 deletions tokio-util/src/codec/framed_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use futures_core::Stream;
use tokio::io::{AsyncRead, AsyncWrite};

use bytes::BytesMut;
use futures_core::ready;
use futures_sink::Sink;
use pin_project_lite::pin_project;
use std::borrow::{Borrow, BorrowMut};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

pin_project! {
#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions tokio-util/src/compat.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! Compatibility between the `tokio::io` and `futures-io` versions of the
//! `AsyncRead` and `AsyncWrite` traits.
use futures_core::ready;
use pin_project_lite::pin_project;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

pin_project! {
/// A compatibility layer that allows conversion between the
Expand Down
3 changes: 1 addition & 2 deletions tokio-util/src/io/inspect.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use futures_core::ready;
use pin_project_lite::pin_project;
use std::io::{IoSlice, Result};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

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

Expand Down
3 changes: 1 addition & 2 deletions tokio-util/src/io/sink_writer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use futures_core::ready;
use futures_sink::Sink;

use futures_core::stream::Stream;
use pin_project_lite::pin_project;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite};

pin_project! {
Expand Down
4 changes: 2 additions & 2 deletions tokio-util/src/sync/poll_semaphore.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use futures_core::{ready, Stream};
use futures_core::Stream;
use std::fmt;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};
use tokio::sync::{AcquireError, OwnedSemaphorePermit, Semaphore, TryAcquireError};

use super::ReusableBoxFuture;
Expand Down
6 changes: 2 additions & 4 deletions tokio-util/src/time/delay_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use crate::time::wheel::{self, Wheel};

use futures_core::ready;
use tokio::time::{sleep_until, Duration, Instant, Sleep};

use core::ops::{Index, IndexMut};
Expand All @@ -19,7 +18,7 @@ use std::fmt::Debug;
use std::future::Future;
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{self, Poll, Waker};
use std::task::{self, ready, Poll, Waker};

/// A queue of delayed elements.
///
Expand Down Expand Up @@ -74,9 +73,8 @@ use std::task::{self, Poll, Waker};
/// ```rust,no_run
/// use tokio_util::time::{DelayQueue, delay_queue};
///
/// use futures::ready;
/// use std::collections::HashMap;
/// use std::task::{Context, Poll};
/// use std::task::{ready, Context, Poll};
/// use std::time::Duration;
/// # type CacheKey = String;
/// # type Value = String;
Expand Down
3 changes: 1 addition & 2 deletions tokio-util/src/udp/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use futures_core::Stream;
use tokio::{io::ReadBuf, net::UdpSocket};

use bytes::{BufMut, BytesMut};
use futures_core::ready;
use futures_sink::Sink;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};
use std::{
borrow::Borrow,
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
Expand Down
3 changes: 1 addition & 2 deletions tokio-util/src/util/poll_buf.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

use bytes::{Buf, BufMut};
use futures_core::ready;
use std::io::{self, IoSlice};
use std::mem::MaybeUninit;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

/// Try to read data from an `AsyncRead` into an implementer of the [`BufMut`] trait.
///
Expand Down
3 changes: 1 addition & 2 deletions tokio/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use std::io::{self, Seek, SeekFrom};
use std::path::Path;
use std::pin::Pin;
use std::sync::Arc;
use std::task::Context;
use std::task::Poll;
use std::task::{ready, Context, Poll};

#[cfg(test)]
use super::mocks::JoinHandle;
Expand Down
3 changes: 1 addition & 2 deletions tokio/src/fs/read_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use std::io;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::Arc;
use std::task::Context;
use std::task::Poll;
use std::task::{ready, Context, Poll};

#[cfg(test)]
use super::mocks::spawn_blocking;
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/future/maybe_done.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use pin_project_lite::pin_project;
use std::future::{Future, IntoFuture};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::task::{ready, Context, Poll};

pin_project! {
/// A future that may have completed.
Expand Down
5 changes: 2 additions & 3 deletions tokio/src/io/async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::error::Error;
use std::fmt;
use std::io;
use std::os::unix::io::{AsRawFd, RawFd};
use std::{task::Context, task::Poll};
use std::task::{ready, Context, Poll};

/// Associates an IO object backed by a Unix file descriptor with the tokio
/// reactor, allowing for readiness to be polled. The file descriptor must be of
Expand Down Expand Up @@ -71,11 +71,10 @@ use std::{task::Context, task::Poll};
/// and using the IO traits [`AsyncRead`] and [`AsyncWrite`].
///
/// ```no_run
/// use futures::ready;
/// use std::io::{self, Read, Write};
/// use std::net::TcpStream;
/// use std::pin::Pin;
/// use std::task::{Context, Poll};
/// use std::task::{ready, Context, Poll};
/// use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
/// use tokio::io::unix::AsyncFd;
///
Expand Down
Loading

0 comments on commit 11f66f4

Please sign in to comment.