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.
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
9 reorder_imports = false
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.
16 # Configuration Options
18 Below you find a detailed visual guide on all the supported configuration options of rustfmt:
23 Where to put a binary operator when a binary expression goes multiline.
25 - **Default value**: `"Front"`
26 - **Possible values**: `"Front"`, `"Back"`
27 - **Stable**: No (tracking issue: #3368)
29 #### `"Front"` (default):
33 let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
34 || barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
36 let sum = 123456789012345678901234567890
37 + 123456789012345678901234567890
38 + 123456789012345678901234567890;
40 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
41 ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
49 let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo ||
50 barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
52 let sum = 123456789012345678901234567890 +
53 123456789012345678901234567890 +
54 123456789012345678901234567890;
56 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
57 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
61 ## `blank_lines_lower_bound`
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.
66 - **Default value**: `0`
67 - **Possible values**: *unsigned integer*
68 - **Stable**: No (tracking issue: #3382)
71 Original Code (rustfmt will not change it with the default value of `0`):
101 ## `blank_lines_upper_bound`
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.
106 - **Default value**: `1`
107 - **Possible values**: any non-negative integer
108 - **Stable**: No (tracking issue: #3381)
158 See also: [`blank_lines_lower_bound`](#blank_lines_lower_bound)
162 Brace style for items
164 - **Default value**: `"SameLineWhere"`
165 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
166 - **Stable**: No (tracking issue: #3376)
170 #### `"SameLineWhere"` (default):
177 fn lorem(ipsum: usize) {
181 fn lorem<T>(ipsum: T)
183 T: Add + Sub + Mul + Div,
189 #### `"AlwaysNextLine"`:
197 fn lorem(ipsum: usize)
202 fn lorem<T>(ipsum: T)
204 T: Add + Sub + Mul + Div,
210 #### `"PreferSameLine"`:
217 fn lorem(ipsum: usize) {
221 fn lorem<T>(ipsum: T)
223 T: Add + Sub + Mul + Div, {
228 ### Structs and enums
230 #### `"SameLineWhere"` (default):
245 #### `"AlwaysNextLine"`:
261 #### `"PreferSameLine"`:
278 Whether to use colored output or not.
280 - **Default value**: `"Auto"`
281 - **Possible values**: "Auto", "Always", "Never"
282 - **Stable**: No (tracking issue: #3385)
284 ## `combine_control_expr`
286 Combine control expressions with function calls.
288 - **Default value**: `true`
289 - **Possible values**: `true`, `false`
290 - **Stable**: No (tracking issue: #3369)
292 #### `true` (default):
304 foo!(if let Some(..) = x {
317 foo!(while let Some(..) = x {
351 if let Some(..) = x {
368 while let Some(..) = x {
394 Maximum length of comments. No effect unless`wrap_comments = true`.
396 - **Default value**: `80`
397 - **Possible values**: any positive integer
398 - **Stable**: No (tracking issue: #3349)
400 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
402 #### `80` (default; comments shorter than `comment_width`):
404 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
407 #### `60` (comments longer than `comment_width`):
409 // Lorem ipsum dolor sit amet,
410 // consectetur adipiscing elit.
413 See also [`wrap_comments`](#wrap_comments).
415 ## `condense_wildcard_suffixes`
417 Replace strings of _ wildcards by a single .. in tuple patterns
419 - **Default value**: `false`
420 - **Possible values**: `true`, `false`
421 - **Stable**: No (tracking issue: #3384)
423 #### `false` (default):
427 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
428 let (lorem, ipsum, ..) = (1, 2, 3, 4);
436 let (lorem, ipsum, ..) = (1, 2, 3, 4);
440 ## `control_brace_style`
442 Brace style for control flow constructs
444 - **Default value**: `"AlwaysSameLine"`
445 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
446 - **Stable**: No (tracking issue: #3377)
448 #### `"AlwaysSameLine"` (default):
460 #### `"AlwaysNextLine"`:
475 #### `"ClosingNextLine"`:
488 ## `disable_all_formatting`
490 Don't reformat anything
492 - **Default value**: `false`
493 - **Possible values**: `true`, `false`
494 - **Stable**: No (tracking issue: #3388)
498 Specifies which edition is used by the parser.
500 - **Default value**: `2015`
501 - **Possible values**: `2015`, `2018`
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
512 ## `empty_item_single_line`
514 Put empty-body functions and impls on a single line
516 - **Default value**: `true`
517 - **Possible values**: `true`, `false`
518 - **Stable**: No (tracking issue: #3356)
520 #### `true` (default):
538 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
541 ## `enum_discrim_align_threshold`
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.
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.
549 - **Default value** : 0
550 - **Possible values**: any positive integer
551 - **Stable**: No (tracking issue: #3372)
559 RandomLongVariantGoesHere = 10,
564 VeryLongVariantNameHereA = 0,
565 VeryLongVariantNameHereBb = 1,
566 VeryLongVariantNameHereCcc = 2,
576 RandomLongVariantGoesHere = 10,
581 VeryLongVariantNameHereA = 0,
582 VeryLongVariantNameHereBb = 1,
583 VeryLongVariantNameHereCcc = 2,
588 ## `error_on_line_overflow`
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.
595 - **Default value**: `false`
596 - **Possible values**: `true`, `false`
597 - **Stable**: No (tracking issue: #3391)
599 See also [`max_width`](#max_width).
601 ## `error_on_unformatted`
603 Error if unable to get comments or string literals within `max_width`, or they are left with
604 trailing whitespaces.
606 - **Default value**: `false`
607 - **Possible values**: `true`, `false`
608 - **Stable**: No (tracking issue: #3392)
612 Control the layout of arguments in a function
614 - **Default value**: `"Tall"`
615 - **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
618 #### `"Tall"` (default):
622 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
624 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
633 consectetur: Consectetur,
634 adipiscing: Adipiscing,
643 consectetur: Consectetur,
644 adipiscing: Adipiscing,
656 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
658 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
663 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
664 adipiscing: Adipiscing, elit: Elit,
668 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
669 adipiscing: Adipiscing, elit: Elit,
701 consectetur: Consectetur,
702 adipiscing: Adipiscing,
711 consectetur: Consectetur,
712 adipiscing: Adipiscing,
723 Put single-expression functions on a single line
725 - **Default value**: `false`
726 - **Possible values**: `true`, `false`
727 - **Stable**: No (tracking issue: #3358)
729 #### `false` (default):
732 fn lorem() -> usize {
736 fn lorem() -> usize {
745 fn lorem() -> usize { 42 }
747 fn lorem() -> usize {
753 See also [`control_brace_style`](#control_brace_style).
756 ## `force_explicit_abi`
758 Always print the abi for extern items
760 - **Default value**: `true`
761 - **Possible values**: `true`, `false`
764 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
766 #### `true` (default):
770 pub static lorem: c_int;
778 pub static lorem: c_int;
782 ## `force_multiline_blocks`
784 Force multiline closure and match arm bodies to be wrapped in a block
786 - **Default value**: `false`
787 - **Possible values**: `false`, `true`
788 - **Stable**: No (tracking issue: #3374)
790 #### `false` (default):
794 result.and_then(|maybe_value| match maybe_value {
796 Some(value) => bar(),
801 println!("Hello World");
803 Some(dolor) => foo(),
812 result.and_then(|maybe_value| {
815 Some(value) => bar(),
822 println!("Hello World");
825 Some(dolor) => foo(),
831 ## `format_code_in_doc_comments`
833 Format code snippet included in doc comments.
835 - **Default value**: `false`
836 - **Possible values**: `true`, `false`
837 - **Stable**: No (tracking issue: #3348)
839 #### `false` (default):
842 /// Adds one to the number given.
853 /// # fn add_one(x: i32) -> i32 {
857 fn add_one(x: i32) -> i32 {
865 /// Adds one to the number given.
872 /// assert_eq!(6, add_one(5));
873 /// # fn add_one(x: i32) -> i32 {
877 fn add_one(x: i32) -> i32 {
882 ## `format_macro_matchers`
884 Format the metavariable matching patterns in macros.
886 - **Default value**: `false`
887 - **Possible values**: `true`, `false`
888 - **Stable**: No (tracking issue: #3354)
890 #### `false` (default):
894 ($a: ident : $b: ty) => {
897 ($a: ident $b: ident $c: ident) => {
907 ($a:ident : $b:ty) => {
910 ($a:ident $b:ident $c:ident) => {
916 See also [`format_macro_bodies`](#format_macro_bodies).
919 ## `format_macro_bodies`
921 Format the bodies of macros.
923 - **Default value**: `true`
924 - **Possible values**: `true`, `false`
925 - **Stable**: No (tracking issue: #3355)
927 #### `true` (default):
931 ($a: ident : $b: ty) => {
934 ($a: ident $b: ident $c: ident) => {
944 ($a: ident : $b: ty) => { $a(42): $b; };
945 ($a: ident $b: ident $c: ident) => { $a=$b+$c; };
949 See also [`format_macro_matchers`](#format_macro_matchers).
954 Format string literals where necessary
956 - **Default value**: `false`
957 - **Possible values**: `true`, `false`
958 - **Stable**: No (tracking issue: #3353)
960 #### `false` (default):
964 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing";
972 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet \
973 consectetur adipiscing";
977 See also [`max_width`](#max_width).
981 Use tab characters for indentation, spaces for alignment
983 - **Default value**: `false`
984 - **Possible values**: `true`, `false`
987 #### `false` (default):
990 fn lorem() -> usize {
991 42 // spaces before 42
998 fn lorem() -> usize {
1003 See also: [`tab_spaces`](#tab_spaces).
1006 ## `hide_parse_errors`
1008 Do not show parse errors if the parser failed to parse files.
1010 - **Default value**: `false`
1011 - **Possible values**: `true`, `false`
1012 - **Stable**: No (tracking issue: #3390)
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.
1019 - **Default value**: format every file
1020 - **Possible values**: See an example below
1021 - **Stable**: No (tracking issue: #3395)
1025 If you want to ignore specific files, put the following to your config file:
1034 If you want to ignore every file under `examples/`, put the following to your config file:
1042 If you want to ignore every file under the directory where you put your rustfmt.toml:
1050 Indent style of imports
1052 - **Default Value**: `"Block"`
1053 - **Possible values**: `"Block"`, `"Visual"`
1054 - **Stable**: No (tracking issue: #3360)
1056 #### `"Block"` (default):
1060 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1061 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
1068 use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1069 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
1072 See also: [`imports_layout`](#imports_layout).
1076 Item layout inside a imports block
1078 - **Default value**: "Mixed"
1079 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1080 - **Stable**: No (tracking issue: #3361)
1082 #### `"Mixed"` (default):
1085 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1088 aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
1089 eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
1093 #### `"Horizontal"`:
1095 **Note**: This option forces all imports onto one line and may exceed `max_width`.
1098 use foo::{xxx, yyy, zzz};
1100 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1103 #### `"HorizontalVertical"`:
1106 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1139 Indent on expressions or items.
1141 - **Default value**: `"Block"`
1142 - **Possible values**: `"Block"`, `"Visual"`
1143 - **Stable**: No (tracking issue: #3346)
1147 #### `"Block"` (default):
1167 let lorem = vec!["ipsum",
1179 #### `"Block"` (default):
1187 && dolor_consectetur
1189 && lorem_consectetur
1204 && dolor_consectetur
1206 && lorem_consectetur
1213 See also: [`control_brace_style`](#control_brace_style).
1215 ### Function arguments
1217 #### `"Block"` (default):
1222 fn lorem(ipsum: usize) {}
1242 fn lorem(ipsum: usize) {}
1244 fn lorem(ipsum: usize,
1257 #### `"Block"` (default):
1291 #### `"Block"` (default):
1299 Adipiscing: Eq = usize,
1300 Consectetur: Eq = usize,
1307 adipiscing: Adipiscing,
1308 consectetur: Consectetur,
1318 fn lorem<Ipsum: Eq = usize,
1322 Adipiscing: Eq = usize,
1323 Consectetur: Eq = usize,
1329 adipiscing: Adipiscing,
1330 consectetur: Consectetur,
1339 #### `"Block"` (default):
1354 let lorem = Lorem { ipsum: dolor,
1359 See also: [`struct_lit_single_line`](#struct_lit_single_line), [`indent_style`](#indent_style).
1361 ### Where predicates
1363 #### `"Block"` (default):
1366 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
1380 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
1390 ## `inline_attribute_width`
1392 Write an item and its attribute on the same line if their combined width is below a threshold
1394 - **Default value**: 0
1395 - **Possible values**: any positive integer
1396 - **Stable**: No (tracking issue: #3343)
1402 #[cfg(feature = "alloc")]
1408 #[cfg(feature = "alloc")] use core::slice;
1411 ## `license_template_path`
1413 Check whether beginnings of files match a license template.
1415 - **Default value**: `""`
1416 - **Possible values**: path to a license template file
1417 - **Stable**: No (tracking issue: #3352)
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.:
1426 // Copyright {\d+} The Rust Project Developers.
1429 `\{`, `\}` and `\\` match literal braces / backslashes.
1431 ## `match_arm_blocks`
1433 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
1435 - **Default value**: `true`
1436 - **Possible values**: `true`, `false`
1437 - **Stable**: No (tracking issue: #3373)
1439 #### `true` (default):
1445 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
1447 false => println!("{}", sit),
1458 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
1459 false => println!("{}", sit),
1464 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
1466 ## `match_arm_leading_pipes`
1468 Controls whether to include a leading pipe on match arms
1470 - **Default value**: `Never`
1471 - **Possible values**: `Always`, `Never`, `Preserve`
1474 #### `Never` (default):
1476 // Leading pipes are removed from this:
1479 // | "foo" | "bar" => {}
1481 // | "something relatively long"
1482 // | "something really really really realllllllllllllly long" => println!("x"),
1483 // | "qux" => println!("y"),
1493 | "something relatively long"
1494 | "something really really really realllllllllllllly long" => println!("x"),
1495 "qux" => println!("y"),
1503 // Leading pipes are emitted on all arms of this:
1506 // "foo" | "bar" => {}
1508 // | "something relatively long"
1509 // | "something really really really realllllllllllllly long" => println!("x"),
1510 // "qux" => println!("y"),
1518 | "foo" | "bar" => {}
1520 | "something relatively long"
1521 | "something really really really realllllllllllllly long" => println!("x"),
1522 | "qux" => println!("y"),
1532 | "foo" | "bar" => {}
1534 | "something relatively long"
1535 | "something really really really realllllllllllllly long" => println!("x"),
1536 | "qux" => println!("y"),
1548 ## `match_block_trailing_comma`
1550 Put a trailing comma after a block based match arm (non-block arms are not affected)
1552 - **Default value**: `false`
1553 - **Possible values**: `true`, `false`
1554 - **Stable**: No (tracking issue: #3380)
1556 #### `false` (default):
1564 Lorem::Dolor => println!("dolor"),
1577 Lorem::Dolor => println!("dolor"),
1582 See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
1586 Maximum width of each line
1588 - **Default value**: `100`
1589 - **Possible values**: any positive integer
1592 See also [`error_on_line_overflow`](#error_on_line_overflow).
1596 Merge multiple derives into a single one.
1598 - **Default value**: `true`
1599 - **Possible values**: `true`, `false`
1602 #### `true` (default):
1605 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1612 #[derive(Eq, PartialEq)]
1614 #[derive(Copy, Clone)]
1620 Merge multiple imports into a single nested import.
1622 - **Default value**: `false`
1623 - **Possible values**: `true`, `false`
1624 - **Stable**: No (tracking issue: #3362)
1626 #### `false` (default):
1637 use foo::{a, b, c, d, e, f, g};
1643 Unix or Windows line endings
1645 - **Default value**: `"Auto"`
1646 - **Possible values**: `"Auto"`, `"Native"`, `"Unix"`, `"Windows"`
1649 #### `Auto` (default):
1651 The newline style is detected automatically on a per-file basis. Files
1652 with mixed line endings will be converted to the first detected line
1657 Line endings will be converted to `\r\n` on Windows and `\n` on all
1662 Line endings will be converted to `\n`.
1666 Line endings will be converted to `\r\n`.
1668 ## `normalize_comments`
1670 Convert /* */ comments to // comments where possible
1672 - **Default value**: `false`
1673 - **Possible values**: `true`, `false`
1674 - **Stable**: No (tracking issue: #3350)
1676 #### `false` (default):
1680 fn dolor() -> usize {}
1683 fn adipiscing() -> usize {}
1690 fn dolor() -> usize {}
1693 fn adipiscing() -> usize {}
1696 ## `normalize_doc_attributes`
1698 Convert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments.
1700 - **Default value**: `false`
1701 - **Possible values**: `true`, `false`
1702 - **Stable**: No (tracking issue: #3351)
1704 #### `false` (default):
1707 #![doc = "Example documentation"]
1709 #[doc = "Example item documentation"]
1716 //! Example documentation
1718 /// Example item documentation
1722 ## `overflow_delimited_expr`
1724 When structs, slices, arrays, and block/array-like macros are used as the last
1725 argument in an expression list, allow them to overflow (like blocks/closures)
1726 instead of being indented on a new line.
1728 - **Default value**: `false`
1729 - **Possible values**: `true`, `false`
1730 - **Stable**: No (tracking issue: #3370)
1732 #### `false` (default):
1805 ## `remove_nested_parens`
1807 Remove nested parens.
1809 - **Default value**: `true`,
1810 - **Possible values**: `true`, `false`
1814 #### `true` (default):
1829 ## `reorder_impl_items`
1831 Reorder impl items. `type` and `const` are put first, then macros and methods.
1833 - **Default value**: `false`
1834 - **Possible values**: `true`, `false`
1835 - **Stable**: No (tracking issue: #3363)
1837 #### `false` (default)
1842 impl Iterator for Dummy {
1843 fn next(&mut self) -> Option<Self::Item> {
1856 impl Iterator for Dummy {
1859 fn next(&mut self) -> Option<Self::Item> {
1865 ## `reorder_imports`
1867 Reorder import and extern crate statements alphabetically in groups (a group is
1868 separated by a newline).
1870 - **Default value**: `true`
1871 - **Possible values**: `true`, `false`
1874 #### `true` (default):
1894 Controls the strategy for how imports are grouped together.
1896 - **Default value**: `Preserve`
1897 - **Possible values**: `Preserve`, `StdExternalCrate`
1900 #### `Preserve` (default):
1902 Preserve the source file's import groups.
1905 use super::update::convert_publish_payload;
1908 use alloc::alloc::Layout;
1909 use juniper::{FieldError, FieldResult};
1914 use broker::database::PooledConnection;
1916 use super::schema::{Context, Payload};
1917 use crate::models::Event;
1921 #### `StdExternalCrate`:
1923 Discard existing import groups, and create three groups for:
1924 1. `std`, `core` and `alloc`,
1926 3. `self`, `super` and `crate` imports.
1929 use alloc::alloc::Layout;
1933 use broker::database::PooledConnection;
1935 use juniper::{FieldError, FieldResult};
1938 use super::schema::{Context, Payload};
1939 use super::update::convert_publish_payload;
1940 use crate::models::Event;
1943 ## `reorder_modules`
1945 Reorder `mod` declarations alphabetically in group.
1947 - **Default value**: `true`
1948 - **Possible values**: `true`, `false`
1951 #### `true` (default)
1975 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics
1976 of the original source code.
1980 Report `FIXME` items in comments.
1982 - **Default value**: `"Never"`
1983 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1984 - **Stable**: No (tracking issue: #3394)
1986 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1987 it contains a `#X` (with `X` being a number) in parentheses following the
1988 `FIXME`, `"Unnumbered"` will ignore it.
1990 See also [`report_todo`](#report_todo).
1995 Report `TODO` items in comments.
1997 - **Default value**: `"Never"`
1998 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1999 - **Stable**: No (tracking issue: #3393)
2001 Warns about any comments containing `TODO` in them when set to `"Always"`. If
2002 it contains a `#X` (with `X` being a number) in parentheses following the
2003 `TODO`, `"Unnumbered"` will ignore it.
2005 See also [`report_fixme`](#report_fixme).
2007 ## `required_version`
2009 Require a specific version of rustfmt. If you want to make sure that the
2010 specific version of rustfmt is used in your CI, use this option.
2012 - **Default value**: `CARGO_PKG_VERSION`
2013 - **Possible values**: any published version (e.g. `"0.3.8"`)
2014 - **Stable**: No (tracking issue: #3386)
2018 Don't reformat out of line modules
2020 - **Default value**: `false`
2021 - **Possible values**: `true`, `false`
2022 - **Stable**: No (tracking issue: #3389)
2024 ## `space_after_colon`
2026 Leave a space after the colon.
2028 - **Default value**: `true`
2029 - **Possible values**: `true`, `false`
2030 - **Stable**: No (tracking issue: #3366)
2032 #### `true` (default):
2035 fn lorem<T: Eq>(t: T) {
2036 let lorem: Dolor = Lorem {
2046 fn lorem<T:Eq>(t:T) {
2047 let lorem:Dolor = Lorem {
2054 See also: [`space_before_colon`](#space_before_colon).
2056 ## `space_before_colon`
2058 Leave a space before the colon.
2060 - **Default value**: `false`
2061 - **Possible values**: `true`, `false`
2062 - **Stable**: No (tracking issue: #3365)
2064 #### `false` (default):
2067 fn lorem<T: Eq>(t: T) {
2068 let lorem: Dolor = Lorem {
2078 fn lorem<T : Eq>(t : T) {
2079 let lorem : Dolor = Lorem {
2086 See also: [`space_after_colon`](#space_after_colon).
2088 ## `spaces_around_ranges`
2090 Put spaces around the .., ..=, and ... range operators
2092 - **Default value**: `false`
2093 - **Possible values**: `true`, `false`
2094 - **Stable**: No (tracking issue: #3367)
2096 #### `false` (default):
2124 let lorem = 0 .. 10;
2125 let ipsum = 0 ..= 10;
2144 ## `struct_field_align_threshold`
2146 The maximum diff of width between struct fields to be aligned with each other.
2148 - **Default value** : 0
2149 - **Possible values**: any non-negative integer
2150 - **Stable**: No (tracking issue: #3371)
2172 ## `struct_lit_single_line`
2174 Put small struct literals on a single line
2176 - **Default value**: `true`
2177 - **Possible values**: `true`, `false`
2178 - **Stable**: No (tracking issue: #3357)
2180 #### `true` (default):
2184 let lorem = Lorem { foo: bar, baz: ofo };
2199 See also: [`indent_style`](#indent_style).
2204 Number of spaces per tab
2206 - **Default value**: `4`
2207 - **Possible values**: any positive integer
2214 let ipsum = dolor();
2216 "amet consectetur adipiscing elit amet",
2217 "consectetur adipiscing elit amet consectetur.",
2226 let ipsum = dolor();
2228 "amet consectetur adipiscing elit amet",
2229 "consectetur adipiscing elit amet consectetur.",
2234 See also: [`hard_tabs`](#hard_tabs).
2239 How to handle trailing commas for lists
2241 - **Default value**: `"Vertical"`
2242 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2243 - **Stable**: No (tracking issue: #3379)
2245 #### `"Vertical"` (default):
2249 let Lorem { ipsum, dolor, sit } = amet;
2265 let Lorem { ipsum, dolor, sit, } = amet;
2281 let Lorem { ipsum, dolor, sit } = amet;
2293 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2295 ## `trailing_semicolon`
2297 Add trailing semicolon after break, continue and return
2299 - **Default value**: `true`
2300 - **Possible values**: `true`, `false`
2301 - **Stable**: No (tracking issue: #3378)
2303 #### `true` (default):
2317 ## `type_punctuation_density`
2319 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2321 - **Default value**: `"Wide"`
2322 - **Possible values**: `"Compressed"`, `"Wide"`
2323 - **Stable**: No (tracking issue: #3364)
2325 #### `"Wide"` (default):
2328 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2333 #### `"Compressed"`:
2336 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2341 ## `unstable_features`
2343 Enable unstable features on the unstable channel.
2345 - **Default value**: `false`
2346 - **Possible values**: `true`, `false`
2347 - **Stable**: No (tracking issue: #3387)
2349 ## `use_field_init_shorthand`
2351 Use field initialize shorthand if possible.
2353 - **Default value**: `false`
2354 - **Possible values**: `true`, `false`
2357 #### `false` (default):
2370 let a = Foo { x: x, y: y, z: z };
2387 let a = Foo { x, y, z };
2391 ## `use_small_heuristics`
2393 Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.
2395 - **Default value**: `"Default"`
2396 - **Possible values**: `"Default"`, `"Off"`, `"Max"`
2399 #### `Default` (default):
2405 Sit { amet: Consectetur, adipiscing: Elit },
2423 let lorem = Lorem { ipsum: dolor };
2425 let lorem = if ipsum { dolor } else { sit };
2442 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2449 let lorem = if ipsum {
2463 Sit { amet: Consectetur, adipiscing: Elit },
2467 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
2469 let lorem = Lorem { ipsum: dolor, sit: amet };
2471 let lorem = if ipsum { dolor } else { sit };
2475 ## `use_try_shorthand`
2477 Replace uses of the try! macro by the ? shorthand
2479 - **Default value**: `false`
2480 - **Possible values**: `true`, `false`
2483 #### `false` (default):
2487 let lorem = try!(ipsum.map(|dolor| dolor.sit()));
2495 let lorem = ipsum.map(|dolor| dolor.sit())?;
2501 Which version of the formatting rules to use. `Version::One` is backwards-compatible
2502 with Rustfmt 1.0. Other versions are only backwards compatible within a major
2505 - **Default value**: `One`
2506 - **Possible values**: `One`, `Two`
2507 - **Stable**: No (tracking issue: #3383)
2515 ## `where_single_line`
2517 Forces the `where` clause to be laid out on a single line.
2519 - **Default value**: `false`
2520 - **Possible values**: `true`, `false`
2521 - **Stable**: No (tracking issue: #3359)
2523 #### `false` (default):
2538 where Option<T>: Ipsum
2544 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
2549 Break comments to fit on the line
2551 - **Default value**: `false`
2552 - **Possible values**: `true`, `false`
2553 - **Stable**: No (tracking issue: #3347)
2555 #### `false` (default):
2558 // 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.
2564 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2565 // sed do eiusmod tempor incididunt ut labore et dolore
2566 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2567 // exercitation ullamco laboris nisi ut aliquip ex ea
2568 // commodo consequat.
2579 Internal option, use `--backup`
2581 ## `print_misformatted_file_names`
2583 Internal option, use `-l` or `--files-with-diff`