@@ -32,9 +32,24 @@ create_config! {
32
32
hard_tabs: bool , false , true , "Use tab characters for indentation, spaces for alignment" ;
33
33
tab_spaces: usize , 4 , true , "Number of spaces per tab" ;
34
34
newline_style: NewlineStyle , NewlineStyle :: Auto , true , "Unix or Windows line endings" ;
35
- use_small_heuristics: Heuristics , Heuristics :: Default , true , "Whether to use different \
36
- formatting for items and expressions if they satisfy a heuristic notion of 'small'";
37
35
indent_style: IndentStyle , IndentStyle :: Block , false , "How do we indent expressions or items" ;
36
+ width_heuristics: Heuristics , Heuristics :: Scaled , true , "Controls width heuristics \
37
+ by setting the values for the individual width heuristic options";
38
+
39
+ // Width Heuristics
40
+ fn_call_width: usize , 60 , true , "Maximum width of the args of a function call before \
41
+ falling back to vertical formatting.";
42
+ attr_fn_like_width: usize , 70 , true , "Maximum width of the args of a function-like \
43
+ attributes before falling back to vertical formatting.";
44
+ struct_lit_width: usize , 18 , true , "Maximum width in the body of a struct lit before \
45
+ falling back to vertical formatting.";
46
+ struct_variant_width: usize , 35 , true , "Maximum width in the body of a struct variant before \
47
+ falling back to vertical formatting.";
48
+ array_width: usize , 60 , true , "Maximum width of an array literal before falling \
49
+ back to vertical formatting.";
50
+ chain_width: usize , 60 , true , "Maximum length of a chain to fit on a single line." ;
51
+ single_line_if_else_max_width: usize , 50 , true , "Maximum line length for single line if-else \
52
+ expressions. A value of zero means always break if-else expressions.";
38
53
39
54
// Comments. macros, and strings
40
55
wrap_comments: bool , false , false , "Break comments to fit on the line" ;
@@ -144,8 +159,6 @@ create_config! {
144
159
file_lines: FileLines , FileLines :: all( ) , false ,
145
160
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
146
161
via the --file-lines option";
147
- width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
148
- "'small' heuristic values" ;
149
162
emit_mode: EmitMode , EmitMode :: Files , false ,
150
163
"What emit Mode to use when none is supplied" ;
151
164
print_misformatted_file_names: bool , false , true ,
@@ -165,7 +178,6 @@ impl PartialConfig {
165
178
let mut cloned = self . clone ( ) ;
166
179
cloned. file_lines = None ;
167
180
cloned. verbose = None ;
168
- cloned. width_heuristics = None ;
169
181
cloned. print_misformatted_file_names = None ;
170
182
cloned. recursive = None ;
171
183
cloned. emit_mode = None ;
@@ -387,9 +399,6 @@ mod test {
387
399
create_config ! {
388
400
// Options that are used by the generated functions
389
401
max_width: usize , 100 , true , "Maximum width of each line" ;
390
- use_small_heuristics: Heuristics , Heuristics :: Default , true ,
391
- "Whether to use different formatting for items and \
392
- expressions if they satisfy a heuristic notion of 'small'.";
393
402
license_template_path: String , String :: default ( ) , false ,
394
403
"Beginning of file must match license template" ;
395
404
required_version: String , env!( "CARGO_PKG_VERSION" ) . to_owned( ) , false ,
@@ -401,8 +410,22 @@ mod test {
401
410
file_lines: FileLines , FileLines :: all( ) , false ,
402
411
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
403
412
via the --file-lines option";
404
- width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
405
- "'small' heuristic values" ;
413
+ width_heuristics: Heuristics , Heuristics :: Scaled , true , "Controls width heuristics \
414
+ by setting the values for the individual width heuristic options";
415
+ // Width Heuristics
416
+ fn_call_width: usize , 60 , true , "Maximum width of the args of a function call before \
417
+ falling back to vertical formatting.";
418
+ attr_fn_like_width: usize , 70 , true , "Maximum width of the args of a function-like \
419
+ attributes before falling back to vertical formatting.";
420
+ struct_lit_width: usize , 18 , true , "Maximum width in the body of a struct lit before \
421
+ falling back to vertical formatting.";
422
+ struct_variant_width: usize , 35 , true , "Maximum width in the body of a struct \
423
+ variant before falling back to vertical formatting.";
424
+ array_width: usize , 60 , true , "Maximum width of an array literal before falling \
425
+ back to vertical formatting.";
426
+ chain_width: usize , 60 , true , "Maximum length of a chain to fit on a single line." ;
427
+ single_line_if_else_max_width: usize , 50 , true , "Maximum line length for single \
428
+ line if-else expressions. A value of zero means always break if-else expressions.";
406
429
407
430
// Options that are used by the tests
408
431
stable_option: bool , false , true , "A stable option" ;
@@ -490,8 +513,15 @@ mod test {
490
513
hard_tabs = false
491
514
tab_spaces = 4
492
515
newline_style = "Auto"
493
- use_small_heuristics = "Default"
494
516
indent_style = "Block"
517
+ width_heuristics = "Scaled"
518
+ fn_call_width = 60
519
+ attr_fn_like_width = 70
520
+ struct_lit_width = 18
521
+ struct_variant_width = 35
522
+ array_width = 60
523
+ chain_width = 60
524
+ single_line_if_else_max_width = 50
495
525
wrap_comments = false
496
526
format_code_in_doc_comments = false
497
527
comment_width = 80
0 commit comments