Skip to content

Commit 360972b

Browse files
committed
Use #[project(!Unpin)] instead of PhantomPinned
1 parent e1cd6be commit 360972b

File tree

5 files changed

+7
-23
lines changed

5 files changed

+7
-23
lines changed

tokio-postgres/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ futures-util = { version = "0.3", features = ["sink"] }
5656
log = "0.4"
5757
parking_lot = "0.12"
5858
percent-encoding = "2.0"
59-
pin-project-lite = "0.2"
59+
pin-project-lite = "0.2.11"
6060
phf = "0.11"
6161
postgres-protocol = { version = "0.6.8", path = "../postgres-protocol" }
6262
postgres-types = { version = "0.2.9", path = "../postgres-types" }

tokio-postgres/src/copy_in.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use pin_project_lite::pin_project;
1111
use postgres_protocol::message::backend::Message;
1212
use postgres_protocol::message::frontend;
1313
use postgres_protocol::message::frontend::CopyData;
14-
use std::marker::{PhantomData, PhantomPinned};
14+
use std::marker::PhantomData;
1515
use std::pin::Pin;
1616
use std::task::{Context, Poll};
1717

@@ -73,14 +73,13 @@ pin_project! {
7373
///
7474
/// The copy *must* be explicitly completed via the `Sink::close` or `finish` methods. If it is
7575
/// not, the copy will be aborted.
76+
#[project(!Unpin)]
7677
pub struct CopyInSink<T> {
7778
#[pin]
7879
sender: mpsc::Sender<CopyInMessage>,
7980
responses: Responses,
8081
buf: BytesMut,
8182
state: SinkState,
82-
#[pin]
83-
_p: PhantomPinned,
8483
_p2: PhantomData<T>,
8584
}
8685
}
@@ -220,7 +219,6 @@ where
220219
responses,
221220
buf: BytesMut::new(),
222221
state: SinkState::Active,
223-
_p: PhantomPinned,
224222
_p2: PhantomData,
225223
})
226224
}

tokio-postgres/src/copy_out.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use futures_util::{ready, Stream};
77
use log::debug;
88
use pin_project_lite::pin_project;
99
use postgres_protocol::message::backend::Message;
10-
use std::marker::PhantomPinned;
1110
use std::pin::Pin;
1211
use std::task::{Context, Poll};
1312

@@ -16,10 +15,7 @@ pub async fn copy_out(client: &InnerClient, statement: Statement) -> Result<Copy
1615

1716
let buf = query::encode(client, &statement, slice_iter(&[]))?;
1817
let responses = start(client, buf).await?;
19-
Ok(CopyOutStream {
20-
responses,
21-
_p: PhantomPinned,
22-
})
18+
Ok(CopyOutStream { responses })
2319
}
2420

2521
async fn start(client: &InnerClient, buf: Bytes) -> Result<Responses, Error> {
@@ -40,10 +36,9 @@ async fn start(client: &InnerClient, buf: Bytes) -> Result<Responses, Error> {
4036

4137
pin_project! {
4238
/// A stream of `COPY ... TO STDOUT` query data.
39+
#[project(!Unpin)]
4340
pub struct CopyOutStream {
4441
responses: Responses,
45-
#[pin]
46-
_p: PhantomPinned,
4742
}
4843
}
4944

tokio-postgres/src/query.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use postgres_protocol::message::backend::{CommandCompleteBody, Message};
1313
use postgres_protocol::message::frontend;
1414
use postgres_types::Type;
1515
use std::fmt;
16-
use std::marker::PhantomPinned;
1716
use std::pin::Pin;
1817
use std::sync::Arc;
1918
use std::task::{Context, Poll};
@@ -57,7 +56,6 @@ where
5756
statement,
5857
responses,
5958
rows_affected: None,
60-
_p: PhantomPinned,
6159
})
6260
}
6361

@@ -95,7 +93,6 @@ where
9593
statement: Statement::unnamed(vec![], vec![]),
9694
responses,
9795
rows_affected: None,
98-
_p: PhantomPinned,
9996
});
10097
}
10198
Message::RowDescription(row_description) => {
@@ -115,7 +112,6 @@ where
115112
statement: Statement::unnamed(vec![], columns),
116113
responses,
117114
rows_affected: None,
118-
_p: PhantomPinned,
119115
});
120116
}
121117
_ => return Err(Error::unexpected_message()),
@@ -140,7 +136,6 @@ pub async fn query_portal(
140136
statement: portal.statement().clone(),
141137
responses,
142138
rows_affected: None,
143-
_p: PhantomPinned,
144139
})
145140
}
146141

@@ -285,12 +280,11 @@ where
285280

286281
pin_project! {
287282
/// A stream of table rows.
283+
#[project(!Unpin)]
288284
pub struct RowStream {
289285
statement: Statement,
290286
responses: Responses,
291287
rows_affected: Option<u64>,
292-
#[pin]
293-
_p: PhantomPinned,
294288
}
295289
}
296290

tokio-postgres/src/simple_query.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use log::debug;
1010
use pin_project_lite::pin_project;
1111
use postgres_protocol::message::backend::Message;
1212
use postgres_protocol::message::frontend;
13-
use std::marker::PhantomPinned;
1413
use std::pin::Pin;
1514
use std::sync::Arc;
1615
use std::task::{Context, Poll};
@@ -41,7 +40,6 @@ pub async fn simple_query(client: &InnerClient, query: &str) -> Result<SimpleQue
4140
Ok(SimpleQueryStream {
4241
responses,
4342
columns: None,
44-
_p: PhantomPinned,
4543
})
4644
}
4745

@@ -72,11 +70,10 @@ fn encode(client: &InnerClient, query: &str) -> Result<Bytes, Error> {
7270

7371
pin_project! {
7472
/// A stream of simple query results.
73+
#[project(!Unpin)]
7574
pub struct SimpleQueryStream {
7675
responses: Responses,
7776
columns: Option<Arc<[SimpleColumn]>>,
78-
#[pin]
79-
_p: PhantomPinned,
8077
}
8178
}
8279

0 commit comments

Comments
 (0)