From 7f9aee9c80ed2bddff382d99f838318d283c9c28 Mon Sep 17 00:00:00 2001 From: Gus Wynn Date: Thu, 13 Jan 2022 08:09:15 -0800 Subject: [PATCH] simplify dot cases --- tracing/src/macros.rs | 15 ++++----------- tracing/tests/macros.rs | 3 ++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tracing/src/macros.rs b/tracing/src/macros.rs index 8e6cd795f0..f9fac13afa 100644 --- a/tracing/src/macros.rs +++ b/tracing/src/macros.rs @@ -846,27 +846,20 @@ macro_rules! enabled { ); // These two cases handle fields with no values - (target: $target:expr, $lvl:expr, $($k:ident).+) => ( - $crate::enabled!(target: $target, $lvl, $($k).+,) - ); - (target: $target:expr, $lvl:expr, $($k:ident).+, $($field:tt)*) => ( + (target: $target:expr, $lvl:expr, $($field:tt)*) => ( $crate::enabled!( target: $target, $lvl, - { $($k).+, $($field)*} + { $($field)*} ) ); - - ($lvl:expr, $($k:ident).+, $($field:tt)*) => ( + ($lvl:expr, $($field:tt)*) => ( $crate::enabled!( target: module_path!(), $lvl, - { $($k).+, $($field)*} + { $($field)*} ) ); - ($lvl:expr, $($k:ident).+) => ( - $crate::enabled!($lvl, $($k).+,) - ); // Simplest `enabled!` case ( $lvl:expr ) => ( diff --git a/tracing/tests/macros.rs b/tracing/tests/macros.rs index d010a804dc..0a32ebfc3f 100644 --- a/tracing/tests/macros.rs +++ b/tracing/tests/macros.rs @@ -339,7 +339,8 @@ fn event() { fn enabled() { enabled!(Level::DEBUG, foo, bar.baz, quux,); enabled!(Level::DEBUG, message); - enabled!(Level::INFO, foo, bar.baz, quux, messaged,); + enabled!(Level::INFO, foo, bar.baz, quux, message,); + enabled!(Level::INFO, foo, bar., message,); enabled!(Level::DEBUG, foo); enabled!(Level::DEBUG);