tracing
tracing copied to clipboard
macros: Allow field path segments to be keywords
Motivation
Currently, a keyword like type fails compilation as (a path segment of) a field name, for no clear reason. Trying to use r#type instead leads to the r# being part of the field name, which is unhelpful¹.
Solution
Don't require the field path to match a macro_rules! expr, use repeated tt instead. I can't tell why this was ever required: The internal stringify macro was introduced in https://github.com/tokio-rs/tracing/commit/55091c92edb537bfc126e32f1f24acd614ad9fe0#diff-315c02cd05738da173861537577d159833f70f79cfda8cd7cf1a0d7a28ace31b with an expr matcher without any explanation, and no tests are failing from making it match upstream's stringify! input format.
Special thanks to whoever implemented the unstable macro-backtrace feature in rustc, otherwise this would have been nigh impossible to track down!
¹ this can likely be fixed too by some sort of "unraw" macro that turns r#foo into foo, but that's a separate change not made in this PR
Rebased to fix CI (hopefully).
I'm working on fixing the new CI failures ^^
Rebased to fix another round of CI failures, hoping it's the last time :crossed_fingers:
And after another rebase, we have an ICE! Fix seems to be https://github.com/rust-lang/rust/pull/125493.
Finally the stream of unrelated CI failures has ended! :sweat_smile: Can this be merged now? :)
Hey @hds ! I see you merged this PR - can we get a fresh version of tracing-attributes that supports this?
This needs a new tracing release, not tracing-attributes.