Skip to content

Extra spaces not removed in let-else statements #5585

@adamchalmers

Description

@adamchalmers

I think this is a bug. Consider this program playground

fn main() {
    let x: Option<i32> = None;
    let Some(y) = x       else {
        return;
    };
    println!("{y}");
}

I think the extra spaces on line 3, between x and else, should be removed by rustfmt. But on current stable they aren't.

Activity

ytmimi

ytmimi commented on Nov 3, 2022

@ytmimi
Contributor

Thanks for reaching out. rustfmt doesn't handle let-else formatting because the rules for how it should be formatted are still being discussed in rust-lang/style-team#165

You might also want to follow #4914 to keep track of the implementation on the rustfmt side once the rules have been codified in the fmt-rfc linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @adamchalmers@ytmimi

        Issue actions

          Extra spaces not removed in let-else statements · Issue #5585 · rust-lang/rustfmt