From 445b41f030165fc67689c68110793975d8e8fa77 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Tue, 7 Jul 2020 19:41:45 -0400 Subject: [PATCH 1/3] tracing: attempt to monomorphization is_enabled call --- tracing/src/lib.rs | 7 +++++++ tracing/src/macros.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tracing/src/lib.rs b/tracing/src/lib.rs index f32f67fc7b..126cd66303 100644 --- a/tracing/src/lib.rs +++ b/tracing/src/lib.rs @@ -869,6 +869,13 @@ pub mod __macro_support { pub type Once = tracing_core::Once; } +#[doc(hidden)] +// resolves https://github.com/tokio-rs/tracing/issues/783 by forcing a monomorphization +// in tracing, not downstream crates. +pub fn is_enabled(meta: &crate::Metadata<'_>) -> bool { + crate::dispatcher::get_default(|current| current.enabled(meta)) +} + mod sealed { pub trait Sealed {} } diff --git a/tracing/src/macros.rs b/tracing/src/macros.rs index 024e6c71ce..405ded2ac1 100644 --- a/tracing/src/macros.rs +++ b/tracing/src/macros.rs @@ -1860,7 +1860,7 @@ macro_rules! is_enabled { true } else { let meta = $callsite.metadata(); - $crate::dispatcher::get_default(|current| current.enabled(meta)) + $crate::is_enabled(meta) } }}; } From 6fcef3ea105a986982b2f673a193aba4aec435f8 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Tue, 7 Jul 2020 20:03:16 -0400 Subject: [PATCH 2/3] Update tracing/src/lib.rs Co-authored-by: Eliza Weisman --- tracing/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tracing/src/lib.rs b/tracing/src/lib.rs index 126cd66303..2dd27e7144 100644 --- a/tracing/src/lib.rs +++ b/tracing/src/lib.rs @@ -872,6 +872,7 @@ pub mod __macro_support { #[doc(hidden)] // resolves https://github.com/tokio-rs/tracing/issues/783 by forcing a monomorphization // in tracing, not downstream crates. +#[inline] pub fn is_enabled(meta: &crate::Metadata<'_>) -> bool { crate::dispatcher::get_default(|current| current.enabled(meta)) } From 4c6442acd7aeac946264d5049ce2a6c870a4f47f Mon Sep 17 00:00:00 2001 From: David Barsky Date: Tue, 7 Jul 2020 20:06:30 -0400 Subject: [PATCH 3/3] remove unnecessary imports --- tracing/src/macros.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracing/src/macros.rs b/tracing/src/macros.rs index 405ded2ac1..76a35016ea 100644 --- a/tracing/src/macros.rs +++ b/tracing/src/macros.rs @@ -539,7 +539,7 @@ macro_rules! event { if $crate::level_enabled!($lvl) { #[allow(unused_imports)] - use $crate::{callsite, dispatcher, Event, field::{Value, ValueSet}}; + use $crate::{callsite, Event, field::{Value, ValueSet}}; use $crate::callsite::Callsite; let callsite = callsite! { name: concat!( @@ -584,7 +584,7 @@ macro_rules! event { ); if $crate::level_enabled!($lvl) { #[allow(unused_imports)] - use $crate::{callsite, dispatcher, Event, field::{Value, ValueSet}}; + use $crate::{callsite, Event, field::{Value, ValueSet}}; use $crate::callsite::Callsite; let callsite = callsite! { name: concat!(