Skip to content

Unstable code formatting involving some macros (every rustfmt run indents some lines further) #88959

Closed
@chris-morgan

Description

@chris-morgan

Sample code, minimised as far as I was able:

macro_rules! alpha {
    () => {
        macro_rules! beta {
            () => {
                gamma!(
                    *
                )
            };
        }
    };
}

Every time you run rustfmt over it, it indents lines 4–9 by another two levels.

Closely related, if you remove the first and last two lines (the outer macro_rules layer), formatting leaves lines 4–9 at whatever level it finds them rather than correcting their indentation. (But this is probably better than indenting them by two levels.)

Reproduced on rustc 1.57.0-nightly (c3c0f80 2021-09-14).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions