Skip to content

Commit

Permalink
fix newly introduced clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate authored and arpad-m committed Jan 30, 2025
1 parent 3c7a7a9 commit 1f21e79
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 48 deletions.
96 changes: 83 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions postgres-protocol/src/message/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ pub struct ColumnFormats<'a> {
remaining: u16,
}

impl<'a> FallibleIterator for ColumnFormats<'a> {
impl FallibleIterator for ColumnFormats<'_> {
type Item = u16;
type Error = io::Error;

Expand Down Expand Up @@ -695,7 +695,7 @@ pub struct DataRowRanges<'a> {
remaining: u16,
}

impl<'a> FallibleIterator for DataRowRanges<'a> {
impl FallibleIterator for DataRowRanges<'_> {
type Item = Option<Range<usize>>;
type Error = io::Error;

Expand Down Expand Up @@ -783,7 +783,7 @@ pub struct ErrorField<'a> {
value: &'a str,
}

impl<'a> ErrorField<'a> {
impl ErrorField<'_> {
#[inline]
pub fn type_(&self) -> u8 {
self.type_
Expand Down Expand Up @@ -849,7 +849,7 @@ pub struct Parameters<'a> {
remaining: u16,
}

impl<'a> FallibleIterator for Parameters<'a> {
impl FallibleIterator for Parameters<'_> {
type Item = Oid;
type Error = io::Error;

Expand Down
4 changes: 2 additions & 2 deletions postgres-protocol/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<'a> Array<'a> {
/// An iterator over the dimensions of an array.
pub struct ArrayDimensions<'a>(&'a [u8]);

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

Expand Down Expand Up @@ -950,7 +950,7 @@ pub struct PathPoints<'a> {
buf: &'a [u8],
}

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

Expand Down
1 change: 1 addition & 0 deletions postgres-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keywords = ["database", "postgres", "postgresql", "sql"]
categories = ["database"]

[features]
default = ["with-chrono-0_4"]
derive = ["postgres-derive"]
array-impls = ["array-init"]
with-bit-vec-0_6 = ["bit-vec-06"]
Expand Down
14 changes: 7 additions & 7 deletions postgres-types/src/chrono_04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn base() -> NaiveDateTime {
.unwrap()
}

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

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

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

impl<'a> FromSql<'a> for DateTime<FixedOffset> {
impl FromSql<'_> for DateTime<FixedOffset> {
fn from_sql(
type_: &Type,
raw: &[u8],
Expand All @@ -108,7 +108,7 @@ impl ToSql for DateTime<FixedOffset> {
to_sql_checked!();
}

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

Expand All @@ -135,7 +135,7 @@ impl ToSql for NaiveDate {
to_sql_checked!();
}

impl<'a> FromSql<'a> for NaiveTime {
impl FromSql<'_> for NaiveTime {
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveTime, Box<dyn Error + Sync + Send>> {
let usec = types::time_from_sql(raw)?;
Ok(NaiveTime::from_hms_opt(0, 0, 0).unwrap() + Duration::microseconds(usec))
Expand Down
20 changes: 10 additions & 10 deletions postgres-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ pub enum Format {
Binary,
}

impl<'a, T> ToSql for &'a T
impl<T> ToSql for &T
where
T: ToSql,
{
Expand Down Expand Up @@ -957,7 +957,7 @@ impl<T: ToSql> ToSql for Option<T> {
to_sql_checked!();
}

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

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

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

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

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

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

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

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

0 comments on commit 1f21e79

Please sign in to comment.