Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long slice patterns are not getting wrapped #4530

Closed
erickt opened this issue Nov 16, 2020 · 0 comments · Fixed by #4994
Closed

Long slice patterns are not getting wrapped #4530

erickt opened this issue Nov 16, 2020 · 0 comments · Fixed by #4994
Assignees

Comments

@erickt
Copy link
Contributor

erickt commented Nov 16, 2020

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
pcwalton added a commit to pcwalton/rustfmt-1 that referenced this issue Sep 18, 2021
pcwalton added a commit to pcwalton/rustfmt-1 that referenced this issue Sep 18, 2021
pcwalton added a commit to pcwalton/rustfmt-1 that referenced this issue Sep 18, 2021
pcwalton added a commit to pcwalton/rustfmt-1 that referenced this issue Oct 5, 2021
calebcartwright pushed a commit that referenced this issue Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants