Skip to content

[Bug] rustfmt chokes on a specific combo of method, macro, and string length #6627

@PoignardAzur

Description

@PoignardAzur

Here's the minimal reproduction I managed:

fn foo() {
    option.or_else(|| {
some_macro!(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
);
})
}

Rustfmt refuses to format this.

Some notes:

  • The indentation of the "aaaaa" line doesn't matter, but its length does. Removing a single a is enough for rustfmt to stop choking.
  • Replacing option.or_else with option_or_else is enough for rustfmt to stop choking.
  • The long line doesn't need to be a string. Literals and variable names work too, as do operators. But different types of content trigger the bug at different lenghts.

Anyway, I guess you know rustfmt internals better than I do, so I'll stop there.

gl;hf

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