Skip to content

Long slice patterns are not getting wrapped #4530

Closed
@erickt

Description

@erickt

It seems that rustfmt doesn't wrap long slice pattern lines.

Input

enum Foo {
    IAmALongVariantNameIJustKeepGoingOn { a: usize, b: usize },
}

fn main() {
    let foos = vec![Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 }];

    match foos.as_slice() {
        [
            Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 },
            Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 },
            Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 },
        ] => {}
        _ => {}
    }
}

Output

enum Foo {
    IAmALongVariantNameIJustKeepGoingOn { a: usize, b: usize },
}

fn main() {
    let foos = vec![Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 }];

    match foos.as_slice() {
        [Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 }, Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 }, Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 }] =>
            {}
        _ => {}
    }
}

Expected output

enum Foo {
    IAmALongVariantNameIJustKeepGoingOn { a: usize, b: usize },
}

fn main() {
    let foos = vec![Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 }];

    match foos.as_slice() {
        [
            Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 },
            Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 },
            Foo::IAmALongVariantNameIJustKeepGoingOn { a: 0, b: 0 },
        ] => {}
        _ => {}
    }
}

Meta

  • rustfmt version: rustfmt 1.4.26-nightly (293d7d0 2020-11-14) and rustfmt 2.0.0-rc.2-nightly (8d68652 2020-11-14)
  • From where did you install rustfmt?: rustup, and built by hand

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions