Skip to content

Commit

Permalink
chore: fix new Clippy lints in Rust 1.83.0 (#3164)
Browse files Browse the repository at this point in the history
Most of these changes are places where lifetimes were named, but can be
elided. Then a few cases where a lifetime was elided, but actually
resolves to a named lifetime. So lots of lifetimes.
  • Loading branch information
hds authored Nov 29, 2024
1 parent 827cd14 commit c8049f6
Show file tree
Hide file tree
Showing 31 changed files with 96 additions and 101 deletions.
2 changes: 1 addition & 1 deletion examples/examples/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct Count<'a> {
counters: RwLockReadGuard<'a, HashMap<String, AtomicUsize>>,
}

impl<'a> Visit for Count<'a> {
impl Visit for Count<'_> {
fn record_i64(&mut self, field: &Field, value: i64) {
if let Some(counter) = self.counters.get(field.name()) {
if value > 0 {
Expand Down
4 changes: 2 additions & 2 deletions examples/examples/sloggish/sloggish_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct Event<'a> {

struct ColorLevel<'a>(&'a Level);

impl<'a> fmt::Display for ColorLevel<'a> {
impl fmt::Display for ColorLevel<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self.0 {
Level::TRACE => Color::Purple.paint("TRACE"),
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Visit for Span {
}
}

impl<'a> Visit for Event<'a> {
impl Visit for Event<'_> {
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
write!(
&mut self.stderr,
Expand Down
2 changes: 1 addition & 1 deletion tracing-appender/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl NoOpWriter {
}
}

impl<'a> MakeWriter<'a> for NoOpWriter {
impl MakeWriter<'_> for NoOpWriter {
type Writer = NoOpWriter;

fn make_writer(&self) -> Self::Writer {
Expand Down
2 changes: 1 addition & 1 deletion tracing-appender/src/rolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub use builder::{Builder, InitError};
///
/// // Log all events to a rolling log file.
/// let logfile = tracing_appender::rolling::hourly("/logs", "myapp-logs");
///
/// // Log `INFO` and above to stdout.
/// let stdout = std::io::stdout.with_max_level(tracing::Level::INFO);
///
Expand Down
4 changes: 2 additions & 2 deletions tracing-attributes/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ struct IdentAndTypesRenamer<'a> {
idents: Vec<(Ident, Ident)>,
}

impl<'a> VisitMut for IdentAndTypesRenamer<'a> {
impl VisitMut for IdentAndTypesRenamer<'_> {
// we deliberately compare strings because we want to ignore the spans
// If we apply clippy's lint, the behavior changes
#[allow(clippy::cmp_owned)]
Expand Down Expand Up @@ -802,7 +802,7 @@ struct AsyncTraitBlockReplacer<'a> {
patched_block: Block,
}

impl<'a> VisitMut for AsyncTraitBlockReplacer<'a> {
impl VisitMut for AsyncTraitBlockReplacer<'_> {
fn visit_block_mut(&mut self, i: &mut Block) {
if i == self.block {
*i = self.patched_block.clone();
Expand Down
4 changes: 2 additions & 2 deletions tracing-core/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ where
// the default dispatcher will not be able to access the dispatch context.
// Dropping the guard will allow the dispatch context to be re-entered.
struct Entered<'a>(&'a Cell<bool>);
impl<'a> Drop for Entered<'a> {
impl Drop for Entered<'_> {
#[inline]
fn drop(&mut self) {
self.0.set(true);
Expand Down Expand Up @@ -1039,7 +1039,7 @@ impl<'a> Entered<'a> {
}

#[cfg(feature = "std")]
impl<'a> Drop for Entered<'a> {
impl Drop for Entered<'_> {
#[inline]
fn drop(&mut self) {
self.0.can_enter.set(true);
Expand Down
18 changes: 9 additions & 9 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ where

struct HexBytes<'a>(&'a [u8]);

impl<'a> fmt::Debug for HexBytes<'a> {
impl fmt::Debug for HexBytes<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_char('[')?;

Expand All @@ -310,13 +310,13 @@ impl<'a> fmt::Debug for HexBytes<'a> {

// ===== impl Visit =====

impl<'a, 'b> Visit for fmt::DebugStruct<'a, 'b> {
impl Visit for fmt::DebugStruct<'_, '_> {
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
self.field(field.name(), value);
}
}

impl<'a, 'b> Visit for fmt::DebugMap<'a, 'b> {
impl Visit for fmt::DebugMap<'_, '_> {
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
self.entry(&format_args!("{}", field), value);
}
Expand Down Expand Up @@ -544,9 +544,9 @@ where
}
}

impl<'a> crate::sealed::Sealed for fmt::Arguments<'a> {}
impl crate::sealed::Sealed for fmt::Arguments<'_> {}

impl<'a> Value for fmt::Arguments<'a> {
impl Value for fmt::Arguments<'_> {
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
visitor.record_debug(key, self)
}
Expand Down Expand Up @@ -818,7 +818,7 @@ impl FieldSet {
}
}

impl<'a> IntoIterator for &'a FieldSet {
impl IntoIterator for &FieldSet {
type IntoIter = Iter;
type Item = Field;
#[inline]
Expand Down Expand Up @@ -897,7 +897,7 @@ impl Iterator for Iter {

// ===== impl ValueSet =====

impl<'a> ValueSet<'a> {
impl ValueSet<'_> {
/// Returns an [`Identifier`] that uniquely identifies the [`Callsite`]
/// defining the fields this `ValueSet` refers to.
///
Expand Down Expand Up @@ -958,7 +958,7 @@ impl<'a> ValueSet<'a> {
}
}

impl<'a> fmt::Debug for ValueSet<'a> {
impl fmt::Debug for ValueSet<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.values
.iter()
Expand All @@ -973,7 +973,7 @@ impl<'a> fmt::Debug for ValueSet<'a> {
}
}

impl<'a> fmt::Display for ValueSet<'a> {
impl fmt::Display for ValueSet<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.values
.iter()
Expand Down
8 changes: 4 additions & 4 deletions tracing-core/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub struct Kind(u8);
/// // ...
/// # drop(span); Id::from_u64(1)
/// }
///
/// fn event(&self, event: &Event<'_>) {
/// // ...
/// # drop(event);
Expand Down Expand Up @@ -333,7 +333,7 @@ impl<'a> Metadata<'a> {
}
}

impl<'a> fmt::Debug for Metadata<'a> {
impl fmt::Debug for Metadata<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut meta = f.debug_struct("Metadata");
meta.field("name", &self.name)
Expand Down Expand Up @@ -441,9 +441,9 @@ impl fmt::Debug for Kind {
}
}

impl<'a> Eq for Metadata<'a> {}
impl Eq for Metadata<'_> {}

impl<'a> PartialEq for Metadata<'a> {
impl PartialEq for Metadata<'_> {
#[inline]
fn eq(&self, other: &Self) -> bool {
if core::ptr::eq(&self, &other) {
Expand Down
2 changes: 1 addition & 1 deletion tracing-error/src/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl fmt::Debug for SpanTrace {
fields: &'a str,
}

impl<'a> fmt::Debug for DebugSpan<'a> {
impl fmt::Debug for DebugSpan<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
Expand Down
10 changes: 5 additions & 5 deletions tracing-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub trait AsTrace: crate::sealed::Sealed {
fn as_trace(&self) -> Self::Trace;
}

impl<'a> crate::sealed::Sealed for Metadata<'a> {}
impl crate::sealed::Sealed for Metadata<'_> {}

impl<'a> AsLog for Metadata<'a> {
type Log = log::Metadata<'a>;
Expand All @@ -220,7 +220,7 @@ impl<'a> AsLog for Metadata<'a> {
.build()
}
}
impl<'a> crate::sealed::Sealed for log::Metadata<'a> {}
impl crate::sealed::Sealed for log::Metadata<'_> {}

impl<'a> AsTrace for log::Metadata<'a> {
type Trace = Metadata<'a>;
Expand Down Expand Up @@ -350,7 +350,7 @@ fn loglevel_to_cs(
}
}

impl<'a> crate::sealed::Sealed for log::Record<'a> {}
impl crate::sealed::Sealed for log::Record<'_> {}

impl<'a> AsTrace for log::Record<'a> {
type Trace = Metadata<'a>;
Expand Down Expand Up @@ -461,7 +461,7 @@ pub trait NormalizeEvent<'a>: crate::sealed::Sealed {
fn is_log(&self) -> bool;
}

impl<'a> crate::sealed::Sealed for Event<'a> {}
impl crate::sealed::Sealed for Event<'_> {}

impl<'a> NormalizeEvent<'a> for Event<'a> {
fn normalized_metadata(&'a self) -> Option<Metadata<'a>> {
Expand Down Expand Up @@ -513,7 +513,7 @@ impl<'a> LogVisitor<'a> {
}
}

impl<'a> Visit for LogVisitor<'a> {
impl Visit for LogVisitor<'_> {
fn record_debug(&mut self, _field: &Field, _value: &dyn fmt::Debug) {}

fn record_u64(&mut self, field: &Field, value: u64) {
Expand Down
4 changes: 2 additions & 2 deletions tracing-mock/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ pub(crate) struct CheckVisitor<'a> {
collector_name: &'a str,
}

impl<'a> Visit for CheckVisitor<'a> {
impl Visit for CheckVisitor<'_> {
fn record_f64(&mut self, field: &Field, value: f64) {
self.expect
.compare_or_panic(field.name(), &value, self.ctx, self.collector_name)
Expand Down Expand Up @@ -557,7 +557,7 @@ impl<'a> Visit for CheckVisitor<'a> {
}
}

impl<'a> CheckVisitor<'a> {
impl CheckVisitor<'_> {
pub(crate) fn finish(self) {
assert!(
self.expect.fields.is_empty(),
Expand Down
12 changes: 6 additions & 6 deletions tracing-serde/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pub trait AsMap: Sized + sealed::Sealed {
}
}

impl<'a> AsMap for Event<'a> {}
impl<'a> AsMap for Attributes<'a> {}
impl<'a> AsMap for Record<'a> {}
impl AsMap for Event<'_> {}
impl AsMap for Attributes<'_> {}
impl AsMap for Record<'_> {}

// === impl SerializeFieldMap ===

impl<'a> Serialize for SerializeFieldMap<'a, Event<'_>> {
impl Serialize for SerializeFieldMap<'_, Event<'_>> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -29,7 +29,7 @@ impl<'a> Serialize for SerializeFieldMap<'a, Event<'_>> {
}
}

impl<'a> Serialize for SerializeFieldMap<'a, Attributes<'_>> {
impl Serialize for SerializeFieldMap<'_, Attributes<'_>> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -42,7 +42,7 @@ impl<'a> Serialize for SerializeFieldMap<'a, Attributes<'_>> {
}
}

impl<'a> Serialize for SerializeFieldMap<'a, Record<'_>> {
impl Serialize for SerializeFieldMap<'_, Record<'_>> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
24 changes: 12 additions & 12 deletions tracing-serde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub mod fields;
#[derive(Debug)]
pub struct SerializeField<'a>(&'a Field);

impl<'a> Serialize for SerializeField<'a> {
impl Serialize for SerializeField<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -208,7 +208,7 @@ impl<'a> Serialize for SerializeField<'a> {
#[derive(Debug)]
pub struct SerializeFieldSet<'a>(&'a FieldSet);

impl<'a> Serialize for SerializeFieldSet<'a> {
impl Serialize for SerializeFieldSet<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -224,7 +224,7 @@ impl<'a> Serialize for SerializeFieldSet<'a> {
#[derive(Debug)]
pub struct SerializeLevel<'a>(&'a Level);

impl<'a> Serialize for SerializeLevel<'a> {
impl Serialize for SerializeLevel<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -248,7 +248,7 @@ impl<'a> Serialize for SerializeLevel<'a> {
#[derive(Debug)]
pub struct SerializeId<'a>(&'a Id);

impl<'a> Serialize for SerializeId<'a> {
impl Serialize for SerializeId<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -262,7 +262,7 @@ impl<'a> Serialize for SerializeId<'a> {
#[derive(Debug)]
pub struct SerializeMetadata<'a>(&'a Metadata<'a>);

impl<'a> Serialize for SerializeMetadata<'a> {
impl Serialize for SerializeMetadata<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -285,7 +285,7 @@ impl<'a> Serialize for SerializeMetadata<'a> {
#[derive(Debug)]
pub struct SerializeEvent<'a>(&'a Event<'a>);

impl<'a> Serialize for SerializeEvent<'a> {
impl Serialize for SerializeEvent<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -305,7 +305,7 @@ impl<'a> Serialize for SerializeEvent<'a> {
#[derive(Debug)]
pub struct SerializeAttributes<'a>(&'a Attributes<'a>);

impl<'a> Serialize for SerializeAttributes<'a> {
impl Serialize for SerializeAttributes<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -328,7 +328,7 @@ impl<'a> Serialize for SerializeAttributes<'a> {
#[derive(Debug)]
pub struct SerializeRecord<'a>(&'a Record<'a>);

impl<'a> Serialize for SerializeRecord<'a> {
impl Serialize for SerializeRecord<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down Expand Up @@ -554,17 +554,17 @@ impl<'a> AsSerde<'a> for FieldSet {
}
}

impl<'a> self::sealed::Sealed for Event<'a> {}
impl self::sealed::Sealed for Event<'_> {}

impl<'a> self::sealed::Sealed for Attributes<'a> {}
impl self::sealed::Sealed for Attributes<'_> {}

impl self::sealed::Sealed for Id {}

impl self::sealed::Sealed for Level {}

impl<'a> self::sealed::Sealed for Record<'a> {}
impl self::sealed::Sealed for Record<'_> {}

impl<'a> self::sealed::Sealed for Metadata<'a> {}
impl self::sealed::Sealed for Metadata<'_> {}

impl self::sealed::Sealed for Field {}

Expand Down
1 change: 0 additions & 1 deletion tracing-subscriber/benches/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use support::NoWriter;

/// Prepare a real-world-inspired collector and use it to measure the performance impact of
/// reloadable collectors.
fn mk_builder() -> CollectorBuilder<DefaultFields, Format<Full>, EnvFilter, fn() -> NoWriter> {
let filter = EnvFilter::default()
.add_directive("this=off".parse().unwrap())
Expand Down
Loading

0 comments on commit c8049f6

Please sign in to comment.