rust-lang / rust-lang/rustfmt

Odd formatting of type def with many generics

Open
#5,892 12 comments 0 reactions 1 assignee View on GitHub

@johnhuichen is already working on this.

Since Aug 17, 2024.

A-2024-style-edition I-poor-formatting only-with-option
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I'm seeing this behavior in rustfmt 1.6.0-nightly (c469197b 2023-08-22):

// Before (correct in stable)
type AAAAAAAAAAAAA: BBBBBBBBBBBBBBB<
    CCCCCCCCCCCCCCCCC,
    DDDDDDDDDDDDDDDDD,
    EEEEEEEEEEEEEEEEE,
    FFFFFFFFFFFFFFFFF,
    GGGGGGGGGGGGGGGGG,
    HHHHHHHHHHHHHHHHH,
    IIIIIIIIIIIIIIIII,
>;

// After (hopefully not correct)
type AAAAAAAAAAAAA: BBBBBBBBBBBBBBB<
        CCCCCCCCCCCCCCCCC,
        DDDDDDDDDDDDDDDDD,
        EEEEEEEEEEEEEEEEE,
        FFFFFFFFFFFFFFFFF,
        GGGGGGGGGGGGGGGGG,
        HHHHHHHHHHHHHHHHH,
        IIIIIIIIIIIIIIIII,
    >;

It's completely unclear to me what the expected behavior is at this point, but judging by https://github.com/rust-lang/rustfmt/issues/5577 (specifically this: https://github.com/rust-lang/rustfmt/issues/5577#issuecomment-1407489330), this is not what you want.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.