]> git.lizzy.rs Git - rust.git/blob - Configurations.md
Search for struct body span after any generic arguments
[rust.git] / Configurations.md
1 # Configuring Rustfmt
2
3 Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file. If none of these directories contain such a file, both your home directory and a directory called `rustfmt` in your [global config directory](https://docs.rs/dirs/1.0.4/dirs/fn.config_dir.html) (e.g. `.config/rustfmt/`) are checked as well.
4
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
6
7 ```toml
8 indent_style = "Block"
9 reorder_imports = false
10 ```
11
12 Each configuration option is either stable or unstable.
13 Stable options can 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 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**: `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 ## `license_template_path`
1477
1478 Check whether beginnings of files match a license template.
1479
1480 - **Default value**: `""`
1481 - **Possible values**: path to a license template file
1482 - **Stable**: No (tracking issue: [#3352](https://github.com/rust-lang/rustfmt/issues/3352))
1483
1484 A license template is a plain text file which is matched literally against the
1485 beginning of each source file, except for `{}`-delimited blocks, which are
1486 matched as regular expressions. The following license template therefore
1487 matches strings like `// Copyright 2017 The Rust Project Developers.`, `//
1488 Copyright 2018 The Rust Project Developers.`, etc.:
1489
1490 ```
1491 // Copyright {\d+} The Rust Project Developers.
1492 ```
1493
1494 `\{`, `\}` and `\\` match literal braces / backslashes.
1495
1496 ## `match_arm_blocks`
1497
1498 Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator.
1499
1500 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.
1501
1502 - **Default value**: `true`
1503 - **Possible values**: `true`, `false`
1504 - **Stable**: No (tracking issue: [#3373](https://github.com/rust-lang/rustfmt/issues/3373))
1505
1506 #### `true` (default):
1507
1508 ```rust
1509 fn main() {
1510     match lorem {
1511         ipsum => {
1512             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
1513         }
1514         dolor => println!("{}", sit),
1515         sit => foo(
1516             "foooooooooooooooooooooooo",
1517             "baaaaaaaaaaaaaaaaaaaaaaaarr",
1518             "baaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzz",
1519             "qqqqqqqqquuuuuuuuuuuuuuuuuuuuuuuuuuxxx",
1520         ),
1521     }
1522 }
1523 ```
1524
1525 #### `false`:
1526
1527 ```rust
1528 fn main() {
1529     match lorem {
1530         lorem =>
1531             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
1532         ipsum => println!("{}", sit),
1533         sit => foo(
1534             "foooooooooooooooooooooooo",
1535             "baaaaaaaaaaaaaaaaaaaaaaaarr",
1536             "baaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzz",
1537             "qqqqqqqqquuuuuuuuuuuuuuuuuuuuuuuuuuxxx",
1538         ),
1539     }
1540 }
1541 ```
1542
1543 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
1544
1545 ## `match_arm_leading_pipes`
1546
1547 Controls whether to include a leading pipe on match arms
1548
1549 - **Default value**: `Never`
1550 - **Possible values**: `Always`, `Never`, `Preserve`
1551 - **Stable**: Yes
1552
1553 #### `Never` (default):
1554 ```rust
1555 // Leading pipes are removed from this:
1556 // fn foo() {
1557 //     match foo {
1558 //         | "foo" | "bar" => {}
1559 //         | "baz"
1560 //         | "something relatively long"
1561 //         | "something really really really realllllllllllllly long" => println!("x"),
1562 //         | "qux" => println!("y"),
1563 //         _ => {}
1564 //     }
1565 // }
1566
1567 // Becomes
1568 fn foo() {
1569     match foo {
1570         "foo" | "bar" => {}
1571         "baz"
1572         | "something relatively long"
1573         | "something really really really realllllllllllllly long" => println!("x"),
1574         "qux" => println!("y"),
1575         _ => {}
1576     }
1577 }
1578 ```
1579
1580 #### `Always`:
1581 ```rust
1582 // Leading pipes are emitted on all arms of this:
1583 // fn foo() {
1584 //     match foo {
1585 //         "foo" | "bar" => {}
1586 //         "baz"
1587 //         | "something relatively long"
1588 //         | "something really really really realllllllllllllly long" => println!("x"),
1589 //         "qux" => println!("y"),
1590 //         _ => {}
1591 //     }
1592 // }
1593
1594 // Becomes:
1595 fn foo() {
1596     match foo {
1597         | "foo" | "bar" => {}
1598         | "baz"
1599         | "something relatively long"
1600         | "something really really really realllllllllllllly long" => println!("x"),
1601         | "qux" => println!("y"),
1602         | _ => {}
1603     }
1604 }
1605 ```
1606
1607 #### `Preserve`:
1608 ```rust
1609 fn foo() {
1610     match foo {
1611         | "foo" | "bar" => {}
1612         | "baz"
1613         | "something relatively long"
1614         | "something really really really realllllllllllllly long" => println!("x"),
1615         | "qux" => println!("y"),
1616         _ => {}
1617     }
1618
1619     match baz {
1620         "qux" => {}
1621         "foo" | "bar" => {}
1622         _ => {}
1623     }
1624 }
1625 ```
1626
1627 ## `match_block_trailing_comma`
1628
1629 Put a trailing comma after a block based match arm (non-block arms are not affected)
1630
1631 - **Default value**: `false`
1632 - **Possible values**: `true`, `false`
1633 - **Stable**: Yes
1634
1635 #### `false` (default):
1636
1637 ```rust
1638 fn main() {
1639     match lorem {
1640         Lorem::Ipsum => {
1641             println!("ipsum");
1642         }
1643         Lorem::Dolor => println!("dolor"),
1644     }
1645 }
1646 ```
1647
1648 #### `true`:
1649
1650 ```rust
1651 fn main() {
1652     match lorem {
1653         Lorem::Ipsum => {
1654             println!("ipsum");
1655         },
1656         Lorem::Dolor => println!("dolor"),
1657     }
1658 }
1659 ```
1660
1661 See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
1662
1663 ## `max_width`
1664
1665 Maximum width of each line
1666
1667 - **Default value**: `100`
1668 - **Possible values**: any positive integer
1669 - **Stable**: Yes
1670
1671 See also [`error_on_line_overflow`](#error_on_line_overflow).
1672
1673 ## `merge_derives`
1674
1675 Merge multiple derives into a single one.
1676
1677 - **Default value**: `true`
1678 - **Possible values**: `true`, `false`
1679 - **Stable**: Yes
1680
1681 #### `true` (default):
1682
1683 ```rust
1684 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1685 pub enum Foo {}
1686 ```
1687
1688 #### `false`:
1689
1690 ```rust
1691 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1692 pub enum Bar {}
1693
1694 #[derive(Eq, PartialEq)]
1695 #[derive(Debug)]
1696 #[derive(Copy, Clone)]
1697 pub enum Foo {}
1698 ```
1699
1700 ## `imports_granularity`
1701
1702 How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
1703
1704 - **Default value**: `Preserve`
1705 - **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One`
1706 - **Stable**: No (tracking issue: [#4991](https://github.com/rust-lang/rustfmt/issues/4991))
1707
1708 #### `Preserve` (default):
1709
1710 Do not change the granularity of any imports and preserve the original structure written by the developer.
1711
1712 ```rust
1713 use foo::b;
1714 use foo::b::{f, g};
1715 use foo::{a, c, d::e};
1716 use qux::{h, i};
1717 ```
1718
1719 #### `Crate`:
1720
1721 Merge imports from the same crate into a single `use` statement. Conversely, imports from different crates are split into separate statements.
1722
1723 ```rust
1724 use foo::{
1725     a, b,
1726     b::{f, g},
1727     c,
1728     d::e,
1729 };
1730 use qux::{h, i};
1731 ```
1732
1733 #### `Module`:
1734
1735 Merge imports from the same module into a single `use` statement. Conversely, imports from different modules are split into separate statements.
1736
1737 ```rust
1738 use foo::b::{f, g};
1739 use foo::d::e;
1740 use foo::{a, b, c};
1741 use qux::{h, i};
1742 ```
1743
1744 #### `Item`:
1745
1746 Flatten imports so that each has its own `use` statement.
1747
1748 ```rust
1749 use foo::a;
1750 use foo::b;
1751 use foo::b::f;
1752 use foo::b::g;
1753 use foo::c;
1754 use foo::d::e;
1755 use qux::h;
1756 use qux::i;
1757 ```
1758
1759 #### `One`:
1760
1761 Merge all imports into a single `use` statement as long as they have the same visibility.
1762
1763 ```rust
1764 pub use foo::{x, y};
1765 use {
1766     bar::{
1767         a,
1768         b::{self, f, g},
1769         c,
1770         d::e,
1771     },
1772     qux::{h, i},
1773 };
1774 ```
1775
1776 ## `merge_imports`
1777
1778 This option is deprecated. Use `imports_granularity = "Crate"` instead.
1779
1780 - **Default value**: `false`
1781 - **Possible values**: `true`, `false`
1782
1783 #### `false` (default):
1784
1785 ```rust
1786 use foo::{a, c, d};
1787 use foo::{b, g};
1788 use foo::{e, f};
1789 ```
1790
1791 #### `true`:
1792
1793 ```rust
1794 use foo::{a, b, c, d, e, f, g};
1795 ```
1796
1797
1798 ## `newline_style`
1799
1800 Unix or Windows line endings
1801
1802 - **Default value**: `"Auto"`
1803 - **Possible values**: `"Auto"`, `"Native"`, `"Unix"`, `"Windows"`
1804 - **Stable**: Yes
1805
1806 #### `Auto` (default):
1807
1808 The newline style is detected automatically on a per-file basis. Files
1809 with mixed line endings will be converted to the first detected line
1810 ending style.
1811
1812 #### `Native`
1813
1814 Line endings will be converted to `\r\n` on Windows and `\n` on all
1815 other platforms.
1816
1817 #### `Unix`
1818
1819 Line endings will be converted to `\n`.
1820
1821 #### `Windows`
1822
1823 Line endings will be converted to `\r\n`.
1824
1825 ## `normalize_comments`
1826
1827 Convert /* */ comments to // comments where possible
1828
1829 - **Default value**: `false`
1830 - **Possible values**: `true`, `false`
1831 - **Stable**: No (tracking issue: [#3350](https://github.com/rust-lang/rustfmt/issues/3350))
1832
1833 #### `false` (default):
1834
1835 ```rust
1836 // Lorem ipsum:
1837 fn dolor() -> usize {}
1838
1839 /* sit amet: */
1840 fn adipiscing() -> usize {}
1841 ```
1842
1843 #### `true`:
1844
1845 ```rust
1846 // Lorem ipsum:
1847 fn dolor() -> usize {}
1848
1849 // sit amet:
1850 fn adipiscing() -> usize {}
1851 ```
1852
1853 ## `normalize_doc_attributes`
1854
1855 Convert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments.
1856
1857 - **Default value**: `false`
1858 - **Possible values**: `true`, `false`
1859 - **Stable**: No (tracking issue: [#3351](https://github.com/rust-lang/rustfmt/issues/3351))
1860
1861 #### `false` (default):
1862
1863 ```rust
1864 #![doc = "Example documentation"]
1865
1866 #[doc = "Example item documentation"]
1867 pub enum Bar {}
1868
1869 /// Example item documentation
1870 pub enum Foo {}
1871 ```
1872
1873 #### `true`:
1874
1875 ```rust
1876 //! Example documentation
1877
1878 /// Example item documentation
1879 pub enum Foo {}
1880 ```
1881
1882 ## `overflow_delimited_expr`
1883
1884 When structs, slices, arrays, and block/array-like macros are used as the last
1885 argument in an expression list, allow them to overflow (like blocks/closures)
1886 instead of being indented on a new line.
1887
1888 - **Default value**: `false`
1889 - **Possible values**: `true`, `false`
1890 - **Stable**: No (tracking issue: [#3370](https://github.com/rust-lang/rustfmt/issues/3370))
1891
1892 #### `false` (default):
1893
1894 ```rust
1895 fn example() {
1896     foo(ctx, |param| {
1897         action();
1898         foo(param)
1899     });
1900
1901     foo(
1902         ctx,
1903         Bar {
1904             x: value,
1905             y: value2,
1906         },
1907     );
1908
1909     foo(
1910         ctx,
1911         &[
1912             MAROON_TOMATOES,
1913             PURPLE_POTATOES,
1914             ORGANE_ORANGES,
1915             GREEN_PEARS,
1916             RED_APPLES,
1917         ],
1918     );
1919
1920     foo(
1921         ctx,
1922         vec![
1923             MAROON_TOMATOES,
1924             PURPLE_POTATOES,
1925             ORGANE_ORANGES,
1926             GREEN_PEARS,
1927             RED_APPLES,
1928         ],
1929     );
1930 }
1931 ```
1932
1933 #### `true`:
1934
1935 ```rust
1936 fn example() {
1937     foo(ctx, |param| {
1938         action();
1939         foo(param)
1940     });
1941
1942     foo(ctx, Bar {
1943         x: value,
1944         y: value2,
1945     });
1946
1947     foo(ctx, &[
1948         MAROON_TOMATOES,
1949         PURPLE_POTATOES,
1950         ORGANE_ORANGES,
1951         GREEN_PEARS,
1952         RED_APPLES,
1953     ]);
1954
1955     foo(ctx, vec![
1956         MAROON_TOMATOES,
1957         PURPLE_POTATOES,
1958         ORGANE_ORANGES,
1959         GREEN_PEARS,
1960         RED_APPLES,
1961     ]);
1962 }
1963 ```
1964
1965 ## `remove_nested_parens`
1966
1967 Remove nested parens.
1968
1969 - **Default value**: `true`,
1970 - **Possible values**: `true`, `false`
1971 - **Stable**: Yes
1972
1973
1974 #### `true` (default):
1975 ```rust
1976 fn main() {
1977     (foo());
1978 }
1979 ```
1980
1981 #### `false`:
1982 ```rust
1983 fn main() {
1984     (foo());
1985
1986     ((((foo()))));
1987 }
1988 ```
1989
1990
1991 ## `reorder_impl_items`
1992
1993 Reorder impl items. `type` and `const` are put first, then macros and methods.
1994
1995 - **Default value**: `false`
1996 - **Possible values**: `true`, `false`
1997 - **Stable**: No (tracking issue: [#3363](https://github.com/rust-lang/rustfmt/issues/3363))
1998
1999 #### `false` (default)
2000
2001 ```rust
2002 struct Dummy;
2003
2004 impl Iterator for Dummy {
2005     fn next(&mut self) -> Option<Self::Item> {
2006         None
2007     }
2008
2009     type Item = i32;
2010 }
2011
2012 impl Iterator for Dummy {
2013     type Item = i32;
2014
2015     fn next(&mut self) -> Option<Self::Item> {
2016         None
2017     }
2018 }
2019 ```
2020
2021 #### `true`
2022
2023 ```rust
2024 struct Dummy;
2025
2026 impl Iterator for Dummy {
2027     type Item = i32;
2028
2029     fn next(&mut self) -> Option<Self::Item> {
2030         None
2031     }
2032 }
2033 ```
2034
2035 ## `reorder_imports`
2036
2037 Reorder import and extern crate statements alphabetically in groups (a group is
2038 separated by a newline).
2039
2040 - **Default value**: `true`
2041 - **Possible values**: `true`, `false`
2042 - **Stable**: Yes
2043
2044 #### `true` (default):
2045
2046 ```rust
2047 use dolor;
2048 use ipsum;
2049 use lorem;
2050 use sit;
2051 ```
2052
2053 #### `false`:
2054
2055 ```rust
2056 use lorem;
2057 use ipsum;
2058 use dolor;
2059 use sit;
2060 ```
2061
2062 ## `group_imports`
2063
2064 Controls the strategy for how imports are grouped together.
2065
2066 - **Default value**: `Preserve`
2067 - **Possible values**: `Preserve`, `StdExternalCrate`, `One`
2068 - **Stable**: No (tracking issue: [#5083](https://github.com/rust-lang/rustfmt/issues/5083))
2069
2070 #### `Preserve` (default):
2071
2072 Preserve the source file's import groups.
2073
2074 ```rust
2075 use super::update::convert_publish_payload;
2076 use chrono::Utc;
2077
2078 use alloc::alloc::Layout;
2079 use juniper::{FieldError, FieldResult};
2080 use uuid::Uuid;
2081
2082 use std::sync::Arc;
2083
2084 use broker::database::PooledConnection;
2085
2086 use super::schema::{Context, Payload};
2087 use crate::models::Event;
2088 use core::f32;
2089 ```
2090
2091 #### `StdExternalCrate`:
2092
2093 Discard existing import groups, and create three groups for:
2094 1. `std`, `core` and `alloc`,
2095 2. external crates,
2096 3. `self`, `super` and `crate` imports.
2097
2098 ```rust
2099 use alloc::alloc::Layout;
2100 use core::f32;
2101 use std::sync::Arc;
2102
2103 use broker::database::PooledConnection;
2104 use chrono::Utc;
2105 use juniper::{FieldError, FieldResult};
2106 use uuid::Uuid;
2107
2108 use super::schema::{Context, Payload};
2109 use super::update::convert_publish_payload;
2110 use crate::models::Event;
2111 ```
2112
2113 #### `One`:
2114
2115 Discard existing import groups, and create a single group for everything
2116
2117 ```rust
2118 use super::schema::{Context, Payload};
2119 use super::update::convert_publish_payload;
2120 use crate::models::Event;
2121 use alloc::alloc::Layout;
2122 use broker::database::PooledConnection;
2123 use chrono::Utc;
2124 use core::f32;
2125 use juniper::{FieldError, FieldResult};
2126 use std::sync::Arc;
2127 use uuid::Uuid;
2128 ```
2129
2130 ## `reorder_modules`
2131
2132 Reorder `mod` declarations alphabetically in group.
2133
2134 - **Default value**: `true`
2135 - **Possible values**: `true`, `false`
2136 - **Stable**: Yes
2137
2138 #### `true` (default)
2139
2140 ```rust
2141 mod a;
2142 mod b;
2143
2144 mod dolor;
2145 mod ipsum;
2146 mod lorem;
2147 mod sit;
2148 ```
2149
2150 #### `false`
2151
2152 ```rust
2153 mod b;
2154 mod a;
2155
2156 mod lorem;
2157 mod ipsum;
2158 mod dolor;
2159 mod sit;
2160 ```
2161
2162 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics
2163 of the original source code.
2164
2165 ## `report_fixme`
2166
2167 Report `FIXME` items in comments.
2168
2169 - **Default value**: `"Never"`
2170 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
2171 - **Stable**: No (tracking issue: [#3394](https://github.com/rust-lang/rustfmt/issues/3394))
2172
2173 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
2174 it contains a `#X` (with `X` being a number) in parentheses following the
2175 `FIXME`, `"Unnumbered"` will ignore it.
2176
2177 See also [`report_todo`](#report_todo).
2178
2179
2180 ## `report_todo`
2181
2182 Report `TODO` items in comments.
2183
2184 - **Default value**: `"Never"`
2185 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
2186 - **Stable**: No (tracking issue: [#3393](https://github.com/rust-lang/rustfmt/issues/3393))
2187
2188 Warns about any comments containing `TODO` in them when set to `"Always"`. If
2189 it contains a `#X` (with `X` being a number) in parentheses following the
2190 `TODO`, `"Unnumbered"` will ignore it.
2191
2192 See also [`report_fixme`](#report_fixme).
2193
2194 ## `required_version`
2195
2196 Require a specific version of rustfmt. If you want to make sure that the
2197 specific version of rustfmt is used in your CI, use this option.
2198
2199 - **Default value**: `CARGO_PKG_VERSION`
2200 - **Possible values**: any published version (e.g. `"0.3.8"`)
2201 - **Stable**: No (tracking issue: [#3386](https://github.com/rust-lang/rustfmt/issues/3386))
2202
2203 ## `skip_children`
2204
2205 Don't reformat out of line modules
2206
2207 - **Default value**: `false`
2208 - **Possible values**: `true`, `false`
2209 - **Stable**: No (tracking issue: [#3389](https://github.com/rust-lang/rustfmt/issues/3389))
2210
2211 ## `single_line_if_else_max_width`
2212
2213 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`.
2214
2215 - **Default value**: `50`
2216 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2217 - **Stable**: Yes
2218
2219 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.
2220
2221 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
2222
2223 ## `space_after_colon`
2224
2225 Leave a space after the colon.
2226
2227 - **Default value**: `true`
2228 - **Possible values**: `true`, `false`
2229 - **Stable**: No (tracking issue: [#3366](https://github.com/rust-lang/rustfmt/issues/3366))
2230
2231 #### `true` (default):
2232
2233 ```rust
2234 fn lorem<T: Eq>(t: T) {
2235     let lorem: Dolor = Lorem {
2236         ipsum: dolor,
2237         sit: amet,
2238     };
2239 }
2240 ```
2241
2242 #### `false`:
2243
2244 ```rust
2245 fn lorem<T:Eq>(t:T) {
2246     let lorem:Dolor = Lorem {
2247         ipsum:dolor,
2248         sit:amet,
2249     };
2250 }
2251 ```
2252
2253 See also: [`space_before_colon`](#space_before_colon).
2254
2255 ## `space_before_colon`
2256
2257 Leave a space before the colon.
2258
2259 - **Default value**: `false`
2260 - **Possible values**: `true`, `false`
2261 - **Stable**: No (tracking issue: [#3365](https://github.com/rust-lang/rustfmt/issues/3365))
2262
2263 #### `false` (default):
2264
2265 ```rust
2266 fn lorem<T: Eq>(t: T) {
2267     let lorem: Dolor = Lorem {
2268         ipsum: dolor,
2269         sit: amet,
2270     };
2271 }
2272 ```
2273
2274 #### `true`:
2275
2276 ```rust
2277 fn lorem<T : Eq>(t : T) {
2278     let lorem : Dolor = Lorem {
2279         ipsum : dolor,
2280         sit : amet,
2281     };
2282 }
2283 ```
2284
2285 See also: [`space_after_colon`](#space_after_colon).
2286
2287 ## `spaces_around_ranges`
2288
2289 Put spaces around the .., ..=, and ... range operators
2290
2291 - **Default value**: `false`
2292 - **Possible values**: `true`, `false`
2293 - **Stable**: No (tracking issue: [#3367](https://github.com/rust-lang/rustfmt/issues/3367))
2294
2295 #### `false` (default):
2296
2297 ```rust
2298 fn main() {
2299     let lorem = 0..10;
2300     let ipsum = 0..=10;
2301
2302     match lorem {
2303         1..5 => foo(),
2304         _ => bar,
2305     }
2306
2307     match lorem {
2308         1..=5 => foo(),
2309         _ => bar,
2310     }
2311
2312     match lorem {
2313         1...5 => foo(),
2314         _ => bar,
2315     }
2316 }
2317 ```
2318
2319 #### `true`:
2320
2321 ```rust
2322 fn main() {
2323     let lorem = 0 .. 10;
2324     let ipsum = 0 ..= 10;
2325
2326     match lorem {
2327         1 .. 5 => foo(),
2328         _ => bar,
2329     }
2330
2331     match lorem {
2332         1 ..= 5 => foo(),
2333         _ => bar,
2334     }
2335
2336     match lorem {
2337         1 ... 5 => foo(),
2338         _ => bar,
2339     }
2340 }
2341 ```
2342
2343 ## `struct_field_align_threshold`
2344
2345 The maximum diff of width between struct fields to be aligned with each other.
2346
2347 - **Default value** : 0
2348 - **Possible values**: any non-negative integer
2349 - **Stable**: No (tracking issue: [#3371](https://github.com/rust-lang/rustfmt/issues/3371))
2350
2351 #### `0` (default):
2352
2353 ```rust
2354 struct Foo {
2355     x: u32,
2356     yy: u32,
2357     zzz: u32,
2358 }
2359 ```
2360
2361 #### `20`:
2362
2363 ```rust
2364 struct Foo {
2365     x:   u32,
2366     yy:  u32,
2367     zzz: u32,
2368 }
2369 ```
2370
2371 ## `struct_lit_single_line`
2372
2373 Put small struct literals on a single line
2374
2375 - **Default value**: `true`
2376 - **Possible values**: `true`, `false`
2377 - **Stable**: No (tracking issue: [#3357](https://github.com/rust-lang/rustfmt/issues/3357))
2378
2379 #### `true` (default):
2380
2381 ```rust
2382 fn main() {
2383     let lorem = Lorem { foo: bar, baz: ofo };
2384 }
2385 ```
2386
2387 #### `false`:
2388
2389 ```rust
2390 fn main() {
2391     let lorem = Lorem {
2392         foo: bar,
2393         baz: ofo,
2394     };
2395 }
2396 ```
2397
2398 See also: [`indent_style`](#indent_style).
2399
2400 ## `struct_lit_width`
2401
2402 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`.
2403
2404 - **Default value**: `18`
2405 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2406 - **Stable**: Yes
2407
2408 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.
2409
2410 See also [`max_width`](#max_width), [`use_small_heuristics`](#use_small_heuristics), and [`struct_lit_single_line`](#struct_lit_single_line)
2411
2412 ## `struct_variant_width`
2413
2414 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`.
2415
2416 - **Default value**: `35`
2417 - **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
2418 - **Stable**: Yes
2419
2420 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.
2421
2422 See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)
2423
2424 ## `tab_spaces`
2425
2426 Number of spaces per tab
2427
2428 - **Default value**: `4`
2429 - **Possible values**: any positive integer
2430 - **Stable**: Yes
2431
2432 #### `4` (default):
2433
2434 ```rust
2435 fn lorem() {
2436     let ipsum = dolor();
2437     let sit = vec![
2438         "amet consectetur adipiscing elit amet",
2439         "consectetur adipiscing elit amet consectetur.",
2440     ];
2441 }
2442 ```
2443
2444 #### `2`:
2445
2446 ```rust
2447 fn lorem() {
2448   let ipsum = dolor();
2449   let sit = vec![
2450     "amet consectetur adipiscing elit amet",
2451     "consectetur adipiscing elit amet consectetur.",
2452   ];
2453 }
2454 ```
2455
2456 See also: [`hard_tabs`](#hard_tabs).
2457
2458
2459 ## `trailing_comma`
2460
2461 How to handle trailing commas for lists
2462
2463 - **Default value**: `"Vertical"`
2464 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2465 - **Stable**: No (tracking issue: [#3379](https://github.com/rust-lang/rustfmt/issues/3379))
2466
2467 #### `"Vertical"` (default):
2468
2469 ```rust
2470 fn main() {
2471     let Lorem { ipsum, dolor, sit } = amet;
2472     let Lorem {
2473         ipsum,
2474         dolor,
2475         sit,
2476         amet,
2477         consectetur,
2478         adipiscing,
2479     } = elit;
2480 }
2481 ```
2482
2483 #### `"Always"`:
2484
2485 ```rust
2486 fn main() {
2487     let Lorem { ipsum, dolor, sit, } = amet;
2488     let Lorem {
2489         ipsum,
2490         dolor,
2491         sit,
2492         amet,
2493         consectetur,
2494         adipiscing,
2495     } = elit;
2496 }
2497 ```
2498
2499 #### `"Never"`:
2500
2501 ```rust
2502 fn main() {
2503     let Lorem { ipsum, dolor, sit } = amet;
2504     let Lorem {
2505         ipsum,
2506         dolor,
2507         sit,
2508         amet,
2509         consectetur,
2510         adipiscing
2511     } = elit;
2512 }
2513 ```
2514
2515 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2516
2517 ## `trailing_semicolon`
2518
2519 Add trailing semicolon after break, continue and return
2520
2521 - **Default value**: `true`
2522 - **Possible values**: `true`, `false`
2523 - **Stable**: No (tracking issue: [#3378](https://github.com/rust-lang/rustfmt/issues/3378))
2524
2525 #### `true` (default):
2526 ```rust
2527 fn foo() -> usize {
2528     return 0;
2529 }
2530 ```
2531
2532 #### `false`:
2533 ```rust
2534 fn foo() -> usize {
2535     return 0
2536 }
2537 ```
2538
2539 ## `type_punctuation_density`
2540
2541 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2542
2543 - **Default value**: `"Wide"`
2544 - **Possible values**: `"Compressed"`, `"Wide"`
2545 - **Stable**: No (tracking issue: [#3364](https://github.com/rust-lang/rustfmt/issues/3364))
2546
2547 #### `"Wide"` (default):
2548
2549 ```rust
2550 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2551     // body
2552 }
2553 ```
2554
2555 #### `"Compressed"`:
2556
2557 ```rust
2558 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2559     // body
2560 }
2561 ```
2562
2563 ## `unstable_features`
2564
2565 Enable unstable features on the unstable channel.
2566
2567 - **Default value**: `false`
2568 - **Possible values**: `true`, `false`
2569 - **Stable**: No (tracking issue: [#3387](https://github.com/rust-lang/rustfmt/issues/3387))
2570
2571 ## `use_field_init_shorthand`
2572
2573 Use field initialize shorthand if possible.
2574
2575 - **Default value**: `false`
2576 - **Possible values**: `true`, `false`
2577 - **Stable**: Yes
2578
2579 #### `false` (default):
2580
2581 ```rust
2582 struct Foo {
2583     x: u32,
2584     y: u32,
2585     z: u32,
2586 }
2587
2588 fn main() {
2589     let x = 1;
2590     let y = 2;
2591     let z = 3;
2592     let a = Foo { x, y, z };
2593     let b = Foo { x: x, y: y, z: z };
2594 }
2595 ```
2596
2597 #### `true`:
2598
2599 ```rust
2600 struct Foo {
2601     x: u32,
2602     y: u32,
2603     z: u32,
2604 }
2605
2606 fn main() {
2607     let x = 1;
2608     let y = 2;
2609     let z = 3;
2610     let a = Foo { x, y, z };
2611 }
2612 ```
2613
2614 ## `use_small_heuristics`
2615
2616 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.
2617
2618 Note that explicitly provided values for the width configuration settings take precedence and override the calculated values determined by `use_small_heuristics`.
2619
2620 - **Default value**: `"Default"`
2621 - **Possible values**: `"Default"`, `"Off"`, `"Max"`
2622 - **Stable**: Yes
2623
2624 #### `Default` (default):
2625 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`.
2626
2627 The ratios are:
2628 * [`fn_call_width`](#fn_call_width) - `60%`
2629 * [`attr_fn_like_width`](#attr_fn_like_width) - `70%`
2630 * [`struct_lit_width`](#struct_lit_width) - `18%`
2631 * [`struct_variant_width`](#struct_variant_width) - `35%`
2632 * [`array_width`](#array_width) - `60%`
2633 * [`chain_width`](#chain_width) - `60%`
2634 * [`single_line_if_else_max_width`](#single_line_if_else_max_width) - `50%`
2635
2636 For example when `max_width` is set to `100`, the width settings are:
2637 * `fn_call_width=60`
2638 * `attr_fn_like_width=70`
2639 * `struct_lit_width=18`
2640 * `struct_variant_width=35`
2641 * `array_width=60`
2642 * `chain_width=60`
2643 * `single_line_if_else_max_width=50`
2644
2645 and when `max_width` is set to `200`:
2646 * `fn_call_width=120`
2647 * `attr_fn_like_width=140`
2648 * `struct_lit_width=36`
2649 * `struct_variant_width=70`
2650 * `array_width=120`
2651 * `chain_width=120`
2652 * `single_line_if_else_max_width=100`
2653
2654 ```rust
2655 enum Lorem {
2656     Ipsum,
2657     Dolor(bool),
2658     Sit { amet: Consectetur, adipiscing: Elit },
2659 }
2660
2661 fn main() {
2662     lorem(
2663         "lorem",
2664         "ipsum",
2665         "dolor",
2666         "sit",
2667         "amet",
2668         "consectetur",
2669         "adipiscing",
2670     );
2671
2672     let lorem = Lorem {
2673         ipsum: dolor,
2674         sit: amet,
2675     };
2676     let lorem = Lorem { ipsum: dolor };
2677
2678     let lorem = if ipsum { dolor } else { sit };
2679 }
2680 ```
2681
2682 #### `Off`:
2683 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.
2684
2685 ```rust
2686 enum Lorem {
2687     Ipsum,
2688     Dolor(bool),
2689     Sit {
2690         amet: Consectetur,
2691         adipiscing: Elit,
2692     },
2693 }
2694
2695 fn main() {
2696     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2697
2698     let lorem = Lorem {
2699         ipsum: dolor,
2700         sit: amet,
2701     };
2702
2703     let lorem = if ipsum {
2704         dolor
2705     } else {
2706         sit
2707     };
2708 }
2709 ```
2710
2711 #### `Max`:
2712 When `use_small_heuristics` is set to `Max`, then each granular width setting is set to the same value as `max_width`.
2713
2714 So if `max_width` is set to `200`, then all the width settings are also set to `200`.
2715 * `fn_call_width=200`
2716 * `attr_fn_like_width=200`
2717 * `struct_lit_width=200`
2718 * `struct_variant_width=200`
2719 * `array_width=200`
2720 * `chain_width=200`
2721 * `single_line_if_else_max_width=200`
2722
2723 ```rust
2724 enum Lorem {
2725     Ipsum,
2726     Dolor(bool),
2727     Sit { amet: Consectetur, adipiscing: Elit },
2728 }
2729
2730 fn main() {
2731     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2732
2733     let lorem = Lorem { ipsum: dolor, sit: amet };
2734
2735     let lorem = if ipsum { dolor } else { sit };
2736 }
2737 ```
2738
2739
2740 See also:
2741 * [`max_width`](#max_width)
2742 * [`fn_call_width`](#fn_call_width)
2743 * [`attr_fn_like_width`](#attr_fn_like_width)
2744 * [`struct_lit_width`](#struct_lit_width)
2745 * [`struct_variant_width`](#struct_variant_width)
2746 * [`array_width`](#array_width)
2747 * [`chain_width`](#chain_width)
2748 * [`single_line_if_else_max_width`](#single_line_if_else_max_width)
2749
2750 ## `use_try_shorthand`
2751
2752 Replace uses of the try! macro by the ? shorthand
2753
2754 - **Default value**: `false`
2755 - **Possible values**: `true`, `false`
2756 - **Stable**: Yes
2757
2758 #### `false` (default):
2759
2760 ```rust
2761 fn main() {
2762     let lorem = ipsum.map(|dolor| dolor.sit())?;
2763
2764     let lorem = try!(ipsum.map(|dolor| dolor.sit()));
2765 }
2766 ```
2767
2768 #### `true`:
2769
2770 ```rust
2771 fn main() {
2772     let lorem = ipsum.map(|dolor| dolor.sit())?;
2773 }
2774 ```
2775
2776 ## `version`
2777
2778 Which version of the formatting rules to use. `Version::One` is backwards-compatible
2779 with Rustfmt 1.0. Other versions are only backwards compatible within a major
2780 version number.
2781
2782 - **Default value**: `One`
2783 - **Possible values**: `One`, `Two`
2784 - **Stable**: No (tracking issue: [#3383](https://github.com/rust-lang/rustfmt/issues/3383))
2785
2786 ### Example
2787
2788 ```toml
2789 version = "Two"
2790 ```
2791
2792 ## `where_single_line`
2793
2794 Forces the `where` clause to be laid out on a single line.
2795
2796 - **Default value**: `false`
2797 - **Possible values**: `true`, `false`
2798 - **Stable**: No (tracking issue: [#3359](https://github.com/rust-lang/rustfmt/issues/3359))
2799
2800 #### `false` (default):
2801
2802 ```rust
2803 impl<T> Lorem for T
2804 where
2805     Option<T>: Ipsum,
2806 {
2807     // body
2808 }
2809 ```
2810
2811 #### `true`:
2812
2813 ```rust
2814 impl<T> Lorem for T
2815 where Option<T>: Ipsum
2816 {
2817     // body
2818 }
2819 ```
2820
2821 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
2822
2823
2824 ## `wrap_comments`
2825
2826 Break comments to fit on the line
2827
2828 - **Default value**: `false`
2829 - **Possible values**: `true`, `false`
2830 - **Stable**: No (tracking issue: [#3347](https://github.com/rust-lang/rustfmt/issues/3347))
2831
2832 #### `false` (default):
2833
2834 ```rust
2835 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2836 // sed do eiusmod tempor incididunt ut labore et dolore
2837 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2838 // exercitation ullamco laboris nisi ut aliquip ex ea
2839 // commodo consequat.
2840
2841 // 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.
2842 ```
2843
2844 #### `true`:
2845
2846 ```rust
2847 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2848 // sed do eiusmod tempor incididunt ut labore et dolore
2849 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2850 // exercitation ullamco laboris nisi ut aliquip ex ea
2851 // commodo consequat.
2852 ```
2853
2854 # Internal Options
2855
2856 ## `emit_mode`
2857
2858 Internal option
2859
2860 ## `make_backup`
2861
2862 Internal option, use `--backup`
2863
2864 ## `print_misformatted_file_names`
2865
2866 Internal option, use `-l` or `--files-with-diff`