Skip to content

Commit

Permalink
simplify dot cases
Browse files Browse the repository at this point in the history
  • Loading branch information
guswynn committed Jan 13, 2022
1 parent 9b09230 commit 7f9aee9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 4 additions & 11 deletions tracing/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => (
Expand Down
3 changes: 2 additions & 1 deletion tracing/tests/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7f9aee9

Please sign in to comment.