From 2faae6d20fc27c4b2c04bb235f38ace53248cf80 Mon Sep 17 00:00:00 2001 From: tottoto Date: Sat, 11 Nov 2023 12:34:08 +0900 Subject: [PATCH] Refactor use of futures crate --- examples/tonic-key-value-store/Cargo.toml | 1 - examples/tonic-key-value-store/src/main.rs | 5 ++-- tower-http/Cargo.toml | 28 +++++++++---------- .../src/auth/async_require_authorization.rs | 3 +- tower-http/src/catch_panic.rs | 3 +- tower-http/src/classify/mod.rs | 6 ++-- tower-http/src/compression/body.rs | 3 +- tower-http/src/compression/future.rs | 3 +- tower-http/src/compression/mod.rs | 2 +- tower-http/src/compression_utils.rs | 5 ++-- tower-http/src/cors/mod.rs | 3 +- tower-http/src/decompression/body.rs | 8 ++++-- tower-http/src/decompression/future.rs | 3 +- tower-http/src/follow_redirect/mod.rs | 3 +- tower-http/src/limit/future.rs | 3 +- tower-http/src/map_request_body.rs | 3 +- tower-http/src/map_response_body.rs | 6 ++-- tower-http/src/metrics/in_flight_requests.rs | 5 ++-- tower-http/src/propagate_header.rs | 3 +- tower-http/src/request_id.rs | 4 +-- tower-http/src/sensitive_headers.rs | 3 +- .../src/services/fs/serve_dir/future.rs | 7 ++--- tower-http/src/set_header/response.rs | 3 +- tower-http/src/set_status.rs | 4 +-- tower-http/src/timeout/body.rs | 4 +-- tower-http/src/timeout/service.rs | 3 +- tower-http/src/trace/body.rs | 3 +- tower-http/src/trace/future.rs | 4 +-- tower-http/src/trace/mod.rs | 2 +- 29 files changed, 56 insertions(+), 77 deletions(-) diff --git a/examples/tonic-key-value-store/Cargo.toml b/examples/tonic-key-value-store/Cargo.toml index 530c73cf..5bfb6893 100644 --- a/examples/tonic-key-value-store/Cargo.toml +++ b/examples/tonic-key-value-store/Cargo.toml @@ -11,7 +11,6 @@ bytes = "1" hyper = { version = "0.14.4", features = ["full"] } prost = "0.11" tokio = { version = "1.2.0", features = ["full"] } -futures = "0.3" tokio-stream = { version = "0.1", features = ["sync", "net"] } tonic = "0.9" tower = { version = "0.4.5", features = ["full"] } diff --git a/examples/tonic-key-value-store/src/main.rs b/examples/tonic-key-value-store/src/main.rs index bb7ea04a..b4267dbe 100644 --- a/examples/tonic-key-value-store/src/main.rs +++ b/examples/tonic-key-value-store/src/main.rs @@ -1,6 +1,5 @@ use bytes::Bytes; use clap::Parser; -use futures::StreamExt; use hyper::{ body::HttpBody, header::{self, HeaderValue}, @@ -24,7 +23,7 @@ use tokio::{ }; use tokio_stream::{ wrappers::{BroadcastStream, TcpListenerStream}, - Stream, + Stream, StreamExt, }; use tonic::{async_trait, body::BoxBody, transport::Channel, Code, Request, Response, Status}; use tower::{BoxError, Service, ServiceBuilder}; @@ -245,7 +244,7 @@ impl key_value_store_server::KeyValueStore for ServerImpl { let rx = self.tx.subscribe(); let stream = BroadcastStream::new(rx) - .filter_map(|item| async move { + .filter_map(|item| { // ignore receive errors item.ok() }) diff --git a/tower-http/Cargo.toml b/tower-http/Cargo.toml index 0f060a57..d2ad8ea3 100644 --- a/tower-http/Cargo.toml +++ b/tower-http/Cargo.toml @@ -15,8 +15,6 @@ rust-version = "1.66" [dependencies] bitflags = "2.0.2" bytes = "1" -futures-core = "0.3" -futures-util = { version = "0.3.14", default_features = false, features = [] } http = "0.2.7" http-body = "0.4.5" pin-project-lite = "0.2.7" @@ -26,6 +24,7 @@ tower-service = "0.3" # optional dependencies async-compression = { version = "0.4", optional = true, features = ["tokio"] } base64 = { version = "0.21", optional = true } +futures-util = { version = "0.3.14", optional = true, default_features = false } http-range-header = { version = "0.4.0", optional = true } iri-string = { version = "0.7.0", optional = true } mime = { version = "0.3.17", optional = true, default_features = false } @@ -42,7 +41,6 @@ uuid = { version = "1.0", features = ["v4"], optional = true } bytes = "1" flate2 = "1.0" brotli = "3" -futures = "0.3" hyper = { version = "0.14", features = ["full"] } once_cell = "1" tokio = { version = "1", features = ["full"] } @@ -81,11 +79,11 @@ full = [ ] add-extension = [] -auth = ["base64", "validate-request"] +auth = ["base64", "futures-util", "validate-request"] catch-panic = ["tracing", "futures-util/std"] cors = [] -follow-redirect = ["iri-string", "tower/util"] -fs = ["tokio/fs", "tokio-util/io", "tokio/io-util", "dep:http-range-header", "mime_guess", "mime", "percent-encoding", "httpdate", "set-status", "futures-util/alloc", "tracing"] +follow-redirect = ["futures-util", "iri-string", "tower/util"] +fs = ["futures-util", "tokio/fs", "tokio-util/io", "tokio/io-util", "dep:http-range-header", "mime_guess", "mime", "percent-encoding", "httpdate", "set-status", "futures-util/alloc", "tracing"] limit = [] map-request-body = [] map-response-body = [] @@ -98,21 +96,21 @@ sensitive-headers = [] set-header = [] set-status = [] timeout = ["tokio/time"] -trace = ["tracing"] +trace = ["futures-util", "tracing"] util = ["tower"] validate-request = ["mime"] -compression-br = ["async-compression/brotli", "tokio-util", "tokio"] -compression-deflate = ["async-compression/zlib", "tokio-util", "tokio"] +compression-br = ["async-compression/brotli", "futures-util", "tokio-util", "tokio"] +compression-deflate = ["async-compression/zlib", "futures-util", "tokio-util", "tokio"] compression-full = ["compression-br", "compression-deflate", "compression-gzip", "compression-zstd"] -compression-gzip = ["async-compression/gzip", "tokio-util", "tokio"] -compression-zstd = ["async-compression/zstd", "tokio-util", "tokio"] +compression-gzip = ["async-compression/gzip", "futures-util", "tokio-util", "tokio"] +compression-zstd = ["async-compression/zstd", "futures-util", "tokio-util", "tokio"] -decompression-br = ["async-compression/brotli", "tokio-util", "tokio"] -decompression-deflate = ["async-compression/zlib", "tokio-util", "tokio"] +decompression-br = ["async-compression/brotli", "futures-util", "tokio-util", "tokio"] +decompression-deflate = ["async-compression/zlib", "futures-util", "tokio-util", "tokio"] decompression-full = ["decompression-br", "decompression-deflate", "decompression-gzip", "decompression-zstd"] -decompression-gzip = ["async-compression/gzip", "tokio-util", "tokio"] -decompression-zstd = ["async-compression/zstd", "tokio-util", "tokio"] +decompression-gzip = ["async-compression/gzip", "futures-util", "tokio-util", "tokio"] +decompression-zstd = ["async-compression/zstd", "futures-util", "tokio-util", "tokio"] [package.metadata.docs.rs] all-features = true diff --git a/tower-http/src/auth/async_require_authorization.rs b/tower-http/src/auth/async_require_authorization.rs index 5963e65c..32244e83 100644 --- a/tower-http/src/auth/async_require_authorization.rs +++ b/tower-http/src/auth/async_require_authorization.rs @@ -115,13 +115,12 @@ //! # } //! ``` -use futures_core::ready; use http::{Request, Response}; use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/catch_panic.rs b/tower-http/src/catch_panic.rs index b8e3213e..5cf6bdbf 100644 --- a/tower-http/src/catch_panic.rs +++ b/tower-http/src/catch_panic.rs @@ -83,7 +83,6 @@ //! ``` use bytes::Bytes; -use futures_core::ready; use futures_util::future::{CatchUnwind, FutureExt}; use http::{HeaderValue, Request, Response, StatusCode}; use http_body::{combinators::UnsyncBoxBody, Body, Full}; @@ -93,7 +92,7 @@ use std::{ future::Future, panic::AssertUnwindSafe, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/classify/mod.rs b/tower-http/src/classify/mod.rs index 2c1ecc56..08b322a0 100644 --- a/tower-http/src/classify/mod.rs +++ b/tower-http/src/classify/mod.rs @@ -397,7 +397,7 @@ mod usable_for_retries { Request: Clone, E: std::error::Error + 'static, { - type Future = futures::future::Ready>; + type Future = std::future::Ready>; fn retry( &self, @@ -410,7 +410,7 @@ mod usable_for_retries { self.classifier.clone().classify_response(res) { if class.err()?.is_retryable() { - return Some(futures::future::ready(self.clone())); + return Some(std::future::ready(self.clone())); } } @@ -421,7 +421,7 @@ mod usable_for_retries { .clone() .classify_error(err) .is_retryable() - .then(|| futures::future::ready(self.clone())), + .then(|| std::future::ready(self.clone())), } } diff --git a/tower-http/src/compression/body.rs b/tower-http/src/compression/body.rs index d2a7c549..90229d5e 100644 --- a/tower-http/src/compression/body.rs +++ b/tower-http/src/compression/body.rs @@ -15,7 +15,6 @@ use async_compression::tokio::bufread::ZlibEncoder; use async_compression::tokio::bufread::ZstdEncoder; use bytes::{Buf, Bytes}; -use futures_util::ready; use http::HeaderMap; use http_body::Body; use pin_project_lite::pin_project; @@ -23,7 +22,7 @@ use std::{ io, marker::PhantomData, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tokio_util::io::StreamReader; diff --git a/tower-http/src/compression/future.rs b/tower-http/src/compression/future.rs index 426bb161..ca574fce 100644 --- a/tower-http/src/compression/future.rs +++ b/tower-http/src/compression/future.rs @@ -5,14 +5,13 @@ use crate::compression::predicate::Predicate; use crate::compression::CompressionLevel; use crate::compression_utils::WrapBody; use crate::content_encoding::Encoding; -use futures_util::ready; use http::{header, HeaderMap, HeaderValue, Response}; use http_body::Body; use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; pin_project! { diff --git a/tower-http/src/compression/mod.rs b/tower-http/src/compression/mod.rs index dbfd2364..b3beed9a 100644 --- a/tower-http/src/compression/mod.rs +++ b/tower-http/src/compression/mod.rs @@ -399,7 +399,7 @@ mod tests { let compressed_with_level = { use async_compression::tokio::bufread::BrotliEncoder; - let stream = Box::pin(futures::stream::once(async move { + let stream = Box::pin(futures_util::stream::once(async move { Ok::<_, std::io::Error>(DATA.as_bytes()) })); let reader = StreamReader::new(stream); diff --git a/tower-http/src/compression_utils.rs b/tower-http/src/compression_utils.rs index 5231fc3e..2aabca68 100644 --- a/tower-http/src/compression_utils.rs +++ b/tower-http/src/compression_utils.rs @@ -2,15 +2,14 @@ use crate::{content_encoding::SupportedEncodings, BoxError}; use bytes::{Bytes, BytesMut}; -use futures_core::Stream; -use futures_util::ready; +use futures_util::Stream; use http::HeaderValue; use http_body::Body; use pin_project_lite::pin_project; use std::{ io, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tokio::io::AsyncRead; use tokio_util::io::{poll_read_buf, StreamReader}; diff --git a/tower-http/src/cors/mod.rs b/tower-http/src/cors/mod.rs index 42c355b5..20f2c336 100644 --- a/tower-http/src/cors/mod.rs +++ b/tower-http/src/cors/mod.rs @@ -49,7 +49,6 @@ #![allow(clippy::enum_variant_names)] use bytes::{BufMut, BytesMut}; -use futures_core::ready; use http::{ header::{self, HeaderName}, HeaderMap, HeaderValue, Method, Request, Response, @@ -60,7 +59,7 @@ use std::{ future::Future, mem, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/decompression/body.rs b/tower-http/src/decompression/body.rs index 0b3c3020..58cc40a4 100644 --- a/tower-http/src/decompression/body.rs +++ b/tower-http/src/decompression/body.rs @@ -14,12 +14,16 @@ use async_compression::tokio::bufread::ZlibDecoder; #[cfg(feature = "decompression-zstd")] use async_compression::tokio::bufread::ZstdDecoder; use bytes::{Buf, Bytes}; -use futures_util::ready; use http::HeaderMap; use http_body::Body; use pin_project_lite::pin_project; use std::task::Context; -use std::{io, marker::PhantomData, pin::Pin, task::Poll}; +use std::{ + io, + marker::PhantomData, + pin::Pin, + task::{ready, Poll}, +}; use tokio_util::io::StreamReader; pin_project! { diff --git a/tower-http/src/decompression/future.rs b/tower-http/src/decompression/future.rs index fd72dd2f..36867e97 100644 --- a/tower-http/src/decompression/future.rs +++ b/tower-http/src/decompression/future.rs @@ -3,14 +3,13 @@ use super::{body::BodyInner, DecompressionBody}; use crate::compression_utils::{AcceptEncoding, CompressionLevel, WrapBody}; use crate::content_encoding::SupportedEncodings; -use futures_util::ready; use http::{header, Response}; use http_body::Body; use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; pin_project! { diff --git a/tower-http/src/follow_redirect/mod.rs b/tower-http/src/follow_redirect/mod.rs index 19f825db..8c13415e 100644 --- a/tower-http/src/follow_redirect/mod.rs +++ b/tower-http/src/follow_redirect/mod.rs @@ -93,7 +93,6 @@ pub mod policy; use self::policy::{Action, Attempt, Policy, Standard}; -use futures_core::ready; use futures_util::future::Either; use http::{ header::LOCATION, HeaderMap, HeaderValue, Method, Request, Response, StatusCode, Uri, Version, @@ -107,7 +106,7 @@ use std::{ mem, pin::Pin, str, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower::util::Oneshot; use tower_layer::Layer; diff --git a/tower-http/src/limit/future.rs b/tower-http/src/limit/future.rs index 4a9140eb..fd913c75 100644 --- a/tower-http/src/limit/future.rs +++ b/tower-http/src/limit/future.rs @@ -1,12 +1,11 @@ use super::body::create_error_response; use super::ResponseBody; -use futures_core::ready; use http::Response; use http_body::Body; use pin_project_lite::pin_project; use std::future::Future; use std::pin::Pin; -use std::task::{Context, Poll}; +use std::task::{ready, Context, Poll}; pin_project! { /// Response future for [`RequestBodyLimit`]. diff --git a/tower-http/src/map_request_body.rs b/tower-http/src/map_request_body.rs index 44d5caf9..9389322b 100644 --- a/tower-http/src/map_request_body.rs +++ b/tower-http/src/map_request_body.rs @@ -7,10 +7,9 @@ //! use http::{Request, Response}; //! use hyper::Body; //! use std::convert::Infallible; -//! use std::{pin::Pin, task::{Context, Poll}}; +//! use std::{pin::Pin, task::{ready, Context, Poll}}; //! use tower::{ServiceBuilder, service_fn, ServiceExt, Service}; //! use tower_http::map_request_body::MapRequestBodyLayer; -//! use futures::ready; //! //! // A wrapper for a `hyper::Body` that prints the size of data chunks //! struct PrintChunkSizesBody { diff --git a/tower-http/src/map_response_body.rs b/tower-http/src/map_response_body.rs index bbad79db..5d0bb4c8 100644 --- a/tower-http/src/map_response_body.rs +++ b/tower-http/src/map_response_body.rs @@ -7,10 +7,9 @@ //! use http::{Request, Response}; //! use hyper::Body; //! use std::convert::Infallible; -//! use std::{pin::Pin, task::{Context, Poll}}; +//! use std::{pin::Pin, task::{ready, Context, Poll}}; //! use tower::{ServiceBuilder, service_fn, ServiceExt, Service}; //! use tower_http::map_response_body::MapResponseBodyLayer; -//! use futures::ready; //! //! // A wrapper for a `hyper::Body` that prints the size of data chunks //! struct PrintChunkSizesBody { @@ -75,14 +74,13 @@ //! # } //! ``` -use futures_core::ready; use http::{Request, Response}; use pin_project_lite::pin_project; use std::future::Future; use std::{ fmt, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/metrics/in_flight_requests.rs b/tower-http/src/metrics/in_flight_requests.rs index 85fb5720..2ca33619 100644 --- a/tower-http/src/metrics/in_flight_requests.rs +++ b/tower-http/src/metrics/in_flight_requests.rs @@ -50,7 +50,6 @@ //! # } //! ``` -use futures_util::ready; use http::{Request, Response}; use http_body::Body; use pin_project_lite::pin_project; @@ -61,7 +60,7 @@ use std::{ atomic::{AtomicUsize, Ordering}, Arc, }, - task::{Context, Poll}, + task::{ready, Context, Poll}, time::Duration, }; use tower_layer::Layer; @@ -311,7 +310,7 @@ mod tests { assert_eq!(counter.get(), 0); // driving service to ready shouldn't increment the counter - futures::future::poll_fn(|cx| service.poll_ready(cx)) + std::future::poll_fn(|cx| service.poll_ready(cx)) .await .unwrap(); assert_eq!(counter.get(), 0); diff --git a/tower-http/src/propagate_header.rs b/tower-http/src/propagate_header.rs index 2ac1756a..214b32d8 100644 --- a/tower-http/src/propagate_header.rs +++ b/tower-http/src/propagate_header.rs @@ -34,13 +34,12 @@ //! # } //! ``` -use futures_util::ready; use http::{header::HeaderName, HeaderValue, Request, Response}; use pin_project_lite::pin_project; use std::future::Future; use std::{ pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/request_id.rs b/tower-http/src/request_id.rs index 58a8324e..b328310c 100644 --- a/tower-http/src/request_id.rs +++ b/tower-http/src/request_id.rs @@ -172,7 +172,7 @@ use http::{ Request, Response, }; use pin_project_lite::pin_project; -use std::task::{Context, Poll}; +use std::task::{ready, Context, Poll}; use std::{future::Future, pin::Pin}; use tower_layer::Layer; use tower_service::Service; @@ -450,7 +450,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); - let mut response = futures_core::ready!(this.inner.poll(cx))?; + let mut response = ready!(this.inner.poll(cx))?; if let Some(current_id) = response.headers().get(&*this.header_name) { if response.extensions().get::().is_none() { diff --git a/tower-http/src/sensitive_headers.rs b/tower-http/src/sensitive_headers.rs index 3fcf18d3..5249b43e 100644 --- a/tower-http/src/sensitive_headers.rs +++ b/tower-http/src/sensitive_headers.rs @@ -82,14 +82,13 @@ //! //! [`TraceLayer`]: crate::trace::TraceLayer -use futures_util::ready; use http::{header::HeaderName, Request, Response}; use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, sync::Arc, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/services/fs/serve_dir/future.rs b/tower-http/src/services/fs/serve_dir/future.rs index c351e557..4ffa4cf8 100644 --- a/tower-http/src/services/fs/serve_dir/future.rs +++ b/tower-http/src/services/fs/serve_dir/future.rs @@ -4,10 +4,7 @@ use super::{ }; use crate::{content_encoding::Encoding, services::fs::AsyncReadBody, BoxError}; use bytes::Bytes; -use futures_util::{ - future::{BoxFuture, FutureExt, TryFutureExt}, - ready, -}; +use futures_util::future::{BoxFuture, FutureExt, TryFutureExt}; use http::{ header::{self, ALLOW}, HeaderValue, Request, Response, StatusCode, @@ -19,7 +16,7 @@ use std::{ future::Future, io, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_service::Service; diff --git a/tower-http/src/set_header/response.rs b/tower-http/src/set_header/response.rs index 1440c21b..a612b926 100644 --- a/tower-http/src/set_header/response.rs +++ b/tower-http/src/set_header/response.rs @@ -93,14 +93,13 @@ //! ``` use super::{InsertHeaderMode, MakeHeaderValue}; -use futures_util::ready; use http::{header::HeaderName, Request, Response}; use pin_project_lite::pin_project; use std::{ fmt, future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; diff --git a/tower-http/src/set_status.rs b/tower-http/src/set_status.rs index 3fa87c1f..bdc4999a 100644 --- a/tower-http/src/set_status.rs +++ b/tower-http/src/set_status.rs @@ -37,7 +37,7 @@ use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, }; use tower_layer::Layer; use tower_service::Service; @@ -129,7 +129,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); - let mut response = futures_core::ready!(this.inner.poll(cx)?); + let mut response = ready!(this.inner.poll(cx)?); *response.status_mut() = this.status.take().expect("future polled after completion"); Poll::Ready(Ok(response)) } diff --git a/tower-http/src/timeout/body.rs b/tower-http/src/timeout/body.rs index 29a952da..efdf3165 100644 --- a/tower-http/src/timeout/body.rs +++ b/tower-http/src/timeout/body.rs @@ -1,10 +1,10 @@ use crate::BoxError; -use futures_core::{ready, Future}; use http_body::Body; use pin_project_lite::pin_project; use std::{ + future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, time::Duration, }; use tokio::time::{sleep, Sleep}; diff --git a/tower-http/src/timeout/service.rs b/tower-http/src/timeout/service.rs index 9e209f20..8371b03f 100644 --- a/tower-http/src/timeout/service.rs +++ b/tower-http/src/timeout/service.rs @@ -1,11 +1,10 @@ use crate::timeout::body::TimeoutBody; -use futures_core::ready; use http::{Request, Response, StatusCode}; use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, time::Duration, }; use tokio::time::Sleep; diff --git a/tower-http/src/trace/body.rs b/tower-http/src/trace/body.rs index d38770d5..55648747 100644 --- a/tower-http/src/trace/body.rs +++ b/tower-http/src/trace/body.rs @@ -1,13 +1,12 @@ use super::{OnBodyChunk, OnEos, OnFailure}; use crate::classify::ClassifyEos; -use futures_core::ready; use http::HeaderMap; use http_body::Body; use pin_project_lite::pin_project; use std::{ fmt, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, time::Instant, }; use tracing::Span; diff --git a/tower-http/src/trace/future.rs b/tower-http/src/trace/future.rs index 9a49db8b..feac51bf 100644 --- a/tower-http/src/trace/future.rs +++ b/tower-http/src/trace/future.rs @@ -6,7 +6,7 @@ use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{Context, Poll}, + task::{ready, Context, Poll}, time::Instant, }; use tracing::Span; @@ -49,7 +49,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); let _guard = this.span.enter(); - let result = futures_util::ready!(this.inner.poll(cx)); + let result = ready!(this.inner.poll(cx)); let latency = this.start.elapsed(); let classifier = this.classifier.take().unwrap(); diff --git a/tower-http/src/trace/mod.rs b/tower-http/src/trace/mod.rs index e08da3e3..f46087dc 100644 --- a/tower-http/src/trace/mod.rs +++ b/tower-http/src/trace/mod.rs @@ -606,7 +606,7 @@ mod tests { } async fn streaming_body(_req: Request) -> Result, BoxError> { - use futures::stream::iter; + use futures_util::stream::iter; let stream = iter(vec![ Ok::<_, BoxError>(Bytes::from("one")),