mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00

## Motivation A common pattern in `tokio-trace` is to use the value of a local variable as a field on a span or event. Currently, this requires code like: ```rust info!(foo = foo); ``` which is not particularly ergonomic given how commonly this occurs. Struct initializers support a shorthand syntax for fields where the name of the field is the same as a local variable, and `tokio-trace` should as well. ## Solution This branch adds support for syntax like ```rust let foo = ...; info!(foo); ``` and ```rust let foo = Foo { bar: ..., ... }; info!(foo.bar) ``` to the `tokio-trace` span and event macros. This syntax also works with the `Debug` and `Display` field shorthand. The span macros previously used a field name with no value to indicate an uninitialized field. A new issue, #1138, has been opened for finding a replacement syntax for uninitialized fields. Until then, the `tokio-trace` macros will no longer provide a way to create fields without values, although the `-core` API will continue to support this. Closes #1062 Signed-off-by: Eliza Weisman <eliza@buoyant.io>