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 #5930

Closed
IsaacShelton opened this issue Sep 30, 2023 · 1 comment
Closed

Long slice patterns are not getting wrapped #5930

IsaacShelton opened this issue Sep 30, 2023 · 1 comment

Comments

@IsaacShelton
Copy link

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

This problem #4530 was marked as fixed a few years ago, but the issue must have been reintroduced as the problem exists in rustfmt 1.6.0-nightly (8ce4540b 2023-09-29) (obtained through rustup).

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 },
        ] => {}
        _ => {}
    }
}
@calebcartwright
Copy link
Member

Thanks but going to close as the change/fix already exists but is behind the version/style edition gate as required by the stability policy.

If you run with --config version=Two against the snippet you'll see the desired output

@calebcartwright calebcartwright closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants