From 876d39ca0c75960e5196d49cc92029534aa6b9ea Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 4 Jun 2021 21:22:30 +0200 Subject: [PATCH 1/2] subscriber: Use `as _` trait method re-exports for prelude --- examples/examples/toggle-subscribers.rs | 2 +- tracing-subscriber/src/prelude.rs | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/examples/toggle-subscribers.rs b/examples/examples/toggle-subscribers.rs index 2f53fe8dfd..6c391e4337 100644 --- a/examples/examples/toggle-subscribers.rs +++ b/examples/examples/toggle-subscribers.rs @@ -11,7 +11,7 @@ /// use clap::{App, Arg}; use tracing::info; -use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt}; +use tracing_subscriber::{subscribe::CollectExt, util::SubscriberInitExt}; #[path = "fmt/yak_shave.rs"] mod yak_shave; diff --git a/tracing-subscriber/src/prelude.rs b/tracing-subscriber/src/prelude.rs index 5fa6913f16..643c59f05d 100644 --- a/tracing-subscriber/src/prelude.rs +++ b/tracing-subscriber/src/prelude.rs @@ -3,12 +3,6 @@ //! This brings into scope a number of extension traits that define methods on //! types defined here and in other crates. -pub use crate::field::{ - MakeExt as __tracing_subscriber_field_MakeExt, - RecordFields as __tracing_subscriber_field_RecordFields, -}; -pub use crate::subscribe::{ - CollectExt as __tracing_subscriber_SubscriberExt, Subscribe as __tracing_subscriber_Layer, -}; - +pub use crate::field::{MakeExt as _, RecordFields as _}; +pub use crate::subscribe::{CollectExt as _, Subscribe as _}; pub use crate::util::SubscriberInitExt as _; From 33db49298cd3c4d6e7b04e5d0c0fcefc2555253a Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 4 Jun 2021 21:25:00 +0200 Subject: [PATCH 2/2] subscriber: Stop using prelude imports in doctests Since the compiler hints around this are currently very bad, it's good to have a hint where methods in doc examples could come from in there, for users who prefer not using the prelude. --- tracing-subscriber/src/fmt/fmt_subscriber.rs | 6 +++--- tracing-subscriber/src/fmt/mod.rs | 9 +++++---- tracing-subscriber/src/subscribe.rs | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tracing-subscriber/src/fmt/fmt_subscriber.rs b/tracing-subscriber/src/fmt/fmt_subscriber.rs index ba501bc9f5..ef4a56bf0f 100644 --- a/tracing-subscriber/src/fmt/fmt_subscriber.rs +++ b/tracing-subscriber/src/fmt/fmt_subscriber.rs @@ -23,7 +23,7 @@ use tracing_core::{ /// /// ```rust /// use tracing_subscriber::{fmt, Registry}; -/// use tracing_subscriber::prelude::*; +/// use tracing_subscriber::subscribe::CollectExt; /// /// let collector = Registry::default() /// .with(fmt::Subscriber::default()); @@ -35,7 +35,7 @@ use tracing_core::{ /// /// ```rust /// use tracing_subscriber::{fmt, Registry}; -/// use tracing_subscriber::prelude::*; +/// use tracing_subscriber::subscribe::CollectExt; /// /// let fmt_subscriber = fmt::subscriber() /// .with_target(false) // don't include event targets when logging @@ -49,7 +49,7 @@ use tracing_core::{ /// /// ```rust /// use tracing_subscriber::fmt::{self, format, time}; -/// use tracing_subscriber::prelude::*; +/// use tracing_subscriber::Subscribe; /// /// let fmt = format().with_timer(time::Uptime::default()); /// let fmt_subscriber = fmt::subscriber() diff --git a/tracing-subscriber/src/fmt/mod.rs b/tracing-subscriber/src/fmt/mod.rs index 09988b177a..eaef133dab 100644 --- a/tracing-subscriber/src/fmt/mod.rs +++ b/tracing-subscriber/src/fmt/mod.rs @@ -261,7 +261,8 @@ //! //! ```rust //! use tracing_subscriber::{fmt, EnvFilter}; -//! use tracing_subscriber::prelude::*; +//! use tracing_subscriber::subscribe::CollectExt; +//! use tracing_subscriber::util::SubscriberInitExt; //! //! let fmt_subscriber = fmt::subscriber() //! .with_target(false); @@ -846,12 +847,12 @@ impl CollectorBuilder { /// For example: /// ```rust /// use tracing_subscriber::fmt::format; - /// use tracing_subscriber::prelude::*; + /// use tracing_subscriber::field::MakeExt; /// /// let formatter = /// // Construct a custom formatter for `Debug` fields /// format::debug_fn(|writer, field, value| write!(writer, "{}: {:?}", field, value)) - /// // Use the `tracing_subscriber::MakeFmtExt` trait to wrap the + /// // Use the `tracing_subscriber::MakeExt` trait to wrap the /// // formatter so that a delimiter is added between fields. /// .delimited(", "); /// @@ -982,7 +983,7 @@ impl CollectorBuilder { /// /// ``` /// use tracing::Level; - /// use tracing_subscriber::prelude::*; + /// use tracing_subscriber::util::SubscriberInitExt; /// /// let builder = tracing_subscriber::fmt() /// // Set a max level filter on the collector diff --git a/tracing-subscriber/src/subscribe.rs b/tracing-subscriber/src/subscribe.rs index 48fa2f83c2..b4a3cdef97 100644 --- a/tracing-subscriber/src/subscribe.rs +++ b/tracing-subscriber/src/subscribe.rs @@ -52,7 +52,7 @@ use std::{any::TypeId, marker::PhantomData, ptr::NonNull}; /// For example: /// ```rust /// use tracing_subscriber::Subscribe; -/// use tracing_subscriber::prelude::*; +/// use tracing_subscriber::subscribe::CollectExt; /// use tracing::Collect; /// /// pub struct MySubscriber { @@ -94,7 +94,7 @@ use std::{any::TypeId, marker::PhantomData, ptr::NonNull}; /// Multiple `Subscriber`s may be composed in the same manner: /// ```rust /// # use tracing_subscriber::Subscribe; -/// # use tracing_subscriber::prelude::*; +/// # use tracing_subscriber::subscribe::CollectExt; /// # use tracing::Collect; /// pub struct MyOtherSubscriber { /// // ...