I don't really know what it's trying to do, but forgetting about everything
you've seen before when you see whitespace followed by a semicolon doesn't look
right to me, and absolutely no tests were hitting that.
This check was introduced in 5ecdd072d6, however
it was wrong even at that point, and now rustfmt still passes that test,
regardless of macro name.
Fixes#3154.
Extends the multi line condition to over other control flow
expressions, it now covers: `if`, `if let`, `for`, `loop`, `while`,
`while let` and `match`.
Refs: #3029
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
This improves the formatting and reading of code avoiding the
condition expression to be rewrite, if it goes multi line.
Fixes: #3029.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
If we're only aligning enum discriminants that are "not too far apart
(length-wise)", then this works really well for enums with
consistently-long or consistently-short idents, but not for the mixed
ones.
However, consistently-long idents is somewhate of an uncommon case and
overlong idents may be allowed to be formatted suboptimally if that
makes mixed-length idents work better (and it does in this case).
The issue with the current code is that comments are collapsed, so comments like
the one from the test end up in a string like:
```
"// this is a single line comment\n/* block = */"
```
I chose to fix it by detecting whether we're in a block comment starting from
the end instead, and tested a single-line comment ended in `*/` just for sanity,
ensuring line breaks are not removed in that case, which would break the
formatting.
The right fix eventually is probably to lex the comments properly, but this does
the work for now, I guess :)
Fixes#3025
Lines that didn't start with a comment sigil were returned unchanged in
comment::rewrite_comment. Then these unchanged lines were indented in
MacroBranch::rewrite.
The leading whitespace of a multine string was taken into account when
computing the `min_prefix_space_width`, even if that line couldn't be
trimmed. The consequence is it was always shifting the macro's content
to the right.