From b21d2369c8cba9de812ab5142592029afe837a07 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 25 Mar 2022 12:21:08 -0700 Subject: [PATCH] subscriber: fix `FmtLayer`'s auto traits inheriting `S`'s (#2024) Depends on #2023 ## Motivation Currently, `FmtLayer` holds a `PhantomData` with the `Subscriber` type it wraps. This is unfortunate because it means that the layer's auto traits such as `Send`, `Sync`, and `'static` (as well as `UnwindSafe`, `Unpin`, etc) depend on the `Subscriber` type's auto traits...but the layer will never actually _store_ a value of type `S`. While all `Subscriber` will be `Send + Sync + 'static` in practice, the `PhantomData` means that functions returning a boxed `FmtLayer` must unnecessarily bound the subscriber type parameter. ## Solution This commit changes the `PhantomData` to `PhantomData`, solving the problem. Signed-off-by: Eliza Weisman --- tracing-subscriber/src/fmt/fmt_layer.rs | 2 +- tracing-subscriber/src/layer/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tracing-subscriber/src/fmt/fmt_layer.rs b/tracing-subscriber/src/fmt/fmt_layer.rs index ac0990b3fd..e557f9f0a3 100644 --- a/tracing-subscriber/src/fmt/fmt_layer.rs +++ b/tracing-subscriber/src/fmt/fmt_layer.rs @@ -70,7 +70,7 @@ pub struct Layer< fmt_event: E, fmt_span: format::FmtSpanConfig, is_ansi: bool, - _inner: PhantomData, + _inner: PhantomData, } impl Layer { diff --git a/tracing-subscriber/src/layer/mod.rs b/tracing-subscriber/src/layer/mod.rs index 13eb7e6774..3cd55c832f 100644 --- a/tracing-subscriber/src/layer/mod.rs +++ b/tracing-subscriber/src/layer/mod.rs @@ -236,10 +236,10 @@ //! } //! //! impl LogConfig { -//! pub fn layer(self) -> Box + Send + Sync + 'static> +//! pub fn layer(self) -> Box + Send + Sync + 'static> //! where -//! C: tracing_core::Subscriber + Send + Sync, -//! for<'a> C: LookupSpan<'a>, +//! S: tracing_core::Subscriber, +//! for<'a> S: LookupSpan<'a>, //! { //! // Shared configuration regardless of where logs are output to. //! let fmt = tracing_subscriber::fmt::layer()