Skip to content

Commit 6a34e26

Browse files
authored
feat(router): Use infallible as error type (#2232)
1 parent 7b4803b commit 6a34e26

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

tonic/src/service/router.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
fmt,
66
future::Future,
77
pin::Pin,
8-
task::{ready, Context, Poll},
8+
task::{Context, Poll},
99
};
1010
use tower::{Service, ServiceExt};
1111

@@ -146,7 +146,7 @@ where
146146
B::Error: Into<crate::BoxError>,
147147
{
148148
type Response = Response<Body>;
149-
type Error = crate::BoxError;
149+
type Error = Infallible;
150150
type Future = RoutesFuture;
151151

152152
#[inline]
@@ -168,15 +168,11 @@ impl fmt::Debug for RoutesFuture {
168168
}
169169

170170
impl Future for RoutesFuture {
171-
type Output = Result<Response<Body>, crate::BoxError>;
171+
type Output = Result<Response<Body>, Infallible>;
172172

173173
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
174-
match ready!(Pin::new(&mut self.as_mut().0).poll(cx)) {
175-
Ok(res) => Ok(res.map(Body::new)).into(),
176-
// NOTE: This pattern is not needed from Rust 1.82.
177-
// See https://github.com/rust-lang/rust/pull/122792.
178-
#[allow(unreachable_patterns)]
179-
Err(err) => match err {},
180-
}
174+
Pin::new(&mut self.as_mut().0)
175+
.poll(cx)
176+
.map_ok(|res| res.map(Body::new))
181177
}
182178
}

0 commit comments

Comments
 (0)