Skip to content

Commit abc4f89

Browse files
authored
remove deprecated pin-project attribute (#590)
The #[project] attribute is now deprecated. See https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
1 parent a13433a commit abc4f89

File tree

22 files changed

+97
-142
lines changed

22 files changed

+97
-142
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,18 +1754,18 @@ dependencies = [
17541754

17551755
[[package]]
17561756
name = "pin-project"
1757-
version = "0.4.9"
1757+
version = "0.4.22"
17581758
source = "registry+https://github.com/rust-lang/crates.io-index"
1759-
checksum = "6f6a7f5eee6292c559c793430c55c00aea9d3b3d1905e855806ca4d7253426a2"
1759+
checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17"
17601760
dependencies = [
17611761
"pin-project-internal",
17621762
]
17631763

17641764
[[package]]
17651765
name = "pin-project-internal"
1766-
version = "0.4.9"
1766+
version = "0.4.22"
17671767
source = "registry+https://github.com/rust-lang/crates.io-index"
1768-
checksum = "8988430ce790d8682672117bc06dda364c0be32d3abd738234f19f3240bad99a"
1768+
checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"
17691769
dependencies = [
17701770
"proc-macro2 1.0.10",
17711771
"quote 1.0.2",

linkerd/app/core/src/control.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub mod resolve {
152152
use futures::{ready, TryFuture};
153153
use linkerd2_addr::Addr;
154154
use linkerd2_dns as dns;
155-
use pin_project::{pin_project, project};
155+
use pin_project::pin_project;
156156
use std::future::Future;
157157
use std::net::SocketAddr;
158158
use std::pin::Pin;
@@ -179,7 +179,7 @@ pub mod resolve {
179179
state: State<M>,
180180
}
181181

182-
#[pin_project]
182+
#[pin_project(project = StateProj)]
183183
enum State<M>
184184
where
185185
M: tower::Service<client::Target>,
@@ -248,27 +248,25 @@ pub mod resolve {
248248
{
249249
type Output = Result<M::Response, Error<M::Error>>;
250250

251-
#[project]
252251
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
253252
let mut this = self.project();
254253
loop {
255-
#[project]
256254
match this.state.as_mut().project() {
257-
State::Resolve(fut, stack) => {
255+
StateProj::Resolve(fut, stack) => {
258256
let ip = ready!(fut.poll(cx).map_err(Error::Dns))?;
259257
let (svc, config) = stack.take().unwrap();
260258
let addr = SocketAddr::from((ip, config.addr.port()));
261259
this.state
262260
.as_mut()
263261
.set(State::NotReady(svc, Some((addr, config))));
264262
}
265-
State::NotReady(svc, cfg) => {
263+
StateProj::NotReady(svc, cfg) => {
266264
ready!(svc.poll_ready(cx).map_err(Error::Inner))?;
267265
let (addr, config) = cfg.take().unwrap();
268266
let state = State::make_inner(addr, &config, svc);
269267
this.state.as_mut().set(state);
270268
}
271-
State::Inner(fut) => return fut.poll(cx).map_err(Error::Inner),
269+
StateProj::Inner(fut) => return fut.poll(cx).map_err(Error::Inner),
272270
};
273271
}
274272
}

linkerd/app/core/src/errors.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use linkerd2_error_respond as respond;
77
pub use linkerd2_error_respond::RespondLayer;
88
use linkerd2_proxy_http::HasH2Reason;
99
use linkerd2_timeout::{error::ResponseTimeout, FailFastError};
10-
use pin_project::{pin_project, project};
10+
use pin_project::pin_project;
1111
use std::pin::Pin;
1212
use std::task::{Context, Poll};
1313
use tonic::{self as grpc, Code};
@@ -57,7 +57,7 @@ pub enum Respond {
5757
Http2 { is_grpc: bool },
5858
}
5959

60-
#[pin_project]
60+
#[pin_project(project = ResponseBodyProj)]
6161
pub enum ResponseBody<B> {
6262
NonGrpc(#[pin] B),
6363
Grpc {
@@ -74,15 +74,13 @@ where
7474
type Data = B::Data;
7575
type Error = B::Error;
7676

77-
#[project]
7877
fn poll_data(
7978
self: Pin<&mut Self>,
8079
cx: &mut Context<'_>,
8180
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
82-
#[project]
8381
match self.project() {
84-
ResponseBody::NonGrpc(inner) => inner.poll_data(cx),
85-
ResponseBody::Grpc { inner, trailers } => {
82+
ResponseBodyProj::NonGrpc(inner) => inner.poll_data(cx),
83+
ResponseBodyProj::Grpc { inner, trailers } => {
8684
// should not be calling poll_data if we have set trailers derived from an error
8785
assert!(trailers.is_none());
8886
match inner.poll_data(cx) {
@@ -100,15 +98,13 @@ where
10098
}
10199
}
102100

103-
#[project]
104101
fn poll_trailers(
105102
self: Pin<&mut Self>,
106103
cx: &mut Context<'_>,
107104
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
108-
#[project]
109105
match self.project() {
110-
ResponseBody::NonGrpc(inner) => inner.poll_trailers(cx),
111-
ResponseBody::Grpc { inner, trailers } => match trailers.take() {
106+
ResponseBodyProj::NonGrpc(inner) => inner.poll_trailers(cx),
107+
ResponseBodyProj::Grpc { inner, trailers } => match trailers.take() {
112108
Some(t) => Poll::Ready(Ok(Some(t))),
113109
None => inner.poll_trailers(cx),
114110
},

linkerd/app/core/src/svc.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ pub mod make_response {
433433
use super::Oneshot;
434434
use crate::Error;
435435
use futures::TryFuture;
436-
use pin_project::{pin_project, project};
436+
use pin_project::pin_project;
437437
use std::future::Future;
438438
use std::pin::Pin;
439439
use std::task::{Context, Poll};
@@ -449,7 +449,7 @@ pub mod make_response {
449449
state: State<F, S>,
450450
}
451451

452-
#[pin_project]
452+
#[pin_project(project = StateProj)]
453453
enum State<F, S: tower::Service<()>> {
454454
Make(#[pin] F),
455455
Respond(#[pin] Oneshot<S, ()>),
@@ -493,17 +493,15 @@ pub mod make_response {
493493
{
494494
type Output = Result<S::Response, Error>;
495495

496-
#[project]
497496
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
498497
let mut this = self.project();
499498
loop {
500-
#[project]
501499
match this.state.as_mut().project() {
502-
State::Make(fut) => {
500+
StateProj::Make(fut) => {
503501
let svc = futures::ready!(fut.try_poll(cx)).map_err(Into::into)?;
504502
this.state.set(State::Respond(Oneshot::new(svc, ())))
505503
}
506-
State::Respond(fut) => return fut.poll(cx).map_err(Into::into),
504+
StateProj::Respond(fut) => return fut.poll(cx).map_err(Into::into),
507505
}
508506
}
509507
}

linkerd/opencensus/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use opencensus_proto::agent::trace::v1::{
1010
trace_service_client::TraceServiceClient, ExportTraceServiceRequest, ExportTraceServiceResponse,
1111
};
1212
use opencensus_proto::trace::v1::Span;
13-
use pin_project::{pin_project, project};
13+
use pin_project::pin_project;
1414
use std::convert::TryInto;
1515
use std::future::Future;
1616
use std::pin::Pin;
@@ -167,7 +167,6 @@ where
167167
{
168168
type Output = ();
169169

170-
#[project]
171170
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
172171
loop {
173172
let this = self.as_mut().project();

linkerd/proxy/http/src/canonicalize.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use futures::{ready, TryFuture};
1010
use linkerd2_addr::{Addr, NameAddr};
1111
use linkerd2_dns::Name;
1212
use linkerd2_error::Error;
13-
use pin_project::{pin_project, project};
13+
use pin_project::pin_project;
1414
use std::future::Future;
1515
use std::pin::Pin;
1616
use std::task::{Context, Poll};
@@ -44,7 +44,7 @@ pub struct MakeFuture<T, R, M: tower::Service<T>> {
4444
state: State<T, R, M>,
4545
}
4646

47-
#[pin_project]
47+
#[pin_project(project = StateProj)]
4848
enum State<T, R, M: tower::Service<T>> {
4949
Refine {
5050
#[pin]
@@ -134,13 +134,11 @@ where
134134
{
135135
type Output = Result<M::Response, Error>;
136136

137-
#[project]
138137
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
139138
let mut state = self.project().state;
140139
loop {
141-
#[project]
142140
match state.as_mut().project() {
143-
State::Refine {
141+
StateProj::Refine {
144142
future,
145143
make,
146144
original,
@@ -166,13 +164,13 @@ where
166164
let make = make.take().expect("illegal state");
167165
state.set(State::NotReady(make, Some(target)));
168166
}
169-
State::NotReady(svc, target) => {
167+
StateProj::NotReady(svc, target) => {
170168
ready!(svc.poll_ready(cx)).map_err(Into::into)?;
171169
let target = target.take().expect("illegal state");
172170
let fut = svc.call(target);
173171
state.set(State::Make(fut));
174172
}
175-
State::Make(fut) => return fut.try_poll(cx).map_err(Into::into),
173+
StateProj::Make(fut) => return fut.try_poll(cx).map_err(Into::into),
176174
};
177175
}
178176
}

linkerd/proxy/http/src/client.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use futures::{ready, TryFuture};
99
use http;
1010
use hyper;
1111
use linkerd2_error::Error;
12-
use pin_project::{pin_project, project};
12+
use pin_project::pin_project;
1313
use std::future::Future;
1414
use std::marker::PhantomData;
1515
use std::pin::Pin;
@@ -35,7 +35,7 @@ pub struct MakeClient<C, B> {
3535
}
3636

3737
/// A `Future` returned from `MakeClient::new_service()`.
38-
#[pin_project]
38+
#[pin_project(project = MakeFutureProj)]
3939
pub enum MakeFuture<C, T, B>
4040
where
4141
B: hyper::body::HttpBody + Send + 'static,
@@ -60,7 +60,7 @@ where
6060
Http2(h2::Connection<B>),
6161
}
6262

63-
#[pin_project]
63+
#[pin_project(project = ClientFutureProj)]
6464
pub enum ClientFuture {
6565
Http1 {
6666
#[pin]
@@ -183,12 +183,10 @@ where
183183
{
184184
type Output = Result<Client<C, T, B>, Error>;
185185

186-
#[project]
187186
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
188-
#[project]
189187
let svc = match self.project() {
190-
MakeFuture::Http1(h1) => Client::Http1(h1.take().expect("poll more than once")),
191-
MakeFuture::Http2(h2) => {
188+
MakeFutureProj::Http1(h1) => Client::Http1(h1.take().expect("poll more than once")),
189+
MakeFutureProj::Http2(h2) => {
192190
let svc = ready!(h2.poll(cx))?;
193191
Client::Http2(svc)
194192
}
@@ -253,11 +251,9 @@ where
253251
impl Future for ClientFuture {
254252
type Output = Result<http::Response<Body>, Error>;
255253

256-
#[project]
257254
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
258-
#[project]
259255
match self.project() {
260-
ClientFuture::Http1 {
256+
ClientFutureProj::Http1 {
261257
future,
262258
upgrade,
263259
is_http_connect,
@@ -277,7 +273,7 @@ impl Future for ClientFuture {
277273
}
278274
Poll::Ready(Ok(res))
279275
}
280-
ClientFuture::Http2(f) => f.poll(cx).map_err(Into::into),
276+
ClientFutureProj::Http2(f) => f.poll(cx).map_err(Into::into),
281277
}
282278
}
283279
}

linkerd/proxy/http/src/h2.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use hyper::{
77
client::conn::{self, SendRequest},
88
};
99
use linkerd2_error::Error;
10-
use pin_project::{pin_project, project};
10+
use pin_project::pin_project;
1111
use std::future::Future;
1212
use std::marker::PhantomData;
1313
use std::pin::Pin;
@@ -48,7 +48,7 @@ where
4848
h2_settings: Settings,
4949
}
5050

51-
#[pin_project]
51+
#[pin_project(project = ConnectStateProj)]
5252
enum ConnectState<F, B>
5353
where
5454
F: TryFuture + Send + 'static,
@@ -141,13 +141,11 @@ where
141141
{
142142
type Output = Result<Connection<B>, Error>;
143143

144-
#[project]
145144
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
146145
let mut this = self.project();
147146
loop {
148-
#[project]
149147
match this.state.as_mut().project() {
150-
ConnectState::Connect(fut) => {
148+
ConnectStateProj::Connect(fut) => {
151149
let io = ready!(fut.try_poll(cx)).map_err(Into::into)?;
152150
let hs = conn::Builder::new()
153151
.http2_only(true)
@@ -163,7 +161,7 @@ where
163161

164162
this.state.set(ConnectState::Handshake(Box::pin(hs)));
165163
}
166-
ConnectState::Handshake(hs) => {
164+
ConnectStateProj::Handshake(hs) => {
167165
let (tx, conn) = ready!(hs.poll(cx))?;
168166

169167
tokio::spawn(

linkerd/proxy/resolve/src/recover.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use futures::{ready, stream::TryStreamExt, FutureExt};
44
use indexmap::IndexMap;
55
use linkerd2_error::{Error, Recover};
66
use linkerd2_proxy_core::resolve::{self, Resolution as _, Update};
7-
use pin_project::{pin_project, project};
7+
use pin_project::pin_project;
88
use std::future::Future;
99
use std::net::SocketAddr;
1010
use std::pin::Pin;
@@ -21,7 +21,7 @@ pub struct ResolveFuture<T, E: Recover, R: resolve::Resolve<T>> {
2121
inner: Option<Inner<T, E, R>>,
2222
}
2323

24-
#[pin_project]
24+
#[pin_project(project = ResolutionProj)]
2525
pub struct Resolution<T, E: Recover, R: resolve::Resolve<T>> {
2626
inner: Inner<T, E, R>,
2727
cache: IndexMap<SocketAddr, R::Endpoint>,
@@ -225,8 +225,7 @@ where
225225
}
226226
}
227227

228-
#[project]
229-
impl<T, E, R> Resolution<T, E, R>
228+
impl<T, E, R> ResolutionProj<'_, T, E, R>
230229
where
231230
T: Clone,
232231
R: resolve::Resolve<T>,

0 commit comments

Comments
 (0)