@@ -1695,15 +1695,20 @@ fn rewrite_match_body(
1695
1695
is_last : bool ,
1696
1696
) -> Option < String > {
1697
1697
let ( extend, body) = flatten_arm_body ( context, body) ;
1698
-
1699
- let comma = arm_comma ( context. config , body, is_last) ;
1700
- let alt_block_sep = String :: from ( "\n " ) + & shape. indent . block_only ( ) . to_string ( context. config ) ;
1701
- let alt_block_sep = alt_block_sep. as_str ( ) ;
1702
1698
let ( is_block, is_empty_block) = if let ast:: ExprKind :: Block ( ref block) = body. node {
1703
1699
( true , is_empty_block ( block, context. codemap ) )
1704
1700
} else {
1705
1701
( false , false )
1706
1702
} ;
1703
+ let extend = if context. config . match_arm_forces_newline ( ) {
1704
+ is_block
1705
+ } else {
1706
+ extend
1707
+ } ;
1708
+
1709
+ let comma = arm_comma ( context. config , body, is_last) ;
1710
+ let alt_block_sep = String :: from ( "\n " ) + & shape. indent . block_only ( ) . to_string ( context. config ) ;
1711
+ let alt_block_sep = alt_block_sep. as_str ( ) ;
1707
1712
1708
1713
let combine_orig_body = |body_str : & str | {
1709
1714
let block_sep = match context. config . control_brace_style ( ) {
@@ -1716,7 +1721,11 @@ fn rewrite_match_body(
1716
1721
1717
1722
let forbid_same_line = has_guard && pats_str. contains ( '\n' ) && !is_empty_block;
1718
1723
let next_line_indent = if is_block {
1719
- shape. indent
1724
+ if is_empty_block {
1725
+ shape. indent . block_indent ( context. config )
1726
+ } else {
1727
+ shape. indent
1728
+ }
1720
1729
} else {
1721
1730
shape. indent . block_indent ( context. config )
1722
1731
} ;
@@ -1772,7 +1781,7 @@ fn rewrite_match_body(
1772
1781
1773
1782
match rewrite {
1774
1783
Some ( ref body_str)
1775
- if !forbid_same_line
1784
+ if !forbid_same_line && !context . config . match_arm_forces_newline ( )
1776
1785
&& ( is_block
1777
1786
|| ( !body_str. contains ( '\n' ) && body_str. len ( ) <= body_shape. width ) ) =>
1778
1787
{
0 commit comments