From 729b885a506de79eb0c4bdcf9c56c1aea501a8ac Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Mon, 16 Dec 2024 06:50:26 -0800 Subject: [PATCH] Clippy lint clean Summary: Fixes all Rust 1.81.0 (current) and Rust 1.83.0 (upcoming in D67041293) rustc/clippy lint issues in rust_foundation (and related) code. Reviewed By: dtolnay Differential Revision: D67262078 fbshipit-source-id: bd8807f76b3f3d68d610b69a0448983b4bf1fe41 --- shed/chrome_trace/src/lib.rs | 1 + shed/fbthrift_ext/adapters/chrono.rs | 11 ++++------- shed/slog_glog_fmt/src/collector_serializer.rs | 2 +- shed/slog_glog_fmt/src/glog_format.rs | 4 ++-- shed/sql/common/mysql.rs | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/shed/chrome_trace/src/lib.rs b/shed/chrome_trace/src/lib.rs index 5fc90714f..3e29692ad 100644 --- a/shed/chrome_trace/src/lib.rs +++ b/shed/chrome_trace/src/lib.rs @@ -468,6 +468,7 @@ mod duration { struct DurationVisitor; + #[allow(clippy::needless_lifetimes)] impl<'de> Visitor<'de> for DurationVisitor { type Value = Duration; diff --git a/shed/fbthrift_ext/adapters/chrono.rs b/shed/fbthrift_ext/adapters/chrono.rs index 74bd4987d..95602985f 100644 --- a/shed/fbthrift_ext/adapters/chrono.rs +++ b/shed/fbthrift_ext/adapters/chrono.rs @@ -10,7 +10,6 @@ //! Adapters that interpret thrift integers as [`chrono::DateTime`]s. use chrono::DateTime; -use chrono::NaiveDateTime; use chrono::Utc; use fbthrift::adapter::ThriftAdapter; use thiserror::Error; @@ -164,26 +163,24 @@ macro_rules! impl_timestamp_adapter { #[allow(clippy::redundant_closure_call)] fn from_thrift(value: Self::StandardType) -> Result { - $from_thrift_fn(value) - .ok_or(OutOfRangeError(value)) - .map(|dt| dt.and_utc()) + $from_thrift_fn(value).ok_or(OutOfRangeError(value)) } } }; } impl_timestamp_adapter!(UtcTimestampAdapter, DateTime::::timestamp, |val| { - NaiveDateTime::from_timestamp_opt(val, 0) + DateTime::from_timestamp(val, 0) }); impl_timestamp_adapter!( UtcMillisecondTimestampAdapter, DateTime::::timestamp_millis, - NaiveDateTime::from_timestamp_millis + DateTime::from_timestamp_millis ); impl_timestamp_adapter!( UtcMicrosecondTimestampAdapter, DateTime::::timestamp_micros, - NaiveDateTime::from_timestamp_micros + DateTime::from_timestamp_micros ); macro_rules! test_timestamp_adapter { diff --git a/shed/slog_glog_fmt/src/collector_serializer.rs b/shed/slog_glog_fmt/src/collector_serializer.rs index 84acf1b56..57a4fece5 100644 --- a/shed/slog_glog_fmt/src/collector_serializer.rs +++ b/shed/slog_glog_fmt/src/collector_serializer.rs @@ -54,7 +54,7 @@ macro_rules! impl_emit( }; ); -impl<'a, C: KVCategorizer> Serializer for CollectorSerializer<'a, C> { +impl Serializer for CollectorSerializer<'_, C> { /// Emit None fn emit_none(&mut self, key: Key) -> Result { impl_emit_body!(self, key, "None"); diff --git a/shed/slog_glog_fmt/src/glog_format.rs b/shed/slog_glog_fmt/src/glog_format.rs index 8929c35e7..7550c900f 100644 --- a/shed/slog_glog_fmt/src/glog_format.rs +++ b/shed/slog_glog_fmt/src/glog_format.rs @@ -308,7 +308,7 @@ mod tests { msg: String, } - impl<'a> TestLine { + impl TestLine { fn new(level: &'static str, line: u32, msg: &'static str) -> Self { TestLine { level: level.to_owned(), @@ -320,7 +320,7 @@ mod tests { } } - fn with_captures(captures: Captures<'a>) -> Self { + fn with_captures(captures: Captures<'_>) -> Self { TestLine { level: captures.get(1).unwrap().as_str().to_owned(), tid: captures.get(3).unwrap().as_str().to_owned(), diff --git a/shed/sql/common/mysql.rs b/shed/sql/common/mysql.rs index d0f1f9a90..8c0b062d7 100644 --- a/shed/sql/common/mysql.rs +++ b/shed/sql/common/mysql.rs @@ -95,7 +95,7 @@ impl<'a, T: AsSql> SqlList<'a, T> { } } -impl<'a, T: AsSql> AsSql for SqlList<'a, T> { +impl AsSql for SqlList<'_, T> { fn as_sql(&self, no_backslash_escape: bool) -> String { let mut result = String::new(); result.push('(');