From 66514cde8c4e098fa6ae7960919c5da9eb5400a4 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 7 Apr 2022 17:08:42 -0700 Subject: [PATCH] chore: fix Rust 1.60 warnings (#2056) ## Motivation The Rust 1.60 release introduced a few new lints that trigger on the `tracing` codebase. In particular, `clippy` added some new lints for method naming, and the `unreachable_pub` lint now seems to be triggered incorrectly by `pub use foo as _` re-exports. ## Solution This branch fixes the lints. Signed-off-by: Eliza Weisman --- tracing-error/src/lib.rs | 3 +++ tracing-subscriber/src/filter/env/builder.rs | 4 ++++ tracing-subscriber/src/layer/layered.rs | 2 +- tracing-subscriber/src/registry/sharded.rs | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tracing-error/src/lib.rs b/tracing-error/src/lib.rs index d88f850a6d..a54543c333 100644 --- a/tracing-error/src/lib.rs +++ b/tracing-error/src/lib.rs @@ -232,5 +232,8 @@ pub mod prelude { //! extension traits. These traits allow attaching `SpanTrace`s to errors and //! subsequently retrieving them from `dyn Error` trait objects. + // apparently `as _` reexpoorts now generate `unreachable_pub` linting? which + // seems wrong to me... + #![allow(unreachable_pub)] pub use crate::{ExtractSpanTrace as _, InstrumentError as _, InstrumentResult as _}; } diff --git a/tracing-subscriber/src/filter/env/builder.rs b/tracing-subscriber/src/filter/env/builder.rs index 128b1868e8..d950b1e419 100644 --- a/tracing-subscriber/src/filter/env/builder.rs +++ b/tracing-subscriber/src/filter/env/builder.rs @@ -184,6 +184,10 @@ impl Builder { } // TODO(eliza): consider making this a public API? + // Clippy doesn't love this naming, because it suggests that `from_` methods + // should not take a `Self`...but in this case, it's the `EnvFilter` that is + // being constructed "from" the directives, rather than the builder itself. + #[allow(clippy::wrong_self_convention)] pub(super) fn from_directives( &self, directives: impl IntoIterator, diff --git a/tracing-subscriber/src/layer/layered.rs b/tracing-subscriber/src/layer/layered.rs index c690764add..5e81239a71 100644 --- a/tracing-subscriber/src/layer/layered.rs +++ b/tracing-subscriber/src/layer/layered.rs @@ -152,7 +152,7 @@ where #[cfg(all(feature = "registry", feature = "std"))] { if let Some(g) = guard.as_mut() { - g.is_closing() + g.set_closing() }; } diff --git a/tracing-subscriber/src/registry/sharded.rs b/tracing-subscriber/src/registry/sharded.rs index a6311cb718..c714409ef7 100644 --- a/tracing-subscriber/src/registry/sharded.rs +++ b/tracing-subscriber/src/registry/sharded.rs @@ -380,7 +380,7 @@ impl<'a> LookupSpan<'a> for Registry { // === impl CloseGuard === impl<'a> CloseGuard<'a> { - pub(crate) fn is_closing(&mut self) { + pub(crate) fn set_closing(&mut self) { self.is_closing = true; } }