diff --git a/sqlx-core/src/connection.rs b/sqlx-core/src/connection.rs index 6f9a5fbfd..51fdad992 100644 --- a/sqlx-core/src/connection.rs +++ b/sqlx-core/src/connection.rs @@ -19,7 +19,7 @@ pub trait Connection: Send { fn close(self) -> BoxFuture<'static, Result<(), Error>>; /// Checks if a connection to the database is still valid. - fn ping(&mut self) -> BoxFuture>; + fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>>; /// Begin a new transaction or establish a savepoint within the active transaction. /// @@ -66,7 +66,7 @@ pub trait Connection: Send { /// Flush any pending commands to the database. #[doc(hidden)] - fn flush(&mut self) -> BoxFuture>; + fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>>; #[doc(hidden)] fn get_ref(&self) -> &::Connection; diff --git a/sqlx-core/src/error.rs b/sqlx-core/src/error.rs index 3386441ef..11b791ff7 100644 --- a/sqlx-core/src/error.rs +++ b/sqlx-core/src/error.rs @@ -135,7 +135,7 @@ pub trait DatabaseError: 'static + Send + Sync + StdError { fn message(&self) -> &str; /// The (SQLSTATE) code for the error. - fn code(&self) -> Option> { + fn code(&self) -> Option> { None } diff --git a/sqlx-core/src/io/write_and_flush.rs b/sqlx-core/src/io/write_and_flush.rs index f8350da04..9e7824af8 100644 --- a/sqlx-core/src/io/write_and_flush.rs +++ b/sqlx-core/src/io/write_and_flush.rs @@ -8,12 +8,12 @@ use std::task::{Context, Poll}; // Atomic operation that writes the full buffer to the stream, flushes the stream, and then // clears the buffer (even if either of the two previous operations failed). -pub struct WriteAndFlush<'a, S: 'a> { +pub struct WriteAndFlush<'a, S> { pub(super) stream: &'a mut S, pub(super) buf: Cursor<&'a mut Vec>, } -impl<'a, S: AsyncWrite + Unpin> Future for WriteAndFlush<'a, S> { +impl Future for WriteAndFlush<'_, S> { type Output = Result<(), Error>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { diff --git a/sqlx-core/src/lib.rs b/sqlx-core/src/lib.rs index eccdbe650..8b1b1313c 100644 --- a/sqlx-core/src/lib.rs +++ b/sqlx-core/src/lib.rs @@ -1,6 +1,7 @@ //! Core of SQLx, the rust SQL toolkit. //! Not intended to be used directly. #![recursion_limit = "512"] +#![warn(future_incompatible, rust_2018_idioms)] // // Allows an API be documented as only available in some specific platforms. // diff --git a/sqlx-core/src/mysql/error.rs b/sqlx-core/src/mysql/error.rs index ae2c50302..3f769c7bc 100644 --- a/sqlx-core/src/mysql/error.rs +++ b/sqlx-core/src/mysql/error.rs @@ -58,7 +58,7 @@ impl DatabaseError for MySqlDatabaseError { } #[inline] - fn code(&self) -> Option> { + fn code(&self) -> Option> { self.code().map(Cow::Borrowed) } diff --git a/sqlx-core/src/mysql/row.rs b/sqlx-core/src/mysql/row.rs index 5fe703cd6..8305ee33f 100644 --- a/sqlx-core/src/mysql/row.rs +++ b/sqlx-core/src/mysql/row.rs @@ -33,7 +33,7 @@ impl Row for MySqlRow { self.row.len() } - fn try_get_raw(&self, index: I) -> Result + fn try_get_raw(&self, index: I) -> Result, Error> where I: ColumnIndex, { diff --git a/sqlx-core/src/pool/connection.rs b/sqlx-core/src/pool/connection.rs index 1d953ebf3..668fca3ea 100644 --- a/sqlx-core/src/pool/connection.rs +++ b/sqlx-core/src/pool/connection.rs @@ -69,12 +69,12 @@ impl Connection for PoolConnection { } #[inline] - fn ping(&mut self) -> BoxFuture> { + fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>> { Box::pin(self.deref_mut().ping()) } #[doc(hidden)] - fn flush(&mut self) -> BoxFuture> { + fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> { self.get_mut().flush() } @@ -112,7 +112,7 @@ impl Drop for PoolConnection { } impl Live { - pub fn float(self, pool: &SharedPool) -> Floating { + pub fn float(self, pool: &SharedPool) -> Floating<'_, Self> { Floating { inner: self, guard: DecrementSizeGuard::new(pool), diff --git a/sqlx-core/src/pool/inner.rs b/sqlx-core/src/pool/inner.rs index acabc9140..1ac794ac4 100644 --- a/sqlx-core/src/pool/inner.rs +++ b/sqlx-core/src/pool/inner.rs @@ -58,11 +58,11 @@ impl SharedPool { } #[inline] - pub(super) fn try_acquire(&self) -> Option>> { + pub(super) fn try_acquire(&self) -> Option>> { Some(self.pop_idle()?.into_live()) } - fn pop_idle(&self) -> Option>> { + fn pop_idle(&self) -> Option>> { if self.is_closed.load(Ordering::Acquire) { return None; } @@ -70,7 +70,7 @@ impl SharedPool { Some(Floating::from_idle(self.idle_conns.pop().ok()?, self)) } - pub(super) fn release(&self, floating: Floating>) { + pub(super) fn release(&self, floating: Floating<'_, Live>) { self.idle_conns .push(floating.into_idle().into_leakable()) .expect("BUG: connection queue overflow in release()"); @@ -83,7 +83,7 @@ impl SharedPool { /// Try to atomically increment the pool size for a new connection. /// /// Returns `None` if we are at max_size. - fn try_increment_size(&self) -> Option { + fn try_increment_size(&self) -> Option> { let mut size = self.size(); while size < self.options.max_size { diff --git a/sqlx-core/src/postgres/connection/mod.rs b/sqlx-core/src/postgres/connection/mod.rs index f8c891a2d..def2c0fdb 100644 --- a/sqlx-core/src/postgres/connection/mod.rs +++ b/sqlx-core/src/postgres/connection/mod.rs @@ -125,7 +125,7 @@ impl Connection for PgConnection { } #[doc(hidden)] - fn flush(&mut self) -> BoxFuture> { + fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> { self.wait_until_ready().boxed() } diff --git a/sqlx-core/src/postgres/error.rs b/sqlx-core/src/postgres/error.rs index 6416bd582..b3343d0a4 100644 --- a/sqlx-core/src/postgres/error.rs +++ b/sqlx-core/src/postgres/error.rs @@ -166,7 +166,7 @@ impl DatabaseError for PgDatabaseError { self.message() } - fn code(&self) -> Option> { + fn code(&self) -> Option> { Some(Cow::Borrowed(self.code())) } diff --git a/sqlx-core/src/postgres/row.rs b/sqlx-core/src/postgres/row.rs index 6c2aa0828..63318df7f 100644 --- a/sqlx-core/src/postgres/row.rs +++ b/sqlx-core/src/postgres/row.rs @@ -37,7 +37,7 @@ impl Row for PgRow { self.data.len() } - fn try_get_raw(&self, index: I) -> Result + fn try_get_raw(&self, index: I) -> Result, Error> where I: ColumnIndex, { diff --git a/sqlx-core/src/query.rs b/sqlx-core/src/query.rs index b3e01dcb5..fa5eaca8a 100644 --- a/sqlx-core/src/query.rs +++ b/sqlx-core/src/query.rs @@ -302,7 +302,7 @@ where /// Make a SQL query. #[inline] -pub fn query<'q, DB>(sql: &'q str) -> Query>::Arguments> +pub fn query<'q, DB>(sql: &'q str) -> Query<'q, DB, >::Arguments> where DB: Database, { diff --git a/sqlx-core/src/query_scalar.rs b/sqlx-core/src/query_scalar.rs index 474b3a98f..c843a7bb8 100644 --- a/sqlx-core/src/query_scalar.rs +++ b/sqlx-core/src/query_scalar.rs @@ -133,7 +133,7 @@ where #[inline] pub fn query_scalar<'q, DB, O>( sql: &'q str, -) -> QueryScalar>::Arguments> +) -> QueryScalar<'q, DB, O, >::Arguments> where DB: Database, (O,): for<'r> FromRow<'r, DB::Row>, @@ -146,7 +146,7 @@ where /// Make a SQL query, with the given arguments, that is mapped to a single concrete type /// using [`FromRow`](crate::row::FromRow). #[inline] -pub fn query_scalar_with<'q, DB, O, A>(sql: &'q str, arguments: A) -> QueryScalar +pub fn query_scalar_with<'q, DB, O, A>(sql: &'q str, arguments: A) -> QueryScalar<'q, DB, O, A> where DB: Database, A: IntoArguments<'q, DB>, diff --git a/sqlx-core/src/row.rs b/sqlx-core/src/row.rs index 31b4f037c..f9a60b172 100644 --- a/sqlx-core/src/row.rs +++ b/sqlx-core/src/row.rs @@ -195,7 +195,10 @@ pub trait Row: private_row::Sealed + Unpin + Send + Sync + 'static { /// [`ColumnNotFound`]: crate::Error::ColumnNotFound /// [`ColumnIndexOutOfBounds`]: crate::Error::ColumnIndexOutOfBounds /// - fn try_get_raw(&self, index: I) -> Result<::ValueRef, Error> + fn try_get_raw( + &self, + index: I, + ) -> Result<>::ValueRef, Error> where I: ColumnIndex; } diff --git a/sqlx-core/src/transaction.rs b/sqlx-core/src/transaction.rs index 27879ffb0..ed5fe0627 100644 --- a/sqlx-core/src/transaction.rs +++ b/sqlx-core/src/transaction.rs @@ -21,19 +21,19 @@ pub trait TransactionManager { fn begin( conn: &mut ::Connection, depth: usize, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<(), Error>>; /// Commit the active transaction or release the most recent savepoint. fn commit( conn: &mut ::Connection, depth: usize, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<(), Error>>; /// Abort the active transaction or restore from the most recent savepoint. fn rollback( conn: &mut ::Connection, depth: usize, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<(), Error>>; /// Starts to abort the active transaction or restore from the most recent snapshot. fn start_rollback(conn: &mut ::Connection, depth: usize); @@ -116,7 +116,7 @@ where } #[doc(hidden)] - fn flush(&mut self) -> BoxFuture> { + fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> { self.get_mut().flush() }