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:
Austin Bonander
2025-06-01 21:09:55 -07:00
committed by GitHub
parent bab1b022bd
commit 90797200ee
94 changed files with 213 additions and 1265 deletions

View File

@@ -362,7 +362,7 @@ impl<'lock, C: AsMut<PgConnection>> PgAdvisoryLockGuard<'lock, C> {
}
}
impl<'lock, C: AsMut<PgConnection> + AsRef<PgConnection>> Deref for PgAdvisoryLockGuard<'lock, C> {
impl<C: AsMut<PgConnection> + AsRef<PgConnection>> Deref for PgAdvisoryLockGuard<'_, C> {
type Target = PgConnection;
fn deref(&self) -> &Self::Target {
@@ -376,16 +376,14 @@ impl<'lock, C: AsMut<PgConnection> + AsRef<PgConnection>> Deref for PgAdvisoryLo
/// However, replacing the connection with a different one using, e.g. [`std::mem::replace()`]
/// is a logic error and will cause a warning to be logged by the PostgreSQL server when this
/// guard attempts to release the lock.
impl<'lock, C: AsMut<PgConnection> + AsRef<PgConnection>> DerefMut
for PgAdvisoryLockGuard<'lock, C>
{
impl<C: AsMut<PgConnection> + AsRef<PgConnection>> DerefMut for PgAdvisoryLockGuard<'_, C> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.conn.as_mut().expect(NONE_ERR).as_mut()
}
}
impl<'lock, C: AsMut<PgConnection> + AsRef<PgConnection>> AsRef<PgConnection>
for PgAdvisoryLockGuard<'lock, C>
impl<C: AsMut<PgConnection> + AsRef<PgConnection>> AsRef<PgConnection>
for PgAdvisoryLockGuard<'_, C>
{
fn as_ref(&self) -> &PgConnection {
self.conn.as_ref().expect(NONE_ERR).as_ref()
@@ -398,7 +396,7 @@ impl<'lock, C: AsMut<PgConnection> + AsRef<PgConnection>> AsRef<PgConnection>
/// However, replacing the connection with a different one using, e.g. [`std::mem::replace()`]
/// is a logic error and will cause a warning to be logged by the PostgreSQL server when this
/// guard attempts to release the lock.
impl<'lock, C: AsMut<PgConnection>> AsMut<PgConnection> for PgAdvisoryLockGuard<'lock, C> {
impl<C: AsMut<PgConnection>> AsMut<PgConnection> for PgAdvisoryLockGuard<'_, C> {
fn as_mut(&mut self) -> &mut PgConnection {
self.conn.as_mut().expect(NONE_ERR).as_mut()
}
@@ -407,7 +405,7 @@ impl<'lock, C: AsMut<PgConnection>> AsMut<PgConnection> for PgAdvisoryLockGuard<
/// Queues a `pg_advisory_unlock()` call on the wrapped connection which will be flushed
/// to the server the next time it is used, or when it is returned to [`PgPool`][crate::PgPool]
/// in the case of [`PoolConnection<Postgres>`][crate::pool::PoolConnection].
impl<'lock, C: AsMut<PgConnection>> Drop for PgAdvisoryLockGuard<'lock, C> {
impl<C: AsMut<PgConnection>> Drop for PgAdvisoryLockGuard<'_, C> {
fn drop(&mut self) {
if let Some(mut conn) = self.conn.take() {
// Queue a simple query message to execute next time the connection is used.

View File

@@ -165,7 +165,7 @@ impl PgConnection {
self.inner.pending_ready_for_query_count += 1;
}
async fn get_or_prepare<'a>(
async fn get_or_prepare(
&mut self,
sql: &str,
parameters: &[PgTypeInfo],

View File

@@ -7,7 +7,7 @@ use crate::{PgConnectOptions, PgSslMode};
pub struct MaybeUpgradeTls<'a>(pub &'a PgConnectOptions);
impl<'a> WithSocket for MaybeUpgradeTls<'a> {
impl WithSocket for MaybeUpgradeTls<'_> {
type Output = crate::Result<Box<dyn Socket>>;
async fn with_socket<S: Socket>(self, socket: S) -> Self::Output {

View File

@@ -506,12 +506,12 @@ fn build_listen_all_query(channels: impl IntoIterator<Item = impl AsRef<str>>) -
#[test]
fn test_build_listen_all_query_with_single_channel() {
let output = build_listen_all_query(&["test"]);
let output = build_listen_all_query(["test"]);
assert_eq!(output.as_str(), r#"LISTEN "test";"#);
}
#[test]
fn test_build_listen_all_query_with_multiple_channels() {
let output = build_listen_all_query(&["channel.0", "channel.1"]);
let output = build_listen_all_query(["channel.0", "channel.1"]);
assert_eq!(output.as_str(), r#"LISTEN "channel.0";LISTEN "channel.1";"#);
}

View File

@@ -195,7 +195,7 @@ struct Fields<'a> {
offset: usize,
}
impl<'a> Iterator for Fields<'a> {
impl Iterator for Fields<'_> {
type Item = (u8, Range<usize>);
fn next(&mut self) -> Option<Self::Item> {

View File

@@ -336,7 +336,7 @@ fn built_url_can_be_parsed() {
let url = "postgres://username:p@ssw0rd@hostname:5432/database";
let opts = PgConnectOptions::from_str(url).unwrap();
let parsed = PgConnectOptions::from_str(&opts.build_url().to_string());
let parsed = PgConnectOptions::from_str(opts.build_url().as_ref());
assert!(parsed.is_ok());
}

View File

@@ -213,7 +213,8 @@ fn sign_to_pg(sign: Sign) -> PgNumericSign {
}
#[cfg(test)]
mod bigdecimal_to_pgnumeric {
#[allow(clippy::zero_prefixed_literal)] // Used for clarity
mod tests {
use super::{BigDecimal, PgNumeric, PgNumericSign};
use std::convert::TryFrom;

View File

@@ -55,7 +55,7 @@ impl Decode<'_, Postgres> for BitVec {
let len = usize::try_from(len).map_err(|_| format!("invalid VARBIT len: {len}"))?;
// The smallest amount of data we can read is one byte
let bytes_len = (len + 7) / 8;
let bytes_len = len.div_ceil(8);
if bytes.remaining() != bytes_len {
Err(io::Error::new(

View File

@@ -71,7 +71,7 @@ impl<'r> Decode<'r, Postgres> for PgCube {
}
}
impl<'q> Encode<'q, Postgres> for PgCube {
impl Encode<'_, Postgres> for PgCube {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("cube"))
}

View File

@@ -56,7 +56,7 @@ impl<'r> Decode<'r, Postgres> for PgBox {
}
}
impl<'q> Encode<'q, Postgres> for PgBox {
impl Encode<'_, Postgres> for PgBox {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("box"))
}

View File

@@ -54,7 +54,7 @@ impl<'r> Decode<'r, Postgres> for PgCircle {
}
}
impl<'q> Encode<'q, Postgres> for PgCircle {
impl Encode<'_, Postgres> for PgCircle {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("circle"))
}

View File

@@ -47,7 +47,7 @@ impl<'r> Decode<'r, Postgres> for PgLine {
}
}
impl<'q> Encode<'q, Postgres> for PgLine {
impl Encode<'_, Postgres> for PgLine {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("line"))
}

View File

@@ -57,7 +57,7 @@ impl<'r> Decode<'r, Postgres> for PgLSeg {
}
}
impl<'q> Encode<'q, Postgres> for PgLSeg {
impl Encode<'_, Postgres> for PgLSeg {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("lseg"))
}

View File

@@ -64,7 +64,7 @@ impl<'r> Decode<'r, Postgres> for PgPath {
}
}
impl<'q> Encode<'q, Postgres> for PgPath {
impl Encode<'_, Postgres> for PgPath {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("path"))
}

View File

@@ -50,7 +50,7 @@ impl<'r> Decode<'r, Postgres> for PgPoint {
}
}
impl<'q> Encode<'q, Postgres> for PgPoint {
impl Encode<'_, Postgres> for PgPoint {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("point"))
}

View File

@@ -63,7 +63,7 @@ impl<'r> Decode<'r, Postgres> for PgPolygon {
}
}
impl<'q> Encode<'q, Postgres> for PgPolygon {
impl Encode<'_, Postgres> for PgPolygon {
fn produces(&self) -> Option<PgTypeInfo> {
Some(PgTypeInfo::with_name("polygon"))
}

View File

@@ -231,7 +231,7 @@ fn test_encode_interval() {
microseconds: 0,
};
assert!(matches!(
Encode::<Postgres>::encode(&interval, &mut buf),
Encode::<Postgres>::encode(interval, &mut buf),
Ok(IsNull::No)
));
assert_eq!(&**buf, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -243,7 +243,7 @@ fn test_encode_interval() {
microseconds: 1_000,
};
assert!(matches!(
Encode::<Postgres>::encode(&interval, &mut buf),
Encode::<Postgres>::encode(interval, &mut buf),
Ok(IsNull::No)
));
assert_eq!(&**buf, [0, 0, 0, 0, 0, 0, 3, 232, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -255,7 +255,7 @@ fn test_encode_interval() {
microseconds: 1_000_000,
};
assert!(matches!(
Encode::<Postgres>::encode(&interval, &mut buf),
Encode::<Postgres>::encode(interval, &mut buf),
Ok(IsNull::No)
));
assert_eq!(&**buf, [0, 0, 0, 0, 0, 15, 66, 64, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -267,7 +267,7 @@ fn test_encode_interval() {
microseconds: 3_600_000_000,
};
assert!(matches!(
Encode::<Postgres>::encode(&interval, &mut buf),
Encode::<Postgres>::encode(interval, &mut buf),
Ok(IsNull::No)
));
assert_eq!(
@@ -282,7 +282,7 @@ fn test_encode_interval() {
microseconds: 0,
};
assert!(matches!(
Encode::<Postgres>::encode(&interval, &mut buf),
Encode::<Postgres>::encode(interval, &mut buf),
Ok(IsNull::No)
));
assert_eq!(&**buf, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]);
@@ -294,7 +294,7 @@ fn test_encode_interval() {
microseconds: 0,
};
assert!(matches!(
Encode::<Postgres>::encode(&interval, &mut buf),
Encode::<Postgres>::encode(interval, &mut buf),
Ok(IsNull::No)
));
assert_eq!(&**buf, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);

View File

@@ -54,7 +54,7 @@ impl PgHasArrayType for JsonRawValue {
}
}
impl<'q, T> Encode<'q, Postgres> for Json<T>
impl<T> Encode<'_, Postgres> for Json<T>
where
T: Serialize,
{

View File

@@ -188,6 +188,7 @@ impl Decode<'_, Postgres> for Decimal {
}
#[cfg(test)]
#[allow(clippy::zero_prefixed_literal)] // Used for clarity
mod tests {
use super::{Decimal, PgNumeric, PgNumericSign};
use std::convert::TryFrom;
@@ -205,7 +206,7 @@ mod tests {
fn one() {
let one: Decimal = "1".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&one).unwrap(),
PgNumeric::from(&one),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -219,7 +220,7 @@ mod tests {
fn ten() {
let ten: Decimal = "10".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&ten).unwrap(),
PgNumeric::from(&ten),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -233,7 +234,7 @@ mod tests {
fn one_hundred() {
let one_hundred: Decimal = "100".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&one_hundred).unwrap(),
PgNumeric::from(&one_hundred),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -248,7 +249,7 @@ mod tests {
// Decimal doesn't normalize here
let ten_thousand: Decimal = "10000".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&ten_thousand).unwrap(),
PgNumeric::from(&ten_thousand),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -262,7 +263,7 @@ mod tests {
fn two_digits() {
let two_digits: Decimal = "12345".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&two_digits).unwrap(),
PgNumeric::from(&two_digits),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -276,7 +277,7 @@ mod tests {
fn one_tenth() {
let one_tenth: Decimal = "0.1".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&one_tenth).unwrap(),
PgNumeric::from(&one_tenth),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 1,
@@ -290,7 +291,7 @@ mod tests {
fn decimal_1() {
let decimal: Decimal = "1.2345".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&decimal).unwrap(),
PgNumeric::from(&decimal),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 4,
@@ -304,7 +305,7 @@ mod tests {
fn decimal_2() {
let decimal: Decimal = "0.12345".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&decimal).unwrap(),
PgNumeric::from(&decimal),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 5,
@@ -318,7 +319,7 @@ mod tests {
fn decimal_3() {
let decimal: Decimal = "0.01234".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&decimal).unwrap(),
PgNumeric::from(&decimal),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 5,
@@ -337,7 +338,7 @@ mod tests {
weight: 1,
digits: vec![1, 2345, 6789],
};
assert_eq!(PgNumeric::try_from(&decimal).unwrap(), expected_numeric);
assert_eq!(PgNumeric::from(&decimal), expected_numeric);
let actual_decimal = Decimal::try_from(expected_numeric).unwrap();
assert_eq!(actual_decimal, decimal);
@@ -354,10 +355,7 @@ mod tests {
weight: -2,
digits: vec![1234],
};
assert_eq!(
PgNumeric::try_from(&one_digit_decimal).unwrap(),
expected_numeric
);
assert_eq!(PgNumeric::from(&one_digit_decimal), expected_numeric);
let actual_decimal = Decimal::try_from(expected_numeric).unwrap();
assert_eq!(actual_decimal, one_digit_decimal);
@@ -373,10 +371,7 @@ mod tests {
weight: 7,
digits: vec![7, 9228, 1625, 1426, 4337, 5935, 4395, 0335],
};
assert_eq!(
PgNumeric::try_from(&Decimal::MAX).unwrap(),
expected_numeric
);
assert_eq!(PgNumeric::from(&Decimal::MAX), expected_numeric);
let actual_decimal = Decimal::try_from(expected_numeric).unwrap();
assert_eq!(actual_decimal, Decimal::MAX);
@@ -399,10 +394,7 @@ mod tests {
weight: 0,
digits: vec![7, 9228, 1625, 1426, 4337, 5935, 4395, 0335],
};
assert_eq!(
PgNumeric::try_from(&max_value_max_scale).unwrap(),
expected_numeric
);
assert_eq!(PgNumeric::from(&max_value_max_scale), expected_numeric);
let actual_decimal = Decimal::try_from(expected_numeric).unwrap();
assert_eq!(actual_decimal, max_value_max_scale);
@@ -418,7 +410,7 @@ mod tests {
// This is a regression test for https://github.com/launchbadge/sqlx/issues/423
let four_digit: Decimal = "1234".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&four_digit).unwrap(),
PgNumeric::from(&four_digit),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -433,7 +425,7 @@ mod tests {
// This is a regression test for https://github.com/launchbadge/sqlx/issues/423
let negative_four_digit: Decimal = "-1234".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&negative_four_digit).unwrap(),
PgNumeric::from(&negative_four_digit),
PgNumeric::Number {
sign: PgNumericSign::Negative,
scale: 0,
@@ -448,7 +440,7 @@ mod tests {
// This is a regression test for https://github.com/launchbadge/sqlx/issues/423
let eight_digit: Decimal = "12345678".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&eight_digit).unwrap(),
PgNumeric::from(&eight_digit),
PgNumeric::Number {
sign: PgNumericSign::Positive,
scale: 0,
@@ -463,7 +455,7 @@ mod tests {
// This is a regression test for https://github.com/launchbadge/sqlx/issues/423
let negative_eight_digit: Decimal = "-12345678".parse().unwrap();
assert_eq!(
PgNumeric::try_from(&negative_eight_digit).unwrap(),
PgNumeric::from(&negative_eight_digit),
PgNumeric::Number {
sign: PgNumericSign::Negative,
scale: 0,
@@ -483,7 +475,7 @@ mod tests {
weight: 0,
digits: vec![100],
};
assert_eq!(PgNumeric::try_from(&one_hundred).unwrap(), expected_numeric);
assert_eq!(PgNumeric::from(&one_hundred), expected_numeric);
let actual_decimal = Decimal::try_from(expected_numeric).unwrap();
assert_eq!(actual_decimal, one_hundred);

View File

@@ -18,7 +18,7 @@ impl<T> Type<Postgres> for Text<T> {
}
}
impl<'q, T> Encode<'q, Postgres> for Text<T>
impl<T> Encode<'_, Postgres> for Text<T>
where
T: Display,
{