]> git.lizzy.rs Git - rust.git/blob - Configurations.md
Remove `TreeAndSpacing`.
[rust.git] / 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 always be used, while unstable options are only available on a nightly toolchain and must be opted into.
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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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](https://github.com/rust-lang/rustfmt/issues/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 ## `doc_comment_code_block_width`
930
931 Max width for code snippets included in doc comments. Only used if [`format_code_in_doc_comments`](#format_code_in_doc_comments) is true.
932
933 - **Default value**: `100`
934 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
935 - **Stable**: No (tracking issue: [#5359](https://github.com/rust-lang/rustfmt/issues/5359))
936
937 ## `format_generated_files`
938
939 Format generated files. A file is considered generated
940 if any of the first five lines contain a `@generated` comment marker.
941 By default, generated files are reformatted, i. e. `@generated` marker is ignored.
942 This option is currently ignored for stdin (`@generated` in stdin is ignored.)
943
944 - **Default value**: `true`
945 - **Possible values**: `true`, `false`
946 - **Stable**: No (tracking issue: [#5080](https://github.com/rust-lang/rustfmt/issues/5080))
947
948 ## `format_macro_matchers`
949
950 Format the metavariable matching patterns in macros.
951
952 - **Default value**: `false`
953 - **Possible values**: `true`, `false`
954 - **Stable**: No (tracking issue: [#3354](https://github.com/rust-lang/rustfmt/issues/3354))
955
956 #### `false` (default):
957
958 ```rust
959 macro_rules! foo {
960     ($a: ident : $b: ty) => {
961         $a(42): $b;
962     };
963     ($a: ident $b: ident $c: ident) => {
964         $a = $b + $c;
965     };
966 }
967 ```
968
969 #### `true`:
970
971 ```rust
972 macro_rules! foo {
973     ($a:ident : $b:ty) => {
974         $a(42): $b;
975     };
976     ($a:ident $b:ident $c:ident) => {
977         $a = $b + $c;
978     };
979 }
980 ```
981
982 See also [`format_macro_bodies`](#format_macro_bodies).
983
984
985 ## `format_macro_bodies`
986
987 Format the bodies of macros.
988
989 - **Default value**: `true`
990 - **Possible values**: `true`, `false`
991 - **Stable**: No (tracking issue: [#3355](https://github.com/rust-lang/rustfmt/issues/3355))
992
993 #### `true` (default):
994
995 ```rust
996 macro_rules! foo {
997     ($a: ident : $b: ty) => {
998         $a(42): $b;
999     };
1000     ($a: ident $b: ident $c: ident) => {
1001         $a = $b + $c;
1002     };
1003 }
1004 ```
1005
1006 #### `false`:
1007
1008 ```rust
1009 macro_rules! foo {
1010     ($a: ident : $b: ty) => { $a(42): $b; };
1011     ($a: ident $b: ident $c: ident) => { $a=$b+$c; };
1012 }
1013 ```
1014
1015 See also [`format_macro_matchers`](#format_macro_matchers).
1016
1017
1018 ## `format_strings`
1019
1020 Format string literals where necessary
1021
1022 - **Default value**: `false`
1023 - **Possible values**: `true`, `false`
1024 - **Stable**: No (tracking issue: [#3353](https://github.com/rust-lang/rustfmt/issues/3353))
1025
1026 #### `false` (default):
1027
1028 ```rust
1029 fn main() {
1030     let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing";
1031 }
1032 ```
1033
1034 #### `true`:
1035
1036 ```rust
1037 fn main() {
1038     let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet \
1039                  consectetur adipiscing";
1040 }
1041 ```
1042
1043 See also [`max_width`](#max_width).
1044
1045 ## `hard_tabs`
1046
1047 Use tab characters for indentation, spaces for alignment
1048
1049 - **Default value**: `false`
1050 - **Possible values**: `true`, `false`
1051 - **Stable**: Yes
1052
1053 #### `false` (default):
1054
1055 ```rust
1056 fn lorem() -> usize {
1057     42 // spaces before 42
1058 }
1059 ```
1060
1061 #### `true`:
1062
1063 ```rust
1064 fn lorem() -> usize {
1065         42 // tabs before 42
1066 }
1067 ```
1068
1069 See also: [`tab_spaces`](#tab_spaces).
1070
1071 ## `hex_literal_case`
1072
1073 Control the case of the letters in hexadecimal literal values
1074
1075 - **Default value**: `Preserve`
1076 - **Possible values**: `Preserve`, `Upper`, `Lower`
1077 - **Stable**: No (tracking issue: [#5081](https://github.com/rust-lang/rustfmt/issues/5081))
1078
1079 ## `hide_parse_errors`
1080
1081 Do not show parse errors if the parser failed to parse files.
1082
1083 - **Default value**: `false`
1084 - **Possible values**: `true`, `false`
1085 - **Stable**: No (tracking issue: [#3390](https://github.com/rust-lang/rustfmt/issues/3390))
1086
1087 ## `ignore`
1088
1089 Skip formatting files and directories that match the specified pattern.
1090 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.
1091
1092 - **Default value**: format every file
1093 - **Possible values**: See an example below
1094 - **Stable**: No (tracking issue: [#3395](https://github.com/rust-lang/rustfmt/issues/3395))
1095
1096 ### Example
1097
1098 If you want to ignore specific files, put the following to your config file:
1099
1100 ```toml
1101 ignore = [
1102     "src/types.rs",
1103     "src/foo/bar.rs",
1104 ]
1105 ```
1106
1107 If you want to ignore every file under `examples/`, put the following to your config file:
1108
1109 ```toml
1110 ignore = [
1111     "examples",
1112 ]
1113 ```
1114
1115 If you want to ignore every file under the directory where you put your rustfmt.toml:
1116
1117 ```toml
1118 ignore = ["/"]
1119 ```
1120
1121 ## `imports_indent`
1122
1123 Indent style of imports
1124
1125 - **Default Value**: `"Block"`
1126 - **Possible values**: `"Block"`, `"Visual"`
1127 - **Stable**: No (tracking issue: [#3360](https://github.com/rust-lang/rustfmt/issues/3360))
1128
1129 #### `"Block"` (default):
1130
1131 ```rust
1132 use foo::{
1133     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1134     zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
1135 };
1136 ```
1137
1138 #### `"Visual"`:
1139
1140 ```rust
1141 use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1142           zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
1143 ```
1144
1145 See also: [`imports_layout`](#imports_layout).
1146
1147 ## `imports_layout`
1148
1149 Item layout inside a imports block
1150
1151 - **Default value**: "Mixed"
1152 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1153 - **Stable**: No (tracking issue: [#3361](https://github.com/rust-lang/rustfmt/issues/3361))
1154
1155 #### `"Mixed"` (default):
1156
1157 ```rust
1158 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1159
1160 use foo::{
1161     aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
1162     eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
1163 };
1164 ```
1165
1166 #### `"Horizontal"`:
1167
1168 **Note**: This option forces all imports onto one line and may exceed `max_width`.
1169
1170 ```rust
1171 use foo::{xxx, yyy, zzz};
1172
1173 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1174 ```
1175
1176 #### `"HorizontalVertical"`:
1177
1178 ```rust
1179 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1180
1181 use foo::{
1182     aaaaaaaaaaaaaaaaaa,
1183     bbbbbbbbbbbbbbbbbb,
1184     cccccccccccccccccc,
1185     dddddddddddddddddd,
1186     eeeeeeeeeeeeeeeeee,
1187     ffffffffffffffffff,
1188 };
1189 ```
1190
1191 #### `"Vertical"`:
1192
1193 ```rust
1194 use foo::{
1195     xxx,
1196     yyy,
1197     zzz,
1198 };
1199
1200 use foo::{
1201     aaa,
1202     bbb,
1203     ccc,
1204     ddd,
1205     eee,
1206     fff,
1207 };
1208 ```
1209
1210 ## `indent_style`
1211
1212 Indent on expressions or items.
1213
1214 - **Default value**: `"Block"`
1215 - **Possible values**: `"Block"`, `"Visual"`
1216 - **Stable**: No (tracking issue: [#3346](https://github.com/rust-lang/rustfmt/issues/3346))
1217
1218 ### Array
1219
1220 #### `"Block"` (default):
1221
1222 ```rust
1223 fn main() {
1224     let lorem = vec![
1225         "ipsum",
1226         "dolor",
1227         "sit",
1228         "amet",
1229         "consectetur",
1230         "adipiscing",
1231         "elit",
1232     ];
1233 }
1234 ```
1235
1236 #### `"Visual"`:
1237
1238 ```rust
1239 fn main() {
1240     let lorem = vec!["ipsum",
1241                      "dolor",
1242                      "sit",
1243                      "amet",
1244                      "consectetur",
1245                      "adipiscing",
1246                      "elit"];
1247 }
1248 ```
1249
1250 ### Control flow
1251
1252 #### `"Block"` (default):
1253
1254 ```rust
1255 fn main() {
1256     if lorem_ipsum
1257         && dolor_sit
1258         && amet_consectetur
1259         && lorem_sit
1260         && dolor_consectetur
1261         && amet_ipsum
1262         && lorem_consectetur
1263     {
1264         // ...
1265     }
1266 }
1267 ```
1268
1269 #### `"Visual"`:
1270
1271 ```rust
1272 fn main() {
1273     if lorem_ipsum
1274        && dolor_sit
1275        && amet_consectetur
1276        && lorem_sit
1277        && dolor_consectetur
1278        && amet_ipsum
1279        && lorem_consectetur
1280     {
1281         // ...
1282     }
1283 }
1284 ```
1285
1286 See also: [`control_brace_style`](#control_brace_style).
1287
1288 ### Function arguments
1289
1290 #### `"Block"` (default):
1291
1292 ```rust
1293 fn lorem() {}
1294
1295 fn lorem(ipsum: usize) {}
1296
1297 fn lorem(
1298     ipsum: usize,
1299     dolor: usize,
1300     sit: usize,
1301     amet: usize,
1302     consectetur: usize,
1303     adipiscing: usize,
1304     elit: usize,
1305 ) {
1306     // body
1307 }
1308 ```
1309
1310 #### `"Visual"`:
1311
1312 ```rust
1313 fn lorem() {}
1314
1315 fn lorem(ipsum: usize) {}
1316
1317 fn lorem(ipsum: usize,
1318          dolor: usize,
1319          sit: usize,
1320          amet: usize,
1321          consectetur: usize,
1322          adipiscing: usize,
1323          elit: usize) {
1324     // body
1325 }
1326 ```
1327
1328 ### Function calls
1329
1330 #### `"Block"` (default):
1331
1332 ```rust
1333 fn main() {
1334     lorem(
1335         "lorem",
1336         "ipsum",
1337         "dolor",
1338         "sit",
1339         "amet",
1340         "consectetur",
1341         "adipiscing",
1342         "elit",
1343     );
1344 }
1345 ```
1346
1347 #### `"Visual"`:
1348
1349 ```rust
1350 fn main() {
1351     lorem("lorem",
1352           "ipsum",
1353           "dolor",
1354           "sit",
1355           "amet",
1356           "consectetur",
1357           "adipiscing",
1358           "elit");
1359 }
1360 ```
1361
1362 ### Generics
1363
1364 #### `"Block"` (default):
1365
1366 ```rust
1367 fn lorem<
1368     Ipsum: Eq = usize,
1369     Dolor: Eq = usize,
1370     Sit: Eq = usize,
1371     Amet: Eq = usize,
1372     Adipiscing: Eq = usize,
1373     Consectetur: Eq = usize,
1374     Elit: Eq = usize,
1375 >(
1376     ipsum: Ipsum,
1377     dolor: Dolor,
1378     sit: Sit,
1379     amet: Amet,
1380     adipiscing: Adipiscing,
1381     consectetur: Consectetur,
1382     elit: Elit,
1383 ) -> T {
1384     // body
1385 }
1386 ```
1387
1388 #### `"Visual"`:
1389
1390 ```rust
1391 fn lorem<Ipsum: Eq = usize,
1392          Dolor: Eq = usize,
1393          Sit: Eq = usize,
1394          Amet: Eq = usize,
1395          Adipiscing: Eq = usize,
1396          Consectetur: Eq = usize,
1397          Elit: Eq = usize>(
1398     ipsum: Ipsum,
1399     dolor: Dolor,
1400     sit: Sit,
1401     amet: Amet,
1402     adipiscing: Adipiscing,
1403     consectetur: Consectetur,
1404     elit: Elit)
1405     -> T {
1406     // body
1407 }
1408 ```
1409
1410 #### Struct
1411
1412 #### `"Block"` (default):
1413
1414 ```rust
1415 fn main() {
1416     let lorem = Lorem {
1417         ipsum: dolor,
1418         sit: amet,
1419     };
1420 }
1421 ```
1422
1423 #### `"Visual"`:
1424
1425 ```rust
1426 fn main() {
1427     let lorem = Lorem { ipsum: dolor,
1428                         sit: amet };
1429 }
1430 ```
1431
1432 See also: [`struct_lit_single_line`](#struct_lit_single_line), [`indent_style`](#indent_style).
1433
1434 ### Where predicates
1435
1436 #### `"Block"` (default):
1437
1438 ```rust
1439 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
1440 where
1441     Ipsum: Eq,
1442     Dolor: Eq,
1443     Sit: Eq,
1444     Amet: Eq,
1445 {
1446     // body
1447 }
1448 ```
1449
1450 #### `"Visual"`:
1451
1452 ```rust
1453 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
1454     where Ipsum: Eq,
1455           Dolor: Eq,
1456           Sit: Eq,
1457           Amet: Eq
1458 {
1459     // body
1460 }
1461 ```
1462
1463 ## `inline_attribute_width`
1464
1465 Write an item and its attribute on the same line if their combined width is below a threshold
1466
1467 - **Default value**: 0
1468 - **Possible values**: any positive integer
1469 - **Stable**: No (tracking issue: [#3343](https://github.com/rust-lang/rustfmt/issues/3343))
1470
1471 ### Example
1472
1473 #### `0` (default):
1474 ```rust
1475 #[cfg(feature = "alloc")]
1476 use core::slice;
1477 ```
1478
1479 #### `50`:
1480 ```rust
1481 #[cfg(feature = "alloc")] use core::slice;
1482 ```
1483
1484 ## `match_arm_blocks`
1485
1486 Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator.
1487
1488 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.
1489
1490 - **Default value**: `true`
1491 - **Possible values**: `true`, `false`
1492 - **Stable**: No (tracking issue: [#3373](https://github.com/rust-lang/rustfmt/issues/3373))
1493
1494 #### `true` (default):
1495
1496 ```rust
1497 fn main() {
1498     match lorem {
1499         ipsum => {
1500             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
1501         }
1502         dolor => println!("{}", sit),
1503         sit => foo(
1504             "foooooooooooooooooooooooo",
1505             "baaaaaaaaaaaaaaaaaaaaaaaarr",
1506             "baaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzz",
1507             "qqqqqqqqquuuuuuuuuuuuuuuuuuuuuuuuuuxxx",
1508         ),
1509     }
1510 }
1511 ```
1512
1513 #### `false`:
1514
1515 ```rust
1516 fn main() {
1517     match lorem {
1518         lorem =>
1519             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
1520         ipsum => println!("{}", sit),
1521         sit => foo(
1522             "foooooooooooooooooooooooo",
1523             "baaaaaaaaaaaaaaaaaaaaaaaarr",
1524             "baaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzz",
1525             "qqqqqqqqquuuuuuuuuuuuuuuuuuuuuuuuuuxxx",
1526         ),
1527     }
1528 }
1529 ```
1530
1531 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
1532
1533 ## `match_arm_leading_pipes`
1534
1535 Controls whether to include a leading pipe on match arms
1536
1537 - **Default value**: `Never`
1538 - **Possible values**: `Always`, `Never`, `Preserve`
1539 - **Stable**: Yes
1540
1541 #### `Never` (default):
1542 ```rust
1543 // Leading pipes are removed from this:
1544 // fn foo() {
1545 //     match foo {
1546 //         | "foo" | "bar" => {}
1547 //         | "baz"
1548 //         | "something relatively long"
1549 //         | "something really really really realllllllllllllly long" => println!("x"),
1550 //         | "qux" => println!("y"),
1551 //         _ => {}
1552 //     }
1553 // }
1554
1555 // Becomes
1556 fn foo() {
1557     match foo {
1558         "foo" | "bar" => {}
1559         "baz"
1560         | "something relatively long"
1561         | "something really really really realllllllllllllly long" => println!("x"),
1562         "qux" => println!("y"),
1563         _ => {}
1564     }
1565 }
1566 ```
1567
1568 #### `Always`:
1569 ```rust
1570 // Leading pipes are emitted on all arms of this:
1571 // fn foo() {
1572 //     match foo {
1573 //         "foo" | "bar" => {}
1574 //         "baz"
1575 //         | "something relatively long"
1576 //         | "something really really really realllllllllllllly long" => println!("x"),
1577 //         "qux" => println!("y"),
1578 //         _ => {}
1579 //     }
1580 // }
1581
1582 // Becomes:
1583 fn foo() {
1584     match foo {
1585         | "foo" | "bar" => {}
1586         | "baz"
1587         | "something relatively long"
1588         | "something really really really realllllllllllllly long" => println!("x"),
1589         | "qux" => println!("y"),
1590         | _ => {}
1591     }
1592 }
1593 ```
1594
1595 #### `Preserve`:
1596 ```rust
1597 fn foo() {
1598     match foo {
1599         | "foo" | "bar" => {}
1600         | "baz"
1601         | "something relatively long"
1602         | "something really really really realllllllllllllly long" => println!("x"),
1603         | "qux" => println!("y"),
1604         _ => {}
1605     }
1606
1607     match baz {
1608         "qux" => {}
1609         "foo" | "bar" => {}
1610         _ => {}
1611     }
1612 }
1613 ```
1614
1615 ## `match_block_trailing_comma`
1616
1617 Put a trailing comma after a block based match arm (non-block arms are not affected)
1618
1619 - **Default value**: `false`
1620 - **Possible values**: `true`, `false`
1621 - **Stable**: Yes
1622
1623 #### `false` (default):
1624
1625 ```rust
1626 fn main() {
1627     match lorem {
1628         Lorem::Ipsum => {
1629             println!("ipsum");
1630         }
1631         Lorem::Dolor => println!("dolor"),
1632     }
1633 }
1634 ```
1635
1636 #### `true`:
1637
1638 ```rust
1639 fn main() {
1640     match lorem {
1641         Lorem::Ipsum => {
1642             println!("ipsum");
1643         },
1644         Lorem::Dolor => println!("dolor"),
1645     }
1646 }
1647 ```
1648
1649 See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
1650
1651 ## `max_width`
1652
1653 Maximum width of each line
1654
1655 - **Default value**: `100`
1656 - **Possible values**: any positive integer
1657 - **Stable**: Yes
1658
1659 See also [`error_on_line_overflow`](#error_on_line_overflow).
1660
1661 ## `merge_derives`
1662
1663 Merge multiple derives into a single one.
1664
1665 - **Default value**: `true`
1666 - **Possible values**: `true`, `false`
1667 - **Stable**: Yes
1668
1669 #### `true` (default):
1670
1671 ```rust
1672 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1673 pub enum Foo {}
1674 ```
1675
1676 #### `false`:
1677
1678 ```rust
1679 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1680 pub enum Bar {}
1681
1682 #[derive(Eq, PartialEq)]
1683 #[derive(Debug)]
1684 #[derive(Copy, Clone)]
1685 pub enum Foo {}
1686 ```
1687
1688 ## `imports_granularity`
1689
1690 How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
1691
1692 - **Default value**: `Preserve`
1693 - **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One`
1694 - **Stable**: No (tracking issue: [#4991](https://github.com/rust-lang/rustfmt/issues/4991))
1695
1696 Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments.
1697
1698 #### `Preserve` (default):
1699
1700 Do not change the granularity of any imports and preserve the original structure written by the developer.
1701
1702 ```rust
1703 use foo::b;
1704 use foo::b::{f, g};
1705 use foo::{a, c, d::e};
1706 use qux::{h, i};
1707 ```
1708
1709 #### `Crate`:
1710
1711 Merge imports from the same crate into a single `use` statement. Conversely, imports from different crates are split into separate statements.
1712
1713 ```rust
1714 use foo::{
1715     a, b,
1716     b::{f, g},
1717     c,
1718     d::e,
1719 };
1720 use qux::{h, i};
1721 ```
1722
1723 #### `Module`:
1724
1725 Merge imports from the same module into a single `use` statement. Conversely, imports from different modules are split into separate statements.
1726
1727 ```rust
1728 use foo::b::{f, g};
1729 use foo::d::e;
1730 use foo::{a, b, c};
1731 use qux::{h, i};
1732 ```
1733
1734 #### `Item`:
1735
1736 Flatten imports so that each has its own `use` statement.
1737
1738 ```rust
1739 use foo::a;
1740 use foo::b;
1741 use foo::b::f;
1742 use foo::b::g;
1743 use foo::c;
1744 use foo::d::e;
1745 use qux::h;
1746 use qux::i;
1747 ```
1748
1749 #### `One`:
1750
1751 Merge all imports into a single `use` statement as long as they have the same visibility.
1752
1753 ```rust
1754 pub use foo::{x, y};
1755 use {
1756     bar::{
1757         a,
1758         b::{self, f, g},
1759         c,
1760         d::e,
1761     },
1762     qux::{h, i},
1763 };
1764 ```
1765
1766 ## `merge_imports`
1767
1768 This option is deprecated. Use `imports_granularity = "Crate"` instead.
1769
1770 - **Default value**: `false`
1771 - **Possible values**: `true`, `false`
1772
1773 #### `false` (default):
1774
1775 ```rust
1776 use foo::{a, c, d};
1777 use foo::{b, g};
1778 use foo::{e, f};
1779 ```
1780
1781 #### `true`:
1782
1783 ```rust
1784 use foo::{a, b, c, d, e, f, g};
1785 ```
1786
1787
1788 ## `newline_style`
1789
1790 Unix or Windows line endings
1791
1792 - **Default value**: `"Auto"`
1793 - **Possible values**: `"Auto"`, `"Native"`, `"Unix"`, `"Windows"`
1794 - **Stable**: Yes
1795
1796 #### `Auto` (default):
1797
1798 The newline style is detected automatically on a per-file basis. Files
1799 with mixed line endings will be converted to the first detected line
1800 ending style.
1801
1802 #### `Native`
1803
1804 Line endings will be converted to `\r\n` on Windows and `\n` on all
1805 other platforms.
1806
1807 #### `Unix`
1808
1809 Line endings will be converted to `\n`.
1810
1811 #### `Windows`
1812
1813 Line endings will be converted to `\r\n`.
1814
1815 ## `normalize_comments`
1816
1817 Convert /* */ comments to // comments where possible
1818
1819 - **Default value**: `false`
1820 - **Possible values**: `true`, `false`
1821 - **Stable**: No (tracking issue: [#3350](https://github.com/rust-lang/rustfmt/issues/3350))
1822
1823 #### `false` (default):
1824
1825 ```rust
1826 // Lorem ipsum:
1827 fn dolor() -> usize {}
1828
1829 /* sit amet: */
1830 fn adipiscing() -> usize {}
1831 ```
1832
1833 #### `true`:
1834
1835 ```rust
1836 // Lorem ipsum:
1837 fn dolor() -> usize {}
1838
1839 // sit amet:
1840 fn adipiscing() -> usize {}
1841 ```
1842
1843 ## `normalize_doc_attributes`
1844
1845 Convert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments.
1846
1847 - **Default value**: `false`
1848 - **Possible values**: `true`, `false`
1849 - **Stable**: No (tracking issue: [#3351](https://github.com/rust-lang/rustfmt/issues/3351))
1850
1851 #### `false` (default):
1852
1853 ```rust
1854 #![doc = "Example documentation"]
1855
1856 #[doc = "Example item documentation"]
1857 pub enum Bar {}
1858
1859 /// Example item documentation
1860 pub enum Foo {}
1861 ```
1862
1863 #### `true`:
1864
1865 ```rust
1866 //! Example documentation
1867
1868 /// Example item documentation
1869 pub enum Foo {}
1870 ```
1871
1872 ## `overflow_delimited_expr`
1873
1874 When structs, slices, arrays, and block/array-like macros are used as the last
1875 argument in an expression list, allow them to overflow (like blocks/closures)
1876 instead of being indented on a new line.
1877
1878 - **Default value**: `false`
1879 - **Possible values**: `true`, `false`
1880 - **Stable**: No (tracking issue: [#3370](https://github.com/rust-lang/rustfmt/issues/3370))
1881
1882 #### `false` (default):
1883
1884 ```rust
1885 fn example() {
1886     foo(ctx, |param| {
1887         action();
1888         foo(param)
1889     });
1890
1891     foo(
1892         ctx,
1893         Bar {
1894             x: value,
1895             y: value2,
1896         },
1897     );
1898
1899     foo(
1900         ctx,
1901         &[
1902             MAROON_TOMATOES,
1903             PURPLE_POTATOES,
1904             ORGANE_ORANGES,
1905             GREEN_PEARS,
1906             RED_APPLES,
1907         ],
1908     );
1909
1910     foo(
1911         ctx,
1912         vec![
1913             MAROON_TOMATOES,
1914             PURPLE_POTATOES,
1915             ORGANE_ORANGES,
1916             GREEN_PEARS,
1917             RED_APPLES,
1918         ],
1919     );
1920 }
1921 ```
1922
1923 #### `true`:
1924
1925 ```rust
1926 fn example() {
1927     foo(ctx, |param| {
1928         action();
1929         foo(param)
1930     });
1931
1932     foo(ctx, Bar {
1933         x: value,
1934         y: value2,
1935     });
1936
1937     foo(ctx, &[
1938         MAROON_TOMATOES,
1939         PURPLE_POTATOES,
1940         ORGANE_ORANGES,
1941         GREEN_PEARS,
1942         RED_APPLES,
1943     ]);
1944
1945     foo(ctx, vec![
1946         MAROON_TOMATOES,
1947         PURPLE_POTATOES,
1948         ORGANE_ORANGES,
1949         GREEN_PEARS,
1950         RED_APPLES,
1951     ]);
1952 }
1953 ```
1954
1955 ## `remove_nested_parens`
1956
1957 Remove nested parens.
1958
1959 - **Default value**: `true`,
1960 - **Possible values**: `true`, `false`
1961 - **Stable**: Yes
1962
1963
1964 #### `true` (default):
1965 ```rust
1966 fn main() {
1967     (foo());
1968 }
1969 ```
1970
1971 #### `false`:
1972 ```rust
1973 fn main() {
1974     (foo());
1975
1976     ((((foo()))));
1977 }
1978 ```
1979
1980
1981 ## `reorder_impl_items`
1982
1983 Reorder impl items. `type` and `const` are put first, then macros and methods.
1984
1985 - **Default value**: `false`
1986 - **Possible values**: `true`, `false`
1987 - **Stable**: No (tracking issue: [#3363](https://github.com/rust-lang/rustfmt/issues/3363))
1988
1989 #### `false` (default)
1990
1991 ```rust
1992 struct Dummy;
1993
1994 impl Iterator for Dummy {
1995     fn next(&mut self) -> Option<Self::Item> {
1996         None
1997     }
1998
1999     type Item = i32;
2000 }
2001
2002 impl Iterator for Dummy {
2003     type Item = i32;
2004
2005     fn next(&mut self) -> Option<Self::Item> {
2006         None
2007     }
2008 }
2009 ```
2010
2011 #### `true`
2012
2013 ```rust
2014 struct Dummy;
2015
2016 impl Iterator for Dummy {
2017     type Item = i32;
2018
2019     fn next(&mut self) -> Option<Self::Item> {
2020         None
2021     }
2022 }
2023 ```
2024
2025 ## `reorder_imports`
2026
2027 Reorder import and extern crate statements alphabetically in groups (a group is
2028 separated by a newline).
2029
2030 - **Default value**: `true`
2031 - **Possible values**: `true`, `false`
2032 - **Stable**: Yes
2033
2034 #### `true` (default):
2035
2036 ```rust
2037 use dolor;
2038 use ipsum;
2039 use lorem;
2040 use sit;
2041 ```
2042
2043 #### `false`:
2044
2045 ```rust
2046 use lorem;
2047 use ipsum;
2048 use dolor;
2049 use sit;
2050 ```
2051
2052 ## `group_imports`
2053
2054 Controls the strategy for how consecutive imports are grouped together.
2055
2056 Controls the strategy for grouping sets of consecutive imports. Imports may contain newlines between imports and still be grouped together as a single set, but other statements between imports will result in different grouping sets.
2057
2058 - **Default value**: `Preserve`
2059 - **Possible values**: `Preserve`, `StdExternalCrate`, `One`
2060 - **Stable**: No (tracking issue: [#5083](https://github.com/rust-lang/rustfmt/issues/5083))
2061
2062 Each set of imports (one or more `use` statements, optionally separated by newlines) will be formatted independently. Other statements such as `mod ...` or `extern crate ...` will cause imports to not be grouped together.
2063
2064 #### `Preserve` (default):
2065
2066 Preserve the source file's import groups.
2067
2068 ```rust
2069 use super::update::convert_publish_payload;
2070 use chrono::Utc;
2071
2072 use alloc::alloc::Layout;
2073 use juniper::{FieldError, FieldResult};
2074 use uuid::Uuid;
2075
2076 use std::sync::Arc;
2077
2078 use broker::database::PooledConnection;
2079
2080 use super::schema::{Context, Payload};
2081 use crate::models::Event;
2082 use core::f32;
2083 ```
2084
2085 #### `StdExternalCrate`:
2086
2087 Discard existing import groups, and create three groups for:
2088 1. `std`, `core` and `alloc`,
2089 2. external crates,
2090 3. `self`, `super` and `crate` imports.
2091
2092 ```rust
2093 use alloc::alloc::Layout;
2094 use core::f32;
2095 use std::sync::Arc;
2096
2097 use broker::database::PooledConnection;
2098 use chrono::Utc;
2099 use juniper::{FieldError, FieldResult};
2100 use uuid::Uuid;
2101
2102 use super::schema::{Context, Payload};
2103 use super::update::convert_publish_payload;
2104 use crate::models::Event;
2105 ```
2106
2107 #### `One`:
2108
2109 Discard existing import groups, and create a single group for everything
2110
2111 ```rust
2112 use super::schema::{Context, Payload};
2113 use super::update::convert_publish_payload;
2114 use crate::models::Event;
2115 use alloc::alloc::Layout;
2116 use broker::database::PooledConnection;
2117 use chrono::Utc;
2118 use core::f32;
2119 use juniper::{FieldError, FieldResult};
2120 use std::sync::Arc;
2121 use uuid::Uuid;
2122 ```
2123
2124 ## `reorder_modules`
2125
2126 Reorder `mod` declarations alphabetically in group.
2127
2128 - **Default value**: `true`
2129 - **Possible values**: `true`, `false`
2130 - **Stable**: Yes
2131
2132 #### `true` (default)
2133
2134 ```rust
2135 mod a;
2136 mod b;
2137
2138 mod dolor;
2139 mod ipsum;
2140 mod lorem;
2141 mod sit;
2142 ```
2143
2144 #### `false`
2145
2146 ```rust
2147 mod b;
2148 mod a;
2149
2150 mod lorem;
2151 mod ipsum;
2152 mod dolor;
2153 mod sit;
2154 ```
2155
2156 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics
2157 of the original source code.
2158
2159 ## `required_version`
2160
2161 Require a specific version of rustfmt. If you want to make sure that the
2162 specific version of rustfmt is used in your CI, use this option.
2163
2164 - **Default value**: `CARGO_PKG_VERSION`
2165 - **Possible values**: any published version (e.g. `"0.3.8"`)
2166 - **Stable**: No (tracking issue: [#3386](https://github.com/rust-lang/rustfmt/issues/3386))
2167
2168 ## `short_array_element_width_threshold`
2169
2170 The width threshold for an array element to be considered "short".
2171
2172 The layout of an array is dependent on the length of each of its elements. 
2173 If the length of every element in an array is below this threshold (all elements are "short") then the array can be formatted in the mixed/compressed style, but if any one element has a length that exceeds this threshold then the array elements will have to be formatted vertically.
2174
2175 - **Default value**: `10`
2176 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2177 - **Stable**: Yes
2178
2179 #### `10` (default):
2180 ```rust
2181 fn main() {
2182     pub const FORMAT_TEST: [u64; 5] = [
2183         0x0000000000000000,
2184         0xaaaaaaaaaaaaaaaa,
2185         0xbbbbbbbbbbbbbbbb,
2186         0xcccccccccccccccc,
2187         0xdddddddddddddddd,
2188     ];
2189 }
2190 ```
2191 #### `20`:
2192 ```rust
2193 fn main() {
2194     pub const FORMAT_TEST: [u64; 5] = [
2195         0x0000000000000000, 0xaaaaaaaaaaaaaaaa, 0xbbbbbbbbbbbbbbbb, 0xcccccccccccccccc,
2196         0xdddddddddddddddd,
2197     ];
2198 }
2199 ```
2200 See also [`max_width`](#max_width).
2201
2202 ## `skip_children`
2203
2204 Don't reformat out of line modules
2205
2206 - **Default value**: `false`
2207 - **Possible values**: `true`, `false`
2208 - **Stable**: No (tracking issue: [#3389](https://github.com/rust-lang/rustfmt/issues/3389))
2209
2210 ## `single_line_if_else_max_width`
2211
2212 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`.
2213
2214 - **Default value**: `50`
2215 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2216 - **Stable**: Yes
2217
2218 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.
2219
2220 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
2221
2222 ## `space_after_colon`
2223
2224 Leave a space after the colon.
2225
2226 - **Default value**: `true`
2227 - **Possible values**: `true`, `false`
2228 - **Stable**: No (tracking issue: [#3366](https://github.com/rust-lang/rustfmt/issues/3366))
2229
2230 #### `true` (default):
2231
2232 ```rust
2233 fn lorem<T: Eq>(t: T) {
2234     let lorem: Dolor = Lorem {
2235         ipsum: dolor,
2236         sit: amet,
2237     };
2238 }
2239 ```
2240
2241 #### `false`:
2242
2243 ```rust
2244 fn lorem<T:Eq>(t:T) {
2245     let lorem:Dolor = Lorem {
2246         ipsum:dolor,
2247         sit:amet,
2248     };
2249 }
2250 ```
2251
2252 See also: [`space_before_colon`](#space_before_colon).
2253
2254 ## `space_before_colon`
2255
2256 Leave a space before the colon.
2257
2258 - **Default value**: `false`
2259 - **Possible values**: `true`, `false`
2260 - **Stable**: No (tracking issue: [#3365](https://github.com/rust-lang/rustfmt/issues/3365))
2261
2262 #### `false` (default):
2263
2264 ```rust
2265 fn lorem<T: Eq>(t: T) {
2266     let lorem: Dolor = Lorem {
2267         ipsum: dolor,
2268         sit: amet,
2269     };
2270 }
2271 ```
2272
2273 #### `true`:
2274
2275 ```rust
2276 fn lorem<T : Eq>(t : T) {
2277     let lorem : Dolor = Lorem {
2278         ipsum : dolor,
2279         sit : amet,
2280     };
2281 }
2282 ```
2283
2284 See also: [`space_after_colon`](#space_after_colon).
2285
2286 ## `spaces_around_ranges`
2287
2288 Put spaces around the .., ..=, and ... range operators
2289
2290 - **Default value**: `false`
2291 - **Possible values**: `true`, `false`
2292 - **Stable**: No (tracking issue: [#3367](https://github.com/rust-lang/rustfmt/issues/3367))
2293
2294 #### `false` (default):
2295
2296 ```rust
2297 fn main() {
2298     let lorem = 0..10;
2299     let ipsum = 0..=10;
2300
2301     match lorem {
2302         1..5 => foo(),
2303         _ => bar,
2304     }
2305
2306     match lorem {
2307         1..=5 => foo(),
2308         _ => bar,
2309     }
2310
2311     match lorem {
2312         1...5 => foo(),
2313         _ => bar,
2314     }
2315 }
2316 ```
2317
2318 #### `true`:
2319
2320 ```rust
2321 fn main() {
2322     let lorem = 0 .. 10;
2323     let ipsum = 0 ..= 10;
2324
2325     match lorem {
2326         1 .. 5 => foo(),
2327         _ => bar,
2328     }
2329
2330     match lorem {
2331         1 ..= 5 => foo(),
2332         _ => bar,
2333     }
2334
2335     match lorem {
2336         1 ... 5 => foo(),
2337         _ => bar,
2338     }
2339 }
2340 ```
2341
2342 ## `struct_field_align_threshold`
2343
2344 The maximum diff of width between struct fields to be aligned with each other.
2345
2346 - **Default value** : 0
2347 - **Possible values**: any non-negative integer
2348 - **Stable**: No (tracking issue: [#3371](https://github.com/rust-lang/rustfmt/issues/3371))
2349
2350 #### `0` (default):
2351
2352 ```rust
2353 struct Foo {
2354     x: u32,
2355     yy: u32,
2356     zzz: u32,
2357 }
2358 ```
2359
2360 #### `20`:
2361
2362 ```rust
2363 struct Foo {
2364     x:   u32,
2365     yy:  u32,
2366     zzz: u32,
2367 }
2368 ```
2369
2370 ## `struct_lit_single_line`
2371
2372 Put small struct literals on a single line
2373
2374 - **Default value**: `true`
2375 - **Possible values**: `true`, `false`
2376 - **Stable**: No (tracking issue: [#3357](https://github.com/rust-lang/rustfmt/issues/3357))
2377
2378 #### `true` (default):
2379
2380 ```rust
2381 fn main() {
2382     let lorem = Lorem { foo: bar, baz: ofo };
2383 }
2384 ```
2385
2386 #### `false`:
2387
2388 ```rust
2389 fn main() {
2390     let lorem = Lorem {
2391         foo: bar,
2392         baz: ofo,
2393     };
2394 }
2395 ```
2396
2397 See also: [`indent_style`](#indent_style).
2398
2399 ## `struct_lit_width`
2400
2401 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`.
2402
2403 - **Default value**: `18`
2404 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2405 - **Stable**: Yes
2406
2407 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.
2408
2409 See also [`max_width`](#max_width), [`use_small_heuristics`](#use_small_heuristics), and [`struct_lit_single_line`](#struct_lit_single_line)
2410
2411 ## `struct_variant_width`
2412
2413 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`.
2414
2415 - **Default value**: `35`
2416 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2417 - **Stable**: Yes
2418
2419 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.
2420
2421 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
2422
2423 ## `tab_spaces`
2424
2425 Number of spaces per tab
2426
2427 - **Default value**: `4`
2428 - **Possible values**: any positive integer
2429 - **Stable**: Yes
2430
2431 #### `4` (default):
2432
2433 ```rust
2434 fn lorem() {
2435     let ipsum = dolor();
2436     let sit = vec![
2437         "amet consectetur adipiscing elit amet",
2438         "consectetur adipiscing elit amet consectetur.",
2439     ];
2440 }
2441 ```
2442
2443 #### `2`:
2444
2445 ```rust
2446 fn lorem() {
2447   let ipsum = dolor();
2448   let sit = vec![
2449     "amet consectetur adipiscing elit amet",
2450     "consectetur adipiscing elit amet consectetur.",
2451   ];
2452 }
2453 ```
2454
2455 See also: [`hard_tabs`](#hard_tabs).
2456
2457
2458 ## `trailing_comma`
2459
2460 How to handle trailing commas for lists
2461
2462 - **Default value**: `"Vertical"`
2463 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2464 - **Stable**: No (tracking issue: [#3379](https://github.com/rust-lang/rustfmt/issues/3379))
2465
2466 #### `"Vertical"` (default):
2467
2468 ```rust
2469 fn main() {
2470     let Lorem { ipsum, dolor, sit } = amet;
2471     let Lorem {
2472         ipsum,
2473         dolor,
2474         sit,
2475         amet,
2476         consectetur,
2477         adipiscing,
2478     } = elit;
2479 }
2480 ```
2481
2482 #### `"Always"`:
2483
2484 ```rust
2485 fn main() {
2486     let Lorem { ipsum, dolor, sit, } = amet;
2487     let Lorem {
2488         ipsum,
2489         dolor,
2490         sit,
2491         amet,
2492         consectetur,
2493         adipiscing,
2494     } = elit;
2495 }
2496 ```
2497
2498 #### `"Never"`:
2499
2500 ```rust
2501 fn main() {
2502     let Lorem { ipsum, dolor, sit } = amet;
2503     let Lorem {
2504         ipsum,
2505         dolor,
2506         sit,
2507         amet,
2508         consectetur,
2509         adipiscing
2510     } = elit;
2511 }
2512 ```
2513
2514 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2515
2516 ## `trailing_semicolon`
2517
2518 Add trailing semicolon after break, continue and return
2519
2520 - **Default value**: `true`
2521 - **Possible values**: `true`, `false`
2522 - **Stable**: No (tracking issue: [#3378](https://github.com/rust-lang/rustfmt/issues/3378))
2523
2524 #### `true` (default):
2525 ```rust
2526 fn foo() -> usize {
2527     return 0;
2528 }
2529 ```
2530
2531 #### `false`:
2532 ```rust
2533 fn foo() -> usize {
2534     return 0
2535 }
2536 ```
2537
2538 ## `type_punctuation_density`
2539
2540 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2541
2542 - **Default value**: `"Wide"`
2543 - **Possible values**: `"Compressed"`, `"Wide"`
2544 - **Stable**: No (tracking issue: [#3364](https://github.com/rust-lang/rustfmt/issues/3364))
2545
2546 #### `"Wide"` (default):
2547
2548 ```rust
2549 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2550     // body
2551 }
2552 ```
2553
2554 #### `"Compressed"`:
2555
2556 ```rust
2557 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2558     // body
2559 }
2560 ```
2561
2562 ## `unstable_features`
2563
2564 Enable unstable features on the unstable channel.
2565
2566 - **Default value**: `false`
2567 - **Possible values**: `true`, `false`
2568 - **Stable**: No (tracking issue: [#3387](https://github.com/rust-lang/rustfmt/issues/3387))
2569
2570 ## `use_field_init_shorthand`
2571
2572 Use field initialize shorthand if possible.
2573
2574 - **Default value**: `false`
2575 - **Possible values**: `true`, `false`
2576 - **Stable**: Yes
2577
2578 #### `false` (default):
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     let b = Foo { x: x, y: y, z: z };
2593 }
2594 ```
2595
2596 #### `true`:
2597
2598 ```rust
2599 struct Foo {
2600     x: u32,
2601     y: u32,
2602     z: u32,
2603 }
2604
2605 fn main() {
2606     let x = 1;
2607     let y = 2;
2608     let z = 3;
2609     let a = Foo { x, y, z };
2610 }
2611 ```
2612
2613 ## `use_small_heuristics`
2614
2615 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.
2616
2617 Note that explicitly provided values for the width configuration settings take precedence and override the calculated values determined by `use_small_heuristics`.
2618
2619 - **Default value**: `"Default"`
2620 - **Possible values**: `"Default"`, `"Off"`, `"Max"`
2621 - **Stable**: Yes
2622
2623 #### `Default` (default):
2624 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`.
2625
2626 The ratios are:
2627 * [`fn_call_width`](#fn_call_width) - `60%`
2628 * [`attr_fn_like_width`](#attr_fn_like_width) - `70%`
2629 * [`struct_lit_width`](#struct_lit_width) - `18%`
2630 * [`struct_variant_width`](#struct_variant_width) - `35%`
2631 * [`array_width`](#array_width) - `60%`
2632 * [`chain_width`](#chain_width) - `60%`
2633 * [`single_line_if_else_max_width`](#single_line_if_else_max_width) - `50%`
2634
2635 For example when `max_width` is set to `100`, the width settings are:
2636 * `fn_call_width=60`
2637 * `attr_fn_like_width=70`
2638 * `struct_lit_width=18`
2639 * `struct_variant_width=35`
2640 * `array_width=60`
2641 * `chain_width=60`
2642 * `single_line_if_else_max_width=50`
2643
2644 and when `max_width` is set to `200`:
2645 * `fn_call_width=120`
2646 * `attr_fn_like_width=140`
2647 * `struct_lit_width=36`
2648 * `struct_variant_width=70`
2649 * `array_width=120`
2650 * `chain_width=120`
2651 * `single_line_if_else_max_width=100`
2652
2653 ```rust
2654 enum Lorem {
2655     Ipsum,
2656     Dolor(bool),
2657     Sit { amet: Consectetur, adipiscing: Elit },
2658 }
2659
2660 fn main() {
2661     lorem(
2662         "lorem",
2663         "ipsum",
2664         "dolor",
2665         "sit",
2666         "amet",
2667         "consectetur",
2668         "adipiscing",
2669     );
2670
2671     let lorem = Lorem {
2672         ipsum: dolor,
2673         sit: amet,
2674     };
2675     let lorem = Lorem { ipsum: dolor };
2676
2677     let lorem = if ipsum { dolor } else { sit };
2678 }
2679 ```
2680
2681 #### `Off`:
2682 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.
2683
2684 ```rust
2685 enum Lorem {
2686     Ipsum,
2687     Dolor(bool),
2688     Sit {
2689         amet: Consectetur,
2690         adipiscing: Elit,
2691     },
2692 }
2693
2694 fn main() {
2695     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2696
2697     let lorem = Lorem {
2698         ipsum: dolor,
2699         sit: amet,
2700     };
2701
2702     let lorem = if ipsum {
2703         dolor
2704     } else {
2705         sit
2706     };
2707 }
2708 ```
2709
2710 #### `Max`:
2711 When `use_small_heuristics` is set to `Max`, then each granular width setting is set to the same value as `max_width`.
2712
2713 So if `max_width` is set to `200`, then all the width settings are also set to `200`.
2714 * `fn_call_width=200`
2715 * `attr_fn_like_width=200`
2716 * `struct_lit_width=200`
2717 * `struct_variant_width=200`
2718 * `array_width=200`
2719 * `chain_width=200`
2720 * `single_line_if_else_max_width=200`
2721
2722 ```rust
2723 enum Lorem {
2724     Ipsum,
2725     Dolor(bool),
2726     Sit { amet: Consectetur, adipiscing: Elit },
2727 }
2728
2729 fn main() {
2730     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2731
2732     let lorem = Lorem { ipsum: dolor, sit: amet };
2733
2734     let lorem = if ipsum { dolor } else { sit };
2735 }
2736 ```
2737
2738
2739 See also:
2740 * [`max_width`](#max_width)
2741 * [`fn_call_width`](#fn_call_width)
2742 * [`attr_fn_like_width`](#attr_fn_like_width)
2743 * [`struct_lit_width`](#struct_lit_width)
2744 * [`struct_variant_width`](#struct_variant_width)
2745 * [`array_width`](#array_width)
2746 * [`chain_width`](#chain_width)
2747 * [`single_line_if_else_max_width`](#single_line_if_else_max_width)
2748
2749 ## `use_try_shorthand`
2750
2751 Replace uses of the try! macro by the ? shorthand
2752
2753 - **Default value**: `false`
2754 - **Possible values**: `true`, `false`
2755 - **Stable**: Yes
2756
2757 #### `false` (default):
2758
2759 ```rust
2760 fn main() {
2761     let lorem = ipsum.map(|dolor| dolor.sit())?;
2762
2763     let lorem = try!(ipsum.map(|dolor| dolor.sit()));
2764 }
2765 ```
2766
2767 #### `true`:
2768
2769 ```rust
2770 fn main() {
2771     let lorem = ipsum.map(|dolor| dolor.sit())?;
2772 }
2773 ```
2774
2775 ## `version`
2776
2777 Which version of the formatting rules to use. `Version::One` is backwards-compatible
2778 with Rustfmt 1.0. Other versions are only backwards compatible within a major
2779 version number.
2780
2781 - **Default value**: `One`
2782 - **Possible values**: `One`, `Two`
2783 - **Stable**: No (tracking issue: [#3383](https://github.com/rust-lang/rustfmt/issues/3383))
2784
2785 ### Example
2786
2787 ```toml
2788 version = "Two"
2789 ```
2790
2791 ## `where_single_line`
2792
2793 Forces the `where` clause to be laid out on a single line.
2794
2795 - **Default value**: `false`
2796 - **Possible values**: `true`, `false`
2797 - **Stable**: No (tracking issue: [#3359](https://github.com/rust-lang/rustfmt/issues/3359))
2798
2799 #### `false` (default):
2800
2801 ```rust
2802 impl<T> Lorem for T
2803 where
2804     Option<T>: Ipsum,
2805 {
2806     // body
2807 }
2808 ```
2809
2810 #### `true`:
2811
2812 ```rust
2813 impl<T> Lorem for T
2814 where Option<T>: Ipsum
2815 {
2816     // body
2817 }
2818 ```
2819
2820 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
2821
2822
2823 ## `wrap_comments`
2824
2825 Break comments to fit on the line
2826
2827 - **Default value**: `false`
2828 - **Possible values**: `true`, `false`
2829 - **Stable**: No (tracking issue: [#3347](https://github.com/rust-lang/rustfmt/issues/3347))
2830
2831 #### `false` (default):
2832
2833 ```rust
2834 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2835 // sed do eiusmod tempor incididunt ut labore et dolore
2836 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2837 // exercitation ullamco laboris nisi ut aliquip ex ea
2838 // commodo consequat.
2839
2840 // 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.
2841 ```
2842
2843 #### `true`:
2844
2845 ```rust
2846 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2847 // sed do eiusmod tempor incididunt ut labore et dolore
2848 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2849 // exercitation ullamco laboris nisi ut aliquip ex ea
2850 // commodo consequat.
2851 ```
2852
2853 # Internal Options
2854
2855 ## `emit_mode`
2856
2857 Internal option
2858
2859 ## `make_backup`
2860
2861 Internal option, use `--backup`
2862
2863 ## `print_misformatted_file_names`
2864
2865 Internal option, use `-l` or `--files-with-diff`