Skip to content

nonstandard_macro_braces FN on format![""]/format!{""} #15594

@ada4a

Description

@ada4a

Summary

see the reproducer

Lint Name

nonstandard_macro_braces

Reproducer

I tried this code:

fn main() {
    println!();
    println!("");
    println![];
    println![""];
    println!{}
    println!{""}
    println!{};
    println!{""};
}

I expected to see this happen:

fn main() {
    println!();
    println!("");
    println![];   // lint
    println![""]; // lint
    println!{}    // lint
    println!{""}  // lint
    println!{};   // lint
    println!{""}; // lint
}

Instead, this happened:

fn main() {
    println!();
    println!("");
    println![];   // lint
    println![""]; // no lint
    println!{}    // lint
    println!{""}  // no lint
    println!{};   // lint
    println!{""}; // no lint
}

I thought this might have something to do with the way the macro gets expanded, but there doesn't seem to be an obvious correlation:

fn main() {
    { ::std::io::_print(format_args!("\n")); };
    { ::std::io::_print(format_args!("\n")); };
    { ::std::io::_print(format_args!("\n")); }; // lint
    { ::std::io::_print(format_args!("\n")); }; // no lint
    { ::std::io::_print(format_args!("\n")); }  // lint
    { ::std::io::_print(format_args!("\n")); }  // no lint
    { ::std::io::_print(format_args!("\n")); }; // lint
    { ::std::io::_print(format_args!("\n")); }; // no lint
}

Version

Rust playground:
- stable 1.89.0
- nightly 2025-08-29

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions