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