@@ -415,27 +415,23 @@ fn rewrite_match_body(
415
415
}
416
416
417
417
let indent_str = shape. indent . to_string_with_newline ( context. config ) ;
418
- let ( body_prefix, body_suffix) = if context. config . match_arm_wrapping ( )
419
- == MatchArmWrapping :: Default
420
- && !context. inside_macro ( )
421
- {
422
- let comma = if context. config . match_block_trailing_comma ( ) {
423
- ","
424
- } else {
425
- ""
426
- } ;
427
- let semicolon = if context. config . version ( ) == Version :: One {
428
- ""
429
- } else {
430
- if semicolon_for_expr ( context, body) {
431
- ";"
418
+ let ( body_prefix, body_suffix) = match context. config . match_arm_wrapping ( ) {
419
+ MatchArmWrapping :: Default | MatchArmWrapping :: Always if !context. inside_macro ( ) => {
420
+ let comma = if context. config . match_block_trailing_comma ( ) {
421
+ ","
432
422
} else {
433
423
""
434
- }
435
- } ;
436
- ( "{" , format ! ( "{}{}}}{}" , semicolon, indent_str, comma) )
437
- } else {
438
- ( "" , String :: from ( "," ) )
424
+ } ;
425
+
426
+ let semicolon = match context. config . version ( ) {
427
+ Version :: One => "" ,
428
+ _ if semicolon_for_expr ( context, body) => ";" ,
429
+ _ => "" ,
430
+ } ;
431
+
432
+ ( "{" , format ! ( "{}{}}}{}" , semicolon, indent_str, comma) )
433
+ }
434
+ _ => ( "" , String :: from ( "," ) ) ,
439
435
} ;
440
436
441
437
let block_sep = match context. config . control_brace_style ( ) {
@@ -464,7 +460,10 @@ fn rewrite_match_body(
464
460
let orig_body_shape = shape
465
461
. offset_left ( extra_offset ( pats_str, shape) + 4 )
466
462
. and_then ( |shape| shape. sub_width ( comma. len ( ) ) ) ;
467
- let orig_body = if forbid_same_line || !arrow_comment. is_empty ( ) {
463
+ let orig_body = if forbid_same_line
464
+ || !arrow_comment. is_empty ( )
465
+ || ( !is_block && context. config . match_arm_wrapping ( ) == MatchArmWrapping :: Always )
466
+ {
468
467
None
469
468
} else if let Some ( body_shape) = orig_body_shape {
470
469
let rewrite = nop_block_collapse (
@@ -485,6 +484,7 @@ fn rewrite_match_body(
485
484
} else {
486
485
None
487
486
} ;
487
+
488
488
let orig_budget = orig_body_shape. map_or ( 0 , |shape| shape. width ) ;
489
489
490
490
// Try putting body on the next line and see if it looks better.
@@ -493,6 +493,7 @@ fn rewrite_match_body(
493
493
format_expr ( body, ExprType :: Statement , context, next_line_body_shape) ,
494
494
next_line_body_shape. width ,
495
495
) ;
496
+
496
497
match ( orig_body, next_line_body) {
497
498
( Some ( ref orig_str) , Some ( ref next_line_str) )
498
499
if prefer_next_line ( orig_str, next_line_str, RhsTactics :: Default ) =>
0 commit comments