From a1d12820864842cea8c7dd249a101f37f8593f6f Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 9 Sep 2021 10:53:02 -0700 Subject: [PATCH] subscriber: fix missing `doc(cfg(...))` attributes for `EnvFilter` (#1544) ## Motivation Currently, some types in the `filter` module that require the "env-filter" feature flag don't properly show in the docs that they require this feature. This is because the `doc(cfg(feature = "env-filter"))` attribute is only placed on the _re-export_ from the `env` module (and on the `EnvFilter` type), not on the individual types that are re-exported. However, placing a `doc(cfg(...))` attribute on a re-export doesn't actually do anything. ## Solution This commit fixes that. --- tracing-subscriber/src/filter/env/directive.rs | 1 + tracing-subscriber/src/filter/env/field.rs | 1 + tracing-subscriber/src/filter/env/mod.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/tracing-subscriber/src/filter/env/directive.rs b/tracing-subscriber/src/filter/env/directive.rs index af5d60db47..1bd97cc42d 100644 --- a/tracing-subscriber/src/filter/env/directive.rs +++ b/tracing-subscriber/src/filter/env/directive.rs @@ -8,6 +8,7 @@ use tracing_core::{span, Level, Metadata}; /// A single filtering directive. // TODO(eliza): add a builder for programmatically constructing directives? #[derive(Debug, Eq, PartialEq)] +#[cfg_attr(docsrs, doc(cfg(feature = "env-filter")))] pub struct Directive { in_span: Option, fields: FilterVec, diff --git a/tracing-subscriber/src/filter/env/field.rs b/tracing-subscriber/src/filter/env/field.rs index a6b849a8a8..e9a2fdd152 100644 --- a/tracing-subscriber/src/filter/env/field.rs +++ b/tracing-subscriber/src/filter/env/field.rs @@ -115,6 +115,7 @@ pub(crate) struct MatchPattern { /// Indicates that a field name specified in a filter directive was invalid. #[derive(Clone, Debug)] +#[cfg_attr(docsrs, doc(cfg(feature = "env-filter")))] pub struct BadName { name: String, } diff --git a/tracing-subscriber/src/filter/env/mod.rs b/tracing-subscriber/src/filter/env/mod.rs index c1293896c2..76d65ea916 100644 --- a/tracing-subscriber/src/filter/env/mod.rs +++ b/tracing-subscriber/src/filter/env/mod.rs @@ -119,6 +119,7 @@ type FilterVec = Vec; /// Indicates that an error occurred while parsing a `EnvFilter` from an /// environment variable. +#[cfg_attr(docsrs, doc(cfg(feature = "env-filter")))] #[derive(Debug)] pub struct FromEnvError { kind: ErrorKind,