rust-lang / rust-lang/rustfmt

Format issue on supertrait with bounds on associated types.

Open
#6,316 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

I-poor-formatting
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

For all version I could tests (master and nightly)

this code:

pub trait MyLongTraitName:
    MyLongBoundName<
        MyLongAssociatedType:
            SomeAnotherBound<
                YetAnotherType: YetAnotherBound,
                YetAnotherType2: YetAnotherBound2
            >,
        OtherType: SmallBound
            + SmallBound2
            + AnotherLongBound<
                WithSomeType: BeingBound,
                WithSomeType2: BeingBound,
                WithSomeType3: BeingBound
            >
            + SmallBound3
            + AnotherLongBound2<
                WithSomeType: BeingBound,
                WithSomeType2: BeingBound,
                WithSomeType3: BeingBound
            >,
    >
{
}

fn main() {}

gets formatted into:

pub trait MyLongTraitName:
    MyLongBoundName<
    MyLongAssociatedType: SomeAnotherBound<
        YetAnotherType: YetAnotherBound,
        YetAnotherType2: YetAnotherBound2,
    >,
    OtherType: SmallBound
                   + SmallBound2
                   + AnotherLongBound<
        WithSomeType: BeingBound,
        WithSomeType2: BeingBound,
        WithSomeType3: BeingBound,
    > + SmallBound3
                   + AnotherLongBound2<
        WithSomeType: BeingBound,
        WithSomeType2: BeingBound,
        WithSomeType3: BeingBound,
    >,
>
{
}

fn main() {}

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.

Research direction

Reproduce the formatting difference with the supplied Rust snippet using rustfmt on the reported versions. Trace how supertraits with bounds on associated types are formatted; done means the input no longer produces the incorrect indentation and the expected formatting is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.