-
Notifications
You must be signed in to change notification settings - Fork 888
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
where
clauses in GAT impls aren't formatted
#5580
Comments
Thanks for reaching out! I haven't had a chance to look into this yet, but I'll try to dig into this when I've got a little more time |
I hit an issue where a longer GAT where clause had a linebreak inserted. This then caused an internal error on |
@derekdreery would it be possible for you to post a code snippet? It would help in the investigation! |
Hi @ytmimi. It seems like I can't reproduce the problem - good news! It might have been something to do with the upgrade that is now resolved. Will report back here if I manage to reproduce it again. |
That is good news! I appreciate you taking the time to look into it |
@ytmimi no worries thanks for an awesome tool! |
Still seems to be occurring - the associated type declaration in the trait formats fine, but the impl remains untouched. This is very simple to reproduce: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9bd99971b4d896d785caed1506993ee4 |
Note that this doesn't require GATs; it happens on any associated type in an impl that has a where clause. From #5751: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=448e25cc22bb316f236e5ee6aeb455de. |
Aren't those still considered GATs? I was under the impression that any conditions on associated types were forbidden before GATs were stabilised, and the code is shared for all of them. |
I suspect this is now fixed, although in a weird way. Notice how the actual output differs from the expected output in the original issue comment. You can use the playground link provided there to reproduce. pub trait Test {
type Ref<'a>
where
Test: 'a;
}
impl<T, U> Test for (T,) {
type Ref<'a>
= (&'a T,)
where
T: 'a;
}
impl<T, U> Test for (T, U) {
type Ref<'a>
= (&'a T, &'a U)
where
T: 'a,
U: 'a;
} |
@ia0 Thanks for pointing out that this one is now resolved. The current formatting is expected. As of rustfmt 1.8.0 trailing where clauses in type aliases started to get formatted, and formatting is following the rules outlined by the style guide. If you'd like to propose a different default style you can open an issue on the style-team's repo, or if you'd like to propose a new formatting option in rustfmt you can open a new issue to outline the idea. |
closed by #5887 |
Sounds good, thanks for the link! |
Playground example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=1ef166f9e2b31f3f4093728719de4efc
The above autoformats to:
You'll notice that the
where
clauses for the impls aren't formatted at all, whereas I would expect:The text was updated successfully, but these errors were encountered: