-
Notifications
You must be signed in to change notification settings - Fork 909
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
Or pattern formatting style weirdly inconsistent for lines of the same length #4556
Comments
Thank you for reaching out @ratmice. However, this is working as designed. The formatting emitted by rustfmt is governed by the Rust Style Guide which defines explicit formatting prescriptions for all code constructs, and accordingly rustfmt is a pretty-printer style code formatter that reformats each node in the AST according to those respective rules. The formatting varies here because by changing the struct field name from https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#struct-literals Going to close this accordingly |
@calebcartwright what I don't understand is the lines are literally the same length (in the 2nd and 3rd example), it changes |
The lit width is used to determine the layout of the "body" (e.g. the fields) based on formatted length of the fields/structrest elements; the path (name) doesn't come into the picture for that check but of course does for in other width limit scenarios like total line width, or a containing element width constraint. By default,
|
Input
Given lines of the same or longer length but different contributing factors (enum name vs variant field name
elem
vselement
).Output
Expected output
The last ends up very poor, and should preferably be rendered similarly to the first two blocks.
note that line length on the formatting of the 2nd block actually increases.
I tend to prefer the way that the first/longest block lays out the
=> expression
on the next line,over the middle which pushes the beginning of the
=>
all the way to column 86Meta
I looked didn't see a duplicate for this, with #4005 being the closest that I found.
The text was updated successfully, but these errors were encountered: