Skip to content

pretty printer strips trailing commas from unsafe match arms #19077

Closed
@erickt

Description

@erickt

The pretty printer is removing trailing commas from match arms that contain an unsafe { ... } block expression:

#![allow(unused_unsafe)]

fn main() {
    let _ = match true {
        true => unsafe { true },
        false => false,
    };
}

Running it with rustc --pretty normal test.rs produces:

#![allow(unused_unsafe)]

fn main() { let _ = match true { true => unsafe { true } false => false, }; }

Which when compiled errors with:

test2.rs:3:58: 3:63 error: expected one of `,`, `}`, found `false`
test2.rs:3 fn main() { let _ = match true { true => unsafe { true } false => false, }; }
                                                                    ^~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-prettyArea: Pretty printing (including `-Z unpretty`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions