Skip to content

Commit 51c07f4

Browse files
committed
Fix up lines exceeding max width
1 parent 5f05987 commit 51c07f4

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

src/config/mod.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ create_config! {
5050
comment_width: usize, 80, false,
5151
"Maximum length of comments. No effect unless wrap_comments = true";
5252
normalize_comments: bool, false, true, "Convert /* */ comments to // comments where possible";
53-
license_template_path: String, String::default(), false, "Beginning of file must match license template";
53+
license_template_path: String, String::default(), false,
54+
"Beginning of file must match license template";
5455
format_strings: bool, false, false, "Format string literals where necessary";
5556

5657
// Single line expressions and items
@@ -239,16 +240,21 @@ mod test {
239240
create_config! {
240241
// Options that are used by the generated functions
241242
max_width: usize, 100, true, "Maximum width of each line";
242-
use_small_heuristics: bool, true, false, "Whether to use different formatting for items and \
243-
expressions if they satisfy a heuristic notion of 'small'.";
244-
license_template_path: String, String::default(), false, "Beginning of file must match license template";
245-
required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false, "Require a specific version of rustfmt.";
246-
ignore: IgnoreList, IgnoreList::default(), false, "Skip formatting the specified files and directories.";
243+
use_small_heuristics: bool, true, false,
244+
"Whether to use different formatting for items and \
245+
expressions if they satisfy a heuristic notion of 'small'.";
246+
license_template_path: String, String::default(), false,
247+
"Beginning of file must match license template";
248+
required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false,
249+
"Require a specific version of rustfmt.";
250+
ignore: IgnoreList, IgnoreList::default(), false,
251+
"Skip formatting the specified files and directories.";
247252
verbose: bool, false, false, "Use verbose output";
248253
file_lines: FileLines, FileLines::all(), false,
249254
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
250255
via the --file-lines option";
251-
width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false, "'small' heuristic values";
256+
width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false,
257+
"'small' heuristic values";
252258

253259
// Options that are used by the tests
254260
stable_option: bool, false, true, "A stable option";

src/config/options.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ configuration_option_enum! { WriteMode:
191191
// Output the changed lines (for internal value only)
192192
Modified,
193193
// Checks if a diff can be generated. If so, rustfmt outputs a diff and quits with exit code 1.
194-
// This option is designed to be run in CI where a non-zero exit signifies non-standard code formatting.
194+
// This option is designed to be run in CI where a non-zero exit signifies non-standard code
195+
// formatting.
195196
Check,
196197
// Rustfmt shouldn't output anything formatting-like (e.g., emit a help message).
197198
None,

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ pub(crate) type FileRecord = (FileName, String);
116116
pub enum ErrorKind {
117117
// Line has exceeded character limit (found, maximum)
118118
#[fail(
119-
display = "line formatted, but exceeded maximum width (maximum: {} (see `max_width` option), found: {})",
119+
display = "line formatted, but exceeded maximum width \
120+
(maximum: {} (see `max_width` option), found: {})",
120121
_0,
121122
_1
122123
)]

src/macros.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,9 @@ impl MacroBranch {
12961296
fn format_lazy_static(context: &RewriteContext, shape: Shape, ts: &TokenStream) -> Option<String> {
12971297
let mut result = String::with_capacity(1024);
12981298
let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
1299-
let nested_shape = shape.block_indent(context.config.tab_spaces());
1299+
let nested_shape = shape
1300+
.block_indent(context.config.tab_spaces())
1301+
.with_max_width(context.config);
13001302

13011303
result.push_str("lazy_static! {");
13021304
result.push_str(&nested_shape.indent.to_string_with_newline(context.config));

src/test/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,9 @@ impl ConfigurationSection {
618618
lazy_static! {
619619
static ref CONFIG_NAME_REGEX: regex::Regex =
620620
regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern");
621-
static ref CONFIG_VALUE_REGEX: regex::Regex = regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#)
622-
.expect("Failed creating configuration value pattern");
621+
static ref CONFIG_VALUE_REGEX: regex::Regex =
622+
regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#)
623+
.expect("Failed creating configuration value pattern");
623624
}
624625

625626
loop {

0 commit comments

Comments
 (0)