]> git.lizzy.rs Git - rust.git/blobdiff - src/config/mod.rs
Add width for codeblocks in comments (#5372)
[rust.git] / src / config / mod.rs
index dfce7977bfea1e06d4b9df2b72e931b6336e47fb..f49c18d3a4603a9804168664629c314181d7838f 100644 (file)
@@ -5,7 +5,6 @@
 use std::path::{Path, PathBuf};
 use std::{env, fs};
 
-use regex::Regex;
 use thiserror::Error;
 
 use crate::config::config_type::ConfigType;
@@ -22,7 +21,6 @@
 pub(crate) mod options;
 
 pub(crate) mod file_lines;
-pub(crate) mod license;
 pub(crate) mod lists;
 
 // This macro defines configuration options used in rustfmt. Each option
     hard_tabs: bool, false, true, "Use tab characters for indentation, spaces for alignment";
     tab_spaces: usize, 4, true, "Number of spaces per tab";
     newline_style: NewlineStyle, NewlineStyle::Auto, true, "Unix or Windows line endings";
+    indent_style: IndentStyle, IndentStyle::Block, false, "How do we indent expressions or items";
+
+    // Width Heuristics
     use_small_heuristics: Heuristics, Heuristics::Default, true, "Whether to use different \
         formatting for items and expressions if they satisfy a heuristic notion of 'small'";
-    indent_style: IndentStyle, IndentStyle::Block, false, "How do we indent expressions or items";
+    width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false,
+        "'small' heuristic values";
+    fn_call_width: usize, 60, true, "Maximum width of the args of a function call before \
+        falling back to vertical formatting.";
+    attr_fn_like_width: usize, 70, true, "Maximum width of the args of a function-like \
+        attributes before falling back to vertical formatting.";
+    struct_lit_width: usize, 18, true, "Maximum width in the body of a struct lit before \
+        falling back to vertical formatting.";
+    struct_variant_width: usize, 35, true, "Maximum width in the body of a struct variant before \
+        falling back to vertical formatting.";
+    array_width: usize, 60, true,  "Maximum width of an array literal before falling \
+        back to vertical formatting.";
+    chain_width: usize, 60, true, "Maximum length of a chain to fit on a single line.";
+    single_line_if_else_max_width: usize, 50, true, "Maximum line length for single line if-else \
+        expressions. A value of zero means always break if-else expressions.";
 
     // Comments. macros, and strings
     wrap_comments: bool, false, false, "Break comments to fit on the line";
     format_code_in_doc_comments: bool, false, false, "Format the code snippet in doc comments.";
+    doc_comment_code_block_width: usize, 100, false, "Maximum width for code snippets in doc \
+        comments. No effect unless format_code_in_doc_comments = true";
     comment_width: usize, 80, false,
         "Maximum length of comments. No effect unless wrap_comments = true";
     normalize_comments: bool, false, false, "Convert /* */ comments to // comments where possible";
     normalize_doc_attributes: bool, false, false, "Normalize doc attributes as doc comments";
-    license_template_path: String, String::default(), false,
-        "Beginning of file must match license template";
     format_strings: bool, false, false, "Format string literals where necessary";
     format_macro_matchers: bool, false, false,
         "Format the metavariable matching patterns in macros";
     format_macro_bodies: bool, true, false, "Format the bodies of macros";
+    hex_literal_case: HexLiteralCase, HexLiteralCase::Preserve, false,
+        "Format hexadecimal integer literals";
 
     // Single line expressions and items
     empty_item_single_line: bool, true, false,
     // Misc.
     remove_nested_parens: bool, true, true, "Remove nested parens";
     combine_control_expr: bool, true, false, "Combine control expressions with function calls";
+    short_array_element_width_threshold: usize, 10, true,
+        "Width threshold for an array element to be considered short";
     overflow_delimited_expr: bool, false, false,
         "Allow trailing bracket/brace delimited expressions to overflow";
     struct_field_align_threshold: usize, 0, false,
         "Add trailing semicolon after break, continue and return";
     trailing_comma: SeparatorTactic, SeparatorTactic::Vertical, false,
         "How to handle trailing commas for lists";
-    match_block_trailing_comma: bool, false, false,
+    match_block_trailing_comma: bool, false, true,
         "Put a trailing comma after a block based match arm (non-block arms are not affected)";
     blank_lines_upper_bound: usize, 1, false,
         "Maximum number of blank lines which can be put between items";
     inline_attribute_width: usize, 0, false,
         "Write an item and its attribute on the same line \
         if their combined width is below a threshold";
+    format_generated_files: bool, true, false, "Format generated files";
 
     // Options that can change the source code beyond whitespace/blocks (somewhat linty things)
     merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one";
         "Require a specific version of rustfmt";
     unstable_features: bool, false, false,
             "Enables unstable features. Only available on nightly channel";
-    disable_all_formatting: bool, false, false, "Don't reformat anything";
+    disable_all_formatting: bool, false, true, "Don't reformat anything";
     skip_children: bool, false, false, "Don't reformat out of line modules";
     hide_parse_errors: bool, false, false, "Hide errors from the parser";
     error_on_line_overflow: bool, false, false, "Error if unable to get all lines within max_width";
     error_on_unformatted: bool, false, false,
         "Error if unable to get comments or string literals within max_width, \
          or they are left with trailing whitespaces";
-    report_todo: ReportTactic, ReportTactic::Never, false,
-        "Report all, none or unnumbered occurrences of TODO in source file comments";
-    report_fixme: ReportTactic, ReportTactic::Never, false,
-        "Report all, none or unnumbered occurrences of FIXME in source file comments";
     ignore: IgnoreList, IgnoreList::default(), false,
         "Skip formatting the specified files and directories";
 
     file_lines: FileLines, FileLines::all(), false,
         "Lines to format; this is not supported in rustfmt.toml, and can only be specified \
          via the --file-lines option";
-    width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false,
-        "'small' heuristic values";
     emit_mode: EmitMode, EmitMode::Files, false,
         "What emit Mode to use when none is supplied";
     make_backup: bool, false, false, "Backup changed files";
@@ -346,7 +360,9 @@ fn get_toml_path(dir: &Path) -> Result<Option<PathBuf>, Error> {
             // find the project file yet, and continue searching.
             Err(e) => {
                 if e.kind() != ErrorKind::NotFound {
-                    return Err(e);
+                    let ctx = format!("Failed to get metadata for config file {:?}", &config_file);
+                    let err = anyhow::Error::new(e).context(ctx);
+                    return Err(Error::new(ErrorKind::Other, err));
                 }
             }
             _ => {}
@@ -387,6 +403,8 @@ mod test {
     use super::*;
     use std::str;
 
+    use rustfmt_config_proc_macro::{nightly_only_test, stable_only_test};
+
     #[allow(dead_code)]
     mod mock {
         use super::super::*;
@@ -394,11 +412,6 @@ mod mock {
         create_config! {
             // Options that are used by the generated functions
             max_width: usize, 100, true, "Maximum width of each line";
-            use_small_heuristics: Heuristics, Heuristics::Default, true,
-                "Whether to use different formatting for items and \
-                 expressions if they satisfy a heuristic notion of 'small'.";
-            license_template_path: String, String::default(), false,
-                "Beginning of file must match license template";
             required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false,
                 "Require a specific version of rustfmt.";
             ignore: IgnoreList, IgnoreList::default(), false,
@@ -408,13 +421,33 @@ mod mock {
             file_lines: FileLines, FileLines::all(), false,
                 "Lines to format; this is not supported in rustfmt.toml, and can only be specified \
                     via the --file-lines option";
-            width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false,
-                "'small' heuristic values";
+
             // merge_imports deprecation
             imports_granularity: ImportGranularity, ImportGranularity::Preserve, false,
                 "Merge imports";
             merge_imports: bool, false, false, "(deprecated: use imports_granularity instead)";
 
+            // Width Heuristics
+            use_small_heuristics: Heuristics, Heuristics::Default, true,
+                "Whether to use different formatting for items and \
+                 expressions if they satisfy a heuristic notion of 'small'.";
+            width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false,
+                "'small' heuristic values";
+
+            fn_call_width: usize, 60, true, "Maximum width of the args of a function call before \
+                falling back to vertical formatting.";
+            attr_fn_like_width: usize, 70, true, "Maximum width of the args of a function-like \
+                attributes before falling back to vertical formatting.";
+            struct_lit_width: usize, 18, true, "Maximum width in the body of a struct lit before \
+                falling back to vertical formatting.";
+            struct_variant_width: usize, 35, true, "Maximum width in the body of a struct \
+                variant before falling back to vertical formatting.";
+            array_width: usize, 60, true,  "Maximum width of an array literal before falling \
+                back to vertical formatting.";
+            chain_width: usize, 60, true, "Maximum length of a chain to fit on a single line.";
+            single_line_if_else_max_width: usize, 50, true, "Maximum line length for single \
+                line if-else expressions. A value of zero means always break if-else expressions.";
+
             // Options that are used by the tests
             stable_option: bool, false, true, "A stable option";
             unstable_option: bool, false, false, "An unstable option";
@@ -483,35 +516,6 @@ fn test_print_docs_include_unstable() {
         assert_eq!(s.contains("(unstable)"), true);
     }
 
-    #[test]
-    fn test_empty_string_license_template_path() {
-        let toml = r#"license_template_path = """#;
-        let config = Config::from_toml(toml, Path::new("")).unwrap();
-        assert!(config.license_template.is_none());
-    }
-
-    #[test]
-    fn test_valid_license_template_path() {
-        if !crate::is_nightly_channel!() {
-            return;
-        }
-        let toml = r#"license_template_path = "tests/license-template/lt.txt""#;
-        let config = Config::from_toml(toml, Path::new("")).unwrap();
-        assert!(config.license_template.is_some());
-    }
-
-    #[test]
-    fn test_override_existing_license_with_no_license() {
-        if !crate::is_nightly_channel!() {
-            return;
-        }
-        let toml = r#"license_template_path = "tests/license-template/lt.txt""#;
-        let mut config = Config::from_toml(toml, Path::new("")).unwrap();
-        assert!(config.license_template.is_some());
-        config.override_value("license_template_path", "");
-        assert!(config.license_template.is_none());
-    }
-
     #[test]
     fn test_dump_default_config() {
         let default_config = format!(
@@ -519,17 +523,25 @@ fn test_dump_default_config() {
 hard_tabs = false
 tab_spaces = 4
 newline_style = "Auto"
-use_small_heuristics = "Default"
 indent_style = "Block"
+use_small_heuristics = "Default"
+fn_call_width = 60
+attr_fn_like_width = 70
+struct_lit_width = 18
+struct_variant_width = 35
+array_width = 60
+chain_width = 60
+single_line_if_else_max_width = 50
 wrap_comments = false
 format_code_in_doc_comments = false
+doc_comment_code_block_width = 100
 comment_width = 80
 normalize_comments = false
 normalize_doc_attributes = false
-license_template_path = ""
 format_strings = false
 format_macro_matchers = false
 format_macro_bodies = true
+hex_literal_case = "Preserve"
 empty_item_single_line = true
 struct_lit_single_line = true
 fn_single_line = false
@@ -548,6 +560,7 @@ fn test_dump_default_config() {
 binop_separator = "Front"
 remove_nested_parens = true
 combine_control_expr = true
+short_array_element_width_threshold = 10
 overflow_delimited_expr = false
 struct_field_align_threshold = 0
 enum_discrim_align_threshold = 0
@@ -565,6 +578,7 @@ fn test_dump_default_config() {
 edition = "2015"
 version = "One"
 inline_attribute_width = 0
+format_generated_files = true
 merge_derives = true
 use_try_shorthand = false
 use_field_init_shorthand = false
@@ -578,8 +592,6 @@ fn test_dump_default_config() {
 hide_parse_errors = false
 error_on_line_overflow = false
 error_on_unformatted = false
-report_todo = "Never"
-report_fixme = "Never"
 ignore = []
 emit_mode = "Files"
 make_backup = false
@@ -590,48 +602,42 @@ fn test_dump_default_config() {
         assert_eq!(&toml, &default_config);
     }
 
-    // FIXME(#2183): these tests cannot be run in parallel because they use env vars.
-    // #[test]
-    // fn test_as_not_nightly_channel() {
-    //     let mut config = Config::default();
-    //     assert_eq!(config.was_set().unstable_features(), false);
-    //     config.set().unstable_features(true);
-    //     assert_eq!(config.was_set().unstable_features(), false);
-    // }
-
-    // #[test]
-    // fn test_as_nightly_channel() {
-    //     let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
-    //     ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
-    //     let mut config = Config::default();
-    //     config.set().unstable_features(true);
-    //     assert_eq!(config.was_set().unstable_features(), false);
-    //     config.set().unstable_features(true);
-    //     assert_eq!(config.unstable_features(), true);
-    //     ::std::env::set_var("CFG_RELEASE_CHANNEL", v);
-    // }
-
-    // #[test]
-    // fn test_unstable_from_toml() {
-    //     let mut config = Config::from_toml("unstable_features = true").unwrap();
-    //     assert_eq!(config.was_set().unstable_features(), false);
-    //     let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
-    //     ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
-    //     config = Config::from_toml("unstable_features = true").unwrap();
-    //     assert_eq!(config.was_set().unstable_features(), true);
-    //     assert_eq!(config.unstable_features(), true);
-    //     ::std::env::set_var("CFG_RELEASE_CHANNEL", v);
-    // }
+    #[stable_only_test]
+    #[test]
+    fn test_as_not_nightly_channel() {
+        let mut config = Config::default();
+        assert_eq!(config.was_set().unstable_features(), false);
+        config.set().unstable_features(true);
+        assert_eq!(config.was_set().unstable_features(), false);
+    }
+
+    #[nightly_only_test]
+    #[test]
+    fn test_as_nightly_channel() {
+        let mut config = Config::default();
+        config.set().unstable_features(true);
+        // When we don't set the config from toml or command line options it
+        // doesn't get marked as set by the user.
+        assert_eq!(config.was_set().unstable_features(), false);
+        config.set().unstable_features(true);
+        assert_eq!(config.unstable_features(), true);
+    }
+
+    #[nightly_only_test]
+    #[test]
+    fn test_unstable_from_toml() {
+        let config = Config::from_toml("unstable_features = true", Path::new("")).unwrap();
+        assert_eq!(config.was_set().unstable_features(), true);
+        assert_eq!(config.unstable_features(), true);
+    }
 
     #[cfg(test)]
     mod deprecated_option_merge_imports {
         use super::*;
 
+        #[nightly_only_test]
         #[test]
         fn test_old_option_set() {
-            if !crate::is_nightly_channel!() {
-                return;
-            }
             let toml = r#"
                 unstable_features = true
                 merge_imports = true
@@ -640,11 +646,9 @@ fn test_old_option_set() {
             assert_eq!(config.imports_granularity(), ImportGranularity::Crate);
         }
 
+        #[nightly_only_test]
         #[test]
         fn test_both_set() {
-            if !crate::is_nightly_channel!() {
-                return;
-            }
             let toml = r#"
                 unstable_features = true
                 merge_imports = true
@@ -654,11 +658,9 @@ fn test_both_set() {
             assert_eq!(config.imports_granularity(), ImportGranularity::Preserve);
         }
 
+        #[nightly_only_test]
         #[test]
         fn test_new_overridden() {
-            if !crate::is_nightly_channel!() {
-                return;
-            }
             let toml = r#"
                 unstable_features = true
                 merge_imports = true
@@ -668,11 +670,9 @@ fn test_new_overridden() {
             assert_eq!(config.imports_granularity(), ImportGranularity::Preserve);
         }
 
+        #[nightly_only_test]
         #[test]
         fn test_old_overridden() {
-            if !crate::is_nightly_channel!() {
-                return;
-            }
             let toml = r#"
                 unstable_features = true
                 imports_granularity = "Module"
@@ -683,4 +683,242 @@ fn test_old_overridden() {
             assert_eq!(config.imports_granularity(), ImportGranularity::Module);
         }
     }
+
+    #[cfg(test)]
+    mod use_small_heuristics {
+        use super::*;
+
+        #[test]
+        fn test_default_sets_correct_widths() {
+            let toml = r#"
+                use_small_heuristics = "Default"
+                max_width = 200
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), 120);
+            assert_eq!(config.attr_fn_like_width(), 140);
+            assert_eq!(config.chain_width(), 120);
+            assert_eq!(config.fn_call_width(), 120);
+            assert_eq!(config.single_line_if_else_max_width(), 100);
+            assert_eq!(config.struct_lit_width(), 36);
+            assert_eq!(config.struct_variant_width(), 70);
+        }
+
+        #[test]
+        fn test_max_sets_correct_widths() {
+            let toml = r#"
+                use_small_heuristics = "Max"
+                max_width = 120
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), 120);
+            assert_eq!(config.attr_fn_like_width(), 120);
+            assert_eq!(config.chain_width(), 120);
+            assert_eq!(config.fn_call_width(), 120);
+            assert_eq!(config.single_line_if_else_max_width(), 120);
+            assert_eq!(config.struct_lit_width(), 120);
+            assert_eq!(config.struct_variant_width(), 120);
+        }
+
+        #[test]
+        fn test_off_sets_correct_widths() {
+            let toml = r#"
+                use_small_heuristics = "Off"
+                max_width = 100
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), usize::max_value());
+            assert_eq!(config.attr_fn_like_width(), usize::max_value());
+            assert_eq!(config.chain_width(), usize::max_value());
+            assert_eq!(config.fn_call_width(), usize::max_value());
+            assert_eq!(config.single_line_if_else_max_width(), 0);
+            assert_eq!(config.struct_lit_width(), 0);
+            assert_eq!(config.struct_variant_width(), 0);
+        }
+
+        #[test]
+        fn test_override_works_with_default() {
+            let toml = r#"
+                use_small_heuristics = "Default"
+                array_width = 20
+                attr_fn_like_width = 40
+                chain_width = 20
+                fn_call_width = 90
+                single_line_if_else_max_width = 40
+                struct_lit_width = 30
+                struct_variant_width = 34
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), 20);
+            assert_eq!(config.attr_fn_like_width(), 40);
+            assert_eq!(config.chain_width(), 20);
+            assert_eq!(config.fn_call_width(), 90);
+            assert_eq!(config.single_line_if_else_max_width(), 40);
+            assert_eq!(config.struct_lit_width(), 30);
+            assert_eq!(config.struct_variant_width(), 34);
+        }
+
+        #[test]
+        fn test_override_with_max() {
+            let toml = r#"
+                use_small_heuristics = "Max"
+                array_width = 20
+                attr_fn_like_width = 40
+                chain_width = 20
+                fn_call_width = 90
+                single_line_if_else_max_width = 40
+                struct_lit_width = 30
+                struct_variant_width = 34
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), 20);
+            assert_eq!(config.attr_fn_like_width(), 40);
+            assert_eq!(config.chain_width(), 20);
+            assert_eq!(config.fn_call_width(), 90);
+            assert_eq!(config.single_line_if_else_max_width(), 40);
+            assert_eq!(config.struct_lit_width(), 30);
+            assert_eq!(config.struct_variant_width(), 34);
+        }
+
+        #[test]
+        fn test_override_with_off() {
+            let toml = r#"
+                use_small_heuristics = "Off"
+                array_width = 20
+                attr_fn_like_width = 40
+                chain_width = 20
+                fn_call_width = 90
+                single_line_if_else_max_width = 40
+                struct_lit_width = 30
+                struct_variant_width = 34
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), 20);
+            assert_eq!(config.attr_fn_like_width(), 40);
+            assert_eq!(config.chain_width(), 20);
+            assert_eq!(config.fn_call_width(), 90);
+            assert_eq!(config.single_line_if_else_max_width(), 40);
+            assert_eq!(config.struct_lit_width(), 30);
+            assert_eq!(config.struct_variant_width(), 34);
+        }
+
+        #[test]
+        fn test_fn_call_width_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 90
+                fn_call_width = 95
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.fn_call_width(), 90);
+        }
+
+        #[test]
+        fn test_attr_fn_like_width_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 80
+                attr_fn_like_width = 90
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.attr_fn_like_width(), 80);
+        }
+
+        #[test]
+        fn test_struct_lit_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 78
+                struct_lit_width = 90
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.struct_lit_width(), 78);
+        }
+
+        #[test]
+        fn test_struct_variant_width_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 80
+                struct_variant_width = 90
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.struct_variant_width(), 80);
+        }
+
+        #[test]
+        fn test_array_width_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 60
+                array_width = 80
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.array_width(), 60);
+        }
+
+        #[test]
+        fn test_chain_width_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 80
+                chain_width = 90
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.chain_width(), 80);
+        }
+
+        #[test]
+        fn test_single_line_if_else_max_width_config_exceeds_max_width() {
+            let toml = r#"
+                max_width = 70
+                single_line_if_else_max_width = 90
+            "#;
+            let config = Config::from_toml(toml, Path::new("")).unwrap();
+            assert_eq!(config.single_line_if_else_max_width(), 70);
+        }
+
+        #[test]
+        fn test_override_fn_call_width_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("fn_call_width", "101");
+            assert_eq!(config.fn_call_width(), 100);
+        }
+
+        #[test]
+        fn test_override_attr_fn_like_width_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("attr_fn_like_width", "101");
+            assert_eq!(config.attr_fn_like_width(), 100);
+        }
+
+        #[test]
+        fn test_override_struct_lit_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("struct_lit_width", "101");
+            assert_eq!(config.struct_lit_width(), 100);
+        }
+
+        #[test]
+        fn test_override_struct_variant_width_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("struct_variant_width", "101");
+            assert_eq!(config.struct_variant_width(), 100);
+        }
+
+        #[test]
+        fn test_override_array_width_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("array_width", "101");
+            assert_eq!(config.array_width(), 100);
+        }
+
+        #[test]
+        fn test_override_chain_width_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("chain_width", "101");
+            assert_eq!(config.chain_width(), 100);
+        }
+
+        #[test]
+        fn test_override_single_line_if_else_max_width_exceeds_max_width() {
+            let mut config = Config::default();
+            config.override_value("single_line_if_else_max_width", "101");
+            assert_eq!(config.single_line_if_else_max_width(), 100);
+        }
+    }
 }