]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/Configurations.md
Rollup merge of #90241 - DrMeepster:thiscall_lint_upgrade, r=petrochenkov
[rust.git] / src / tools / rustfmt / Configurations.md
1 # Configuring Rustfmt
2
3 Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file. If none of these directories contain such a file, both your home directory and a directory called `rustfmt` in your [global config directory](https://docs.rs/dirs/1.0.4/dirs/fn.config_dir.html) (e.g. `.config/rustfmt/`) are checked as well.
4
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
6
7 ```toml
8 indent_style = "Block"
9 reorder_imports = false
10 ```
11
12 Each configuration option is either stable or unstable.
13 Stable options can be used directly, while unstable options are opt-in.
14 To enable unstable options, set `unstable_features = true` in `rustfmt.toml` or pass `--unstable-features` to rustfmt.
15
16 # Configuration Options
17
18 Below you find a detailed visual guide on all the supported configuration options of rustfmt:
19
20 ## `array_width`
21
22 Maximum width of an array literal before falling back to vertical formatting.
23
24 - **Default value**: `60`
25 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
26 - **Stable**: Yes
27
28 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `array_width` will take precedence.
29
30 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
31
32 ## `attr_fn_like_width`
33
34 Maximum width of the args of a function-like attributes before falling back to vertical formatting.
35
36 - **Default value**: `70`
37 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
38 - **Stable**: Yes
39
40 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `attr_fn_like_width` will take precedence.
41
42 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
43
44 ## `binop_separator`
45
46 Where to put a binary operator when a binary expression goes multiline.
47
48 - **Default value**: `"Front"`
49 - **Possible values**: `"Front"`, `"Back"`
50 - **Stable**: No (tracking issue: #3368)
51
52 #### `"Front"` (default):
53
54 ```rust
55 fn main() {
56     let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
57         || barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
58
59     let sum = 123456789012345678901234567890
60         + 123456789012345678901234567890
61         + 123456789012345678901234567890;
62
63     let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
64         ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
65 }
66 ```
67
68 #### `"Back"`:
69
70 ```rust
71 fn main() {
72     let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo ||
73         barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
74
75     let sum = 123456789012345678901234567890 +
76         123456789012345678901234567890 +
77         123456789012345678901234567890;
78
79     let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
80         bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
81 }
82 ```
83
84 ## `blank_lines_lower_bound`
85
86 Minimum number of blank lines which must be put between items. If two items have fewer blank lines between
87 them, additional blank lines are inserted.
88
89 - **Default value**: `0`
90 - **Possible values**: *unsigned integer*
91 - **Stable**: No (tracking issue: #3382)
92
93 ### Example
94 Original Code (rustfmt will not change it with the default value of `0`):
95
96 ```rust
97 #![rustfmt::skip]
98
99 fn foo() {
100     println!("a");
101 }
102 fn bar() {
103     println!("b");
104     println!("c");
105 }
106 ```
107
108 #### `1`
109 ```rust
110 fn foo() {
111
112     println!("a");
113 }
114
115 fn bar() {
116
117     println!("b");
118
119     println!("c");
120 }
121 ```
122
123
124 ## `blank_lines_upper_bound`
125
126 Maximum number of blank lines which can be put between items. If more than this number of consecutive empty
127 lines are found, they are trimmed down to match this integer.
128
129 - **Default value**: `1`
130 - **Possible values**: any non-negative integer
131 - **Stable**: No (tracking issue: #3381)
132
133 ### Example
134 Original Code:
135
136 ```rust
137 #![rustfmt::skip]
138
139 fn foo() {
140     println!("a");
141 }
142
143
144
145 fn bar() {
146     println!("b");
147
148
149     println!("c");
150 }
151 ```
152
153 #### `1` (default):
154 ```rust
155 fn foo() {
156     println!("a");
157 }
158
159 fn bar() {
160     println!("b");
161
162     println!("c");
163 }
164 ```
165
166 #### `2`:
167 ```rust
168 fn foo() {
169     println!("a");
170 }
171
172
173 fn bar() {
174     println!("b");
175
176
177     println!("c");
178 }
179 ```
180
181 See also: [`blank_lines_lower_bound`](#blank_lines_lower_bound)
182
183 ## `brace_style`
184
185 Brace style for items
186
187 - **Default value**: `"SameLineWhere"`
188 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
189 - **Stable**: No (tracking issue: #3376)
190
191 ### Functions
192
193 #### `"SameLineWhere"` (default):
194
195 ```rust
196 fn lorem() {
197     // body
198 }
199
200 fn lorem(ipsum: usize) {
201     // body
202 }
203
204 fn lorem<T>(ipsum: T)
205 where
206     T: Add + Sub + Mul + Div,
207 {
208     // body
209 }
210 ```
211
212 #### `"AlwaysNextLine"`:
213
214 ```rust
215 fn lorem()
216 {
217     // body
218 }
219
220 fn lorem(ipsum: usize)
221 {
222     // body
223 }
224
225 fn lorem<T>(ipsum: T)
226 where
227     T: Add + Sub + Mul + Div,
228 {
229     // body
230 }
231 ```
232
233 #### `"PreferSameLine"`:
234
235 ```rust
236 fn lorem() {
237     // body
238 }
239
240 fn lorem(ipsum: usize) {
241     // body
242 }
243
244 fn lorem<T>(ipsum: T)
245 where
246     T: Add + Sub + Mul + Div, {
247     // body
248 }
249 ```
250
251 ### Structs and enums
252
253 #### `"SameLineWhere"` (default):
254
255 ```rust
256 struct Lorem {
257     ipsum: bool,
258 }
259
260 struct Dolor<T>
261 where
262     T: Eq,
263 {
264     sit: T,
265 }
266 ```
267
268 #### `"AlwaysNextLine"`:
269
270 ```rust
271 struct Lorem
272 {
273     ipsum: bool,
274 }
275
276 struct Dolor<T>
277 where
278     T: Eq,
279 {
280     sit: T,
281 }
282 ```
283
284 #### `"PreferSameLine"`:
285
286 ```rust
287 struct Lorem {
288     ipsum: bool,
289 }
290
291 struct Dolor<T>
292 where
293     T: Eq, {
294     sit: T,
295 }
296 ```
297
298 ## `chain_width`
299
300 Maximum width of a chain to fit on one line.
301
302 - **Default value**: `60`
303 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
304 - **Stable**: Yes
305
306 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `chain_width` will take precedence.
307
308 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
309
310 ## `color`
311
312 Whether to use colored output or not.
313
314 - **Default value**: `"Auto"`
315 - **Possible values**: "Auto", "Always", "Never"
316 - **Stable**: No (tracking issue: #3385)
317
318 ## `combine_control_expr`
319
320 Combine control expressions with function calls.
321
322 - **Default value**: `true`
323 - **Possible values**: `true`, `false`
324 - **Stable**: No (tracking issue: #3369)
325
326 #### `true` (default):
327
328 ```rust
329 fn example() {
330     // If
331     foo!(if x {
332         foo();
333     } else {
334         bar();
335     });
336
337     // IfLet
338     foo!(if let Some(..) = x {
339         foo();
340     } else {
341         bar();
342     });
343
344     // While
345     foo!(while x {
346         foo();
347         bar();
348     });
349
350     // WhileLet
351     foo!(while let Some(..) = x {
352         foo();
353         bar();
354     });
355
356     // ForLoop
357     foo!(for x in y {
358         foo();
359         bar();
360     });
361
362     // Loop
363     foo!(loop {
364         foo();
365         bar();
366     });
367 }
368 ```
369
370 #### `false`:
371
372 ```rust
373 fn example() {
374     // If
375     foo!(
376         if x {
377             foo();
378         } else {
379             bar();
380         }
381     );
382
383     // IfLet
384     foo!(
385         if let Some(..) = x {
386             foo();
387         } else {
388             bar();
389         }
390     );
391
392     // While
393     foo!(
394         while x {
395             foo();
396             bar();
397         }
398     );
399
400     // WhileLet
401     foo!(
402         while let Some(..) = x {
403             foo();
404             bar();
405         }
406     );
407
408     // ForLoop
409     foo!(
410         for x in y {
411             foo();
412             bar();
413         }
414     );
415
416     // Loop
417     foo!(
418         loop {
419             foo();
420             bar();
421         }
422     );
423 }
424 ```
425
426 ## `comment_width`
427
428 Maximum length of comments. No effect unless`wrap_comments = true`.
429
430 - **Default value**: `80`
431 - **Possible values**: any positive integer
432 - **Stable**: No (tracking issue: #3349)
433
434 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
435
436 #### `80` (default; comments shorter than `comment_width`):
437 ```rust
438 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
439 ```
440
441 #### `60` (comments longer than `comment_width`):
442 ```rust
443 // Lorem ipsum dolor sit amet,
444 // consectetur adipiscing elit.
445 ```
446
447 See also [`wrap_comments`](#wrap_comments).
448
449 ## `condense_wildcard_suffixes`
450
451 Replace strings of _ wildcards by a single .. in tuple patterns
452
453 - **Default value**: `false`
454 - **Possible values**: `true`, `false`
455 - **Stable**: No (tracking issue: #3384)
456
457 #### `false` (default):
458
459 ```rust
460 fn main() {
461     let (lorem, ipsum, _, _) = (1, 2, 3, 4);
462     let (lorem, ipsum, ..) = (1, 2, 3, 4);
463 }
464 ```
465
466 #### `true`:
467
468 ```rust
469 fn main() {
470     let (lorem, ipsum, ..) = (1, 2, 3, 4);
471 }
472 ```
473
474 ## `control_brace_style`
475
476 Brace style for control flow constructs
477
478 - **Default value**: `"AlwaysSameLine"`
479 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
480 - **Stable**: No (tracking issue: #3377)
481
482 #### `"AlwaysSameLine"` (default):
483
484 ```rust
485 fn main() {
486     if lorem {
487         println!("ipsum!");
488     } else {
489         println!("dolor!");
490     }
491 }
492 ```
493
494 #### `"AlwaysNextLine"`:
495
496 ```rust
497 fn main() {
498     if lorem
499     {
500         println!("ipsum!");
501     }
502     else
503     {
504         println!("dolor!");
505     }
506 }
507 ```
508
509 #### `"ClosingNextLine"`:
510
511 ```rust
512 fn main() {
513     if lorem {
514         println!("ipsum!");
515     }
516     else {
517         println!("dolor!");
518     }
519 }
520 ```
521
522 ## `disable_all_formatting`
523
524 Don't reformat anything.
525
526 Note that this option may be soft-deprecated in the future once the [ignore](#ignore) option is stabilized. Nightly toolchain users are encouraged to use [ignore](#ignore) instead when possible.
527
528 - **Default value**: `false`
529 - **Possible values**: `true`, `false`
530 - **Stable**: Yes
531
532 ## `edition`
533
534 Specifies which edition is used by the parser.
535
536 - **Default value**: `"2015"`
537 - **Possible values**: `"2015"`, `"2018"`, `"2021"`
538 - **Stable**: Yes
539
540 Rustfmt is able to pick up the edition used by reading the `Cargo.toml` file if executed
541 through the Cargo's formatting tool `cargo fmt`. Otherwise, the edition needs to be specified
542 in your config file:
543
544 ```toml
545 edition = "2018"
546 ```
547
548 ## `empty_item_single_line`
549
550 Put empty-body functions and impls on a single line
551
552 - **Default value**: `true`
553 - **Possible values**: `true`, `false`
554 - **Stable**: No (tracking issue: #3356)
555
556 #### `true` (default):
557
558 ```rust
559 fn lorem() {}
560
561 impl Lorem {}
562 ```
563
564 #### `false`:
565
566 ```rust
567 fn lorem() {
568 }
569
570 impl Lorem {
571 }
572 ```
573
574 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
575
576
577 ## `enum_discrim_align_threshold`
578
579 The maximum length of enum variant having discriminant, that gets vertically aligned with others.
580 Variants without discriminants would be ignored for the purpose of alignment.
581
582 Note that this is not how much whitespace is inserted, but instead the longest variant name that
583 doesn't get ignored when aligning.
584
585 - **Default value** : 0
586 - **Possible values**: any positive integer
587 - **Stable**: No (tracking issue: #3372)
588
589 #### `0` (default):
590
591 ```rust
592 enum Bar {
593     A = 0,
594     Bb = 1,
595     RandomLongVariantGoesHere = 10,
596     Ccc = 71,
597 }
598
599 enum Bar {
600     VeryLongVariantNameHereA = 0,
601     VeryLongVariantNameHereBb = 1,
602     VeryLongVariantNameHereCcc = 2,
603 }
604 ```
605
606 #### `20`:
607
608 ```rust
609 enum Foo {
610     A   = 0,
611     Bb  = 1,
612     RandomLongVariantGoesHere = 10,
613     Ccc = 2,
614 }
615
616 enum Bar {
617     VeryLongVariantNameHereA = 0,
618     VeryLongVariantNameHereBb = 1,
619     VeryLongVariantNameHereCcc = 2,
620 }
621 ```
622
623
624 ## `error_on_line_overflow`
625
626 Error if Rustfmt is unable to get all lines within `max_width`, except for comments and string
627 literals. If this happens, then it is a bug in Rustfmt. You might be able to work around the bug by
628 refactoring your code to avoid long/complex expressions, usually by extracting a local variable or
629 using a shorter name.
630
631 - **Default value**: `false`
632 - **Possible values**: `true`, `false`
633 - **Stable**: No (tracking issue: #3391)
634
635 See also [`max_width`](#max_width).
636
637 ## `error_on_unformatted`
638
639 Error if unable to get comments or string literals within `max_width`, or they are left with
640 trailing whitespaces.
641
642 - **Default value**: `false`
643 - **Possible values**: `true`, `false`
644 - **Stable**: No (tracking issue: #3392)
645
646 ## `fn_args_layout`
647
648 Control the layout of arguments in a function
649
650 - **Default value**: `"Tall"`
651 - **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
652 - **Stable**: Yes
653
654 #### `"Tall"` (default):
655
656 ```rust
657 trait Lorem {
658     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
659
660     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
661         // body
662     }
663
664     fn lorem(
665         ipsum: Ipsum,
666         dolor: Dolor,
667         sit: Sit,
668         amet: Amet,
669         consectetur: Consectetur,
670         adipiscing: Adipiscing,
671         elit: Elit,
672     );
673
674     fn lorem(
675         ipsum: Ipsum,
676         dolor: Dolor,
677         sit: Sit,
678         amet: Amet,
679         consectetur: Consectetur,
680         adipiscing: Adipiscing,
681         elit: Elit,
682     ) {
683         // body
684     }
685 }
686 ```
687
688 #### `"Compressed"`:
689
690 ```rust
691 trait Lorem {
692     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
693
694     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
695         // body
696     }
697
698     fn lorem(
699         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
700         adipiscing: Adipiscing, elit: Elit,
701     );
702
703     fn lorem(
704         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
705         adipiscing: Adipiscing, elit: Elit,
706     ) {
707         // body
708     }
709 }
710 ```
711
712 #### `"Vertical"`:
713
714 ```rust
715 trait Lorem {
716     fn lorem(
717         ipsum: Ipsum,
718         dolor: Dolor,
719         sit: Sit,
720         amet: Amet,
721     );
722
723     fn lorem(
724         ipsum: Ipsum,
725         dolor: Dolor,
726         sit: Sit,
727         amet: Amet,
728     ) {
729         // body
730     }
731
732     fn lorem(
733         ipsum: Ipsum,
734         dolor: Dolor,
735         sit: Sit,
736         amet: Amet,
737         consectetur: Consectetur,
738         adipiscing: Adipiscing,
739         elit: Elit,
740     );
741
742     fn lorem(
743         ipsum: Ipsum,
744         dolor: Dolor,
745         sit: Sit,
746         amet: Amet,
747         consectetur: Consectetur,
748         adipiscing: Adipiscing,
749         elit: Elit,
750     ) {
751         // body
752     }
753 }
754 ```
755
756 ## `fn_call_width`
757
758 Maximum width of the args of a function call before falling back to vertical formatting.
759
760 - **Default value**: `60`
761 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
762 - **Stable**: Yes
763
764 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `fn_call_width` will take precedence.
765
766 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
767
768 ## `fn_single_line`
769
770 Put single-expression functions on a single line
771
772 - **Default value**: `false`
773 - **Possible values**: `true`, `false`
774 - **Stable**: No (tracking issue: #3358)
775
776 #### `false` (default):
777
778 ```rust
779 fn lorem() -> usize {
780     42
781 }
782
783 fn lorem() -> usize {
784     let ipsum = 42;
785     ipsum
786 }
787 ```
788
789 #### `true`:
790
791 ```rust
792 fn lorem() -> usize { 42 }
793
794 fn lorem() -> usize {
795     let ipsum = 42;
796     ipsum
797 }
798 ```
799
800 See also [`control_brace_style`](#control_brace_style).
801
802
803 ## `force_explicit_abi`
804
805 Always print the abi for extern items
806
807 - **Default value**: `true`
808 - **Possible values**: `true`, `false`
809 - **Stable**: Yes
810
811 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
812
813 #### `true` (default):
814
815 ```rust
816 extern "C" {
817     pub static lorem: c_int;
818 }
819 ```
820
821 #### `false`:
822
823 ```rust
824 extern {
825     pub static lorem: c_int;
826 }
827 ```
828
829 ## `force_multiline_blocks`
830
831 Force multiline closure and match arm bodies to be wrapped in a block
832
833 - **Default value**: `false`
834 - **Possible values**: `false`, `true`
835 - **Stable**: No (tracking issue: #3374)
836
837 #### `false` (default):
838
839 ```rust
840 fn main() {
841     result.and_then(|maybe_value| match maybe_value {
842         None => foo(),
843         Some(value) => bar(),
844     });
845
846     match lorem {
847         None => |ipsum| {
848             println!("Hello World");
849         },
850         Some(dolor) => foo(),
851     }
852 }
853 ```
854
855 #### `true`:
856
857 ```rust
858 fn main() {
859     result.and_then(|maybe_value| {
860         match maybe_value {
861             None => foo(),
862             Some(value) => bar(),
863         }
864     });
865
866     match lorem {
867         None => {
868             |ipsum| {
869                 println!("Hello World");
870             }
871         }
872         Some(dolor) => foo(),
873     }
874 }
875 ```
876
877
878 ## `format_code_in_doc_comments`
879
880 Format code snippet included in doc comments.
881
882 - **Default value**: `false`
883 - **Possible values**: `true`, `false`
884 - **Stable**: No (tracking issue: #3348)
885
886 #### `false` (default):
887
888 ```rust
889 /// Adds one to the number given.
890 ///
891 /// # Examples
892 ///
893 /// ```rust
894 /// let five=5;
895 ///
896 /// assert_eq!(
897 ///     6,
898 ///     add_one(5)
899 /// );
900 /// # fn add_one(x: i32) -> i32 {
901 /// #     x + 1
902 /// # }
903 /// ```
904 fn add_one(x: i32) -> i32 {
905     x + 1
906 }
907 ```
908
909 #### `true`
910
911 ```rust
912 /// Adds one to the number given.
913 ///
914 /// # Examples
915 ///
916 /// ```rust
917 /// let five = 5;
918 ///
919 /// assert_eq!(6, add_one(5));
920 /// # fn add_one(x: i32) -> i32 {
921 /// #     x + 1
922 /// # }
923 /// ```
924 fn add_one(x: i32) -> i32 {
925     x + 1
926 }
927 ```
928
929 ## `format_generated_files`
930
931 Format generated files. A file is considered generated
932 if any of the first five lines contains `@generated` marker.
933
934 - **Default value**: `false`
935 - **Possible values**: `true`, `false`
936 - **Stable**: No
937
938 ## `format_macro_matchers`
939
940 Format the metavariable matching patterns in macros.
941
942 - **Default value**: `false`
943 - **Possible values**: `true`, `false`
944 - **Stable**: No (tracking issue: #3354)
945
946 #### `false` (default):
947
948 ```rust
949 macro_rules! foo {
950     ($a: ident : $b: ty) => {
951         $a(42): $b;
952     };
953     ($a: ident $b: ident $c: ident) => {
954         $a = $b + $c;
955     };
956 }
957 ```
958
959 #### `true`:
960
961 ```rust
962 macro_rules! foo {
963     ($a:ident : $b:ty) => {
964         $a(42): $b;
965     };
966     ($a:ident $b:ident $c:ident) => {
967         $a = $b + $c;
968     };
969 }
970 ```
971
972 See also [`format_macro_bodies`](#format_macro_bodies).
973
974
975 ## `format_macro_bodies`
976
977 Format the bodies of macros.
978
979 - **Default value**: `true`
980 - **Possible values**: `true`, `false`
981 - **Stable**: No (tracking issue: #3355)
982
983 #### `true` (default):
984
985 ```rust
986 macro_rules! foo {
987     ($a: ident : $b: ty) => {
988         $a(42): $b;
989     };
990     ($a: ident $b: ident $c: ident) => {
991         $a = $b + $c;
992     };
993 }
994 ```
995
996 #### `false`:
997
998 ```rust
999 macro_rules! foo {
1000     ($a: ident : $b: ty) => { $a(42): $b; };
1001     ($a: ident $b: ident $c: ident) => { $a=$b+$c; };
1002 }
1003 ```
1004
1005 See also [`format_macro_matchers`](#format_macro_matchers).
1006
1007
1008 ## `format_strings`
1009
1010 Format string literals where necessary
1011
1012 - **Default value**: `false`
1013 - **Possible values**: `true`, `false`
1014 - **Stable**: No (tracking issue: #3353)
1015
1016 #### `false` (default):
1017
1018 ```rust
1019 fn main() {
1020     let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing";
1021 }
1022 ```
1023
1024 #### `true`:
1025
1026 ```rust
1027 fn main() {
1028     let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet \
1029                  consectetur adipiscing";
1030 }
1031 ```
1032
1033 See also [`max_width`](#max_width).
1034
1035 ## `hard_tabs`
1036
1037 Use tab characters for indentation, spaces for alignment
1038
1039 - **Default value**: `false`
1040 - **Possible values**: `true`, `false`
1041 - **Stable**: Yes
1042
1043 #### `false` (default):
1044
1045 ```rust
1046 fn lorem() -> usize {
1047     42 // spaces before 42
1048 }
1049 ```
1050
1051 #### `true`:
1052
1053 ```rust
1054 fn lorem() -> usize {
1055         42 // tabs before 42
1056 }
1057 ```
1058
1059 See also: [`tab_spaces`](#tab_spaces).
1060
1061 ## `hex_literal_case`
1062
1063 Control the case of the letters in hexadecimal literal values
1064
1065 - **Default value**: `Preserve`
1066 - **Possible values**: `Upper`, `Lower`
1067 - **Stable**: No
1068
1069 ## `hide_parse_errors`
1070
1071 Do not show parse errors if the parser failed to parse files.
1072
1073 - **Default value**: `false`
1074 - **Possible values**: `true`, `false`
1075 - **Stable**: No (tracking issue: #3390)
1076
1077 ## `ignore`
1078
1079 Skip formatting files and directories that match the specified pattern.
1080 The pattern format is the same as [.gitignore](https://git-scm.com/docs/gitignore#_pattern_format). Be sure to use Unix/forwardslash `/` style  paths. This path style will work on all platforms. Windows style paths with backslashes `\` are not supported.
1081
1082 - **Default value**: format every file
1083 - **Possible values**: See an example below
1084 - **Stable**: No (tracking issue: #3395)
1085
1086 ### Example
1087
1088 If you want to ignore specific files, put the following to your config file:
1089
1090 ```toml
1091 ignore = [
1092     "src/types.rs",
1093     "src/foo/bar.rs",
1094 ]
1095 ```
1096
1097 If you want to ignore every file under `examples/`, put the following to your config file:
1098
1099 ```toml
1100 ignore = [
1101     "examples",
1102 ]
1103 ```
1104
1105 If you want to ignore every file under the directory where you put your rustfmt.toml:
1106
1107 ```toml
1108 ignore = ["/"]
1109 ```
1110
1111 ## `imports_indent`
1112
1113 Indent style of imports
1114
1115 - **Default Value**: `"Block"`
1116 - **Possible values**: `"Block"`, `"Visual"`
1117 - **Stable**: No (tracking issue: #3360)
1118
1119 #### `"Block"` (default):
1120
1121 ```rust
1122 use foo::{
1123     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1124     zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
1125 };
1126 ```
1127
1128 #### `"Visual"`:
1129
1130 ```rust
1131 use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1132           zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
1133 ```
1134
1135 See also: [`imports_layout`](#imports_layout).
1136
1137 ## `imports_layout`
1138
1139 Item layout inside a imports block
1140
1141 - **Default value**: "Mixed"
1142 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1143 - **Stable**: No (tracking issue: #3361)
1144
1145 #### `"Mixed"` (default):
1146
1147 ```rust
1148 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1149
1150 use foo::{
1151     aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
1152     eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
1153 };
1154 ```
1155
1156 #### `"Horizontal"`:
1157
1158 **Note**: This option forces all imports onto one line and may exceed `max_width`.
1159
1160 ```rust
1161 use foo::{xxx, yyy, zzz};
1162
1163 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1164 ```
1165
1166 #### `"HorizontalVertical"`:
1167
1168 ```rust
1169 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1170
1171 use foo::{
1172     aaaaaaaaaaaaaaaaaa,
1173     bbbbbbbbbbbbbbbbbb,
1174     cccccccccccccccccc,
1175     dddddddddddddddddd,
1176     eeeeeeeeeeeeeeeeee,
1177     ffffffffffffffffff,
1178 };
1179 ```
1180
1181 #### `"Vertical"`:
1182
1183 ```rust
1184 use foo::{
1185     xxx,
1186     yyy,
1187     zzz,
1188 };
1189
1190 use foo::{
1191     aaa,
1192     bbb,
1193     ccc,
1194     ddd,
1195     eee,
1196     fff,
1197 };
1198 ```
1199
1200 ## `indent_style`
1201
1202 Indent on expressions or items.
1203
1204 - **Default value**: `"Block"`
1205 - **Possible values**: `"Block"`, `"Visual"`
1206 - **Stable**: No (tracking issue: #3346)
1207
1208 ### Array
1209
1210 #### `"Block"` (default):
1211
1212 ```rust
1213 fn main() {
1214     let lorem = vec![
1215         "ipsum",
1216         "dolor",
1217         "sit",
1218         "amet",
1219         "consectetur",
1220         "adipiscing",
1221         "elit",
1222     ];
1223 }
1224 ```
1225
1226 #### `"Visual"`:
1227
1228 ```rust
1229 fn main() {
1230     let lorem = vec!["ipsum",
1231                      "dolor",
1232                      "sit",
1233                      "amet",
1234                      "consectetur",
1235                      "adipiscing",
1236                      "elit"];
1237 }
1238 ```
1239
1240 ### Control flow
1241
1242 #### `"Block"` (default):
1243
1244 ```rust
1245 fn main() {
1246     if lorem_ipsum
1247         && dolor_sit
1248         && amet_consectetur
1249         && lorem_sit
1250         && dolor_consectetur
1251         && amet_ipsum
1252         && lorem_consectetur
1253     {
1254         // ...
1255     }
1256 }
1257 ```
1258
1259 #### `"Visual"`:
1260
1261 ```rust
1262 fn main() {
1263     if lorem_ipsum
1264        && dolor_sit
1265        && amet_consectetur
1266        && lorem_sit
1267        && dolor_consectetur
1268        && amet_ipsum
1269        && lorem_consectetur
1270     {
1271         // ...
1272     }
1273 }
1274 ```
1275
1276 See also: [`control_brace_style`](#control_brace_style).
1277
1278 ### Function arguments
1279
1280 #### `"Block"` (default):
1281
1282 ```rust
1283 fn lorem() {}
1284
1285 fn lorem(ipsum: usize) {}
1286
1287 fn lorem(
1288     ipsum: usize,
1289     dolor: usize,
1290     sit: usize,
1291     amet: usize,
1292     consectetur: usize,
1293     adipiscing: usize,
1294     elit: usize,
1295 ) {
1296     // body
1297 }
1298 ```
1299
1300 #### `"Visual"`:
1301
1302 ```rust
1303 fn lorem() {}
1304
1305 fn lorem(ipsum: usize) {}
1306
1307 fn lorem(ipsum: usize,
1308          dolor: usize,
1309          sit: usize,
1310          amet: usize,
1311          consectetur: usize,
1312          adipiscing: usize,
1313          elit: usize) {
1314     // body
1315 }
1316 ```
1317
1318 ### Function calls
1319
1320 #### `"Block"` (default):
1321
1322 ```rust
1323 fn main() {
1324     lorem(
1325         "lorem",
1326         "ipsum",
1327         "dolor",
1328         "sit",
1329         "amet",
1330         "consectetur",
1331         "adipiscing",
1332         "elit",
1333     );
1334 }
1335 ```
1336
1337 #### `"Visual"`:
1338
1339 ```rust
1340 fn main() {
1341     lorem("lorem",
1342           "ipsum",
1343           "dolor",
1344           "sit",
1345           "amet",
1346           "consectetur",
1347           "adipiscing",
1348           "elit");
1349 }
1350 ```
1351
1352 ### Generics
1353
1354 #### `"Block"` (default):
1355
1356 ```rust
1357 fn lorem<
1358     Ipsum: Eq = usize,
1359     Dolor: Eq = usize,
1360     Sit: Eq = usize,
1361     Amet: Eq = usize,
1362     Adipiscing: Eq = usize,
1363     Consectetur: Eq = usize,
1364     Elit: Eq = usize,
1365 >(
1366     ipsum: Ipsum,
1367     dolor: Dolor,
1368     sit: Sit,
1369     amet: Amet,
1370     adipiscing: Adipiscing,
1371     consectetur: Consectetur,
1372     elit: Elit,
1373 ) -> T {
1374     // body
1375 }
1376 ```
1377
1378 #### `"Visual"`:
1379
1380 ```rust
1381 fn lorem<Ipsum: Eq = usize,
1382          Dolor: Eq = usize,
1383          Sit: Eq = usize,
1384          Amet: Eq = usize,
1385          Adipiscing: Eq = usize,
1386          Consectetur: Eq = usize,
1387          Elit: Eq = usize>(
1388     ipsum: Ipsum,
1389     dolor: Dolor,
1390     sit: Sit,
1391     amet: Amet,
1392     adipiscing: Adipiscing,
1393     consectetur: Consectetur,
1394     elit: Elit)
1395     -> T {
1396     // body
1397 }
1398 ```
1399
1400 #### Struct
1401
1402 #### `"Block"` (default):
1403
1404 ```rust
1405 fn main() {
1406     let lorem = Lorem {
1407         ipsum: dolor,
1408         sit: amet,
1409     };
1410 }
1411 ```
1412
1413 #### `"Visual"`:
1414
1415 ```rust
1416 fn main() {
1417     let lorem = Lorem { ipsum: dolor,
1418                         sit: amet };
1419 }
1420 ```
1421
1422 See also: [`struct_lit_single_line`](#struct_lit_single_line), [`indent_style`](#indent_style).
1423
1424 ### Where predicates
1425
1426 #### `"Block"` (default):
1427
1428 ```rust
1429 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
1430 where
1431     Ipsum: Eq,
1432     Dolor: Eq,
1433     Sit: Eq,
1434     Amet: Eq,
1435 {
1436     // body
1437 }
1438 ```
1439
1440 #### `"Visual"`:
1441
1442 ```rust
1443 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
1444     where Ipsum: Eq,
1445           Dolor: Eq,
1446           Sit: Eq,
1447           Amet: Eq
1448 {
1449     // body
1450 }
1451 ```
1452
1453 ## `inline_attribute_width`
1454
1455 Write an item and its attribute on the same line if their combined width is below a threshold
1456
1457 - **Default value**: 0
1458 - **Possible values**: any positive integer
1459 - **Stable**: No (tracking issue: #3343)
1460
1461 ### Example
1462
1463 #### `0` (default):
1464 ```rust
1465 #[cfg(feature = "alloc")]
1466 use core::slice;
1467 ```
1468
1469 #### `50`:
1470 ```rust
1471 #[cfg(feature = "alloc")] use core::slice;
1472 ```
1473
1474 ## `license_template_path`
1475
1476 Check whether beginnings of files match a license template.
1477
1478 - **Default value**: `""`
1479 - **Possible values**: path to a license template file
1480 - **Stable**: No (tracking issue: #3352)
1481
1482 A license template is a plain text file which is matched literally against the
1483 beginning of each source file, except for `{}`-delimited blocks, which are
1484 matched as regular expressions. The following license template therefore
1485 matches strings like `// Copyright 2017 The Rust Project Developers.`, `//
1486 Copyright 2018 The Rust Project Developers.`, etc.:
1487
1488 ```
1489 // Copyright {\d+} The Rust Project Developers.
1490 ```
1491
1492 `\{`, `\}` and `\\` match literal braces / backslashes.
1493
1494 ## `match_arm_blocks`
1495
1496 Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator.
1497
1498 The Style Guide requires that bodies are block wrapped by default if a line break is required after the `=>`, but this option can be used to disable that behavior to prevent wrapping arm bodies in that event, so long as the body does not contain multiple statements nor line comments.
1499
1500 - **Default value**: `true`
1501 - **Possible values**: `true`, `false`
1502 - **Stable**: No (tracking issue: #3373)
1503
1504 #### `true` (default):
1505
1506 ```rust
1507 fn main() {
1508     match lorem {
1509         ipsum => {
1510             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
1511         }
1512         dolor => println!("{}", sit),
1513         sit => foo(
1514             "foooooooooooooooooooooooo",
1515             "baaaaaaaaaaaaaaaaaaaaaaaarr",
1516             "baaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzz",
1517             "qqqqqqqqquuuuuuuuuuuuuuuuuuuuuuuuuuxxx",
1518         ),
1519     }
1520 }
1521 ```
1522
1523 #### `false`:
1524
1525 ```rust
1526 fn main() {
1527     match lorem {
1528         lorem =>
1529             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
1530         ipsum => println!("{}", sit),
1531         sit => foo(
1532             "foooooooooooooooooooooooo",
1533             "baaaaaaaaaaaaaaaaaaaaaaaarr",
1534             "baaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzz",
1535             "qqqqqqqqquuuuuuuuuuuuuuuuuuuuuuuuuuxxx",
1536         ),
1537     }
1538 }
1539 ```
1540
1541 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
1542
1543 ## `match_arm_leading_pipes`
1544
1545 Controls whether to include a leading pipe on match arms
1546
1547 - **Default value**: `Never`
1548 - **Possible values**: `Always`, `Never`, `Preserve`
1549 - **Stable**: Yes
1550
1551 #### `Never` (default):
1552 ```rust
1553 // Leading pipes are removed from this:
1554 // fn foo() {
1555 //     match foo {
1556 //         | "foo" | "bar" => {}
1557 //         | "baz"
1558 //         | "something relatively long"
1559 //         | "something really really really realllllllllllllly long" => println!("x"),
1560 //         | "qux" => println!("y"),
1561 //         _ => {}
1562 //     }
1563 // }
1564
1565 // Becomes
1566 fn foo() {
1567     match foo {
1568         "foo" | "bar" => {}
1569         "baz"
1570         | "something relatively long"
1571         | "something really really really realllllllllllllly long" => println!("x"),
1572         "qux" => println!("y"),
1573         _ => {}
1574     }
1575 }
1576 ```
1577
1578 #### `Always`:
1579 ```rust
1580 // Leading pipes are emitted on all arms of this:
1581 // fn foo() {
1582 //     match foo {
1583 //         "foo" | "bar" => {}
1584 //         "baz"
1585 //         | "something relatively long"
1586 //         | "something really really really realllllllllllllly long" => println!("x"),
1587 //         "qux" => println!("y"),
1588 //         _ => {}
1589 //     }
1590 // }
1591
1592 // Becomes:
1593 fn foo() {
1594     match foo {
1595         | "foo" | "bar" => {}
1596         | "baz"
1597         | "something relatively long"
1598         | "something really really really realllllllllllllly long" => println!("x"),
1599         | "qux" => println!("y"),
1600         | _ => {}
1601     }
1602 }
1603 ```
1604
1605 #### `Preserve`:
1606 ```rust
1607 fn foo() {
1608     match foo {
1609         | "foo" | "bar" => {}
1610         | "baz"
1611         | "something relatively long"
1612         | "something really really really realllllllllllllly long" => println!("x"),
1613         | "qux" => println!("y"),
1614         _ => {}
1615     }
1616
1617     match baz {
1618         "qux" => {}
1619         "foo" | "bar" => {}
1620         _ => {}
1621     }
1622 }
1623 ```
1624
1625 ## `match_block_trailing_comma`
1626
1627 Put a trailing comma after a block based match arm (non-block arms are not affected)
1628
1629 - **Default value**: `false`
1630 - **Possible values**: `true`, `false`
1631 - **Stable**: Yes
1632
1633 #### `false` (default):
1634
1635 ```rust
1636 fn main() {
1637     match lorem {
1638         Lorem::Ipsum => {
1639             println!("ipsum");
1640         }
1641         Lorem::Dolor => println!("dolor"),
1642     }
1643 }
1644 ```
1645
1646 #### `true`:
1647
1648 ```rust
1649 fn main() {
1650     match lorem {
1651         Lorem::Ipsum => {
1652             println!("ipsum");
1653         },
1654         Lorem::Dolor => println!("dolor"),
1655     }
1656 }
1657 ```
1658
1659 See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
1660
1661 ## `max_width`
1662
1663 Maximum width of each line
1664
1665 - **Default value**: `100`
1666 - **Possible values**: any positive integer
1667 - **Stable**: Yes
1668
1669 See also [`error_on_line_overflow`](#error_on_line_overflow).
1670
1671 ## `merge_derives`
1672
1673 Merge multiple derives into a single one.
1674
1675 - **Default value**: `true`
1676 - **Possible values**: `true`, `false`
1677 - **Stable**: Yes
1678
1679 #### `true` (default):
1680
1681 ```rust
1682 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1683 pub enum Foo {}
1684 ```
1685
1686 #### `false`:
1687
1688 ```rust
1689 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1690 pub enum Bar {}
1691
1692 #[derive(Eq, PartialEq)]
1693 #[derive(Debug)]
1694 #[derive(Copy, Clone)]
1695 pub enum Foo {}
1696 ```
1697
1698 ## `imports_granularity`
1699
1700 How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
1701
1702 - **Default value**: `Preserve`
1703 - **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One`
1704 - **Stable**: No
1705
1706 #### `Preserve` (default):
1707
1708 Do not change the granularity of any imports and preserve the original structure written by the developer.
1709
1710 ```rust
1711 use foo::b;
1712 use foo::b::{f, g};
1713 use foo::{a, c, d::e};
1714 use qux::{h, i};
1715 ```
1716
1717 #### `Crate`:
1718
1719 Merge imports from the same crate into a single `use` statement. Conversely, imports from different crates are split into separate statements.
1720
1721 ```rust
1722 use foo::{
1723     a, b,
1724     b::{f, g},
1725     c,
1726     d::e,
1727 };
1728 use qux::{h, i};
1729 ```
1730
1731 #### `Module`:
1732
1733 Merge imports from the same module into a single `use` statement. Conversely, imports from different modules are split into separate statements.
1734
1735 ```rust
1736 use foo::b::{f, g};
1737 use foo::d::e;
1738 use foo::{a, b, c};
1739 use qux::{h, i};
1740 ```
1741
1742 #### `Item`:
1743
1744 Flatten imports so that each has its own `use` statement.
1745
1746 ```rust
1747 use foo::a;
1748 use foo::b;
1749 use foo::b::f;
1750 use foo::b::g;
1751 use foo::c;
1752 use foo::d::e;
1753 use qux::h;
1754 use qux::i;
1755 ```
1756
1757 #### `One`:
1758
1759 Merge all imports into a single `use` statement as long as they have the same visibility.
1760
1761 ```rust
1762 pub use foo::{x, y};
1763 use {
1764     bar::{
1765         a,
1766         b::{self, f, g},
1767         c,
1768         d::e,
1769     },
1770     qux::{h, i},
1771 };
1772 ```
1773
1774 ## `merge_imports`
1775
1776 This option is deprecated. Use `imports_granularity = "Crate"` instead.
1777
1778 - **Default value**: `false`
1779 - **Possible values**: `true`, `false`
1780
1781 #### `false` (default):
1782
1783 ```rust
1784 use foo::{a, c, d};
1785 use foo::{b, g};
1786 use foo::{e, f};
1787 ```
1788
1789 #### `true`:
1790
1791 ```rust
1792 use foo::{a, b, c, d, e, f, g};
1793 ```
1794
1795
1796 ## `newline_style`
1797
1798 Unix or Windows line endings
1799
1800 - **Default value**: `"Auto"`
1801 - **Possible values**: `"Auto"`, `"Native"`, `"Unix"`, `"Windows"`
1802 - **Stable**: Yes
1803
1804 #### `Auto` (default):
1805
1806 The newline style is detected automatically on a per-file basis. Files
1807 with mixed line endings will be converted to the first detected line
1808 ending style.
1809
1810 #### `Native`
1811
1812 Line endings will be converted to `\r\n` on Windows and `\n` on all
1813 other platforms.
1814
1815 #### `Unix`
1816
1817 Line endings will be converted to `\n`.
1818
1819 #### `Windows`
1820
1821 Line endings will be converted to `\r\n`.
1822
1823 ## `normalize_comments`
1824
1825 Convert /* */ comments to // comments where possible
1826
1827 - **Default value**: `false`
1828 - **Possible values**: `true`, `false`
1829 - **Stable**: No (tracking issue: #3350)
1830
1831 #### `false` (default):
1832
1833 ```rust
1834 // Lorem ipsum:
1835 fn dolor() -> usize {}
1836
1837 /* sit amet: */
1838 fn adipiscing() -> usize {}
1839 ```
1840
1841 #### `true`:
1842
1843 ```rust
1844 // Lorem ipsum:
1845 fn dolor() -> usize {}
1846
1847 // sit amet:
1848 fn adipiscing() -> usize {}
1849 ```
1850
1851 ## `normalize_doc_attributes`
1852
1853 Convert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments.
1854
1855 - **Default value**: `false`
1856 - **Possible values**: `true`, `false`
1857 - **Stable**: No (tracking issue: #3351)
1858
1859 #### `false` (default):
1860
1861 ```rust
1862 #![doc = "Example documentation"]
1863
1864 #[doc = "Example item documentation"]
1865 pub enum Bar {}
1866
1867 /// Example item documentation
1868 pub enum Foo {}
1869 ```
1870
1871 #### `true`:
1872
1873 ```rust
1874 //! Example documentation
1875
1876 /// Example item documentation
1877 pub enum Foo {}
1878 ```
1879
1880 ## `overflow_delimited_expr`
1881
1882 When structs, slices, arrays, and block/array-like macros are used as the last
1883 argument in an expression list, allow them to overflow (like blocks/closures)
1884 instead of being indented on a new line.
1885
1886 - **Default value**: `false`
1887 - **Possible values**: `true`, `false`
1888 - **Stable**: No (tracking issue: #3370)
1889
1890 #### `false` (default):
1891
1892 ```rust
1893 fn example() {
1894     foo(ctx, |param| {
1895         action();
1896         foo(param)
1897     });
1898
1899     foo(
1900         ctx,
1901         Bar {
1902             x: value,
1903             y: value2,
1904         },
1905     );
1906
1907     foo(
1908         ctx,
1909         &[
1910             MAROON_TOMATOES,
1911             PURPLE_POTATOES,
1912             ORGANE_ORANGES,
1913             GREEN_PEARS,
1914             RED_APPLES,
1915         ],
1916     );
1917
1918     foo(
1919         ctx,
1920         vec![
1921             MAROON_TOMATOES,
1922             PURPLE_POTATOES,
1923             ORGANE_ORANGES,
1924             GREEN_PEARS,
1925             RED_APPLES,
1926         ],
1927     );
1928 }
1929 ```
1930
1931 #### `true`:
1932
1933 ```rust
1934 fn example() {
1935     foo(ctx, |param| {
1936         action();
1937         foo(param)
1938     });
1939
1940     foo(ctx, Bar {
1941         x: value,
1942         y: value2,
1943     });
1944
1945     foo(ctx, &[
1946         MAROON_TOMATOES,
1947         PURPLE_POTATOES,
1948         ORGANE_ORANGES,
1949         GREEN_PEARS,
1950         RED_APPLES,
1951     ]);
1952
1953     foo(ctx, vec![
1954         MAROON_TOMATOES,
1955         PURPLE_POTATOES,
1956         ORGANE_ORANGES,
1957         GREEN_PEARS,
1958         RED_APPLES,
1959     ]);
1960 }
1961 ```
1962
1963 ## `remove_nested_parens`
1964
1965 Remove nested parens.
1966
1967 - **Default value**: `true`,
1968 - **Possible values**: `true`, `false`
1969 - **Stable**: Yes
1970
1971
1972 #### `true` (default):
1973 ```rust
1974 fn main() {
1975     (foo());
1976 }
1977 ```
1978
1979 #### `false`:
1980 ```rust
1981 fn main() {
1982     (foo());
1983
1984     ((((foo()))));
1985 }
1986 ```
1987
1988
1989 ## `reorder_impl_items`
1990
1991 Reorder impl items. `type` and `const` are put first, then macros and methods.
1992
1993 - **Default value**: `false`
1994 - **Possible values**: `true`, `false`
1995 - **Stable**: No (tracking issue: #3363)
1996
1997 #### `false` (default)
1998
1999 ```rust
2000 struct Dummy;
2001
2002 impl Iterator for Dummy {
2003     fn next(&mut self) -> Option<Self::Item> {
2004         None
2005     }
2006
2007     type Item = i32;
2008 }
2009
2010 impl Iterator for Dummy {
2011     type Item = i32;
2012
2013     fn next(&mut self) -> Option<Self::Item> {
2014         None
2015     }
2016 }
2017 ```
2018
2019 #### `true`
2020
2021 ```rust
2022 struct Dummy;
2023
2024 impl Iterator for Dummy {
2025     type Item = i32;
2026
2027     fn next(&mut self) -> Option<Self::Item> {
2028         None
2029     }
2030 }
2031 ```
2032
2033 ## `reorder_imports`
2034
2035 Reorder import and extern crate statements alphabetically in groups (a group is
2036 separated by a newline).
2037
2038 - **Default value**: `true`
2039 - **Possible values**: `true`, `false`
2040 - **Stable**: Yes
2041
2042 #### `true` (default):
2043
2044 ```rust
2045 use dolor;
2046 use ipsum;
2047 use lorem;
2048 use sit;
2049 ```
2050
2051 #### `false`:
2052
2053 ```rust
2054 use lorem;
2055 use ipsum;
2056 use dolor;
2057 use sit;
2058 ```
2059
2060 ## `group_imports`
2061
2062 Controls the strategy for how imports are grouped together.
2063
2064 - **Default value**: `Preserve`
2065 - **Possible values**: `Preserve`, `StdExternalCrate`
2066 - **Stable**: No
2067
2068 #### `Preserve` (default):
2069
2070 Preserve the source file's import groups.
2071
2072 ```rust
2073 use super::update::convert_publish_payload;
2074 use chrono::Utc;
2075
2076 use alloc::alloc::Layout;
2077 use juniper::{FieldError, FieldResult};
2078 use uuid::Uuid;
2079
2080 use std::sync::Arc;
2081
2082 use broker::database::PooledConnection;
2083
2084 use super::schema::{Context, Payload};
2085 use crate::models::Event;
2086 use core::f32;
2087 ```
2088
2089 #### `StdExternalCrate`:
2090
2091 Discard existing import groups, and create three groups for:
2092 1. `std`, `core` and `alloc`,
2093 2. external crates,
2094 3. `self`, `super` and `crate` imports.
2095
2096 ```rust
2097 use alloc::alloc::Layout;
2098 use core::f32;
2099 use std::sync::Arc;
2100
2101 use broker::database::PooledConnection;
2102 use chrono::Utc;
2103 use juniper::{FieldError, FieldResult};
2104 use uuid::Uuid;
2105
2106 use super::schema::{Context, Payload};
2107 use super::update::convert_publish_payload;
2108 use crate::models::Event;
2109 ```
2110
2111 ## `reorder_modules`
2112
2113 Reorder `mod` declarations alphabetically in group.
2114
2115 - **Default value**: `true`
2116 - **Possible values**: `true`, `false`
2117 - **Stable**: Yes
2118
2119 #### `true` (default)
2120
2121 ```rust
2122 mod a;
2123 mod b;
2124
2125 mod dolor;
2126 mod ipsum;
2127 mod lorem;
2128 mod sit;
2129 ```
2130
2131 #### `false`
2132
2133 ```rust
2134 mod b;
2135 mod a;
2136
2137 mod lorem;
2138 mod ipsum;
2139 mod dolor;
2140 mod sit;
2141 ```
2142
2143 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics
2144 of the original source code.
2145
2146 ## `report_fixme`
2147
2148 Report `FIXME` items in comments.
2149
2150 - **Default value**: `"Never"`
2151 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
2152 - **Stable**: No (tracking issue: #3394)
2153
2154 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
2155 it contains a `#X` (with `X` being a number) in parentheses following the
2156 `FIXME`, `"Unnumbered"` will ignore it.
2157
2158 See also [`report_todo`](#report_todo).
2159
2160
2161 ## `report_todo`
2162
2163 Report `TODO` items in comments.
2164
2165 - **Default value**: `"Never"`
2166 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
2167 - **Stable**: No (tracking issue: #3393)
2168
2169 Warns about any comments containing `TODO` in them when set to `"Always"`. If
2170 it contains a `#X` (with `X` being a number) in parentheses following the
2171 `TODO`, `"Unnumbered"` will ignore it.
2172
2173 See also [`report_fixme`](#report_fixme).
2174
2175 ## `required_version`
2176
2177 Require a specific version of rustfmt. If you want to make sure that the
2178 specific version of rustfmt is used in your CI, use this option.
2179
2180 - **Default value**: `CARGO_PKG_VERSION`
2181 - **Possible values**: any published version (e.g. `"0.3.8"`)
2182 - **Stable**: No (tracking issue: #3386)
2183
2184 ## `skip_children`
2185
2186 Don't reformat out of line modules
2187
2188 - **Default value**: `false`
2189 - **Possible values**: `true`, `false`
2190 - **Stable**: No (tracking issue: #3389)
2191
2192 ## `single_line_if_else_max_width`
2193
2194 Maximum line length for single line if-else expressions. A value of `0` (zero) results in if-else expressions always being broken into multiple lines. Note this occurs when `use_small_heuristics` is set to `Off`.
2195
2196 - **Default value**: `50`
2197 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2198 - **Stable**: Yes
2199
2200 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `single_line_if_else_max_width` will take precedence.
2201
2202 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
2203
2204 ## `space_after_colon`
2205
2206 Leave a space after the colon.
2207
2208 - **Default value**: `true`
2209 - **Possible values**: `true`, `false`
2210 - **Stable**: No (tracking issue: #3366)
2211
2212 #### `true` (default):
2213
2214 ```rust
2215 fn lorem<T: Eq>(t: T) {
2216     let lorem: Dolor = Lorem {
2217         ipsum: dolor,
2218         sit: amet,
2219     };
2220 }
2221 ```
2222
2223 #### `false`:
2224
2225 ```rust
2226 fn lorem<T:Eq>(t:T) {
2227     let lorem:Dolor = Lorem {
2228         ipsum:dolor,
2229         sit:amet,
2230     };
2231 }
2232 ```
2233
2234 See also: [`space_before_colon`](#space_before_colon).
2235
2236 ## `space_before_colon`
2237
2238 Leave a space before the colon.
2239
2240 - **Default value**: `false`
2241 - **Possible values**: `true`, `false`
2242 - **Stable**: No (tracking issue: #3365)
2243
2244 #### `false` (default):
2245
2246 ```rust
2247 fn lorem<T: Eq>(t: T) {
2248     let lorem: Dolor = Lorem {
2249         ipsum: dolor,
2250         sit: amet,
2251     };
2252 }
2253 ```
2254
2255 #### `true`:
2256
2257 ```rust
2258 fn lorem<T : Eq>(t : T) {
2259     let lorem : Dolor = Lorem {
2260         ipsum : dolor,
2261         sit : amet,
2262     };
2263 }
2264 ```
2265
2266 See also: [`space_after_colon`](#space_after_colon).
2267
2268 ## `spaces_around_ranges`
2269
2270 Put spaces around the .., ..=, and ... range operators
2271
2272 - **Default value**: `false`
2273 - **Possible values**: `true`, `false`
2274 - **Stable**: No (tracking issue: #3367)
2275
2276 #### `false` (default):
2277
2278 ```rust
2279 fn main() {
2280     let lorem = 0..10;
2281     let ipsum = 0..=10;
2282
2283     match lorem {
2284         1..5 => foo(),
2285         _ => bar,
2286     }
2287
2288     match lorem {
2289         1..=5 => foo(),
2290         _ => bar,
2291     }
2292
2293     match lorem {
2294         1...5 => foo(),
2295         _ => bar,
2296     }
2297 }
2298 ```
2299
2300 #### `true`:
2301
2302 ```rust
2303 fn main() {
2304     let lorem = 0 .. 10;
2305     let ipsum = 0 ..= 10;
2306
2307     match lorem {
2308         1 .. 5 => foo(),
2309         _ => bar,
2310     }
2311
2312     match lorem {
2313         1 ..= 5 => foo(),
2314         _ => bar,
2315     }
2316
2317     match lorem {
2318         1 ... 5 => foo(),
2319         _ => bar,
2320     }
2321 }
2322 ```
2323
2324 ## `struct_field_align_threshold`
2325
2326 The maximum diff of width between struct fields to be aligned with each other.
2327
2328 - **Default value** : 0
2329 - **Possible values**: any non-negative integer
2330 - **Stable**: No (tracking issue: #3371)
2331
2332 #### `0` (default):
2333
2334 ```rust
2335 struct Foo {
2336     x: u32,
2337     yy: u32,
2338     zzz: u32,
2339 }
2340 ```
2341
2342 #### `20`:
2343
2344 ```rust
2345 struct Foo {
2346     x:   u32,
2347     yy:  u32,
2348     zzz: u32,
2349 }
2350 ```
2351
2352 ## `struct_lit_single_line`
2353
2354 Put small struct literals on a single line
2355
2356 - **Default value**: `true`
2357 - **Possible values**: `true`, `false`
2358 - **Stable**: No (tracking issue: #3357)
2359
2360 #### `true` (default):
2361
2362 ```rust
2363 fn main() {
2364     let lorem = Lorem { foo: bar, baz: ofo };
2365 }
2366 ```
2367
2368 #### `false`:
2369
2370 ```rust
2371 fn main() {
2372     let lorem = Lorem {
2373         foo: bar,
2374         baz: ofo,
2375     };
2376 }
2377 ```
2378
2379 See also: [`indent_style`](#indent_style).
2380
2381 ## `struct_lit_width`
2382
2383 Maximum width in the body of a struct literal before falling back to vertical formatting. A value of `0` (zero) results in struct literals always being broken into multiple lines. Note this occurs when `use_small_heuristics` is set to `Off`.
2384
2385 - **Default value**: `18`
2386 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2387 - **Stable**: Yes
2388
2389 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `struct_lit_width` will take precedence.
2390
2391 See also [`max_width`](#max_width), [`use_small_heuristics`](#use_small_heuristics), and [`struct_lit_single_line`](#struct_lit_single_line)
2392
2393 ## `struct_variant_width`
2394
2395 Maximum width in the body of a struct variant before falling back to vertical formatting. A value of `0` (zero) results in struct literals always being broken into multiple lines. Note this occurs when `use_small_heuristics` is set to `Off`.
2396
2397 - **Default value**: `35`
2398 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2399 - **Stable**: Yes
2400
2401 By default this option is set as a percentage of [`max_width`](#max_width) provided by [`use_small_heuristics`](#use_small_heuristics), but a value set directly for `struct_variant_width` will take precedence.
2402
2403 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
2404
2405 ## `tab_spaces`
2406
2407 Number of spaces per tab
2408
2409 - **Default value**: `4`
2410 - **Possible values**: any positive integer
2411 - **Stable**: Yes
2412
2413 #### `4` (default):
2414
2415 ```rust
2416 fn lorem() {
2417     let ipsum = dolor();
2418     let sit = vec![
2419         "amet consectetur adipiscing elit amet",
2420         "consectetur adipiscing elit amet consectetur.",
2421     ];
2422 }
2423 ```
2424
2425 #### `2`:
2426
2427 ```rust
2428 fn lorem() {
2429   let ipsum = dolor();
2430   let sit = vec![
2431     "amet consectetur adipiscing elit amet",
2432     "consectetur adipiscing elit amet consectetur.",
2433   ];
2434 }
2435 ```
2436
2437 See also: [`hard_tabs`](#hard_tabs).
2438
2439
2440 ## `trailing_comma`
2441
2442 How to handle trailing commas for lists
2443
2444 - **Default value**: `"Vertical"`
2445 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2446 - **Stable**: No (tracking issue: #3379)
2447
2448 #### `"Vertical"` (default):
2449
2450 ```rust
2451 fn main() {
2452     let Lorem { ipsum, dolor, sit } = amet;
2453     let Lorem {
2454         ipsum,
2455         dolor,
2456         sit,
2457         amet,
2458         consectetur,
2459         adipiscing,
2460     } = elit;
2461 }
2462 ```
2463
2464 #### `"Always"`:
2465
2466 ```rust
2467 fn main() {
2468     let Lorem { ipsum, dolor, sit, } = amet;
2469     let Lorem {
2470         ipsum,
2471         dolor,
2472         sit,
2473         amet,
2474         consectetur,
2475         adipiscing,
2476     } = elit;
2477 }
2478 ```
2479
2480 #### `"Never"`:
2481
2482 ```rust
2483 fn main() {
2484     let Lorem { ipsum, dolor, sit } = amet;
2485     let Lorem {
2486         ipsum,
2487         dolor,
2488         sit,
2489         amet,
2490         consectetur,
2491         adipiscing
2492     } = elit;
2493 }
2494 ```
2495
2496 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2497
2498 ## `trailing_semicolon`
2499
2500 Add trailing semicolon after break, continue and return
2501
2502 - **Default value**: `true`
2503 - **Possible values**: `true`, `false`
2504 - **Stable**: No (tracking issue: #3378)
2505
2506 #### `true` (default):
2507 ```rust
2508 fn foo() -> usize {
2509     return 0;
2510 }
2511 ```
2512
2513 #### `false`:
2514 ```rust
2515 fn foo() -> usize {
2516     return 0
2517 }
2518 ```
2519
2520 ## `type_punctuation_density`
2521
2522 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2523
2524 - **Default value**: `"Wide"`
2525 - **Possible values**: `"Compressed"`, `"Wide"`
2526 - **Stable**: No (tracking issue: #3364)
2527
2528 #### `"Wide"` (default):
2529
2530 ```rust
2531 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2532     // body
2533 }
2534 ```
2535
2536 #### `"Compressed"`:
2537
2538 ```rust
2539 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2540     // body
2541 }
2542 ```
2543
2544 ## `unstable_features`
2545
2546 Enable unstable features on the unstable channel.
2547
2548 - **Default value**: `false`
2549 - **Possible values**: `true`, `false`
2550 - **Stable**: No (tracking issue: #3387)
2551
2552 ## `use_field_init_shorthand`
2553
2554 Use field initialize shorthand if possible.
2555
2556 - **Default value**: `false`
2557 - **Possible values**: `true`, `false`
2558 - **Stable**: Yes
2559
2560 #### `false` (default):
2561
2562 ```rust
2563 struct Foo {
2564     x: u32,
2565     y: u32,
2566     z: u32,
2567 }
2568
2569 fn main() {
2570     let x = 1;
2571     let y = 2;
2572     let z = 3;
2573     let a = Foo { x, y, z };
2574     let b = Foo { x: x, y: y, z: z };
2575 }
2576 ```
2577
2578 #### `true`:
2579
2580 ```rust
2581 struct Foo {
2582     x: u32,
2583     y: u32,
2584     z: u32,
2585 }
2586
2587 fn main() {
2588     let x = 1;
2589     let y = 2;
2590     let z = 3;
2591     let a = Foo { x, y, z };
2592 }
2593 ```
2594
2595 ## `use_small_heuristics`
2596
2597 This option can be used to simplify the management and bulk updates of the granular width configuration settings ([`fn_call_width`](#fn_call_width), [`attr_fn_like_width`](#attr_fn_like_width), [`struct_lit_width`](#struct_lit_width), [`struct_variant_width`](#struct_variant_width), [`array_width`](#array_width), [`chain_width`](#chain_width), [`single_line_if_else_max_width`](#single_line_if_else_max_width)), that respectively control when formatted constructs are multi-lined/vertical based on width.
2598
2599 Note that explicitly provided values for the width configuration settings take precedence and override the calculated values determined by `use_small_heuristics`.
2600
2601 - **Default value**: `"Default"`
2602 - **Possible values**: `"Default"`, `"Off"`, `"Max"`
2603 - **Stable**: Yes
2604
2605 #### `Default` (default):
2606 When `use_small_heuristics` is set to `Default`, the values for the granular width settings are calculated as a ratio of the value for `max_width`.
2607
2608 The ratios are:
2609 * [`fn_call_width`](#fn_call_width) - `60%`
2610 * [`attr_fn_like_width`](#attr_fn_like_width) - `70%`
2611 * [`struct_lit_width`](#struct_lit_width) - `18%`
2612 * [`struct_variant_width`](#struct_variant_width) - `35%`
2613 * [`array_width`](#array_width) - `60%`
2614 * [`chain_width`](#chain_width) - `60%`
2615 * [`single_line_if_else_max_width`](#single_line_if_else_max_width) - `50%`
2616
2617 For example when `max_width` is set to `100`, the width settings are:
2618 * `fn_call_width=60`
2619 * `attr_fn_like_width=70`
2620 * `struct_lit_width=18`
2621 * `struct_variant_width=35`
2622 * `array_width=60`
2623 * `chain_width=60`
2624 * `single_line_if_else_max_width=50`
2625
2626 and when `max_width` is set to `200`:
2627 * `fn_call_width=120`
2628 * `attr_fn_like_width=140`
2629 * `struct_lit_width=36`
2630 * `struct_variant_width=70`
2631 * `array_width=120`
2632 * `chain_width=120`
2633 * `single_line_if_else_max_width=100`
2634
2635 ```rust
2636 enum Lorem {
2637     Ipsum,
2638     Dolor(bool),
2639     Sit { amet: Consectetur, adipiscing: Elit },
2640 }
2641
2642 fn main() {
2643     lorem(
2644         "lorem",
2645         "ipsum",
2646         "dolor",
2647         "sit",
2648         "amet",
2649         "consectetur",
2650         "adipiscing",
2651     );
2652
2653     let lorem = Lorem {
2654         ipsum: dolor,
2655         sit: amet,
2656     };
2657     let lorem = Lorem { ipsum: dolor };
2658
2659     let lorem = if ipsum { dolor } else { sit };
2660 }
2661 ```
2662
2663 #### `Off`:
2664 When `use_small_heuristics` is set to `Off`, the granular width settings are functionally disabled and ignored. See the documentation for the respective width config options for specifics.
2665
2666 ```rust
2667 enum Lorem {
2668     Ipsum,
2669     Dolor(bool),
2670     Sit {
2671         amet: Consectetur,
2672         adipiscing: Elit,
2673     },
2674 }
2675
2676 fn main() {
2677     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2678
2679     let lorem = Lorem {
2680         ipsum: dolor,
2681         sit: amet,
2682     };
2683
2684     let lorem = if ipsum {
2685         dolor
2686     } else {
2687         sit
2688     };
2689 }
2690 ```
2691
2692 #### `Max`:
2693 When `use_small_heuristics` is set to `Max`, then each granular width setting is set to the same value as `max_width`.
2694
2695 So if `max_width` is set to `200`, then all the width settings are also set to `200`.
2696 * `fn_call_width=200`
2697 * `attr_fn_like_width=200`
2698 * `struct_lit_width=200`
2699 * `struct_variant_width=200`
2700 * `array_width=200`
2701 * `chain_width=200`
2702 * `single_line_if_else_max_width=200`
2703
2704 ```rust
2705 enum Lorem {
2706     Ipsum,
2707     Dolor(bool),
2708     Sit { amet: Consectetur, adipiscing: Elit },
2709 }
2710
2711 fn main() {
2712     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2713
2714     let lorem = Lorem { ipsum: dolor, sit: amet };
2715
2716     let lorem = if ipsum { dolor } else { sit };
2717 }
2718 ```
2719
2720
2721 See also:
2722 * [`max_width`](#max_width)
2723 * [`fn_call_width`](#fn_call_width)
2724 * [`attr_fn_like_width`](#attr_fn_like_width)
2725 * [`struct_lit_width`](#struct_lit_width)
2726 * [`struct_variant_width`](#struct_variant_width)
2727 * [`array_width`](#array_width)
2728 * [`chain_width`](#chain_width)
2729 * [`single_line_if_else_max_width`](#single_line_if_else_max_width)
2730
2731 ## `use_try_shorthand`
2732
2733 Replace uses of the try! macro by the ? shorthand
2734
2735 - **Default value**: `false`
2736 - **Possible values**: `true`, `false`
2737 - **Stable**: Yes
2738
2739 #### `false` (default):
2740
2741 ```rust
2742 fn main() {
2743     let lorem = ipsum.map(|dolor| dolor.sit())?;
2744
2745     let lorem = try!(ipsum.map(|dolor| dolor.sit()));
2746 }
2747 ```
2748
2749 #### `true`:
2750
2751 ```rust
2752 fn main() {
2753     let lorem = ipsum.map(|dolor| dolor.sit())?;
2754 }
2755 ```
2756
2757 ## `version`
2758
2759 Which version of the formatting rules to use. `Version::One` is backwards-compatible
2760 with Rustfmt 1.0. Other versions are only backwards compatible within a major
2761 version number.
2762
2763 - **Default value**: `One`
2764 - **Possible values**: `One`, `Two`
2765 - **Stable**: No (tracking issue: #3383)
2766
2767 ### Example
2768
2769 ```toml
2770 version = "Two"
2771 ```
2772
2773 ## `where_single_line`
2774
2775 Forces the `where` clause to be laid out on a single line.
2776
2777 - **Default value**: `false`
2778 - **Possible values**: `true`, `false`
2779 - **Stable**: No (tracking issue: #3359)
2780
2781 #### `false` (default):
2782
2783 ```rust
2784 impl<T> Lorem for T
2785 where
2786     Option<T>: Ipsum,
2787 {
2788     // body
2789 }
2790 ```
2791
2792 #### `true`:
2793
2794 ```rust
2795 impl<T> Lorem for T
2796 where Option<T>: Ipsum
2797 {
2798     // body
2799 }
2800 ```
2801
2802 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
2803
2804
2805 ## `wrap_comments`
2806
2807 Break comments to fit on the line
2808
2809 - **Default value**: `false`
2810 - **Possible values**: `true`, `false`
2811 - **Stable**: No (tracking issue: #3347)
2812
2813 #### `false` (default):
2814
2815 ```rust
2816 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2817 // sed do eiusmod tempor incididunt ut labore et dolore
2818 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2819 // exercitation ullamco laboris nisi ut aliquip ex ea
2820 // commodo consequat.
2821
2822 // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
2823 ```
2824
2825 #### `true`:
2826
2827 ```rust
2828 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2829 // sed do eiusmod tempor incididunt ut labore et dolore
2830 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2831 // exercitation ullamco laboris nisi ut aliquip ex ea
2832 // commodo consequat.
2833 ```
2834
2835 # Internal Options
2836
2837 ## `emit_mode`
2838
2839 Internal option
2840
2841 ## `make_backup`
2842
2843 Internal option, use `--backup`
2844
2845 ## `print_misformatted_file_names`
2846
2847 Internal option, use `-l` or `--files-with-diff`