-
Notifications
You must be signed in to change notification settings - Fork 56
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
Multi-line expressions on both sides of an assignment shouldn't wrap to the same indent level #189
Comments
This also happens with a simpler version: impl SomeType {
fn method(&mut self) {
self.array[array_index as usize]
.as_mut()
.expect("thing must exist")
.extra_info =
long_long_long_long_long_long_long_long_long_long_long_long_long_long_long;
}
} |
Turns out this happens with other binary operators like @compiler-errors came up with a concise rule for how to fix these cases:
|
We discussed this in the T-style meeting today, and the consensus was that we should adopt the rule that Josh just mentioned:
(Credit to @compiler-errors for this rule.) |
Use the indentation of the *last* line of the first operand, not the first. Fixes rust-lang/style-team#189
Use the indentation of the *last* line of the first operand, not the first. Fixes rust-lang/style-team#189
…ent, r=compiler-errors style-guide: When breaking binops handle multi-line first operand better Use the indentation of the *last* line of the first operand, not the first. Fixes rust-lang/style-team#189
Rollup merge of rust-lang#119838 - joshtriplett:style-guide-binop-indent, r=compiler-errors style-guide: When breaking binops handle multi-line first operand better Use the indentation of the *last* line of the first operand, not the first. Fixes rust-lang/style-team#189
@rustbot claim |
I discovered this issue in some code I'm working on, and constructed this sample to match the issue I observed:
The fields of
ExtraInfo
should not be wrapping to the same indent level as the method chain. I can imagine a few ways to format this better, and don't feel strongly about which one, just that this definitely isn't the right formatting.The text was updated successfully, but these errors were encountered: