Skip to content

Rustfmt incorrectly adds whitespace inside multiline string literals within macro calls that have curly braces #5283

Open
@Aiden2207

Description

@Aiden2207

Code:

macro_rules! test {
    ($l:literal) => {};
}

fn main() {
    test!{
        "
"};
}

expected output:

macro_rules! test {
    ($l:literal) => {};
}

fn main() {
    test!{
        "
"
    };
}

actual output:

macro_rules! test {
    ($l:literal) => {};
}

fn main() {
    test! {
            "
    "};
}

Rustfmt added an extra indentation to the literal, including inside the string itself. This only occurs when the macro invocation is delimited by curly brackets, it works fine when square or parentheses are used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-macrosa-stringsString literalsbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions