Skip to content

Closing brace in {} can be separated #4125

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

Closed
varkor opened this issue Apr 18, 2020 · 1 comment · Fixed by #4187
Closed

Closing brace in {} can be separated #4125

varkor opened this issue Apr 18, 2020 · 1 comment · Fixed by #4187

Comments

@varkor
Copy link
Member

varkor commented Apr 18, 2020

See here, for instance, where rustfmt decided that

                (AngleBracketedArg::Arg(_), None) | (AngleBracketedArg::Constraint(_), Some(_)) => {
                }

was ideal. This looks ugly — {} (and any other paired symbols) should be kept together.

I originally opened this as #4098, but had not pointed out that this is in violating of the formatting spec: according to the RFC, empty blocks should be written {}: https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#blocks. This rule should take precedence over the line width rule.

@topecongiro
Copy link
Contributor

Hmm, so I think that we should try to break the arm patterns into multiple lines if the arm body is empty. If that is not possible, then put the empty block on the next line:

(AngleBracketedArg::Arg(_), None)
| (AngleBracketedArg::Constraint(_), Some(_)) => {}
// <= max width
UnsplitableVeryLongArmPattern =>
    {}

// > max width
UnsplitableVeryLongArmPattern => {}

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

Successfully merging a pull request may close this issue.

2 participants