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.
This commit is contained in:
Eliza Weisman 2021-09-09 10:53:02 -07:00
parent c95321a02e
commit a1d1282086
3 changed files with 3 additions and 0 deletions

View File

@ -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<String>,
fields: FilterVec<field::Match>,

View File

@ -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,
}

View File

@ -119,6 +119,7 @@ type FilterVec<T> = Vec<T>;
/// 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,