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