Closed upsuper closed 2 months ago
The struct literal formatting you're highlighting above is consistent with what happens if a chain contains multi-line elements. For example take the following function call:
fn m() {
bar(
Some(value_a),
Some(value_b),
Some(value_c),
Some(value_d),
Some(value_e),
Some(value_f),
Some(value_g),
)
.call_some_method()
.do_something(lots, of, arguments)
.do_another_thing(also, many, arguments)
}
I'd say that is inconsistent with when it follows a single line as well. Why would the chain get indented when it starts with a single line, but not when it starts with a multi-line block?
Got a response to my question in https://github.com/rust-lang/style-team/issues/195#issuecomment-2368749866, and there's nothing to change on the rustfmt side.
Currently code like
gets formatted as
However, something like
gets formatted as
Noting that the chained call is at the same depth as the block above.
This feels inconsistent, and I think it would be good if it can be formatted as
instead, or at least make it configurable.
On a separate note, if this whole thing is wrapped with another block, the formatting is even more weird, for example:
which I would expect to become something like