Skip to content

Commit

Permalink
Clippy lint clean
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zertosh authored and facebook-github-bot committed Dec 16, 2024
1 parent 00bc32a commit 729b885
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions shed/chrome_trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ mod duration {

struct DurationVisitor;

#[allow(clippy::needless_lifetimes)]
impl<'de> Visitor<'de> for DurationVisitor {
type Value = Duration;

Expand Down
11 changes: 4 additions & 7 deletions shed/fbthrift_ext/adapters/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -164,26 +163,24 @@ macro_rules! impl_timestamp_adapter {

#[allow(clippy::redundant_closure_call)]
fn from_thrift(value: Self::StandardType) -> Result<Self::AdaptedType, Self::Error> {
$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::<Utc>::timestamp, |val| {
NaiveDateTime::from_timestamp_opt(val, 0)
DateTime::from_timestamp(val, 0)
});
impl_timestamp_adapter!(
UtcMillisecondTimestampAdapter,
DateTime::<Utc>::timestamp_millis,
NaiveDateTime::from_timestamp_millis
DateTime::from_timestamp_millis
);
impl_timestamp_adapter!(
UtcMicrosecondTimestampAdapter,
DateTime::<Utc>::timestamp_micros,
NaiveDateTime::from_timestamp_micros
DateTime::from_timestamp_micros
);

macro_rules! test_timestamp_adapter {
Expand Down
2 changes: 1 addition & 1 deletion shed/slog_glog_fmt/src/collector_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ macro_rules! impl_emit(
};
);

impl<'a, C: KVCategorizer> Serializer for CollectorSerializer<'a, C> {
impl<C: KVCategorizer> Serializer for CollectorSerializer<'_, C> {
/// Emit None
fn emit_none(&mut self, key: Key) -> Result {
impl_emit_body!(self, key, "None");
Expand Down
4 changes: 2 additions & 2 deletions shed/slog_glog_fmt/src/glog_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion shed/sql/common/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<'a, T: AsSql> SqlList<'a, T> {
}
}

impl<'a, T: AsSql> AsSql for SqlList<'a, T> {
impl<T: AsSql> AsSql for SqlList<'_, T> {
fn as_sql(&self, no_backslash_escape: bool) -> String {
let mut result = String::new();
result.push('(');
Expand Down

0 comments on commit 729b885

Please sign in to comment.