Fixes 5912
When `control_brace_style = "AlwaysNextLine"`, the code seems to always assume that `body_prefix` is `{`. This is however not the case when `match_arm_blocks = false`. This causes `block_sep` to introduce extra white space that causes the error.
The fix was to check if `body_prefix` is empty before matching on `ControlBraceStyle::AlwaysNextLine`.
* Inline format arguments for easier reading
Code becomes shorter and often easier to read when format args are inlined. Note that I skipped the mixed cases to make it more straightforward (could be done separatelly).
Also, there are two FIXME comments - for some reasons inlining makes format string exceed 100 char line width and crash.
```
cargo clippy --workspace --allow-dirty --fix --benches --tests --bins -- -A clippy::all -W clippy::uninlined_format_args
```
* address feedback
Previously we alwasy assumed the match arm pattern would have
`shape.width` - 5 characters of space to work with.
Now if we're formatting a block expression with a label we'll take the
label into account.
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.
This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.
This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
We no longer flatten a block that looks like this:
```rust
match val {
pat => { macro_call!() }
}
```
Currently, rust ignores trailing semicolons in macro expansion in
expression position (see https://github.com/rust-lang/rust/issues/33953)
If this is changed, flattening a block with a macro call may break the
user's code - the trailing semicolon will no longer parse if the macro
call occurs immediately on the right-hand side of the match arm
(e.g. `pat => macro_call!()`)
The `NotUnicode` branch was unecessarily put on a new line, although it
was within max width:
```diff
fn baz() {
let our_error_b = result_b_from_func.or_else(|e| match e {
NotPresent => Err(e).chain_err(|| "env var wasn't provided"),
- NotUnicode(_) => Err(e).chain_err(|| "env var was very very very borkæ–‡å—化ã"),
+ NotUnicode(_) => {
+ Err(e).chain_err(|| "env var was very very very borkæ–‡å—化ã")
+ }
});
}
```