Skip to content

Commit 8b44892

Browse files
committed
fix newly introduced clippy lints
1 parent a7dac54 commit 8b44892

File tree

17 files changed

+45
-45
lines changed

17 files changed

+45
-45
lines changed

postgres-protocol/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ macro_rules! from_usize {
6767
impl FromUsize for $t {
6868
#[inline]
6969
fn from_usize(x: usize) -> io::Result<$t> {
70-
if x > <$t>::max_value() as usize {
70+
if x > <$t>::MAX as usize {
7171
Err(io::Error::new(
7272
io::ErrorKind::InvalidInput,
7373
"value too large to transmit",

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

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

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

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

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

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

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-protocol/src/types/test.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ fn ltree_str() {
174174
let mut query = vec![1u8];
175175
query.extend_from_slice("A.B.C".as_bytes());
176176

177-
assert!(matches!(ltree_from_sql(query.as_slice()), Ok(_)))
177+
assert!(ltree_from_sql(query.as_slice()).is_ok())
178178
}
179179

180180
#[test]
181181
fn ltree_wrong_version() {
182182
let mut query = vec![2u8];
183183
query.extend_from_slice("A.B.C".as_bytes());
184184

185-
assert!(matches!(ltree_from_sql(query.as_slice()), Err(_)))
185+
assert!(ltree_from_sql(query.as_slice()).is_err())
186186
}
187187

188188
#[test]
@@ -202,15 +202,15 @@ fn lquery_str() {
202202
let mut query = vec![1u8];
203203
query.extend_from_slice("A.B.C".as_bytes());
204204

205-
assert!(matches!(lquery_from_sql(query.as_slice()), Ok(_)))
205+
assert!(lquery_from_sql(query.as_slice()).is_ok())
206206
}
207207

208208
#[test]
209209
fn lquery_wrong_version() {
210210
let mut query = vec![2u8];
211211
query.extend_from_slice("A.B.C".as_bytes());
212212

213-
assert!(matches!(lquery_from_sql(query.as_slice()), Err(_)))
213+
assert!(lquery_from_sql(query.as_slice()).is_err())
214214
}
215215

216216
#[test]
@@ -230,13 +230,13 @@ fn ltxtquery_str() {
230230
let mut query = vec![1u8];
231231
query.extend_from_slice("a & b*".as_bytes());
232232

233-
assert!(matches!(ltree_from_sql(query.as_slice()), Ok(_)))
233+
assert!(ltree_from_sql(query.as_slice()).is_ok())
234234
}
235235

236236
#[test]
237237
fn ltxtquery_wrong_version() {
238238
let mut query = vec![2u8];
239239
query.extend_from_slice("a & b*".as_bytes());
240240

241-
assert!(matches!(ltree_from_sql(query.as_slice()), Err(_)))
241+
assert!(ltree_from_sql(query.as_slice()).is_err())
242242
}

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ pub enum Format {
901901
Binary,
902902
}
903903

904-
impl<'a, T> ToSql for &'a T
904+
impl<T> ToSql for &T
905905
where
906906
T: ToSql,
907907
{
@@ -950,7 +950,7 @@ impl<T: ToSql> ToSql for Option<T> {
950950
to_sql_checked!();
951951
}
952952

953-
impl<'a, T: ToSql> ToSql for &'a [T] {
953+
impl<T: ToSql> ToSql for &[T] {
954954
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
955955
let member_type = match *ty.kind() {
956956
Kind::Array(ref member) => member,
@@ -991,7 +991,7 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
991991
to_sql_checked!();
992992
}
993993

994-
impl<'a> ToSql for &'a [u8] {
994+
impl ToSql for &[u8] {
995995
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
996996
types::bytea_to_sql(self, w);
997997
Ok(IsNull::No)
@@ -1051,7 +1051,7 @@ impl<T: ToSql> ToSql for Box<[T]> {
10511051
to_sql_checked!();
10521052
}
10531053

1054-
impl<'a> ToSql for Cow<'a, [u8]> {
1054+
impl ToSql for Cow<'_, [u8]> {
10551055
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10561056
<&[u8] as ToSql>::to_sql(&self.as_ref(), ty, w)
10571057
}
@@ -1075,7 +1075,7 @@ impl ToSql for Vec<u8> {
10751075
to_sql_checked!();
10761076
}
10771077

1078-
impl<'a> ToSql for &'a str {
1078+
impl ToSql for &str {
10791079
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10801080
match ty.name() {
10811081
"ltree" => types::ltree_to_sql(self, w),
@@ -1096,7 +1096,7 @@ impl<'a> ToSql for &'a str {
10961096
to_sql_checked!();
10971097
}
10981098

1099-
impl<'a> ToSql for Cow<'a, str> {
1099+
impl ToSql for Cow<'_, str> {
11001100
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
11011101
<&str as ToSql>::to_sql(&self.as_ref(), ty, w)
11021102
}
@@ -1215,7 +1215,7 @@ impl ToSql for IpAddr {
12151215
}
12161216

12171217
fn downcast(len: usize) -> Result<i32, Box<dyn Error + Sync + Send>> {
1218-
if len > i32::max_value() as usize {
1218+
if len > i32::MAX as usize {
12191219
Err("value too large to transmit".into())
12201220
} else {
12211221
Ok(len as i32)
@@ -1243,17 +1243,17 @@ impl BorrowToSql for &dyn ToSql {
12431243
}
12441244
}
12451245

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

1248-
impl<'a> BorrowToSql for Box<dyn ToSql + Sync + 'a> {
1248+
impl BorrowToSql for Box<dyn ToSql + Sync + '_> {
12491249
#[inline]
12501250
fn borrow_to_sql(&self) -> &dyn ToSql {
12511251
self.as_ref()
12521252
}
12531253
}
12541254

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

postgres-types/src/special.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use bytes::BytesMut;
22
use postgres_protocol::types;
33
use std::error::Error;
4-
use std::{i32, i64};
54

65
use crate::{FromSql, IsNull, ToSql, Type};
76

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/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl Client {
502502
done: bool,
503503
}
504504

505-
impl<'a> Drop for RollbackIfNotDone<'a> {
505+
impl Drop for RollbackIfNotDone<'_> {
506506
fn drop(&mut self) {
507507
if self.done {
508508
return;

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
@@ -330,7 +330,7 @@ async fn simple_query() {
330330
}
331331
match &messages[2] {
332332
SimpleQueryMessage::Row(row) => {
333-
assert_eq!(row.columns().get(0).map(|c| c.name()), Some("id"));
333+
assert_eq!(row.columns().first().map(|c| c.name()), Some("id"));
334334
assert_eq!(row.columns().get(1).map(|c| c.name()), Some("name"));
335335
assert_eq!(row.get(0), Some("1"));
336336
assert_eq!(row.get(1), Some("steven"));
@@ -339,7 +339,7 @@ async fn simple_query() {
339339
}
340340
match &messages[3] {
341341
SimpleQueryMessage::Row(row) => {
342-
assert_eq!(row.columns().get(0).map(|c| c.name()), Some("id"));
342+
assert_eq!(row.columns().first().map(|c| c.name()), Some("id"));
343343
assert_eq!(row.columns().get(1).map(|c| c.name()), Some("name"));
344344
assert_eq!(row.get(0), Some("2"));
345345
assert_eq!(row.get(1), Some("joe"));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ async fn domain() {
509509
to_sql_checked!();
510510
}
511511

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

0 commit comments

Comments
 (0)