diff --git a/tracing-subscriber/src/layer.rs b/tracing-subscriber/src/layer.rs index 374db9ed72..5b35bfb2ff 100644 --- a/tracing-subscriber/src/layer.rs +++ b/tracing-subscriber/src/layer.rs @@ -1301,7 +1301,6 @@ impl Identity { #[cfg(test)] pub(crate) mod tests { - use std::sync::{Arc, Mutex}; use super::*; @@ -1419,7 +1418,9 @@ pub(crate) mod tests { } #[test] + #[cfg(feature = "registry")] fn context_event_span() { + use std::sync::{Arc, Mutex}; let last_event_span = Arc::new(Mutex::new(None)); struct RecordingLayer { diff --git a/tracing-subscriber/src/registry/mod.rs b/tracing-subscriber/src/registry/mod.rs index 214c4a17b8..5db41e35d3 100644 --- a/tracing-subscriber/src/registry/mod.rs +++ b/tracing-subscriber/src/registry/mod.rs @@ -474,7 +474,7 @@ where } } -#[cfg(test)] +#[cfg(all(test, feature = "registry"))] mod tests { use crate::{ layer::{Context, Layer}, diff --git a/tracing-subscriber/tests/duplicate_spans.rs b/tracing-subscriber/tests/duplicate_spans.rs index 34174d1657..c4a736f747 100644 --- a/tracing-subscriber/tests/duplicate_spans.rs +++ b/tracing-subscriber/tests/duplicate_spans.rs @@ -1,3 +1,4 @@ +#![cfg(all(feature = "env-filter", feature = "fmt"))] mod support; use tracing::{self, subscriber::with_default, Span}; use tracing_subscriber::{filter::EnvFilter, FmtSubscriber}; diff --git a/tracing-subscriber/tests/field_filter.rs b/tracing-subscriber/tests/field_filter.rs index b2ef345006..12b4053b62 100644 --- a/tracing-subscriber/tests/field_filter.rs +++ b/tracing-subscriber/tests/field_filter.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "env-filter")] mod support; use self::support::*; use tracing::{self, subscriber::with_default, Level}; diff --git a/tracing-subscriber/tests/filter.rs b/tracing-subscriber/tests/filter.rs index 5b6afbb595..8386d34d24 100644 --- a/tracing-subscriber/tests/filter.rs +++ b/tracing-subscriber/tests/filter.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "env-filter")] + mod support; use self::support::*; use tracing::{self, subscriber::with_default, Level}; diff --git a/tracing-subscriber/tests/filter_log.rs b/tracing-subscriber/tests/filter_log.rs index ec1f2481e9..28e742501a 100644 --- a/tracing-subscriber/tests/filter_log.rs +++ b/tracing-subscriber/tests/filter_log.rs @@ -1,3 +1,4 @@ +#![cfg(all(feature = "env-filter", feature = "tracing-log"))] mod support; use self::support::*; use tracing::{self, Level}; diff --git a/tracing-subscriber/tests/fmt_max_level_hint.rs b/tracing-subscriber/tests/fmt_max_level_hint.rs index 8af7b043ed..57a0f6e3f6 100644 --- a/tracing-subscriber/tests/fmt_max_level_hint.rs +++ b/tracing-subscriber/tests/fmt_max_level_hint.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "fmt")] use tracing_subscriber::filter::LevelFilter; #[test] diff --git a/tracing-subscriber/tests/registry_max_level_hint.rs b/tracing-subscriber/tests/registry_max_level_hint.rs index f76617a5f7..f94c8a1fb7 100644 --- a/tracing-subscriber/tests/registry_max_level_hint.rs +++ b/tracing-subscriber/tests/registry_max_level_hint.rs @@ -1,3 +1,4 @@ +#![cfg(all(feature = "registry", feature = "fmt"))] use tracing_subscriber::{filter::LevelFilter, prelude::*}; #[test] diff --git a/tracing-subscriber/tests/registry_with_subscriber.rs b/tracing-subscriber/tests/registry_with_subscriber.rs index e0d6544e0a..3f8d99b1d9 100644 --- a/tracing-subscriber/tests/registry_with_subscriber.rs +++ b/tracing-subscriber/tests/registry_with_subscriber.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "registry")] use tracing_futures::{Instrument, WithSubscriber}; use tracing_subscriber::prelude::*; diff --git a/tracing-subscriber/tests/reload.rs b/tracing-subscriber/tests/reload.rs index b43aad6ea0..5fe422e085 100644 --- a/tracing-subscriber/tests/reload.rs +++ b/tracing-subscriber/tests/reload.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "reload")] use std::sync::atomic::{AtomicUsize, Ordering}; use tracing_core::{ span::{Attributes, Id, Record}, diff --git a/tracing-subscriber/tests/same_len_filters.rs b/tracing-subscriber/tests/same_len_filters.rs index 5b85ac7717..b525ea6fdb 100644 --- a/tracing-subscriber/tests/same_len_filters.rs +++ b/tracing-subscriber/tests/same_len_filters.rs @@ -1,6 +1,6 @@ // These tests include field filters with no targets, so they have to go in a // separate file. - +#![cfg(feature = "env-filter")] mod support; use self::support::*; use tracing::{self, subscriber::with_default, Level}; diff --git a/tracing-subscriber/tests/utils.rs b/tracing-subscriber/tests/utils.rs index baef27defa..1229a6a493 100644 --- a/tracing-subscriber/tests/utils.rs +++ b/tracing-subscriber/tests/utils.rs @@ -19,6 +19,7 @@ fn init_ext_works() { } #[test] +#[cfg(feature = "fmt")] fn builders_are_init_ext() { tracing_subscriber::fmt().set_default(); let _ = tracing_subscriber::fmt() @@ -28,6 +29,7 @@ fn builders_are_init_ext() { } #[test] +#[cfg(all(feature = "fmt", feature = "env-filter"))] fn layered_is_init_ext() { tracing_subscriber::registry() .with(tracing_subscriber::fmt::layer())