diff --git a/.circleci/config.yml b/.circleci/config.yml index f3dae710..8038a2c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,7 @@ version: 2 jobs: build: docker: - - image: rust:1.41.0 + - image: rust:1.45.0 environment: RUSTFLAGS: -D warnings - image: sfackler/rust-postgres-test:6 diff --git a/codegen/src/type_gen.rs b/codegen/src/type_gen.rs index 485442a3..7e92e062 100644 --- a/codegen/src/type_gen.rs +++ b/codegen/src/type_gen.rs @@ -136,10 +136,7 @@ impl<'a> DatParser<'a> { fn peek(&mut self, target: char) -> bool { self.skip_ws(); - match self.it.peek() { - Some((_, ch)) if *ch == target => true, - _ => false, - } + matches!(self.it.peek(), Some((_, ch)) if *ch == target) } fn eof(&mut self) { diff --git a/postgres-native-tls/Cargo.toml b/postgres-native-tls/Cargo.toml index e2d60d1f..51145bf9 100644 --- a/postgres-native-tls/Cargo.toml +++ b/postgres-native-tls/Cargo.toml @@ -16,13 +16,12 @@ default = ["runtime"] runtime = ["tokio-postgres/runtime"] [dependencies] -bytes = "0.5" futures = "0.3" native-tls = "0.2" -tokio = "0.2" -tokio-tls = "0.3" +tokio = "0.3" +tokio-native-tls = "0.2" tokio-postgres = { version = "0.5.0", path = "../tokio-postgres", default-features = false } [dev-dependencies] -tokio = { version = "0.2", features = ["full"] } +tokio = { version = "0.3", features = ["full"] } postgres = { version = "0.17.0", path = "../postgres" } diff --git a/postgres-native-tls/src/lib.rs b/postgres-native-tls/src/lib.rs index 207ae6cb..00413c27 100644 --- a/postgres-native-tls/src/lib.rs +++ b/postgres-native-tls/src/lib.rs @@ -48,13 +48,11 @@ #![doc(html_root_url = "https://docs.rs/postgres-native-tls/0.3")] #![warn(rust_2018_idioms, clippy::all, missing_docs)] -use bytes::{Buf, BufMut}; use std::future::Future; use std::io; -use std::mem::MaybeUninit; use std::pin::Pin; use std::task::{Context, Poll}; -use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio_postgres::tls; #[cfg(feature = "runtime")] use tokio_postgres::tls::MakeTlsConnect; @@ -94,7 +92,7 @@ where /// A `TlsConnect` implementation using the `native-tls` crate. pub struct TlsConnector { - connector: tokio_tls::TlsConnector, + connector: tokio_native_tls::TlsConnector, domain: String, } @@ -102,7 +100,7 @@ impl TlsConnector { /// Creates a new connector configured to connect to the specified domain. pub fn new(connector: native_tls::TlsConnector, domain: &str) -> TlsConnector { TlsConnector { - connector: tokio_tls::TlsConnector::from(connector), + connector: tokio_native_tls::TlsConnector::from(connector), domain: domain.to_string(), } } @@ -129,34 +127,19 @@ where } /// The stream returned by `TlsConnector`. -pub struct TlsStream(tokio_tls::TlsStream); +pub struct TlsStream(tokio_native_tls::TlsStream); impl AsyncRead for TlsStream where S: AsyncRead + AsyncWrite + Unpin, { - unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit]) -> bool { - self.0.prepare_uninitialized_buffer(buf) - } - fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut ReadBuf<'_>, + ) -> Poll> { Pin::new(&mut self.0).poll_read(cx, buf) } - - fn poll_read_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - { - Pin::new(&mut self.0).poll_read_buf(cx, buf) - } } impl AsyncWrite for TlsStream @@ -178,17 +161,6 @@ where fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Pin::new(&mut self.0).poll_shutdown(cx) } - - fn poll_write_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - { - Pin::new(&mut self.0).poll_write_buf(cx, buf) - } } impl tls::TlsStream for TlsStream @@ -196,7 +168,9 @@ where S: AsyncRead + AsyncWrite + Unpin, { fn channel_binding(&self) -> ChannelBinding { - // FIXME https://github.com/tokio-rs/tokio/issues/1383 - ChannelBinding::none() + match self.0.get_ref().tls_server_end_point().ok().flatten() { + Some(buf) => ChannelBinding::tls_server_end_point(buf), + None => ChannelBinding::none(), + } } } diff --git a/postgres-openssl/Cargo.toml b/postgres-openssl/Cargo.toml index a3c9f65f..e022a4f8 100644 --- a/postgres-openssl/Cargo.toml +++ b/postgres-openssl/Cargo.toml @@ -16,13 +16,12 @@ default = ["runtime"] runtime = ["tokio-postgres/runtime"] [dependencies] -bytes = "0.5" futures = "0.3" openssl = "0.10" -tokio = "0.2" -tokio-openssl = "0.4" +tokio = "0.3" +tokio-openssl = "0.5" tokio-postgres = { version = "0.5.0", path = "../tokio-postgres", default-features = false } [dev-dependencies] -tokio = { version = "0.2", features = ["full"] } +tokio = { version = "0.3", features = ["full"] } postgres = { version = "0.17.0", path = "../postgres" } diff --git a/postgres-openssl/src/lib.rs b/postgres-openssl/src/lib.rs index 23a653c6..3780f208 100644 --- a/postgres-openssl/src/lib.rs +++ b/postgres-openssl/src/lib.rs @@ -42,7 +42,6 @@ #![doc(html_root_url = "https://docs.rs/postgres-openssl/0.3")] #![warn(rust_2018_idioms, clippy::all, missing_docs)] -use bytes::{Buf, BufMut}; #[cfg(feature = "runtime")] use openssl::error::ErrorStack; use openssl::hash::MessageDigest; @@ -53,12 +52,11 @@ use openssl::ssl::{ConnectConfiguration, SslRef}; use std::fmt::Debug; use std::future::Future; use std::io; -use std::mem::MaybeUninit; use std::pin::Pin; #[cfg(feature = "runtime")] use std::sync::Arc; use std::task::{Context, Poll}; -use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio_openssl::{HandshakeError, SslStream}; use tokio_postgres::tls; #[cfg(feature = "runtime")] @@ -157,28 +155,13 @@ impl AsyncRead for TlsStream where S: AsyncRead + AsyncWrite + Unpin, { - unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit]) -> bool { - self.0.prepare_uninitialized_buffer(buf) - } - fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut ReadBuf<'_>, + ) -> Poll> { Pin::new(&mut self.0).poll_read(cx, buf) } - - fn poll_read_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - { - Pin::new(&mut self.0).poll_read_buf(cx, buf) - } } impl AsyncWrite for TlsStream @@ -200,17 +183,6 @@ where fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Pin::new(&mut self.0).poll_shutdown(cx) } - - fn poll_write_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - { - Pin::new(&mut self.0).poll_write_buf(cx, buf) - } } impl tls::TlsStream for TlsStream diff --git a/postgres-protocol/src/authentication/sasl.rs b/postgres-protocol/src/authentication/sasl.rs index c99a27a2..416b4b99 100644 --- a/postgres-protocol/src/authentication/sasl.rs +++ b/postgres-protocol/src/authentication/sasl.rs @@ -330,10 +330,7 @@ impl<'a> Parser<'a> { } fn printable(&mut self) -> io::Result<&'a str> { - self.take_while(|c| match c { - '\x21'..='\x2b' | '\x2d'..='\x7e' => true, - _ => false, - }) + self.take_while(|c| matches!(c, '\x21'..='\x2b' | '\x2d'..='\x7e')) } fn nonce(&mut self) -> io::Result<&'a str> { @@ -343,10 +340,7 @@ impl<'a> Parser<'a> { } fn base64(&mut self) -> io::Result<&'a str> { - self.take_while(|c| match c { - 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '=' => true, - _ => false, - }) + self.take_while(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '=')) } fn salt(&mut self) -> io::Result<&'a str> { @@ -356,10 +350,7 @@ impl<'a> Parser<'a> { } fn posit_number(&mut self) -> io::Result { - let n = self.take_while(|c| match c { - '0'..='9' => true, - _ => false, - })?; + let n = self.take_while(|c| matches!(c, '0'..='9'))?; n.parse() .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e)) } @@ -396,10 +387,7 @@ impl<'a> Parser<'a> { } fn value(&mut self) -> io::Result<&'a str> { - self.take_while(|c| match c { - '\0' | '=' | ',' => false, - _ => true, - }) + self.take_while(|c| matches!(c, '\0' | '=' | ',')) } fn server_error(&mut self) -> io::Result> { diff --git a/postgres-types/src/lib.rs b/postgres-types/src/lib.rs index 258b68ed..e9a5846e 100644 --- a/postgres-types/src/lib.rs +++ b/postgres-types/src/lib.rs @@ -144,10 +144,7 @@ const NSEC_PER_USEC: u64 = 1_000; macro_rules! accepts { ($($expected:ident),+) => ( fn accepts(ty: &$crate::Type) -> bool { - match *ty { - $($crate::Type::$expected)|+ => true, - _ => false - } + matches!(*ty, $($crate::Type::$expected)|+) } ) } diff --git a/postgres-types/src/special.rs b/postgres-types/src/special.rs index 5a2d7bc0..8579885e 100644 --- a/postgres-types/src/special.rs +++ b/postgres-types/src/special.rs @@ -75,10 +75,7 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for Timestamp { } fn accepts(ty: &Type) -> bool { - match *ty { - Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true, - _ => false, - } + matches!(*ty, Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty)) } } @@ -99,10 +96,7 @@ impl ToSql for Timestamp { } fn accepts(ty: &Type) -> bool { - match *ty { - Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true, - _ => false, - } + matches!(*ty, Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty)) } to_sql_checked!(); diff --git a/postgres/Cargo.toml b/postgres/Cargo.toml index 3652ac35..db910445 100644 --- a/postgres/Cargo.toml +++ b/postgres/Cargo.toml @@ -36,7 +36,7 @@ fallible-iterator = "0.2" futures = "0.3" tokio-postgres = { version = "0.5.5", path = "../tokio-postgres" } -tokio = { version = "0.2", features = ["rt-core", "time"] } +tokio = { version = "0.3", features = ["rt", "time"] } log = "0.4" [dev-dependencies] diff --git a/postgres/src/cancel_token.rs b/postgres/src/cancel_token.rs index f140e60e..be24edcc 100644 --- a/postgres/src/cancel_token.rs +++ b/postgres/src/cancel_token.rs @@ -26,9 +26,8 @@ impl CancelToken { where T: MakeTlsConnect, { - runtime::Builder::new() + runtime::Builder::new_current_thread() .enable_all() - .basic_scheduler() .build() .unwrap() // FIXME don't unwrap .block_on(self.0.cancel_query(tls)) diff --git a/postgres/src/config.rs b/postgres/src/config.rs index b4d01b1d..249e6b44 100644 --- a/postgres/src/config.rs +++ b/postgres/src/config.rs @@ -336,9 +336,8 @@ impl Config { T::Stream: Send, >::Future: Send, { - let mut runtime = runtime::Builder::new() + let runtime = runtime::Builder::new_current_thread() .enable_all() - .basic_scheduler() .build() .unwrap(); // FIXME don't unwrap diff --git a/postgres/src/connection.rs b/postgres/src/connection.rs index a6abb727..bc8564f5 100644 --- a/postgres/src/connection.rs +++ b/postgres/src/connection.rs @@ -45,7 +45,8 @@ impl Connection { where F: FnOnce() -> T, { - self.runtime.enter(f) + let _guard = self.runtime.enter(); + f() } pub fn block_on(&mut self, future: F) -> Result diff --git a/postgres/src/notifications.rs b/postgres/src/notifications.rs index e8c68154..241c95a5 100644 --- a/postgres/src/notifications.rs +++ b/postgres/src/notifications.rs @@ -6,7 +6,7 @@ use fallible_iterator::FallibleIterator; use futures::{ready, FutureExt}; use std::task::Poll; use std::time::Duration; -use tokio::time::{self, Delay, Instant}; +use tokio::time::{self, Instant, Sleep}; /// Notifications from a PostgreSQL backend. pub struct Notifications<'a> { @@ -64,7 +64,7 @@ impl<'a> Notifications<'a> { /// This iterator may start returning `Some` after previously returning `None` if more notifications are received. pub fn timeout_iter(&mut self, timeout: Duration) -> TimeoutIter<'_> { TimeoutIter { - delay: self.connection.enter(|| time::delay_for(timeout)), + delay: self.connection.enter(|| time::sleep(timeout)), timeout, connection: self.connection.as_ref(), } @@ -124,7 +124,7 @@ impl<'a> FallibleIterator for BlockingIter<'a> { /// A time-limited blocking iterator over pending notifications. pub struct TimeoutIter<'a> { connection: ConnectionRef<'a>, - delay: Delay, + delay: Sleep, timeout: Duration, } diff --git a/tokio-postgres/Cargo.toml b/tokio-postgres/Cargo.toml index 84cc3bc8..aea6aa5c 100644 --- a/tokio-postgres/Cargo.toml +++ b/tokio-postgres/Cargo.toml @@ -25,7 +25,7 @@ circle-ci = { repository = "sfackler/rust-postgres" } [features] default = ["runtime"] -runtime = ["tokio/dns", "tokio/net", "tokio/time"] +runtime = ["tokio/net", "tokio/time"] with-bit-vec-0_6 = ["postgres-types/with-bit-vec-0_6"] with-chrono-0_4 = ["postgres-types/with-chrono-0_4"] @@ -49,11 +49,11 @@ pin-project-lite = "0.1" phf = "0.8" postgres-protocol = { version = "0.5.0", path = "../postgres-protocol" } postgres-types = { version = "0.1.2", path = "../postgres-types" } -tokio = { version = "0.2", features = ["io-util"] } -tokio-util = { version = "0.3", features = ["codec"] } +tokio = { version = "0.3", features = ["io-util"] } +tokio-util = { version = "0.4", features = ["codec"] } [dev-dependencies] -tokio = { version = "0.2", features = ["full"] } +tokio = { version = "0.3", features = ["full"] } env_logger = "0.7" criterion = "0.3" diff --git a/tokio-postgres/benches/bench.rs b/tokio-postgres/benches/bench.rs index 315bea8e..fececa2b 100644 --- a/tokio-postgres/benches/bench.rs +++ b/tokio-postgres/benches/bench.rs @@ -7,7 +7,7 @@ use tokio::runtime::Runtime; use tokio_postgres::{Client, NoTls}; fn setup() -> (Client, Runtime) { - let mut runtime = Runtime::new().unwrap(); + let runtime = Runtime::new().unwrap(); let (client, conn) = runtime .block_on(tokio_postgres::connect( "host=localhost port=5433 user=postgres", @@ -19,7 +19,7 @@ fn setup() -> (Client, Runtime) { } fn query_prepared(c: &mut Criterion) { - let (client, mut runtime) = setup(); + let (client, runtime) = setup(); let statement = runtime.block_on(client.prepare("SELECT $1::INT8")).unwrap(); c.bench_function("runtime_block_on", move |b| { b.iter(|| { @@ -29,13 +29,13 @@ fn query_prepared(c: &mut Criterion) { }) }); - let (client, mut runtime) = setup(); + let (client, runtime) = setup(); let statement = runtime.block_on(client.prepare("SELECT $1::INT8")).unwrap(); c.bench_function("executor_block_on", move |b| { b.iter(|| executor::block_on(client.query(&statement, &[&1i64])).unwrap()) }); - let (client, mut runtime) = setup(); + let (client, runtime) = setup(); let client = Arc::new(client); let statement = runtime.block_on(client.prepare("SELECT $1::INT8")).unwrap(); c.bench_function("spawned", move |b| { diff --git a/tokio-postgres/src/connect_socket.rs b/tokio-postgres/src/connect_socket.rs index 2d56a2ed..145eb7dc 100644 --- a/tokio-postgres/src/connect_socket.rs +++ b/tokio-postgres/src/connect_socket.rs @@ -12,19 +12,15 @@ pub(crate) async fn connect_socket( host: &Host, port: u16, connect_timeout: Option, - keepalives: bool, - keepalives_idle: Duration, + _keepalives: bool, + _keepalives_idle: Duration, ) -> Result { match host { Host::Tcp(host) => { let socket = connect_with_timeout(TcpStream::connect((&**host, port)), connect_timeout).await?; socket.set_nodelay(true).map_err(Error::connect)?; - if keepalives { - socket - .set_keepalive(Some(keepalives_idle)) - .map_err(Error::connect)?; - } + // FIXME support keepalives? Ok(Socket::new_tcp(socket)) } diff --git a/tokio-postgres/src/maybe_tls_stream.rs b/tokio-postgres/src/maybe_tls_stream.rs index 652236ee..73b0c472 100644 --- a/tokio-postgres/src/maybe_tls_stream.rs +++ b/tokio-postgres/src/maybe_tls_stream.rs @@ -1,10 +1,8 @@ use crate::tls::{ChannelBinding, TlsStream}; -use bytes::{Buf, BufMut}; use std::io; -use std::mem::MaybeUninit; use std::pin::Pin; use std::task::{Context, Poll}; -use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; pub enum MaybeTlsStream { Raw(S), @@ -16,38 +14,16 @@ where S: AsyncRead + Unpin, T: AsyncRead + Unpin, { - unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit]) -> bool { - match self { - MaybeTlsStream::Raw(s) => s.prepare_uninitialized_buffer(buf), - MaybeTlsStream::Tls(s) => s.prepare_uninitialized_buffer(buf), - } - } - fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut ReadBuf<'_>, + ) -> Poll> { match &mut *self { MaybeTlsStream::Raw(s) => Pin::new(s).poll_read(cx, buf), MaybeTlsStream::Tls(s) => Pin::new(s).poll_read(cx, buf), } } - - fn poll_read_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - B: BufMut, - { - match &mut *self { - MaybeTlsStream::Raw(s) => Pin::new(s).poll_read_buf(cx, buf), - MaybeTlsStream::Tls(s) => Pin::new(s).poll_read_buf(cx, buf), - } - } } impl AsyncWrite for MaybeTlsStream @@ -79,21 +55,6 @@ where MaybeTlsStream::Tls(s) => Pin::new(s).poll_shutdown(cx), } } - - fn poll_write_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - B: Buf, - { - match &mut *self { - MaybeTlsStream::Raw(s) => Pin::new(s).poll_write_buf(cx, buf), - MaybeTlsStream::Tls(s) => Pin::new(s).poll_write_buf(cx, buf), - } - } } impl TlsStream for MaybeTlsStream diff --git a/tokio-postgres/src/socket.rs b/tokio-postgres/src/socket.rs index cc714967..966510d5 100644 --- a/tokio-postgres/src/socket.rs +++ b/tokio-postgres/src/socket.rs @@ -1,9 +1,7 @@ -use bytes::{Buf, BufMut}; use std::io; -use std::mem::MaybeUninit; use std::pin::Pin; use std::task::{Context, Poll}; -use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::net::TcpStream; #[cfg(unix)] use tokio::net::UnixStream; @@ -33,41 +31,17 @@ impl Socket { } impl AsyncRead for Socket { - unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit]) -> bool { - match &self.0 { - Inner::Tcp(s) => s.prepare_uninitialized_buffer(buf), - #[cfg(unix)] - Inner::Unix(s) => s.prepare_uninitialized_buffer(buf), - } - } - fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { + buf: &mut ReadBuf<'_>, + ) -> Poll> { match &mut self.0 { Inner::Tcp(s) => Pin::new(s).poll_read(cx, buf), #[cfg(unix)] Inner::Unix(s) => Pin::new(s).poll_read(cx, buf), } } - - fn poll_read_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - B: BufMut, - { - match &mut self.0 { - Inner::Tcp(s) => Pin::new(s).poll_read_buf(cx, buf), - #[cfg(unix)] - Inner::Unix(s) => Pin::new(s).poll_read_buf(cx, buf), - } - } } impl AsyncWrite for Socket { @@ -98,20 +72,4 @@ impl AsyncWrite for Socket { Inner::Unix(s) => Pin::new(s).poll_shutdown(cx), } } - - fn poll_write_buf( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut B, - ) -> Poll> - where - Self: Sized, - B: Buf, - { - match &mut self.0 { - Inner::Tcp(s) => Pin::new(s).poll_write_buf(cx, buf), - #[cfg(unix)] - Inner::Unix(s) => Pin::new(s).poll_write_buf(cx, buf), - } - } } diff --git a/tokio-postgres/src/tls.rs b/tokio-postgres/src/tls.rs index 4e852d3f..963daed1 100644 --- a/tokio-postgres/src/tls.rs +++ b/tokio-postgres/src/tls.rs @@ -5,7 +5,7 @@ use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, io}; -use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; pub(crate) mod private { pub struct ForcePrivateApi; @@ -125,8 +125,8 @@ impl AsyncRead for NoTlsStream { fn poll_read( self: Pin<&mut Self>, _: &mut Context<'_>, - _: &mut [u8], - ) -> Poll> { + _: &mut ReadBuf<'_>, + ) -> Poll> { match *self {} } } diff --git a/tokio-postgres/tests/test/main.rs b/tokio-postgres/tests/test/main.rs index b01037ed..bf6d72d3 100644 --- a/tokio-postgres/tests/test/main.rs +++ b/tokio-postgres/tests/test/main.rs @@ -308,7 +308,7 @@ async fn cancel_query_raw() { let socket = TcpStream::connect("127.0.0.1:5433").await.unwrap(); let cancel_token = client.cancel_token(); let cancel = cancel_token.cancel_query_raw(socket, NoTls); - let cancel = time::delay_for(Duration::from_millis(100)).then(|()| cancel); + let cancel = time::sleep(Duration::from_millis(100)).then(|()| cancel); let sleep = client.batch_execute("SELECT pg_sleep(100)"); diff --git a/tokio-postgres/tests/test/runtime.rs b/tokio-postgres/tests/test/runtime.rs index e07aa4a6..b088d6c9 100644 --- a/tokio-postgres/tests/test/runtime.rs +++ b/tokio-postgres/tests/test/runtime.rs @@ -72,7 +72,7 @@ async fn cancel_query() { let cancel_token = client.cancel_token(); let cancel = cancel_token.cancel_query(NoTls); - let cancel = time::delay_for(Duration::from_millis(100)).then(|()| cancel); + let cancel = time::sleep(Duration::from_millis(100)).then(|()| cancel); let sleep = client.batch_execute("SELECT pg_sleep(100)");