Skip to content

info!/error!/warn! macros don't accept constants for first field name #2837

Closed
@tim3z

Description

@tim3z

Version

tracing v0.1.40
    ├── tracing-attributes v0.1.27 (proc-macro)
    └── tracing-core v0.1.32

Platform

macOS 13.6
Darwin HAMACL00492 22.6.0 Darwin Kernel Version 22.6.0: Tue Nov 7 21:40:08 PST 2023; root:xnu-8796.141.3.702.9~2/RELEASE_ARM64_T6000 arm64

stable-aarch64-apple-darwin (default)
rustc 1.74.1 (a28077b28 2023-12-04)

Description

I expected the following sample to compile. The problem is the same on all the different log levels (I tried only info, warn and error)

const FOO: &str = "foo";
fn main() {
    tracing::info!(bar = 42, { FOO } = 23, "tada"); // works
    tracing::event!(tracing::Level::INFO, { FOO } = 23, bar = 42, "tada"); // works, too
    tracing::info!({ FOO } = 23, bar = 42, "tada"); // doesn't compile
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions