diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 0cd42cbae..87f207628 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -141,7 +141,7 @@ hyper = "0.13" warp = { version = "0.2", default-features = false } http = "0.2" http-body = "0.3" -pin-project = "0.4" +pin-project = "0.4.17" # Health example tonic-health = { path = "../tonic-health" } listenfd = "0.3" diff --git a/examples/src/hyper_warp/server.rs b/examples/src/hyper_warp/server.rs index ba97e3716..931dcd54a 100644 --- a/examples/src/hyper_warp/server.rs +++ b/examples/src/hyper_warp/server.rs @@ -6,7 +6,7 @@ use futures::future::{self, Either, TryFutureExt}; use http::version::Version; use hyper::{service::make_service_fn, Server}; -use pin_project::{pin_project, project}; +use pin_project::pin_project; use std::convert::Infallible; use std::{ pin::Pin, @@ -77,7 +77,7 @@ async fn main() -> Result<(), Box> { Ok(()) } -#[pin_project] +#[pin_project(project = EitherBodyProj)] enum EitherBody { Left(#[pin] A), Right(#[pin] B), @@ -100,27 +100,23 @@ where } } - #[project] fn poll_data( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll>> { - #[project] match self.project() { - EitherBody::Left(b) => b.poll_data(cx).map(map_option_err), - EitherBody::Right(b) => b.poll_data(cx).map(map_option_err), + EitherBodyProj::Left(b) => b.poll_data(cx).map(map_option_err), + EitherBodyProj::Right(b) => b.poll_data(cx).map(map_option_err), } } - #[project] fn poll_trailers( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll, Self::Error>> { - #[project] match self.project() { - EitherBody::Left(b) => b.poll_trailers(cx).map_err(Into::into), - EitherBody::Right(b) => b.poll_trailers(cx).map_err(Into::into), + EitherBodyProj::Left(b) => b.poll_trailers(cx).map_err(Into::into), + EitherBodyProj::Right(b) => b.poll_trailers(cx).map_err(Into::into), } } } diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index e2726c298..47f3b62ab 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -54,7 +54,7 @@ tower-service = "0.3" tokio-util = { version = "0.3", features = ["codec"] } async-stream = "0.2" http-body = "0.3" -pin-project = "0.4" +pin-project = "0.4.17" # prost prost1 = { package = "prost", version = "0.6", optional = true } diff --git a/tonic/src/transport/service/reconnect.rs b/tonic/src/transport/service/reconnect.rs index 55cc58cbd..68a19d79a 100644 --- a/tonic/src/transport/service/reconnect.rs +++ b/tonic/src/transport/service/reconnect.rs @@ -1,5 +1,5 @@ use crate::Error; -use pin_project::{pin_project, project}; +use pin_project::pin_project; use std::fmt; use std::{ future::Future, @@ -161,7 +161,7 @@ pub(crate) struct ResponseFuture { inner: Inner, } -#[pin_project] +#[pin_project(project = InnerProj)] #[derive(Debug)] enum Inner { Future(#[pin] F), @@ -190,14 +190,12 @@ where { type Output = Result; - #[project] fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { //self.project().inner.poll(cx).map_err(Into::into) let me = self.project(); - #[project] match me.inner.project() { - Inner::Future(fut) => fut.poll(cx).map_err(Into::into), - Inner::Error(e) => { + InnerProj::Future(fut) => fut.poll(cx).map_err(Into::into), + InnerProj::Error(e) => { let e = e.take().expect("Polled after ready.").into(); Poll::Ready(Err(e)) }