Skip to content

Error formatting with block comment after match scrutinee #6663

@austenadler

Description

@austenadler

I am getting error[internal]: left behind trailing whitespace on the latest stable 1.90 and nightly rustc 1.92.0-nightly (4645a7988 2025-09-17)

Minimum example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=67d8495779f0d47760dff7bea024ad75

fn main() {
    match () /*x*/ {
     
        _ => {}
    }
}

The issue is caused by the comment after the scrutinee. If you remove the x (but keep the /**/), it will format, or if you replace x with any number of spaces, it formats fine.

Also fails if scrutinee is a variable name.

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