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