File tree 4 files changed +12
-13
lines changed
4 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,7 @@ macro_rules! create_config {
435
435
self . match_arm_wrapping. 2 = if self . match_arm_blocks( ) {
436
436
MatchArmWrapping :: Default
437
437
} else {
438
- MatchArmWrapping :: NoBlockFirstLine
438
+ MatchArmWrapping :: FitFirstLine
439
439
} ;
440
440
}
441
441
}
Original file line number Diff line number Diff line change @@ -745,10 +745,7 @@ make_backup = false
745
745
match_arm_blocks = false
746
746
"# ;
747
747
let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
748
- assert_eq ! (
749
- config. match_arm_wrapping( ) ,
750
- MatchArmWrapping :: NoBlockFirstLine
751
- ) ;
748
+ assert_eq ! ( config. match_arm_wrapping( ) , MatchArmWrapping :: FitFirstLine ) ;
752
749
}
753
750
754
751
#[ test]
@@ -786,15 +783,12 @@ make_backup = false
786
783
}
787
784
let toml = r#"
788
785
unstable_features = true
789
- match_arm_wrapping = "NoBlockFirstLine "
786
+ match_arm_wrapping = "FitFirstLine "
790
787
"# ;
791
788
let mut config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
792
789
config. override_value ( "match_arm_blocks" , "false" ) ;
793
790
// no effect: the new option always takes precedence
794
- assert_eq ! (
795
- config. match_arm_wrapping( ) ,
796
- MatchArmWrapping :: NoBlockFirstLine
797
- ) ;
791
+ assert_eq ! ( config. match_arm_wrapping( ) , MatchArmWrapping :: FitFirstLine ) ;
798
792
}
799
793
}
800
794
Original file line number Diff line number Diff line change @@ -450,9 +450,12 @@ pub enum MatchArmWrapping {
450
450
Default ,
451
451
/// Same as Default, except don't block wrap match arms when the opening line of its body
452
452
/// can't fit on the same line as the `=>`.
453
- NoBlockFirstLine ,
453
+ FitFirstLine ,
454
454
/// Always block wrap match arms
455
455
Always ,
456
456
/// Preserve the block wrapping on match arms
457
457
Preserve ,
458
+ /// Same as Default, except wrap the match arm if the entire body cannot fit on the same line
459
+ /// as the `=>`.
460
+ FitEntireBody ,
458
461
}
Original file line number Diff line number Diff line change @@ -420,7 +420,7 @@ fn rewrite_match_body(
420
420
421
421
let indent_str = shape. indent . to_string_with_newline ( context. config ) ;
422
422
let ( body_prefix, body_suffix) = match context. config . match_arm_wrapping ( ) {
423
- MatchArmWrapping :: NoBlockFirstLine => ( "" , String :: from ( "," ) ) ,
423
+ MatchArmWrapping :: FitFirstLine => ( "" , String :: from ( "," ) ) ,
424
424
_ if !context. inside_macro ( ) => {
425
425
let comma = if context. config . match_block_trailing_comma ( ) {
426
426
","
@@ -501,7 +501,9 @@ fn rewrite_match_body(
501
501
502
502
match ( orig_body, next_line_body) {
503
503
( Some ( ref orig_str) , Some ( ref next_line_str) )
504
- if prefer_next_line ( orig_str, next_line_str, RhsTactics :: Default ) =>
504
+ if prefer_next_line ( orig_str, next_line_str, RhsTactics :: Default )
505
+ || ( context. config . match_arm_wrapping ( ) == MatchArmWrapping :: FitEntireBody
506
+ && orig_str. contains ( '\n' ) ) =>
505
507
{
506
508
combine_next_line_body ( next_line_str)
507
509
}
You can’t perform that action at this time.
0 commit comments