diff --git a/netlify.toml b/netlify.toml index a59c675e27..d552741a23 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,6 +8,7 @@ [build.environment] RUSTDOCFLAGS=""" -D warnings \ + --force-warn rustdoc::redundant-explicit-links \ --force-warn renamed-and-removed-lints \ --cfg docsrs \ --html-before-content /opt/build/repo/assets/warning.html \ diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index d4c95aa62f..d7a01bb814 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -373,6 +373,10 @@ macro_rules! impl_one_value { impl $crate::sealed::Sealed for $value_ty {} impl $crate::field::Value for $value_ty { fn record(&self, key: &$crate::field::Field, visitor: &mut dyn $crate::field::Visit) { + // `op` is always a function; the closure is used because + // sometimes there isn't a real function corresponding to that + // operation. the clippy warning is not that useful here. + #[allow(clippy::redundant_closure_call)] visitor.$record(key, $op(*self)) } } @@ -388,6 +392,10 @@ macro_rules! impl_one_value { impl $crate::sealed::Sealed for ty_to_nonzero!($value_ty) {} impl $crate::field::Value for ty_to_nonzero!($value_ty) { fn record(&self, key: &$crate::field::Field, visitor: &mut dyn $crate::field::Visit) { + // `op` is always a function; the closure is used because + // sometimes there isn't a real function corresponding to that + // operation. the clippy warning is not that useful here. + #[allow(clippy::redundant_closure_call)] visitor.$record(key, $op(self.get())) } } diff --git a/tracing-subscriber/src/field/mod.rs b/tracing-subscriber/src/field/mod.rs index 705fa5841c..e55ec82d6e 100644 --- a/tracing-subscriber/src/field/mod.rs +++ b/tracing-subscriber/src/field/mod.rs @@ -55,7 +55,7 @@ pub trait VisitOutput: Visit { /// Extension trait implemented by types which can be recorded by a [visitor]. /// /// This allows writing code that is generic over `tracing_core`'s -/// [`span::Attributes`][attr], [`span::Record`][rec], and [`Event`][event] +/// [`span::Attributes`][attr], [`span::Record`][rec], and [`Event`] /// types. These types all provide inherent `record` methods that allow a /// visitor to record their fields, but there is no common trait representing this. /// @@ -85,7 +85,6 @@ pub trait VisitOutput: Visit { /// [visitor]: tracing_core::field::Visit /// [attr]: tracing_core::span::Attributes /// [rec]: tracing_core::span::Record -/// [event]: tracing_core::event::Event pub trait RecordFields: crate::sealed::Sealed { /// Record all the fields in `self` with the provided `visitor`. fn record(&self, visitor: &mut dyn Visit); diff --git a/tracing-subscriber/src/filter/directive.rs b/tracing-subscriber/src/filter/directive.rs index 3745662385..8e00a57a43 100644 --- a/tracing-subscriber/src/filter/directive.rs +++ b/tracing-subscriber/src/filter/directive.rs @@ -45,7 +45,8 @@ enum ParseErrorKind { // === impl DirectiveSet === impl DirectiveSet { - #[cfg(feature = "std")] + // this is only used by `env-filter`. + #[cfg(all(feature = "std", feature = "env-filter"))] pub(crate) fn is_empty(&self) -> bool { self.directives.is_empty() } @@ -388,7 +389,7 @@ impl FromStr for StaticDirective { // === impl ParseError === impl ParseError { - #[cfg(feature = "std")] + #[cfg(all(feature = "std", feature = "env-filter"))] pub(crate) fn new() -> Self { ParseError { kind: ParseErrorKind::Other(None), diff --git a/tracing-subscriber/src/filter/env/directive.rs b/tracing-subscriber/src/filter/env/directive.rs index f0ccbd7ed3..1f0b118661 100644 --- a/tracing-subscriber/src/filter/env/directive.rs +++ b/tracing-subscriber/src/filter/env/directive.rs @@ -120,8 +120,9 @@ impl Directive { } pub(super) fn parse(from: &str, regex: bool) -> Result { - static DIRECTIVE_RE: Lazy = Lazy::new(|| Regex::new( - r"(?x) + static DIRECTIVE_RE: Lazy = Lazy::new(|| { + Regex::new( + r"(?x) ^(?P(?i:trace|debug|info|warn|error|off|[0-5]))$ | # ^^^. # `note: we match log level names case-insensitively @@ -135,15 +136,18 @@ impl Directive { # `note: we match log level names case-insensitively )? $ - " - ) - .unwrap()); + ", + ) + .unwrap() + }); static SPAN_PART_RE: Lazy = - Lazy::new(|| Regex::new(r#"(?P[^\]\{]+)?(?:\{(?P[^\}]*)\})?"#).unwrap()); + Lazy::new(|| Regex::new(r"(?P[^\]\{]+)?(?:\{(?P[^\}]*)\})?").unwrap()); static FIELD_FILTER_RE: Lazy = // TODO(eliza): this doesn't _currently_ handle value matchers that include comma // characters. We should fix that. - Lazy::new(|| Regex::new(r#"(?x) + Lazy::new(|| { + Regex::new( + r"(?x) ( # field name [[:word:]][[[:word:]]\.]* @@ -152,7 +156,10 @@ impl Directive { ) # trailing comma or EOS (?:,\s?|$) - "#).unwrap()); + ", + ) + .unwrap() + }); let caps = DIRECTIVE_RE.captures(from).ok_or_else(ParseError::new)?; diff --git a/tracing-subscriber/src/fmt/format/mod.rs b/tracing-subscriber/src/fmt/format/mod.rs index c9760138ab..2d0fbfa6d2 100644 --- a/tracing-subscriber/src/fmt/format/mod.rs +++ b/tracing-subscriber/src/fmt/format/mod.rs @@ -333,9 +333,8 @@ pub struct FieldFnVisitor<'a, F> { /// The compact format includes fields from all currently entered spans, after /// the event's fields. Span fields are ordered (but not grouped) grouped by /// span, and span names are not shown.A more compact representation of the -/// event's [`Level`](tracing::Level) is used, and additional information, such -/// as the event's target, is disabled by default (but can be enabled -/// explicitly). +/// event's [`Level`] is used, and additional information, such as the event's +/// target, is disabled by default (but can be enabled explicitly). /// /// # Example Output /// @@ -1067,7 +1066,12 @@ where let dimmed = writer.dimmed(); if self.display_target { - write!(writer, "{}{}", dimmed.paint(meta.target()), dimmed.paint(":"))?; + write!( + writer, + "{}{}", + dimmed.paint(meta.target()), + dimmed.paint(":") + )?; } if self.display_filename { diff --git a/tracing-subscriber/src/fmt/mod.rs b/tracing-subscriber/src/fmt/mod.rs index 38acf4d092..036099211b 100644 --- a/tracing-subscriber/src/fmt/mod.rs +++ b/tracing-subscriber/src/fmt/mod.rs @@ -733,7 +733,7 @@ where /// Sets the collector being built to use a less verbose formatter. /// - /// See [`format::Compact`]. + /// See [`format::Compact`] for details. pub fn compact(self) -> CollectorBuilder, F, W> where N: for<'writer> FormatFields<'writer> + 'static, @@ -758,7 +758,7 @@ where /// Sets the collector being built to use a JSON formatter. /// - /// See [`format::Json`](super::fmt::format::Json) + /// See [`format::Json`] for details. #[cfg(feature = "json")] #[cfg_attr(docsrs, doc(cfg(feature = "json")))] pub fn json(self) -> CollectorBuilder, F, W> @@ -777,7 +777,7 @@ where impl CollectorBuilder, F, W> { /// Sets the json collector being built to flatten event metadata. /// - /// See [`format::Json`](super::fmt::format::Json) + /// See [`format::Json`] for details. pub fn flatten_event( self, flatten_event: bool, @@ -791,7 +791,7 @@ impl CollectorBuilder CollectorBuilder MutexGuard<'_, Vec> { self.buf.lock().unwrap() } diff --git a/tracing-subscriber/src/fmt/writer.rs b/tracing-subscriber/src/fmt/writer.rs index fc3d4f4e70..fcd529a563 100644 --- a/tracing-subscriber/src/fmt/writer.rs +++ b/tracing-subscriber/src/fmt/writer.rs @@ -17,7 +17,7 @@ use tracing_core::Metadata; /// This trait is already implemented for function pointers and /// immutably-borrowing closures that return an instance of [`io::Write`], such /// as [`io::stdout`] and [`io::stderr`]. Additionally, it is implemented for -/// [`std::sync::Mutex`][mutex] when the type inside the mutex implements +/// [`std::sync::Mutex`] when the type inside the mutex implements /// [`io::Write`]. /// /// The [`MakeWriter::make_writer_for`] method takes [`Metadata`] describing a @@ -79,7 +79,7 @@ use tracing_core::Metadata; /// ``` /// /// A single instance of a type implementing [`io::Write`] may be used as a -/// `MakeWriter` by wrapping it in a [`Mutex`][mutex]. For example, we could +/// `MakeWriter` by wrapping it in a [`Mutex`]. For example, we could /// write to a file like so: /// /// ``` @@ -101,7 +101,6 @@ use tracing_core::Metadata; /// [`Event`]: tracing_core::event::Event /// [`io::stdout`]: std::io::stdout() /// [`io::stderr`]: std::io::stderr() -/// [mutex]: std::sync::Mutex /// [`MakeWriter::make_writer_for`]: MakeWriter::make_writer_for /// [`Metadata`]: tracing_core::Metadata /// [levels]: tracing_core::Level @@ -339,7 +338,7 @@ pub trait MakeWriterExt<'a>: MakeWriter<'a> { /// Wraps `self` with a predicate that takes a span or event's [`Metadata`] /// and returns a `bool`. The returned [`MakeWriter`]'s - /// [`MakeWriter::make_writer_for`][mwf] method will check the predicate to + /// [`MakeWriter::make_writer_for`] method will check the predicate to /// determine if a writer should be produced for a given span or event. /// /// If the predicate returns `false`, the wrapped [`MakeWriter`]'s @@ -486,7 +485,6 @@ pub trait MakeWriterExt<'a>: MakeWriter<'a> { /// requires the `Writer` type to implement [`io::Write`], it's necessary to add /// a newtype that forwards the trait implementation. /// -/// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html /// [`MutexGuard`]: https://doc.rust-lang.org/std/sync/struct.MutexGuard.html /// [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html /// [`MakeWriter`]: trait.MakeWriter.html @@ -540,13 +538,12 @@ pub struct TestWriter { /// ``` /// /// [`Collect`]: tracing::Collect -/// [`io::Write`]: std::io::Write pub struct BoxMakeWriter { inner: Box MakeWriter<'a, Writer = Box> + Send + Sync>, name: &'static str, } -/// A [writer] that is one of two types implementing [`io::Write`][writer]. +/// A [writer] that is one of two types implementing [`io::Write`]. /// /// This may be used by [`MakeWriter`] implementations that may conditionally /// return one of two writers. diff --git a/tracing-subscriber/src/registry/mod.rs b/tracing-subscriber/src/registry/mod.rs index 48b378d1ed..b712aa73ab 100644 --- a/tracing-subscriber/src/registry/mod.rs +++ b/tracing-subscriber/src/registry/mod.rs @@ -205,11 +205,9 @@ pub trait SpanData<'a> { /// A reference to [span data] and the associated [registry]. /// -/// This type implements all the same methods as [`SpanData`][span data], and -/// provides additional methods for querying the registry based on values from -/// the span. +/// This type implements all the same methods as [`SpanData`], and provides +/// additional methods for querying the registry based on values from the span. /// -/// [span data]: SpanData /// [registry]: LookupSpan #[derive(Debug)] pub struct SpanRef<'a, R: LookupSpan<'a>> { diff --git a/tracing-subscriber/src/subscribe/mod.rs b/tracing-subscriber/src/subscribe/mod.rs index 8601ca3287..6f375654a9 100644 --- a/tracing-subscriber/src/subscribe/mod.rs +++ b/tracing-subscriber/src/subscribe/mod.rs @@ -1388,11 +1388,10 @@ pub trait Filter { /// multiple invocations of this method. However, note that changes in the /// maximum level will **only** be reflected after the callsite [`Interest`] /// cache is rebuilt, by calling the - /// [`tracing_core::callsite::rebuild_interest_cache`][rebuild] function. + /// [`tracing_core::callsite::rebuild_interest_cache`] function. /// Therefore, if the `Filter will change the value returned by this - /// method, it is responsible for ensuring that - /// [`rebuild_interest_cache`][rebuild] is called after the value of the max - /// level changes. + /// method, it is responsible for ensuring that [`rebuild_interest_cache`] + /// is called after the value of the max level changes. /// /// ## Default Implementation /// @@ -1402,7 +1401,7 @@ pub trait Filter { /// [level]: tracing_core::metadata::Level /// [`LevelFilter`]: crate::filter::LevelFilter /// [`Interest`]: tracing_core::collect::Interest - /// [rebuild]: tracing_core::callsite::rebuild_interest_cache + /// [`rebuild_interest_cache`]: tracing_core::callsite::rebuild_interest_cache fn max_level_hint(&self) -> Option { None } diff --git a/tracing/src/lib.rs b/tracing/src/lib.rs index f698648232..de54bffbd2 100644 --- a/tracing/src/lib.rs +++ b/tracing/src/lib.rs @@ -902,7 +902,7 @@ //! [event]: Event //! [events]: Event //! [`collect`]: collect::Collect -//! [Collect::event]: collect::Collect::event +//! [Collect::event]: fn@collect::Collect::event //! [`enter`]: collect::Collect::enter //! [`exit`]: collect::Collect::exit //! [`enabled`]: collect::Collect::enabled