diff --git a/sqlx-core/src/connection.rs b/sqlx-core/src/connection.rs index f946fef2..080a735d 100644 --- a/sqlx-core/src/connection.rs +++ b/sqlx-core/src/connection.rs @@ -19,11 +19,9 @@ pub trait Connection: Executor + Send + 'static { } /// Represents a type that can directly establish a new connection. -pub trait Connect { - type Connection: Connection; - +pub trait Connect: Connection { /// Establish a new database connection. - fn connect(url: T) -> BoxFuture<'static, crate::Result> + fn connect(url: T) -> BoxFuture<'static, crate::Result> where T: TryInto, Self: Sized; diff --git a/sqlx-core/src/mysql/connection.rs b/sqlx-core/src/mysql/connection.rs index efd40585..3fd5b054 100644 --- a/sqlx-core/src/mysql/connection.rs +++ b/sqlx-core/src/mysql/connection.rs @@ -603,8 +603,6 @@ impl MySqlConnection { } impl Connect for MySqlConnection { - type Connection = MySqlConnection; - fn connect(url: T) -> BoxFuture<'static, crate::Result> where T: TryInto, diff --git a/sqlx-core/src/pool/conn.rs b/sqlx-core/src/pool/conn.rs index a84bad21..8e5adc75 100644 --- a/sqlx-core/src/pool/conn.rs +++ b/sqlx-core/src/pool/conn.rs @@ -11,7 +11,7 @@ use super::inner::{DecrementSizeGuard, SharedPool}; /// Will be returned to the pool on-drop. pub struct PoolConnection where - C: Connection + Connect, + C: Connect, { live: Option>, pool: Arc>, @@ -37,7 +37,7 @@ const DEREF_ERR: &str = "(bug) connection already released to pool"; impl Deref for PoolConnection where - C: Connection + Connect, + C: Connect, { type Target = C; @@ -48,7 +48,7 @@ where impl DerefMut for PoolConnection where - C: Connection + Connect, + C: Connect, { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.live.as_mut().expect(DEREF_ERR).raw @@ -57,7 +57,7 @@ where impl Connection for PoolConnection where - C: Connection + Connect, + C: Connect, { /// Detach the connection from the pool and close it nicely. fn close(mut self) -> BoxFuture<'static, crate::Result<()>> { @@ -71,7 +71,7 @@ where /// Returns the connection to the [`Pool`][crate::Pool] it was checked-out from. impl Drop for PoolConnection where - C: Connection + Connect, + C: Connect, { fn drop(&mut self) { if let Some(live) = self.live.take() { @@ -130,7 +130,7 @@ impl<'s, C> Floating<'s, Live> { pub fn attach(self, pool: &Arc>) -> PoolConnection where - C: Connection + Connect, + C: Connect, { let Floating { inner, guard } = self; diff --git a/sqlx-core/src/pool/executor.rs b/sqlx-core/src/pool/executor.rs index ff5bda5e..c84f36f5 100644 --- a/sqlx-core/src/pool/executor.rs +++ b/sqlx-core/src/pool/executor.rs @@ -3,19 +3,13 @@ use std::ops::DerefMut; use futures_core::{future::BoxFuture, stream::BoxStream}; use futures_util::StreamExt; -use crate::{ - connection::{Connect, Connection}, - describe::Describe, - executor::Executor, - pool::Pool, - Database, -}; +use crate::{connection::Connect, describe::Describe, executor::Executor, pool::Pool, Database}; use super::PoolConnection; impl Executor for Pool where - C: Connection + Connect, + C: Connect, { type Database = ::Database; @@ -66,7 +60,7 @@ where impl Executor for &'_ Pool where - C: Connection + Connect, + C: Connect, { type Database = ::Database; @@ -115,7 +109,7 @@ where impl Executor for PoolConnection where - C: Connection + Connect, + C: Connect, { type Database = ::Database; diff --git a/sqlx-core/src/pool/inner.rs b/sqlx-core/src/pool/inner.rs index 2981cbc4..7a6f9a89 100644 --- a/sqlx-core/src/pool/inner.rs +++ b/sqlx-core/src/pool/inner.rs @@ -130,7 +130,7 @@ where impl SharedPool where - C: Connection + Connect, + C: Connect, { pub(super) async fn new_arc(url: &str, options: Options) -> crate::Result> { let mut pool = Self { diff --git a/sqlx-core/src/pool/mod.rs b/sqlx-core/src/pool/mod.rs index 5d89d0c4..373d3de8 100644 --- a/sqlx-core/src/pool/mod.rs +++ b/sqlx-core/src/pool/mod.rs @@ -6,7 +6,7 @@ use std::{ time::{Duration, Instant}, }; -use crate::connection::{Connect, Connection}; +use crate::connection::Connect; use crate::transaction::Transaction; use self::inner::SharedPool; @@ -26,7 +26,7 @@ pub struct Pool(Arc>); impl Pool where - C: Connection + Connect, + C: Connect, { /// Creates a connection pool with the default configuration. /// @@ -127,7 +127,7 @@ impl Clone for Pool { impl fmt::Debug for Pool where - C: Connection + Connect, + C: Connect, { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Pool") @@ -154,7 +154,7 @@ fn assert_pool_traits() { fn assert_send_sync() {} fn assert_clone() {} - fn assert_pool>() { + fn assert_pool() { assert_send_sync::>(); assert_clone::>(); } diff --git a/sqlx-core/src/pool/options.rs b/sqlx-core/src/pool/options.rs index 7687f051..318d5434 100644 --- a/sqlx-core/src/pool/options.rs +++ b/sqlx-core/src/pool/options.rs @@ -1,7 +1,7 @@ use std::{marker::PhantomData, time::Duration}; use super::Pool; -use crate::connection::{Connect, Connection}; +use crate::connection::Connect; /// Builder for [Pool]. pub struct Builder { @@ -102,7 +102,7 @@ impl Builder { /// opened and placed into the pool. pub async fn build(self, url: &str) -> crate::Result> where - C: Connection + Connect, + C: Connect, { Pool::with_options(url, self.options).await } diff --git a/sqlx-core/src/postgres/connection.rs b/sqlx-core/src/postgres/connection.rs index 8392ef53..7c0e3411 100644 --- a/sqlx-core/src/postgres/connection.rs +++ b/sqlx-core/src/postgres/connection.rs @@ -409,8 +409,6 @@ impl PgConnection { } impl Connect for PgConnection { - type Connection = PgConnection; - fn connect(url: T) -> BoxFuture<'static, Result> where T: TryInto,