-
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
Fix brace_style="PreferSameLine"
with trailing_comma="Vertical"
results
#5556
base: master
Are you sure you want to change the base?
Conversation
brace_style="PreferSameLine"
with trailing_comma="Vertical"
results
Thanks for your first contribution to rustfmt 🎉 I try and get around to reviewing this in the coming days! |
T: UUUUUUUUUUU, { | ||
T: UUUUUUUUUUU { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically changing existing tests is not something we want to do and is usually a sign that the change needs to be version gated to prevent breaking formatting changes. However brace_style
is an unstable option so the version gate might not be necessary in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do it if I have to! 👍
fn lorem<S, T,>(lorem: S, ipsum: T,) | ||
where | ||
S: Add + Sub, | ||
T: Mul + Div, { | ||
// body | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also include a where clause with with a single bound. I like that you've included tests with trailing_comma: Always
and trailing_comma: Vertical
. Could you also expand the tests to include the other combinations of brace_style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review. I added test case for brace_style AlwaysNextLine and SameLineWhere pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for including those additional test cases! I'll have some time later this week to give this a more thorough review 😁
S: Add + Sub, | ||
T: Mul + Div { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this output, I'd actually expect there to be a trailing comma after T: Mul + Div
, since the where clause bounds were formatted vertically.
where | ||
S: Add + Sub, | ||
T: Mul + Div, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I don't understand the brace_style
config fully, but with an option like SameLineWhere
I'd expect this to format with the opening brace on the same line as the last where clause bound. Do you think the current behavior is correct?
fn lorem<S, T,>(lorem: S, ipsum: T,) | ||
where | ||
S: Add + Sub, | ||
T: Mul + Div, | ||
{ | ||
// body | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where clauses can appear in other contexts besides function definitions. Can we also add some examples with enum / struct definitions, and impl blocks to highlight how brace_style
interacts with trailing_comma
for those other language constructs?
Also including some tests with a single where clause bound (e.g. just S: Add + Sub
) would also be helpful to highlight the difference between how a list of bounds VS a single bound is formatted.
It looks like there's no activity last months. Is it ok, if I pick up the baton? |
@gentoid thanks for asking to get involved! You're more than welcome to open up a PR that builds off of this one, but I want to be mindful or your time and say that this is a fairly low priority issue and is unlikely to be reviewed any time soon. |
Ok, great.
That's fine. Thanks! |
Fixes #2321
brace_style="PreferSameLine"
andtrailing_comma="Vertical"
.Example
When
brace_style="PreferSameLine"
andtrailing_comma="Vertical"
configured, the results would be as in the following example:before
after