Skip to content

Put operands on its own line when each fits in a single line #2679

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

Merged
merged 4 commits into from
May 6, 2018

Conversation

topecongiro
Copy link
Contributor

Currently rustfmt puts as many operands as possible in a single line, then after exceeding max width, it puts other operands on its own line. e.g.

        if self.items.len() == 1 && self.one_line_width != 0 && !list_items[0].has_comment()
             && !list_items[0].inner_as_ref().contains('\n')
             && ::lists::total_item_width(&list_items[0]) <= self.one_line_width

Instead, we should put each operand on its own line when it fits in a single line:

        if self.items.len() == 1
             && self.one_line_width != 0
             && !list_items[0].has_comment()
             && !list_items[0].inner_as_ref().contains('\n')
             && ::lists::total_item_width(&list_items[0]) <= self.one_line_width

Closes #2530.

@nrc
Copy link
Member

nrc commented May 6, 2018

Hmm, so this is a spec change. The style guide is a bit ambiguous, nothing is specified in the text, but the example implies multiple clauses per line. There was no discussion of this in the issue.

I think this is probably better though and we should amend the style guide.

Thanks for the PR!

@nrc nrc merged commit effba71 into rust-lang:master May 6, 2018
@topecongiro topecongiro deleted the multi-lined-binary branch July 21, 2019 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants