Skip to content

Commit 12b2567

Browse files
authored
chore: use poll_fn from std (#6810)
1 parent 35f244a commit 12b2567

Some content is hidden

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

52 files changed

+67
-187
lines changed

tests-integration/src/bin/test-mem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use futures::future::poll_fn;
1+
use std::future::poll_fn;
22

33
fn main() {
44
let rt = tokio::runtime::Builder::new_multi_thread()

tests-integration/tests/process_stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async fn vectored_writes() {
206206
let mut input = Bytes::from_static(b"hello\n").chain(Bytes::from_static(b"world!\n"));
207207
let mut writes_completed = 0;
208208

209-
futures::future::poll_fn(|cx| loop {
209+
std::future::poll_fn(|cx| loop {
210210
let mut slices = [IoSlice::new(&[]); 2];
211211
let vectored = input.chunks_vectored(&mut slices);
212212
if vectored == 0 {

tokio-stream/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
#[macro_use]
7575
mod macros;
7676

77-
mod poll_fn;
78-
pub(crate) use poll_fn::poll_fn;
79-
8077
pub mod wrappers;
8178

8279
mod stream_ext;

tokio-stream/src/poll_fn.rs

-35
This file was deleted.

tokio-stream/src/stream_map.rs

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

33
use std::borrow::Borrow;
4+
use std::future::poll_fn;
45
use std::hash::Hash;
56
use std::pin::Pin;
67
use std::task::{ready, Context, Poll};

tokio-util/src/util/poll_buf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::task::{ready, Context, Poll};
1717
/// use tokio_stream as stream;
1818
/// use tokio::io::Result;
1919
/// use tokio_util::io::{StreamReader, poll_read_buf};
20-
/// use futures::future::poll_fn;
20+
/// use std::future::poll_fn;
2121
/// use std::pin::Pin;
2222
/// # #[tokio::main]
2323
/// # async fn main() -> std::io::Result<()> {
@@ -95,9 +95,9 @@ pub fn poll_read_buf<T: AsyncRead + ?Sized, B: BufMut>(
9595
/// use tokio::fs::File;
9696
///
9797
/// use bytes::Buf;
98+
/// use std::future::poll_fn;
9899
/// use std::io::Cursor;
99100
/// use std::pin::Pin;
100-
/// use futures::future::poll_fn;
101101
///
102102
/// #[tokio::main]
103103
/// async fn main() -> io::Result<()> {

tokio-util/tests/io_inspect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use futures::future::poll_fn;
21
use std::{
2+
future::poll_fn,
33
io::IoSlice,
44
pin::Pin,
55
task::{Context, Poll},

tokio-util/tests/mpsc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use futures::future::poll_fn;
21
use futures::sink::SinkExt;
2+
use std::future::poll_fn;
33
use tokio::sync::mpsc::channel;
44
use tokio_test::task::spawn;
55
use tokio_test::{

tokio-util/tests/poll_semaphore.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ type SemRet = Option<OwnedSemaphorePermit>;
99
fn semaphore_poll(
1010
sem: &mut PollSemaphore,
1111
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + '_> {
12-
let fut = futures::future::poll_fn(move |cx| sem.poll_acquire(cx));
12+
let fut = std::future::poll_fn(move |cx| sem.poll_acquire(cx));
1313
tokio_test::task::spawn(fut)
1414
}
1515

1616
fn semaphore_poll_many(
1717
sem: &mut PollSemaphore,
1818
permits: u32,
1919
) -> tokio_test::task::Spawn<impl Future<Output = SemRet> + '_> {
20-
let fut = futures::future::poll_fn(move |cx| sem.poll_acquire_many(cx, permits));
20+
let fut = std::future::poll_fn(move |cx| sem.poll_acquire_many(cx, permits));
2121
tokio_test::task::spawn(fut)
2222
}
2323

tokio/src/fs/file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ cfg_windows! {
936936

937937
impl Inner {
938938
async fn complete_inflight(&mut self) {
939-
use crate::future::poll_fn;
939+
use std::future::poll_fn;
940940

941941
poll_fn(|cx| self.poll_complete_inflight(cx)).await;
942942
}

tokio/src/fs/read_dir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl ReadDir {
7676
///
7777
/// This method is cancellation safe.
7878
pub async fn next_entry(&mut self) -> io::Result<Option<DirEntry>> {
79-
use crate::future::poll_fn;
79+
use std::future::poll_fn;
8080
poll_fn(|cx| self.poll_next_entry(cx)).await
8181
}
8282

tokio/src/future/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#[cfg(any(feature = "macros", feature = "process"))]
66
pub(crate) mod maybe_done;
77

8-
mod poll_fn;
9-
#[allow(unused_imports)]
10-
pub use poll_fn::poll_fn;
11-
128
cfg_process! {
139
mod try_join;
1410
pub(crate) use try_join::try_join3;

tokio/src/future/poll_fn.rs

-60
This file was deleted.

tokio/src/io/util/copy_bidirectional.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::copy::CopyBuffer;
22

3-
use crate::future::poll_fn;
43
use crate::io::{AsyncRead, AsyncWrite};
54

5+
use std::future::poll_fn;
66
use std::io;
77
use std::pin::Pin;
88
use std::task::{ready, Context, Poll};

tokio/src/io/util/lines.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ where
6767
/// # }
6868
/// ```
6969
pub async fn next_line(&mut self) -> io::Result<Option<String>> {
70-
use crate::future::poll_fn;
70+
use std::future::poll_fn;
7171

7272
poll_fn(|cx| Pin::new(&mut *self).poll_next_line(cx)).await
7373
}

tokio/src/io/util/split.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ where
5959
/// # }
6060
/// ```
6161
pub async fn next_segment(&mut self) -> io::Result<Option<Vec<u8>>> {
62-
use crate::future::poll_fn;
62+
use std::future::poll_fn;
6363

6464
poll_fn(|cx| Pin::new(&mut *self).poll_next_segment(cx)).await
6565
}

tokio/src/macros/support.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
cfg_macros! {
2-
pub use crate::future::poll_fn;
32
pub use crate::future::maybe_done::maybe_done;
43

4+
pub use std::future::poll_fn;
5+
56
#[doc(hidden)]
67
pub fn thread_rng_n(n: u32) -> u32 {
78
crate::runtime::context::thread_rng_n(n)

tokio/src/net/tcp/split.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
//! split has no associated overhead and enforces all invariants at the type
99
//! level.
1010
11-
use crate::future::poll_fn;
1211
use crate::io::{AsyncRead, AsyncWrite, Interest, ReadBuf, Ready};
1312
use crate::net::TcpStream;
1413

14+
use std::future::poll_fn;
1515
use std::io;
1616
use std::net::{Shutdown, SocketAddr};
1717
use std::pin::Pin;
@@ -69,7 +69,7 @@ impl ReadHalf<'_> {
6969
/// use tokio::io::{self, ReadBuf};
7070
/// use tokio::net::TcpStream;
7171
///
72-
/// use futures::future::poll_fn;
72+
/// use std::future::poll_fn;
7373
///
7474
/// #[tokio::main]
7575
/// async fn main() -> io::Result<()> {

tokio/src/net/tcp/split_owned.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
//! split has no associated overhead and enforces all invariants at the type
99
//! level.
1010
11-
use crate::future::poll_fn;
1211
use crate::io::{AsyncRead, AsyncWrite, Interest, ReadBuf, Ready};
1312
use crate::net::TcpStream;
1413

1514
use std::error::Error;
15+
use std::future::poll_fn;
1616
use std::net::{Shutdown, SocketAddr};
1717
use std::pin::Pin;
1818
use std::sync::Arc;
@@ -124,7 +124,7 @@ impl OwnedReadHalf {
124124
/// use tokio::io::{self, ReadBuf};
125125
/// use tokio::net::TcpStream;
126126
///
127-
/// use futures::future::poll_fn;
127+
/// use std::future::poll_fn;
128128
///
129129
/// #[tokio::main]
130130
/// async fn main() -> io::Result<()> {

tokio/src/net/tcp/stream.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cfg_not_wasi! {
2-
use crate::future::poll_fn;
32
use crate::net::{to_socket_addrs, ToSocketAddrs};
3+
use std::future::poll_fn;
44
use std::time::Duration;
55
}
66

@@ -340,7 +340,7 @@ impl TcpStream {
340340
/// use tokio::io::{self, ReadBuf};
341341
/// use tokio::net::TcpStream;
342342
///
343-
/// use futures::future::poll_fn;
343+
/// use std::future::poll_fn;
344344
///
345345
/// #[tokio::main]
346346
/// async fn main() -> io::Result<()> {

tokio/src/net/unix/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::future::poll_fn;
21
use crate::io::{AsyncRead, AsyncWrite, Interest, PollEvented, ReadBuf, Ready};
32
use crate::net::unix::split::{split, ReadHalf, WriteHalf};
43
use crate::net::unix::split_owned::{split_owned, OwnedReadHalf, OwnedWriteHalf};
54
use crate::net::unix::ucred::{self, UCred};
65
use crate::net::unix::SocketAddr;
76

87
use std::fmt;
8+
use std::future::poll_fn;
99
use std::io::{self, Read, Write};
1010
use std::net::Shutdown;
1111
#[cfg(target_os = "android")]

tokio/src/runtime/coop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ mod test {
255255

256256
#[test]
257257
fn budgeting() {
258-
use futures::future::poll_fn;
258+
use std::future::poll_fn;
259259
use tokio_test::*;
260260

261261
assert!(get().0.is_none());

tokio/src/runtime/io/registration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Registration {
219219
loop {
220220
let event = self.readiness(interest).await?;
221221

222-
let coop = crate::future::poll_fn(crate::runtime::coop::poll_proceed).await;
222+
let coop = std::future::poll_fn(crate::runtime::coop::poll_proceed).await;
223223

224224
match f() {
225225
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {

tokio/src/runtime/scheduler/current_thread/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::future::poll_fn;
21
use crate::loom::sync::atomic::AtomicBool;
32
use crate::loom::sync::Arc;
43
use crate::runtime::driver::{self, Driver};
@@ -15,7 +14,7 @@ use crate::util::{waker_ref, RngSeedGenerator, Wake, WakerRef};
1514

1615
use std::cell::RefCell;
1716
use std::collections::VecDeque;
18-
use std::future::Future;
17+
use std::future::{poll_fn, Future};
1918
use std::sync::atomic::Ordering::{AcqRel, Release};
2019
use std::task::Poll::{Pending, Ready};
2120
use std::task::Waker;

tokio/src/runtime/tests/loom_local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn wake_during_shutdown() {
2323
ls.spawn_local(async move {
2424
let mut send = Some(send);
2525

26-
let () = futures::future::poll_fn(|cx| {
26+
let () = std::future::poll_fn(|cx| {
2727
if let Some(send) = send.take() {
2828
send.send(cx.waker().clone());
2929
}

tokio/src/runtime/tests/loom_multi_thread.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ mod yield_now;
88
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
99
///
1010
/// In order to speed up the C
11-
use crate::future::poll_fn;
1211
use crate::runtime::tests::loom_oneshot as oneshot;
1312
use crate::runtime::{self, Runtime};
1413
use crate::{spawn, task};
@@ -18,7 +17,7 @@ use loom::sync::atomic::{AtomicBool, AtomicUsize};
1817
use loom::sync::Arc;
1918

2019
use pin_project_lite::pin_project;
21-
use std::future::Future;
20+
use std::future::{poll_fn, Future};
2221
use std::pin::Pin;
2322
use std::sync::atomic::Ordering::{Relaxed, SeqCst};
2423
use std::task::{ready, Context, Poll};

tokio/src/runtime/tests/loom_multi_thread_alt.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod yield_now;
1010
/// Use `LOOM_MAX_PREEMPTIONS=1` to do a "quick" run as a smoke test.
1111
///
1212
/// In order to speed up the C
13-
use crate::future::poll_fn;
1413
use crate::runtime::tests::loom_oneshot as oneshot;
1514
use crate::runtime::{self, Runtime};
1615
use crate::{spawn, task};
@@ -20,7 +19,7 @@ use loom::sync::atomic::{AtomicBool, AtomicUsize};
2019
use loom::sync::Arc;
2120

2221
use pin_project_lite::pin_project;
23-
use std::future::Future;
22+
use std::future::{poll_fn, Future};
2423
use std::pin::Pin;
2524
use std::sync::atomic::Ordering::{Relaxed, SeqCst};
2625
use std::task::{ready, Context, Poll};

0 commit comments

Comments
 (0)