@@ -730,6 +730,74 @@ make_backup = false
730
730
}
731
731
}
732
732
733
+ #[ cfg( test) ]
734
+ mod deprecated_option_match_arm_blocks {
735
+ use super :: * ;
736
+
737
+ #[ test]
738
+ fn test_old_option_set ( ) {
739
+ if !crate :: is_nightly_channel!( ) {
740
+ return ;
741
+ }
742
+ // Old option defaults to true - set it to false
743
+ let toml = r#"
744
+ unstable_features = true
745
+ match_arm_blocks = false
746
+ "# ;
747
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
748
+ assert_eq ! (
749
+ config. match_arm_wrapping( ) ,
750
+ MatchArmWrapping :: NoBlockFirstLine
751
+ ) ;
752
+ }
753
+
754
+ #[ test]
755
+ fn test_both_set ( ) {
756
+ if !crate :: is_nightly_channel!( ) {
757
+ return ;
758
+ }
759
+ let toml = r#"
760
+ unstable_features = true
761
+ match_arm_blocks = false
762
+ match_arm_wrapping = "Default"
763
+ "# ;
764
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
765
+ assert_eq ! ( config. match_arm_wrapping( ) , MatchArmWrapping :: Default ) ;
766
+ }
767
+
768
+ #[ test]
769
+ fn test_new_overridden ( ) {
770
+ if !crate :: is_nightly_channel!( ) {
771
+ return ;
772
+ }
773
+ let toml = r#"
774
+ unstable_features = true
775
+ merge_imports = false
776
+ "# ;
777
+ let mut config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
778
+ config. override_value ( "match_arm_wrapping" , "Default" ) ;
779
+ assert_eq ! ( config. match_arm_wrapping( ) , MatchArmWrapping :: Default ) ;
780
+ }
781
+
782
+ #[ test]
783
+ fn test_old_overridden ( ) {
784
+ if !crate :: is_nightly_channel!( ) {
785
+ return ;
786
+ }
787
+ let toml = r#"
788
+ unstable_features = true
789
+ match_arm_wrapping = "NoBlockFirstLine"
790
+ "# ;
791
+ let mut config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
792
+ config. override_value ( "match_arm_blocks" , "false" ) ;
793
+ // no effect: the new option always takes precedence
794
+ assert_eq ! (
795
+ config. match_arm_wrapping( ) ,
796
+ MatchArmWrapping :: NoBlockFirstLine
797
+ ) ;
798
+ }
799
+ }
800
+
733
801
#[ cfg( test) ]
734
802
mod use_small_heuristics {
735
803
use super :: * ;
0 commit comments