mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-22 10:04:02 +00:00
groundwork for 0.9.0-alpha.1 (#3821)
* chore: bump version to `0.9.0-alpha.1` * chore: delete unused `sqlx-bench` package * chore: set `rust-version` to 1.85 for all crates * fix: lots of new Clippy warnings * fix: lots more Clippy warnings * fix(cli): add `_sqlite` feature * fix: lots, *lots* more Clippy warnings * fix(core): warning in `tls_rustls` * breaking: delete runtime+TLS combination features * chore: don't re-export unstable `TransactionManager` trait * chore: 0.9.0-alplha.1 CHANGELOG * chore: increase MSRV further to 1.86 * fix: more clippy warnings
This commit is contained in:
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["offline"]
|
||||
|
||||
@@ -32,7 +32,7 @@ impl<'q> Arguments<'q> for AnyArguments<'q> {
|
||||
|
||||
pub struct AnyArgumentBuffer<'q>(#[doc(hidden)] pub Vec<AnyValueKind<'q>>);
|
||||
|
||||
impl<'q> Default for AnyArguments<'q> {
|
||||
impl Default for AnyArguments<'_> {
|
||||
fn default() -> Self {
|
||||
AnyArguments {
|
||||
values: AnyArgumentBuffer(vec![]),
|
||||
|
||||
@@ -63,7 +63,7 @@ impl Row for AnyRow {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'i> ColumnIndex<AnyRow> for &'i str {
|
||||
impl ColumnIndex<AnyRow> for &'_ str {
|
||||
fn index(&self, row: &AnyRow) -> Result<usize, Error> {
|
||||
row.column_names
|
||||
.get(*self)
|
||||
|
||||
@@ -51,7 +51,7 @@ impl<'q> Statement<'q> for AnyStatement<'q> {
|
||||
impl_statement_query!(AnyArguments<'_>);
|
||||
}
|
||||
|
||||
impl<'i> ColumnIndex<AnyStatement<'_>> for &'i str {
|
||||
impl ColumnIndex<AnyStatement<'_>> for &'_ str {
|
||||
fn index(&self, statement: &AnyStatement<'_>) -> Result<usize, Error> {
|
||||
statement
|
||||
.column_names
|
||||
|
||||
@@ -95,7 +95,7 @@ impl<T> Yielder<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Stream for TryAsyncStream<'a, T> {
|
||||
impl<T> Stream for TryAsyncStream<'_, T> {
|
||||
type Item = Result<T, Error>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
|
||||
@@ -9,7 +9,7 @@ pub trait ProtocolEncode<'en, Context = ()> {
|
||||
fn encode_with(&self, buf: &mut Vec<u8>, context: Context) -> Result<(), crate::Error>;
|
||||
}
|
||||
|
||||
impl<'en, C> ProtocolEncode<'en, C> for &'_ [u8] {
|
||||
impl<C> ProtocolEncode<'_, C> for &'_ [u8] {
|
||||
fn encode_with(&self, buf: &mut Vec<u8>, _context: C) -> Result<(), crate::Error> {
|
||||
buf.extend_from_slice(self);
|
||||
Ok(())
|
||||
|
||||
@@ -158,7 +158,7 @@ impl<'q> QueryLogger<'q> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'q> Drop for QueryLogger<'q> {
|
||||
impl Drop for QueryLogger<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.finish();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ pub struct Read<'a, S: ?Sized, B> {
|
||||
buf: &'a mut B,
|
||||
}
|
||||
|
||||
impl<'a, S: ?Sized, B> Future for Read<'a, S, B>
|
||||
impl<S: ?Sized, B> Future for Read<'_, S, B>
|
||||
where
|
||||
S: Socket,
|
||||
B: ReadBuf,
|
||||
@@ -90,7 +90,7 @@ pub struct Write<'a, S: ?Sized> {
|
||||
buf: &'a [u8],
|
||||
}
|
||||
|
||||
impl<'a, S: ?Sized> Future for Write<'a, S>
|
||||
impl<S: ?Sized> Future for Write<'_, S>
|
||||
where
|
||||
S: Socket,
|
||||
{
|
||||
@@ -116,7 +116,7 @@ pub struct Flush<'a, S: ?Sized> {
|
||||
socket: &'a mut S,
|
||||
}
|
||||
|
||||
impl<'a, S: Socket + ?Sized> Future for Flush<'a, S> {
|
||||
impl<S: Socket + ?Sized> Future for Flush<'_, S> {
|
||||
type Output = io::Result<()>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
@@ -128,7 +128,7 @@ pub struct Shutdown<'a, S: ?Sized> {
|
||||
socket: &'a mut S,
|
||||
}
|
||||
|
||||
impl<'a, S: ?Sized> Future for Shutdown<'a, S>
|
||||
impl<S: ?Sized> Future for Shutdown<'_, S>
|
||||
where
|
||||
S: Socket,
|
||||
{
|
||||
|
||||
@@ -137,10 +137,7 @@ where
|
||||
.with_no_client_auth()
|
||||
}
|
||||
} else {
|
||||
#[cfg(any(feature = "_tls-rustls-aws-lc-rs", feature = "_tls-rustls-ring-webpki"))]
|
||||
let mut cert_store = certs_from_webpki();
|
||||
#[cfg(feature = "_tls-rustls-ring-native-roots")]
|
||||
let mut cert_store = certs_from_native_store();
|
||||
let mut cert_store = import_root_certs();
|
||||
|
||||
if let Some(ca) = tls_config.root_cert_path {
|
||||
let data = ca.data().await?;
|
||||
@@ -211,13 +208,13 @@ fn private_key_from_pem(pem: Vec<u8>) -> Result<PrivateKeyDer<'static>, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "_tls-rustls-aws-lc-rs", feature = "_tls-rustls-ring-webpki"))]
|
||||
fn certs_from_webpki() -> RootCertStore {
|
||||
#[cfg(all(feature = "webpki-roots", not(feature = "rustls-native-certs")))]
|
||||
fn import_root_certs() -> RootCertStore {
|
||||
RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.iter().cloned())
|
||||
}
|
||||
|
||||
#[cfg(feature = "_tls-rustls-ring-native-roots")]
|
||||
fn certs_from_native_store() -> RootCertStore {
|
||||
#[cfg(feature = "rustls-native-certs")]
|
||||
fn import_root_certs() -> RootCertStore {
|
||||
let mut root_cert_store = RootCertStore::empty();
|
||||
|
||||
let load_results = rustls_native_certs::load_native_certs();
|
||||
@@ -225,7 +222,7 @@ fn certs_from_native_store() -> RootCertStore {
|
||||
log::warn!("Error loading native certificates: {e:?}");
|
||||
}
|
||||
for cert in load_results.certs {
|
||||
if let Err(e) = root_cert_store.add(cert.into()) {
|
||||
if let Err(e) = root_cert_store.add(cert) {
|
||||
log::warn!("rustls failed to parse native certificate: {e:?}");
|
||||
}
|
||||
}
|
||||
@@ -233,6 +230,12 @@ fn certs_from_native_store() -> RootCertStore {
|
||||
root_cert_store
|
||||
}
|
||||
|
||||
// Not currently used but allows for a "tls-rustls-no-roots" feature.
|
||||
#[cfg(not(any(feature = "rustls-native-certs", feature = "webpki-roots")))]
|
||||
fn import_root_certs() -> RootCertStore {
|
||||
RootCertStore::empty()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct DummyTlsVerifier {
|
||||
provider: Arc<CryptoProvider>,
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::error::Error;
|
||||
use crate::executor::{Execute, Executor};
|
||||
use crate::pool::Pool;
|
||||
|
||||
impl<'p, DB: Database> Executor<'p> for &'_ Pool<DB>
|
||||
impl<DB: Database> Executor<'_> for &'_ Pool<DB>
|
||||
where
|
||||
for<'c> &'c mut DB::Connection: Executor<'c, Database = DB>,
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ impl<DB: Database> PoolInner<DB> {
|
||||
self.on_closed.notify(usize::MAX);
|
||||
}
|
||||
|
||||
pub(super) fn close<'a>(self: &'a Arc<Self>) -> impl Future<Output = ()> + 'a {
|
||||
pub(super) fn close(self: &Arc<Self>) -> impl Future<Output = ()> + '_ {
|
||||
self.mark_closed();
|
||||
|
||||
async move {
|
||||
@@ -124,7 +124,7 @@ impl<DB: Database> PoolInner<DB> {
|
||||
///
|
||||
/// If we steal a permit from the parent but *don't* open a connection,
|
||||
/// it should be returned to the parent.
|
||||
async fn acquire_permit<'a>(self: &'a Arc<Self>) -> Result<AsyncSemaphoreReleaser<'a>, Error> {
|
||||
async fn acquire_permit(self: &Arc<Self>) -> Result<AsyncSemaphoreReleaser<'_>, Error> {
|
||||
let parent = self
|
||||
.parent()
|
||||
// If we're already at the max size, we shouldn't try to steal from the parent.
|
||||
@@ -452,14 +452,14 @@ pub(super) fn is_beyond_max_lifetime<DB: Database>(
|
||||
) -> bool {
|
||||
options
|
||||
.max_lifetime
|
||||
.map_or(false, |max| live.created_at.elapsed() > max)
|
||||
.is_some_and(|max| live.created_at.elapsed() > max)
|
||||
}
|
||||
|
||||
/// Returns `true` if the connection has exceeded `options.idle_timeout` if set, `false` otherwise.
|
||||
fn is_beyond_idle_timeout<DB: Database>(idle: &Idle<DB>, options: &PoolOptions<DB>) -> bool {
|
||||
options
|
||||
.idle_timeout
|
||||
.map_or(false, |timeout| idle.idle_since.elapsed() > timeout)
|
||||
.is_some_and(|timeout| idle.idle_since.elapsed() > timeout)
|
||||
}
|
||||
|
||||
async fn check_idle_conn<DB: Database>(
|
||||
|
||||
@@ -8,7 +8,7 @@ pub enum MaybePoolConnection<'c, DB: Database> {
|
||||
PoolConnection(PoolConnection<DB>),
|
||||
}
|
||||
|
||||
impl<'c, DB: Database> Deref for MaybePoolConnection<'c, DB> {
|
||||
impl<DB: Database> Deref for MaybePoolConnection<'_, DB> {
|
||||
type Target = DB::Connection;
|
||||
|
||||
#[inline]
|
||||
@@ -20,7 +20,7 @@ impl<'c, DB: Database> Deref for MaybePoolConnection<'c, DB> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, DB: Database> DerefMut for MaybePoolConnection<'c, DB> {
|
||||
impl<DB: Database> DerefMut for MaybePoolConnection<'_, DB> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
match self {
|
||||
@@ -30,7 +30,7 @@ impl<'c, DB: Database> DerefMut for MaybePoolConnection<'c, DB> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, DB: Database> From<PoolConnection<DB>> for MaybePoolConnection<'c, DB> {
|
||||
impl<DB: Database> From<PoolConnection<DB>> for MaybePoolConnection<'_, DB> {
|
||||
fn from(v: PoolConnection<DB>) -> Self {
|
||||
MaybePoolConnection::PoolConnection(v)
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ impl<'q, DB: Database> Query<'q, DB, <DB as Database>::Arguments<'q>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'q, DB, A> Query<'q, DB, A>
|
||||
impl<DB, A> Query<'_, DB, A>
|
||||
where
|
||||
DB: Database + HasStatementCache,
|
||||
{
|
||||
@@ -499,7 +499,7 @@ where
|
||||
/// Execute a single SQL query as a prepared statement (explicitly created).
|
||||
pub fn query_statement<'q, DB>(
|
||||
statement: &'q DB::Statement<'q>,
|
||||
) -> Query<'q, DB, <DB as Database>::Arguments<'_>>
|
||||
) -> Query<'q, DB, <DB as Database>::Arguments<'q>>
|
||||
where
|
||||
DB: Database,
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ impl<'q, DB: Database, O> QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'q, DB, O, A> QueryAs<'q, DB, O, A>
|
||||
impl<DB, O, A> QueryAs<'_, DB, O, A>
|
||||
where
|
||||
DB: Database + HasStatementCache,
|
||||
{
|
||||
@@ -386,7 +386,7 @@ where
|
||||
// Make a SQL query from a statement, that is mapped to a concrete type.
|
||||
pub fn query_statement_as<'q, DB, O>(
|
||||
statement: &'q DB::Statement<'q>,
|
||||
) -> QueryAs<'q, DB, O, <DB as Database>::Arguments<'_>>
|
||||
) -> QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>>
|
||||
where
|
||||
DB: Database,
|
||||
O: for<'r> FromRow<'r, DB::Row>,
|
||||
|
||||
@@ -30,7 +30,7 @@ where
|
||||
arguments: Option<<DB as Database>::Arguments<'args>>,
|
||||
}
|
||||
|
||||
impl<'args, DB: Database> Default for QueryBuilder<'args, DB> {
|
||||
impl<DB: Database> Default for QueryBuilder<'_, DB> {
|
||||
fn default() -> Self {
|
||||
QueryBuilder {
|
||||
init_len: 0,
|
||||
@@ -191,7 +191,6 @@ where
|
||||
/// assert!(sql.ends_with("in (?, ?) "));
|
||||
/// # }
|
||||
/// ```
|
||||
|
||||
pub fn separated<'qb, Sep>(&'qb mut self, separator: Sep) -> Separated<'qb, 'args, DB, Sep>
|
||||
where
|
||||
'args: 'qb,
|
||||
|
||||
@@ -54,7 +54,7 @@ impl<'q, DB: Database, O> QueryScalar<'q, DB, O, <DB as Database>::Arguments<'q>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>
|
||||
impl<DB, O, A> QueryScalar<'_, DB, O, A>
|
||||
where
|
||||
DB: Database + HasStatementCache,
|
||||
{
|
||||
@@ -365,7 +365,7 @@ where
|
||||
// Make a SQL query from a statement, that is mapped to a concrete value.
|
||||
pub fn query_statement_scalar<'q, DB, O>(
|
||||
statement: &'q DB::Statement<'q>,
|
||||
) -> QueryScalar<'q, DB, O, <DB as Database>::Arguments<'_>>
|
||||
) -> QueryScalar<'q, DB, O, <DB as Database>::Arguments<'q>>
|
||||
where
|
||||
DB: Database,
|
||||
(O,): for<'r> FromRow<'r, DB::Row>,
|
||||
|
||||
@@ -116,11 +116,11 @@ pub async fn yield_now() {
|
||||
pub fn test_block_on<F: Future>(f: F) -> F::Output {
|
||||
#[cfg(feature = "_rt-tokio")]
|
||||
{
|
||||
return tokio::runtime::Builder::new_current_thread()
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("failed to start Tokio runtime")
|
||||
.block_on(f);
|
||||
.block_on(f)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "_rt-async-std", not(feature = "_rt-tokio")))]
|
||||
|
||||
@@ -11,7 +11,6 @@ use crate::pool::MaybePoolConnection;
|
||||
/// Generic management of database transactions.
|
||||
///
|
||||
/// This trait should not be used, except when implementing [`Connection`].
|
||||
#[doc(hidden)]
|
||||
pub trait TransactionManager {
|
||||
type Database: Database;
|
||||
|
||||
@@ -199,7 +198,7 @@ where
|
||||
// }
|
||||
// }
|
||||
|
||||
impl<'c, DB> Debug for Transaction<'c, DB>
|
||||
impl<DB> Debug for Transaction<'_, DB>
|
||||
where
|
||||
DB: Database,
|
||||
{
|
||||
@@ -209,7 +208,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, DB> Deref for Transaction<'c, DB>
|
||||
impl<DB> Deref for Transaction<'_, DB>
|
||||
where
|
||||
DB: Database,
|
||||
{
|
||||
@@ -221,7 +220,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, DB> DerefMut for Transaction<'c, DB>
|
||||
impl<DB> DerefMut for Transaction<'_, DB>
|
||||
where
|
||||
DB: Database,
|
||||
{
|
||||
@@ -235,13 +234,13 @@ where
|
||||
// `PgAdvisoryLockGuard`.
|
||||
//
|
||||
// See: https://github.com/launchbadge/sqlx/issues/2520
|
||||
impl<'c, DB: Database> AsMut<DB::Connection> for Transaction<'c, DB> {
|
||||
impl<DB: Database> AsMut<DB::Connection> for Transaction<'_, DB> {
|
||||
fn as_mut(&mut self) -> &mut DB::Connection {
|
||||
&mut self.connection
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, 't, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'c, DB> {
|
||||
impl<'t, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'_, DB> {
|
||||
type Database = DB;
|
||||
|
||||
type Connection = &'t mut <DB as Database>::Connection;
|
||||
@@ -257,7 +256,7 @@ impl<'c, 't, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, DB> Drop for Transaction<'c, DB>
|
||||
impl<DB> Drop for Transaction<'_, DB>
|
||||
where
|
||||
DB: Database,
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'v, DB> Debug for FmtValue<'v, DB>
|
||||
impl<DB> Debug for FmtValue<'_, DB>
|
||||
where
|
||||
DB: Database,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user