Skip to content

instrument macro compiles just fine with a missing comma #3377

@typetetris

Description

@typetetris

Bug Report

If you omit the comma after certain specifiers in the instruments macros inputs,
it compiles and works just fine.

The documentation doesn't mention commas being optional, so this is probably
a bug?

Also if you usually use the commas and forget them in some other place you end
up with a stylistic mixture.

Also, it might hint at another bug in parsing the macros inputs if it wasn't intended?

Version

tracing-test v0.1.0 (/home/Projects/tracing-test)
├── tracing v0.1.41
│   ├── tracing-attributes v0.1.30 (proc-macro)
│   └── tracing-core v0.1.34
└── tracing-subscriber v0.3.20
    ├── tracing-core v0.1.34 (*)
    └── tracing-log v0.2.0
        └── tracing-core v0.1.34 (*)

Platform

Darwin MBP-von-Codefy.fritz.box 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041 arm64

Crates

tracing

Description

This compiles just fine, even if the comma after skip_all is missing:

use tracing::instrument;

#[instrument(skip_all fields(mowmow))]
fn test(level_of_happiness_today: u16) {
    tracing::Span::current().record("mowmow", "mooo");
    tracing::error!(
        "Hello, tracing! I feel a happiness of {} out of 10 today.",
        level_of_happiness_today
    );
}

fn main() {
    tracing_subscriber::fmt().init();
    test(9);
}

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