Skip to content

Commit 37343f4

Browse files
committed
Auto merge of rust-lang#114154 - calebcartwright:style-match-mac, r=joshtriplett
style-guide: don't flatten match arms with macro call This pulls forward the gist of the text that was added to the style guide in rust-lang/style-team#159 to account for needing to tweak/soften rustfmt's behavior based on the style guide prescriptions. There were a few options I considered, noted below, and although I don't particularly love any of them, I felt this was the lesser of the evils. r? `@joshtriplett`
2 parents e40e22b + 45b2559 commit 37343f4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/doc/style-guide/src/expressions.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ never use a block (unless the block is empty).
663663

664664
If the right-hand side consists of multiple statements, or has line comments,
665665
or the start of the line does not fit on the same line as the left-hand side,
666-
use a block.
666+
use a block. Do not flatten a right-hand side block containing a single macro call
667+
because its expanded form could contain a trailing semicolon.
667668

668669
Block-indent the body of a block arm.
669670

@@ -686,6 +687,10 @@ match foo {
686687
bar => {}
687688
// Trailing comma on last item.
688689
foo => bar,
690+
baz => qux!(),
691+
lorem => {
692+
ipsum!()
693+
}
689694
}
690695
```
691696

0 commit comments

Comments
 (0)