@@ -35,9 +35,26 @@ create_config! {
35
35
hard_tabs: bool , false , true , "Use tab characters for indentation, spaces for alignment" ;
36
36
tab_spaces: usize , 4 , true , "Number of spaces per tab" ;
37
37
newline_style: NewlineStyle , NewlineStyle :: Auto , true , "Unix or Windows line endings" ;
38
+ indent_style: IndentStyle , IndentStyle :: Block , false , "How do we indent expressions or items" ;
39
+
40
+ // Width Heuristics
38
41
use_small_heuristics: Heuristics , Heuristics :: Default , true , "Whether to use different \
39
42
formatting for items and expressions if they satisfy a heuristic notion of 'small'";
40
- indent_style: IndentStyle , IndentStyle :: Block , false , "How do we indent expressions or items" ;
43
+ width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
44
+ "'small' heuristic values" ;
45
+ fn_call_width: usize , 60 , true , "Maximum width of the args of a function call before \
46
+ falling back to vertical formatting.";
47
+ attr_fn_like_width: usize , 70 , true , "Maximum width of the args of a function-like \
48
+ attributes before falling back to vertical formatting.";
49
+ struct_lit_width: usize , 18 , true , "Maximum width in the body of a struct lit before \
50
+ falling back to vertical formatting.";
51
+ struct_variant_width: usize , 35 , true , "Maximum width in the body of a struct variant before \
52
+ falling back to vertical formatting.";
53
+ array_width: usize , 60 , true , "Maximum width of an array literal before falling \
54
+ back to vertical formatting.";
55
+ chain_width: usize , 60 , true , "Maximum length of a chain to fit on a single line." ;
56
+ single_line_if_else_max_width: usize , 50 , true , "Maximum line length for single line if-else \
57
+ expressions. A value of zero means always break if-else expressions.";
41
58
42
59
// Comments. macros, and strings
43
60
wrap_comments: bool , false , false , "Break comments to fit on the line" ;
@@ -154,8 +171,6 @@ create_config! {
154
171
file_lines: FileLines , FileLines :: all( ) , false ,
155
172
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
156
173
via the --file-lines option";
157
- width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
158
- "'small' heuristic values" ;
159
174
emit_mode: EmitMode , EmitMode :: Files , false ,
160
175
"What emit Mode to use when none is supplied" ;
161
176
make_backup: bool , false , false , "Backup changed files" ;
@@ -394,9 +409,6 @@ mod test {
394
409
create_config ! {
395
410
// Options that are used by the generated functions
396
411
max_width: usize , 100 , true , "Maximum width of each line" ;
397
- use_small_heuristics: Heuristics , Heuristics :: Default , true ,
398
- "Whether to use different formatting for items and \
399
- expressions if they satisfy a heuristic notion of 'small'.";
400
412
license_template_path: String , String :: default ( ) , false ,
401
413
"Beginning of file must match license template" ;
402
414
required_version: String , env!( "CARGO_PKG_VERSION" ) . to_owned( ) , false ,
@@ -408,13 +420,33 @@ mod test {
408
420
file_lines: FileLines , FileLines :: all( ) , false ,
409
421
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
410
422
via the --file-lines option";
411
- width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
412
- "'small' heuristic values" ;
423
+
413
424
// merge_imports deprecation
414
425
imports_granularity: ImportGranularity , ImportGranularity :: Preserve , false ,
415
426
"Merge imports" ;
416
427
merge_imports: bool , false , false , "(deprecated: use imports_granularity instead)" ;
417
428
429
+ // Width Heuristics
430
+ use_small_heuristics: Heuristics , Heuristics :: Default , true ,
431
+ "Whether to use different formatting for items and \
432
+ expressions if they satisfy a heuristic notion of 'small'.";
433
+ width_heuristics: WidthHeuristics , WidthHeuristics :: scaled( 100 ) , false ,
434
+ "'small' heuristic values" ;
435
+
436
+ fn_call_width: usize , 60 , true , "Maximum width of the args of a function call before \
437
+ falling back to vertical formatting.";
438
+ attr_fn_like_width: usize , 70 , true , "Maximum width of the args of a function-like \
439
+ attributes before falling back to vertical formatting.";
440
+ struct_lit_width: usize , 18 , true , "Maximum width in the body of a struct lit before \
441
+ falling back to vertical formatting.";
442
+ struct_variant_width: usize , 35 , true , "Maximum width in the body of a struct \
443
+ variant before falling back to vertical formatting.";
444
+ array_width: usize , 60 , true , "Maximum width of an array literal before falling \
445
+ back to vertical formatting.";
446
+ chain_width: usize , 60 , true , "Maximum length of a chain to fit on a single line." ;
447
+ single_line_if_else_max_width: usize , 50 , true , "Maximum line length for single \
448
+ line if-else expressions. A value of zero means always break if-else expressions.";
449
+
418
450
// Options that are used by the tests
419
451
stable_option: bool , false , true , "A stable option" ;
420
452
unstable_option: bool , false , false , "An unstable option" ;
@@ -519,8 +551,15 @@ mod test {
519
551
hard_tabs = false
520
552
tab_spaces = 4
521
553
newline_style = "Auto"
522
- use_small_heuristics = "Default"
523
554
indent_style = "Block"
555
+ use_small_heuristics = "Default"
556
+ fn_call_width = 60
557
+ attr_fn_like_width = 70
558
+ struct_lit_width = 18
559
+ struct_variant_width = 35
560
+ array_width = 60
561
+ chain_width = 60
562
+ single_line_if_else_max_width = 50
524
563
wrap_comments = false
525
564
format_code_in_doc_comments = false
526
565
comment_width = 80
0 commit comments