Skip to content

error[internal]: left behind trailing whitespace in file with long string line #6738

@VojtaStanek

Description

@VojtaStanek

In my own code I have ran into following bug.

Reproduction:

impl Foo {
    fn execute() -> () {
        func()
            .cond_where(
                {
                    let _ = ();
                
                    ()
                }
            )
            .map({
                func(
                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                );
            });
    }
}

note there are whitespaces left on line 7.

Rustfmt exits with:

error[internal]: left behind trailing whitespace
 --> /playground/src/main.rs:7:7:1
  |
7 |                 
  | ^^^^^^^^^^^^^^^^
  |

warning: rustfmt has failed to format. See previous 1 errors.

Tested with 1.8.0-stable (2025-11-07 ed61e7d7e2) on rust playground.

Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=ad4bcc62a9593ffd9998f1977aac0c83

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-trailing-whitespaceIssue: internal error; left behind trailing whitespaceneeds-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions