From f0322fb8923b6104cea43ebeb83d187e53dfcb9a Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 6 Jun 2020 09:26:07 +0900 Subject: [PATCH] Remove uses of pin_project::project attribute pin-project will deprecate the project attribute due to some unfixable limitations. Refs: https://github.com/taiki-e/pin-project/issues/225 --- tarpc/Cargo.toml | 3 +-- tarpc/src/rpc/client/channel.rs | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tarpc/Cargo.toml b/tarpc/Cargo.toml index 4a8936db..bba7c880 100644 --- a/tarpc/Cargo.toml +++ b/tarpc/Cargo.toml @@ -30,7 +30,7 @@ fnv = "1.0" futures = "0.3" humantime = "1.0" log = "0.4" -pin-project = "0.4" +pin-project = "0.4.17" rand = "0.7" tokio = { version = "0.2", features = ["time"] } serde = { optional = true, version = "1.0", features = ["derive"] } @@ -60,4 +60,3 @@ required-features = ["full"] [[example]] name = "pubsub" required-features = ["full"] - diff --git a/tarpc/src/rpc/client/channel.rs b/tarpc/src/rpc/client/channel.rs index 290602e5..916eb495 100644 --- a/tarpc/src/rpc/client/channel.rs +++ b/tarpc/src/rpc/client/channel.rs @@ -19,7 +19,7 @@ use futures::{ task::*, }; use log::{debug, info, trace}; -use pin_project::{pin_project, pinned_drop, project}; +use pin_project::{pin_project, pinned_drop}; use std::{ io, pin::Pin, @@ -628,7 +628,7 @@ where } } -#[pin_project] +#[pin_project(project = TryChainProj)] #[must_use = "futures do nothing unless polled"] #[derive(Debug)] enum TryChain { @@ -654,7 +654,6 @@ where TryChain::First(fut1) } - #[project] fn poll( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -666,20 +665,19 @@ where let mut f = Some(f); loop { - #[project] let output = match self.as_mut().project() { - TryChain::First(fut1) => { + TryChainProj::First(fut1) => { // Poll the first future match fut1.try_poll(cx) { Poll::Pending => return Poll::Pending, Poll::Ready(output) => output, } } - TryChain::Second(fut2) => { + TryChainProj::Second(fut2) => { // Poll the second future return fut2.try_poll(cx); } - TryChain::Empty => { + TryChainProj::Empty => { panic!("future must not be polled after it returned `Poll::Ready`"); } };