Skip to content

Commit 1992ebd

Browse files
authored
chore(util): remove redundant ready! wrapping in poll implementations (#844)
1 parent 21e01e9 commit 1992ebd

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

tower/src/limit/concurrency/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pin_project_lite::pin_project;
55
use std::{
66
future::Future,
77
pin::Pin,
8-
task::{ready, Context, Poll},
8+
task::{Context, Poll},
99
};
1010
use tokio::sync::OwnedSemaphorePermit;
1111

@@ -35,6 +35,6 @@ where
3535
type Output = Result<T, E>;
3636

3737
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
38-
Poll::Ready(ready!(self.project().inner.poll(cx)))
38+
self.project().inner.poll(cx)
3939
}
4040
}

tower/src/limit/rate/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::Rate;
22
use std::{
33
future::Future,
44
pin::Pin,
5-
task::{ready, Context, Poll},
5+
task::{Context, Poll},
66
};
77
use tokio::time::{Instant, Sleep};
88
use tower_service::Service;
@@ -70,7 +70,7 @@ where
7070

7171
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
7272
match self.state {
73-
State::Ready { .. } => return Poll::Ready(ready!(self.inner.poll_ready(cx))),
73+
State::Ready { .. } => return self.inner.poll_ready(cx),
7474
State::Limited => {
7575
if Pin::new(&mut self.sleep).poll(cx).is_pending() {
7676
tracing::trace!("rate limit exceeded; sleeping.");
@@ -84,7 +84,7 @@ where
8484
rem: self.rate.num(),
8585
};
8686

87-
Poll::Ready(ready!(self.inner.poll_ready(cx)))
87+
self.inner.poll_ready(cx)
8888
}
8989

9090
fn call(&mut self, request: Request) -> Self::Future {

tower/src/load_shed/future.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::fmt;
44
use std::future::Future;
55
use std::pin::Pin;
6-
use std::task::{ready, Context, Poll};
6+
use std::task::{Context, Poll};
77

88
use pin_project_lite::pin_project;
99

@@ -53,9 +53,7 @@ where
5353

5454
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
5555
match self.project().state.project() {
56-
ResponseStateProj::Called { fut } => {
57-
Poll::Ready(ready!(fut.poll(cx)).map_err(Into::into))
58-
}
56+
ResponseStateProj::Called { fut } => fut.poll(cx).map_err(Into::into),
5957
ResponseStateProj::Overloaded => Poll::Ready(Err(Overloaded::new().into())),
6058
}
6159
}

tower/src/util/optional/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use pin_project_lite::pin_project;
33
use std::{
44
future::Future,
55
pin::Pin,
6-
task::{ready, Context, Poll},
6+
task::{Context, Poll},
77
};
88

99
pin_project! {
@@ -32,7 +32,7 @@ where
3232

3333
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
3434
match self.project().inner.as_pin_mut() {
35-
Some(inner) => Poll::Ready(Ok(ready!(inner.poll(cx)).map_err(Into::into)?)),
35+
Some(inner) => inner.poll(cx).map_err(Into::into),
3636
None => Poll::Ready(Err(error::None::new().into())),
3737
}
3838
}

0 commit comments

Comments
 (0)