diff --git a/src/config/mod.rs b/src/config/mod.rs index abfdb8049a2..382e7e7cc92 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -50,7 +50,8 @@ create_config! { comment_width: usize, 80, false, "Maximum length of comments. No effect unless wrap_comments = true"; normalize_comments: bool, false, true, "Convert /* */ comments to // comments where possible"; - license_template_path: String, String::default(), false, "Beginning of file must match license template"; + license_template_path: String, String::default(), false, + "Beginning of file must match license template"; format_strings: bool, false, false, "Format string literals where necessary"; // Single line expressions and items @@ -239,16 +240,21 @@ mod test { create_config! { // Options that are used by the generated functions max_width: usize, 100, true, "Maximum width of each line"; - use_small_heuristics: bool, true, false, "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, "Skip formatting the specified files and directories."; + use_small_heuristics: bool, true, false, + "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, + "Skip formatting the specified files and directories."; verbose: bool, false, false, "Use verbose output"; 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"; + width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false, + "'small' heuristic values"; // Options that are used by the tests stable_option: bool, false, true, "A stable option"; diff --git a/src/config/options.rs b/src/config/options.rs index c350aac8d96..272acef2b3a 100644 --- a/src/config/options.rs +++ b/src/config/options.rs @@ -191,7 +191,8 @@ configuration_option_enum! { WriteMode: // Output the changed lines (for internal value only) Modified, // Checks if a diff can be generated. If so, rustfmt outputs a diff and quits with exit code 1. - // This option is designed to be run in CI where a non-zero exit signifies non-standard code formatting. + // This option is designed to be run in CI where a non-zero exit signifies non-standard code + // formatting. Check, // Rustfmt shouldn't output anything formatting-like (e.g., emit a help message). None, diff --git a/src/lib.rs b/src/lib.rs index ec8646acc1c..bae548a4b2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -116,7 +116,8 @@ pub(crate) type FileRecord = (FileName, String); pub enum ErrorKind { // Line has exceeded character limit (found, maximum) #[fail( - display = "line formatted, but exceeded maximum width (maximum: {} (see `max_width` option), found: {})", + display = "line formatted, but exceeded maximum width \ + (maximum: {} (see `max_width` option), found: {})", _0, _1 )] diff --git a/src/macros.rs b/src/macros.rs index 1fc150e1256..cbc42dae0a9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1296,7 +1296,9 @@ impl MacroBranch { fn format_lazy_static(context: &RewriteContext, shape: Shape, ts: &TokenStream) -> Option { let mut result = String::with_capacity(1024); let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect()); - let nested_shape = shape.block_indent(context.config.tab_spaces()); + let nested_shape = shape + .block_indent(context.config.tab_spaces()) + .with_max_width(context.config); result.push_str("lazy_static! {"); result.push_str(&nested_shape.indent.to_string_with_newline(context.config)); diff --git a/src/test/mod.rs b/src/test/mod.rs index d1e7cbd5a64..06fd1e5a98f 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -618,8 +618,9 @@ impl ConfigurationSection { lazy_static! { static ref CONFIG_NAME_REGEX: regex::Regex = regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern"); - static ref CONFIG_VALUE_REGEX: regex::Regex = regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#) - .expect("Failed creating configuration value pattern"); + static ref CONFIG_VALUE_REGEX: regex::Regex = + regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#) + .expect("Failed creating configuration value pattern"); } loop {