Skip to content

Tracing event macros should use #[clippy::format_args] to get clippy support #3385

@lilyball

Description

@lilyball

Bug Report

Version

tracing 0.1.41

Platform

Any platform

Crates

tracing

Description

Clippy has a lint uninlined_format_args that can be used to warn about format strings that use {} placeholders with variable args instead of inlining those args. This lint does not fire for tracing event macros because Clippy doesn't recognize the macro. It looks like Clippy can be taught to recognize the tracing event macros by adding the #[clippy::format_args] attribute; this attribute is supposed to work for any macro whose arguments end in format args, which the tracing event macros do.

By adding this attribute, code like

#![warn(clippy::uninlined_format_args)]

info!(foo = 5, "hello, {}", name);

should start producing a clippy warning that recommends info!(foo = 5, "hello, {name}") instead.

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