Skip to content

Commit

Permalink
chore: fix new Clippy lints in Rust 1.83.0
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.

This is the `v0.1.x` branch sister PR to #3164 (for the `master`)
branch, since `clippy --fix` on another branch is a much better way to
apply these changes than backporting.
  • Loading branch information
hds committed Nov 28, 2024
1 parent c66a692 commit c05f756
Show file tree
Hide file tree
Showing 29 changed files with 94 additions and 96 deletions.
2 changes: 1 addition & 1 deletion examples/examples/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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 @@ -116,7 +116,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 @@ -801,7 +801,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
2 changes: 1 addition & 1 deletion tracing-core/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,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 @@ -387,7 +387,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 @@ -407,13 +407,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 @@ -641,9 +641,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 @@ -938,7 +938,7 @@ impl FieldSet {
}
}

impl<'a> IntoIterator for &'a FieldSet {
impl IntoIterator for &FieldSet {
type IntoIter = Iter;
type Item = Field;
#[inline]
Expand Down Expand Up @@ -1017,7 +1017,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 @@ -1078,7 +1078,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 @@ -1093,7 +1093,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 @@ -332,7 +332,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 @@ -440,9 +440,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 @@ -212,7 +212,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 @@ -223,7 +223,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 @@ -353,7 +353,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 @@ -464,7 +464,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 @@ -516,7 +516,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 @@ -527,7 +527,7 @@ pub(crate) struct CheckVisitor<'a> {
subscriber_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.subscriber_name)
Expand Down Expand Up @@ -563,7 +563,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 @@ -208,7 +208,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 @@ -220,7 +220,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 @@ -236,7 +236,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 @@ -260,7 +260,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 @@ -274,7 +274,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 @@ -297,7 +297,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 @@ -317,7 +317,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 @@ -340,7 +340,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 @@ -586,17 +586,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
Loading

0 comments on commit c05f756

Please sign in to comment.