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