Skip to content

Commit 1f21e79

Browse files
conradludgatearpad-m
authored andcommittedJan 30, 2025·
fix newly introduced clippy lints
1 parent 3c7a7a9 commit 1f21e79

File tree

14 files changed

+119
-48
lines changed

14 files changed

+119
-48
lines changed
 

‎Cargo.lock

+83-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎postgres-protocol/src/message/backend.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ pub struct ColumnFormats<'a> {
591591
remaining: u16,
592592
}
593593

594-
impl<'a> FallibleIterator for ColumnFormats<'a> {
594+
impl FallibleIterator for ColumnFormats<'_> {
595595
type Item = u16;
596596
type Error = io::Error;
597597

@@ -695,7 +695,7 @@ pub struct DataRowRanges<'a> {
695695
remaining: u16,
696696
}
697697

698-
impl<'a> FallibleIterator for DataRowRanges<'a> {
698+
impl FallibleIterator for DataRowRanges<'_> {
699699
type Item = Option<Range<usize>>;
700700
type Error = io::Error;
701701

@@ -783,7 +783,7 @@ pub struct ErrorField<'a> {
783783
value: &'a str,
784784
}
785785

786-
impl<'a> ErrorField<'a> {
786+
impl ErrorField<'_> {
787787
#[inline]
788788
pub fn type_(&self) -> u8 {
789789
self.type_
@@ -849,7 +849,7 @@ pub struct Parameters<'a> {
849849
remaining: u16,
850850
}
851851

852-
impl<'a> FallibleIterator for Parameters<'a> {
852+
impl FallibleIterator for Parameters<'_> {
853853
type Item = Oid;
854854
type Error = io::Error;
855855

‎postgres-protocol/src/types/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl<'a> Array<'a> {
582582
/// An iterator over the dimensions of an array.
583583
pub struct ArrayDimensions<'a>(&'a [u8]);
584584

585-
impl<'a> FallibleIterator for ArrayDimensions<'a> {
585+
impl FallibleIterator for ArrayDimensions<'_> {
586586
type Item = ArrayDimension;
587587
type Error = StdBox<dyn Error + Sync + Send>;
588588

@@ -950,7 +950,7 @@ pub struct PathPoints<'a> {
950950
buf: &'a [u8],
951951
}
952952

953-
impl<'a> FallibleIterator for PathPoints<'a> {
953+
impl FallibleIterator for PathPoints<'_> {
954954
type Item = Point;
955955
type Error = StdBox<dyn Error + Sync + Send>;
956956

‎postgres-types/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ keywords = ["database", "postgres", "postgresql", "sql"]
1111
categories = ["database"]
1212

1313
[features]
14+
default = ["with-chrono-0_4"]
1415
derive = ["postgres-derive"]
1516
array-impls = ["array-init"]
1617
with-bit-vec-0_6 = ["bit-vec-06"]

‎postgres-types/src/chrono_04.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn base() -> NaiveDateTime {
1414
.unwrap()
1515
}
1616

17-
impl<'a> FromSql<'a> for NaiveDateTime {
17+
impl FromSql<'_> for NaiveDateTime {
1818
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDateTime, Box<dyn Error + Sync + Send>> {
1919
let t = types::timestamp_from_sql(raw)?;
2020
base()
@@ -39,7 +39,7 @@ impl ToSql for NaiveDateTime {
3939
to_sql_checked!();
4040
}
4141

42-
impl<'a> FromSql<'a> for DateTime<Utc> {
42+
impl FromSql<'_> for DateTime<Utc> {
4343
fn from_sql(type_: &Type, raw: &[u8]) -> Result<DateTime<Utc>, Box<dyn Error + Sync + Send>> {
4444
let naive = NaiveDateTime::from_sql(type_, raw)?;
4545
Ok(Utc.from_utc_datetime(&naive))
@@ -61,7 +61,7 @@ impl ToSql for DateTime<Utc> {
6161
to_sql_checked!();
6262
}
6363

64-
impl<'a> FromSql<'a> for DateTime<Local> {
64+
impl FromSql<'_> for DateTime<Local> {
6565
fn from_sql(type_: &Type, raw: &[u8]) -> Result<DateTime<Local>, Box<dyn Error + Sync + Send>> {
6666
let utc = DateTime::<Utc>::from_sql(type_, raw)?;
6767
Ok(utc.with_timezone(&Local))
@@ -83,7 +83,7 @@ impl ToSql for DateTime<Local> {
8383
to_sql_checked!();
8484
}
8585

86-
impl<'a> FromSql<'a> for DateTime<FixedOffset> {
86+
impl FromSql<'_> for DateTime<FixedOffset> {
8787
fn from_sql(
8888
type_: &Type,
8989
raw: &[u8],
@@ -108,7 +108,7 @@ impl ToSql for DateTime<FixedOffset> {
108108
to_sql_checked!();
109109
}
110110

111-
impl<'a> FromSql<'a> for NaiveDate {
111+
impl FromSql<'_> for NaiveDate {
112112
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
113113
let jd = types::date_from_sql(raw)?;
114114
base()
@@ -123,7 +123,7 @@ impl<'a> FromSql<'a> for NaiveDate {
123123
impl ToSql for NaiveDate {
124124
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
125125
let jd = self.signed_duration_since(base().date()).num_days();
126-
if jd > i64::from(i32::max_value()) || jd < i64::from(i32::min_value()) {
126+
if jd > i64::from(i32::MAX) || jd < i64::from(i32::MIN) {
127127
return Err("value too large to transmit".into());
128128
}
129129

@@ -135,7 +135,7 @@ impl ToSql for NaiveDate {
135135
to_sql_checked!();
136136
}
137137

138-
impl<'a> FromSql<'a> for NaiveTime {
138+
impl FromSql<'_> for NaiveTime {
139139
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveTime, Box<dyn Error + Sync + Send>> {
140140
let usec = types::time_from_sql(raw)?;
141141
Ok(NaiveTime::from_hms_opt(0, 0, 0).unwrap() + Duration::microseconds(usec))

‎postgres-types/src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ pub enum Format {
908908
Binary,
909909
}
910910

911-
impl<'a, T> ToSql for &'a T
911+
impl<T> ToSql for &T
912912
where
913913
T: ToSql,
914914
{
@@ -957,7 +957,7 @@ impl<T: ToSql> ToSql for Option<T> {
957957
to_sql_checked!();
958958
}
959959

960-
impl<'a, T: ToSql> ToSql for &'a [T] {
960+
impl<T: ToSql> ToSql for &[T] {
961961
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
962962
let member_type = match *ty.kind() {
963963
Kind::Array(ref member) => member,
@@ -998,7 +998,7 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
998998
to_sql_checked!();
999999
}
10001000

1001-
impl<'a> ToSql for &'a [u8] {
1001+
impl ToSql for &[u8] {
10021002
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10031003
types::bytea_to_sql(self, w);
10041004
Ok(IsNull::No)
@@ -1058,7 +1058,7 @@ impl<T: ToSql> ToSql for Box<[T]> {
10581058
to_sql_checked!();
10591059
}
10601060

1061-
impl<'a> ToSql for Cow<'a, [u8]> {
1061+
impl ToSql for Cow<'_, [u8]> {
10621062
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10631063
<&[u8] as ToSql>::to_sql(&self.as_ref(), ty, w)
10641064
}
@@ -1082,7 +1082,7 @@ impl ToSql for Vec<u8> {
10821082
to_sql_checked!();
10831083
}
10841084

1085-
impl<'a> ToSql for &'a str {
1085+
impl ToSql for &str {
10861086
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10871087
match ty.name() {
10881088
"ltree" => types::ltree_to_sql(self, w),
@@ -1103,7 +1103,7 @@ impl<'a> ToSql for &'a str {
11031103
to_sql_checked!();
11041104
}
11051105

1106-
impl<'a> ToSql for Cow<'a, str> {
1106+
impl ToSql for Cow<'_, str> {
11071107
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
11081108
<&str as ToSql>::to_sql(&self.as_ref(), ty, w)
11091109
}
@@ -1250,17 +1250,17 @@ impl BorrowToSql for &dyn ToSql {
12501250
}
12511251
}
12521252

1253-
impl<'a> sealed::Sealed for Box<dyn ToSql + Sync + 'a> {}
1253+
impl sealed::Sealed for Box<dyn ToSql + Sync + '_> {}
12541254

1255-
impl<'a> BorrowToSql for Box<dyn ToSql + Sync + 'a> {
1255+
impl BorrowToSql for Box<dyn ToSql + Sync + '_> {
12561256
#[inline]
12571257
fn borrow_to_sql(&self) -> &dyn ToSql {
12581258
self.as_ref()
12591259
}
12601260
}
12611261

1262-
impl<'a> sealed::Sealed for Box<dyn ToSql + Sync + Send + 'a> {}
1263-
impl<'a> BorrowToSql for Box<dyn ToSql + Sync + Send + 'a> {
1262+
impl sealed::Sealed for Box<dyn ToSql + Sync + Send + '_> {}
1263+
impl BorrowToSql for Box<dyn ToSql + Sync + Send + '_> {
12641264
#[inline]
12651265
fn borrow_to_sql(&self) -> &dyn ToSql {
12661266
self.as_ref()

‎postgres/src/notifications.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub struct Iter<'a> {
7777
connection: ConnectionRef<'a>,
7878
}
7979

80-
impl<'a> FallibleIterator for Iter<'a> {
80+
impl FallibleIterator for Iter<'_> {
8181
type Item = Notification;
8282
type Error = Error;
8383

@@ -100,7 +100,7 @@ pub struct BlockingIter<'a> {
100100
connection: ConnectionRef<'a>,
101101
}
102102

103-
impl<'a> FallibleIterator for BlockingIter<'a> {
103+
impl FallibleIterator for BlockingIter<'_> {
104104
type Item = Notification;
105105
type Error = Error;
106106

@@ -129,7 +129,7 @@ pub struct TimeoutIter<'a> {
129129
timeout: Duration,
130130
}
131131

132-
impl<'a> FallibleIterator for TimeoutIter<'a> {
132+
impl FallibleIterator for TimeoutIter<'_> {
133133
type Item = Notification;
134134
type Error = Error;
135135

‎postgres/src/transaction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Transaction<'a> {
1212
transaction: Option<tokio_postgres::Transaction<'a>>,
1313
}
1414

15-
impl<'a> Drop for Transaction<'a> {
15+
impl Drop for Transaction<'_> {
1616
fn drop(&mut self) {
1717
if let Some(transaction) = self.transaction.take() {
1818
let _ = self.connection.block_on(transaction.rollback());

‎tokio-postgres/src/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::task::{Context, Poll};
1616

1717
struct BorrowToSqlParamsDebug<'a, T>(&'a [T]);
1818

19-
impl<'a, T> fmt::Debug for BorrowToSqlParamsDebug<'a, T>
19+
impl<T> fmt::Debug for BorrowToSqlParamsDebug<'_, T>
2020
where
2121
T: BorrowToSql,
2222
{

‎tokio-postgres/src/row.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ impl RowIndex for str {
7979
}
8080
}
8181

82-
impl<'a, T> Sealed for &'a T where T: ?Sized + Sealed {}
82+
impl<T> Sealed for &T where T: ?Sized + Sealed {}
8383

84-
impl<'a, T> RowIndex for &'a T
84+
impl<T> RowIndex for &T
8585
where
8686
T: ?Sized + RowIndex,
8787
{

‎tokio-postgres/src/to_statement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod private {
1111
Query(&'a str),
1212
}
1313

14-
impl<'a> ToStatementType<'a> {
14+
impl ToStatementType<'_> {
1515
pub async fn into_statement(self, client: &Client) -> Result<Statement, Error> {
1616
match self {
1717
ToStatementType::Statement(s) => Ok(s.clone()),

‎tokio-postgres/src/transaction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct Savepoint {
3333
depth: u32,
3434
}
3535

36-
impl<'a> Drop for Transaction<'a> {
36+
impl Drop for Transaction<'_> {
3737
fn drop(&mut self) {
3838
if self.done {
3939
return;

‎tokio-postgres/tests/test/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ async fn simple_query() {
331331
}
332332
match &messages[2] {
333333
SimpleQueryMessage::Row(row) => {
334-
assert_eq!(row.columns().get(0).map(|c| c.name()), Some("id"));
334+
assert_eq!(row.columns().first().map(|c| c.name()), Some("id"));
335335
assert_eq!(row.columns().get(1).map(|c| c.name()), Some("name"));
336336
assert_eq!(row.get(0), Some("1"));
337337
assert_eq!(row.get(1), Some("steven"));
@@ -340,7 +340,7 @@ async fn simple_query() {
340340
}
341341
match &messages[3] {
342342
SimpleQueryMessage::Row(row) => {
343-
assert_eq!(row.columns().get(0).map(|c| c.name()), Some("id"));
343+
assert_eq!(row.columns().first().map(|c| c.name()), Some("id"));
344344
assert_eq!(row.columns().get(1).map(|c| c.name()), Some("name"));
345345
assert_eq!(row.get(0), Some("2"));
346346
assert_eq!(row.get(1), Some("joe"));

‎tokio-postgres/tests/test/types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ async fn domain() {
507507
to_sql_checked!();
508508
}
509509

510-
impl<'a> FromSql<'a> for SessionId {
510+
impl FromSql<'_> for SessionId {
511511
fn from_sql(ty: &Type, raw: &[u8]) -> result::Result<Self, Box<dyn Error + Sync + Send>> {
512512
Vec::<u8>::from_sql(ty, raw).map(SessionId)
513513
}

0 commit comments

Comments
 (0)
Please sign in to comment.