@@ -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" ;
@@ -146,8 +161,6 @@ create_config! {
146
161
file_lines: FileLines , FileLines :: all( ) , false ,
147
162
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
148
163
via the --file-lines option";
149
- width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
150
- "'small' heuristic values" ;
151
164
emit_mode: EmitMode , EmitMode :: Files , false ,
152
165
"What emit Mode to use when none is supplied" ;
153
166
print_misformatted_file_names: bool , false , true ,
@@ -167,7 +180,6 @@ impl PartialConfig {
167
180
let mut cloned = self . clone ( ) ;
168
181
cloned. file_lines = None ;
169
182
cloned. verbose = None ;
170
- cloned. width_heuristics = None ;
171
183
cloned. print_misformatted_file_names = None ;
172
184
cloned. recursive = None ;
173
185
cloned. emit_mode = None ;
@@ -389,9 +401,6 @@ mod test {
389
401
create_config ! {
390
402
// Options that are used by the generated functions
391
403
max_width: usize , 100 , true , "Maximum width of each line" ;
392
- use_small_heuristics: Heuristics , Heuristics :: Default , true ,
393
- "Whether to use different formatting for items and \
394
- expressions if they satisfy a heuristic notion of 'small'.";
395
404
license_template_path: String , String :: default ( ) , false ,
396
405
"Beginning of file must match license template" ;
397
406
required_version: String , env!( "CARGO_PKG_VERSION" ) . to_owned( ) , false ,
@@ -403,8 +412,22 @@ mod test {
403
412
file_lines: FileLines , FileLines :: all( ) , false ,
404
413
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
405
414
via the --file-lines option";
406
- width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
407
- "'small' heuristic values" ;
415
+ width_heuristics: Heuristics , Heuristics :: Scaled , true , "Controls width heuristics \
416
+ by setting the values for the individual width heuristic options";
417
+ // Width Heuristics
418
+ fn_call_width: usize , 60 , true , "Maximum width of the args of a function call before \
419
+ falling back to vertical formatting.";
420
+ attr_fn_like_width: usize , 70 , true , "Maximum width of the args of a function-like \
421
+ attributes before falling back to vertical formatting.";
422
+ struct_lit_width: usize , 18 , true , "Maximum width in the body of a struct lit before \
423
+ falling back to vertical formatting.";
424
+ struct_variant_width: usize , 35 , true , "Maximum width in the body of a struct \
425
+ variant before falling back to vertical formatting.";
426
+ array_width: usize , 60 , true , "Maximum width of an array literal before falling \
427
+ back to vertical formatting.";
428
+ chain_width: usize , 60 , true , "Maximum length of a chain to fit on a single line." ;
429
+ single_line_if_else_max_width: usize , 50 , true , "Maximum line length for single \
430
+ line if-else expressions. A value of zero means always break if-else expressions.";
408
431
409
432
// Options that are used by the tests
410
433
stable_option: bool , false , true , "A stable option" ;
@@ -492,8 +515,15 @@ mod test {
492
515
hard_tabs = false
493
516
tab_spaces = 4
494
517
newline_style = "Auto"
495
- use_small_heuristics = "Default"
496
518
indent_style = "Block"
519
+ width_heuristics = "Scaled"
520
+ fn_call_width = 60
521
+ attr_fn_like_width = 70
522
+ struct_lit_width = 18
523
+ struct_variant_width = 35
524
+ array_width = 60
525
+ chain_width = 60
526
+ single_line_if_else_max_width = 50
497
527
wrap_comments = false
498
528
format_code_in_doc_comments = false
499
529
comment_width = 80
0 commit comments