tracing icon indicating copy to clipboard operation
tracing copied to clipboard

macros: Allow field path segments to be keywords

Open svix-jplatte opened this issue 1 year ago • 5 comments

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

svix-jplatte avatar Apr 03 '24 13:04 svix-jplatte

Rebased to fix CI (hopefully).

svix-jplatte avatar May 02 '24 11:05 svix-jplatte

I'm working on fixing the new CI failures ^^

svix-jplatte avatar May 13 '24 16:05 svix-jplatte

Rebased to fix another round of CI failures, hoping it's the last time :crossed_fingers:

svix-jplatte avatar May 21 '24 15:05 svix-jplatte

CI failed again /o\ (error)

Looks like a Windows-specific nextest bug? :melting_face:

svix-jplatte avatar May 21 '24 16:05 svix-jplatte

And after another rebase, we have an ICE! Fix seems to be https://github.com/rust-lang/rust/pull/125493.

svix-jplatte avatar Jun 04 '24 09:06 svix-jplatte

Finally the stream of unrelated CI failures has ended! :sweat_smile: Can this be merged now? :)

svix-jplatte avatar Jul 05 '24 11:07 svix-jplatte

Hey @hds ! I see you merged this PR - can we get a fresh version of tracing-attributes that supports this?

nimrodkor avatar Sep 30 '24 18:09 nimrodkor

This needs a new tracing release, not tracing-attributes.

svix-jplatte avatar Oct 01 '24 07:10 svix-jplatte