From 1992ebd196467deffe193d5a073db655492ce168 Mon Sep 17 00:00:00 2001 From: Kirill Rudakov Date: Sun, 7 Dec 2025 15:31:29 +0300 Subject: [PATCH] chore(util): remove redundant ready! wrapping in poll implementations (#844) --- tower/src/limit/concurrency/future.rs | 4 ++-- tower/src/limit/rate/service.rs | 6 +++--- tower/src/load_shed/future.rs | 6 ++---- tower/src/util/optional/future.rs | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tower/src/limit/concurrency/future.rs b/tower/src/limit/concurrency/future.rs index 9506ecb4..2d883369 100644 --- a/tower/src/limit/concurrency/future.rs +++ b/tower/src/limit/concurrency/future.rs @@ -5,7 +5,7 @@ use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll}, }; use tokio::sync::OwnedSemaphorePermit; @@ -35,6 +35,6 @@ where type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - Poll::Ready(ready!(self.project().inner.poll(cx))) + self.project().inner.poll(cx) } } diff --git a/tower/src/limit/rate/service.rs b/tower/src/limit/rate/service.rs index 6c476ad9..8604de66 100644 --- a/tower/src/limit/rate/service.rs +++ b/tower/src/limit/rate/service.rs @@ -2,7 +2,7 @@ use super::Rate; use std::{ future::Future, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll}, }; use tokio::time::{Instant, Sleep}; use tower_service::Service; @@ -70,7 +70,7 @@ where fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { match self.state { - State::Ready { .. } => return Poll::Ready(ready!(self.inner.poll_ready(cx))), + State::Ready { .. } => return self.inner.poll_ready(cx), State::Limited => { if Pin::new(&mut self.sleep).poll(cx).is_pending() { tracing::trace!("rate limit exceeded; sleeping."); @@ -84,7 +84,7 @@ where rem: self.rate.num(), }; - Poll::Ready(ready!(self.inner.poll_ready(cx))) + self.inner.poll_ready(cx) } fn call(&mut self, request: Request) -> Self::Future { diff --git a/tower/src/load_shed/future.rs b/tower/src/load_shed/future.rs index 4ad115b6..1170fd43 100644 --- a/tower/src/load_shed/future.rs +++ b/tower/src/load_shed/future.rs @@ -3,7 +3,7 @@ use std::fmt; use std::future::Future; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll}; use pin_project_lite::pin_project; @@ -53,9 +53,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.project().state.project() { - ResponseStateProj::Called { fut } => { - Poll::Ready(ready!(fut.poll(cx)).map_err(Into::into)) - } + ResponseStateProj::Called { fut } => fut.poll(cx).map_err(Into::into), ResponseStateProj::Overloaded => Poll::Ready(Err(Overloaded::new().into())), } } diff --git a/tower/src/util/optional/future.rs b/tower/src/util/optional/future.rs index 29129451..5f863f83 100644 --- a/tower/src/util/optional/future.rs +++ b/tower/src/util/optional/future.rs @@ -3,7 +3,7 @@ use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll}, }; pin_project! { @@ -32,7 +32,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.project().inner.as_pin_mut() { - Some(inner) => Poll::Ready(Ok(ready!(inner.poll(cx)).map_err(Into::into)?)), + Some(inner) => inner.poll(cx).map_err(Into::into), None => Poll::Ready(Err(error::None::new().into())), } }