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

Format issue on supertrait with bounds on associated types. #6316

Open
gui1117 opened this issue Sep 8, 2024 · 5 comments
Open

Format issue on supertrait with bounds on associated types. #6316

gui1117 opened this issue Sep 8, 2024 · 5 comments

Comments

@gui1117
Copy link

gui1117 commented Sep 8, 2024

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() {}
@ytmimi
Copy link
Contributor

ytmimi commented Sep 9, 2024

Thanks for the report. Confirming I can reproduce this the latest master rustfmt 1.7.1-nightly (1a70f40 2024-09-03)

@gui1117
Copy link
Author

gui1117 commented Sep 10, 2024

It seems those types are formatted with the overflow formatting, do you suggest to change the overflow formatting or change formatting so it doesn't go into overflow?

@ytmimi
Copy link
Contributor

ytmimi commented Sep 10, 2024

@gui1117 have you started looking into this issue?

@gui1117
Copy link
Author

gui1117 commented Sep 10, 2024

@gui1117 have you started looking into this issue?

Not really, and I would prefer not because I struggle to understand the code.
But I look a bit when I have free time.

@ytmimi
Copy link
Contributor

ytmimi commented Sep 11, 2024

@gui1117 no worries. Based on #6316 (comment) I thought maybe you'd looked through the code.

Not really, and I would prefer not because I struggle to understand the code.

It's quite a tricky part of the codebase. Definitely don't feel obligated to dive in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants