Closed mladedav closed 4 months ago
@hawkw This (commit 908cc432 after squashing and merging into master) should also be cherry-picked onto v0.1.x
. For future reference, if it applies to both, should I mention that in the description?
If so I can also try and change the PR template so that it's always clear which branches a PR should apply for and future contributors now to base things on master even if a patch is also needed on the v0.1.x
branch.
Motivation
2837
Const argumetns in
level!
macros do not work when in the first positoin.This also seems to have fixed #2748 where literals for fields names like
info!("foo" = 2)
could not be used outside theevent!
macro.Solution
Previsously,
level!($(args:tt))
was forwarded toevent!(target: ..., level: ..., { $(args:tt) })
but the added curly braces seem to have prevented theevent
macro from correctly understanding the arguments and it tried to pass them toformat!
.With this change there may have some performance impact when expanding the macros in most cases where the braces could have been added as it will take one more step.
These are the two relevant
event!
blocks I believe, the new tests used to expand to the first one (with empty fields), now they expand to the latter: