```toml
indent_style = "Block"
-array_width = 80
-reorder_imported_names = true
+reorder_imports = false
```
+Each configuration option is either stable or unstable.
+Stable options can be used directly, while unstable options are opt-in.
+To enable unstable options, set `unstable_features = true` in `rustfmt.toml` or pass `--unstable-features` to rustfmt.
+
# Configuration Options
Below you find a detailed visual guide on all the supported configuration options of rustfmt:
-## `array_horizontal_layout_threshold`
-
-How many elements array must have before rustfmt uses horizontal layout.
-Use this option to prevent a huge array from being vertically formatted.
-
-- **Default value**: `0`
-- **Possible values**: any positive integer
-
-**Note:** A value of `0` results in [`indent_style`](#indent_style) being applied regardless of a line's width.
-
-#### `0` (default):
-
-```rust
-// Each element will be placed on its own line.
-let a = vec![
- 0,
- 1,
- 2,
- 3,
- 4,
- ...
- 999,
- 1000,
-];
-```
-
-#### `1000`:
-
-```rust
-// Each element will be placed on the same line as much as possible.
-let a = vec![
- 0, 1, 2, 3, 4, ...
- ..., 999, 1000,
-];
-```
## `indent_style`
- **Default value**: `"Block"`
- **Possible values**: `"Block"`, `"Visual"`
+- **Stable**: No
### Array
#### `"Block"` (default):
```rust
-let lorem = vec![
- "ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit",
-];
+fn main() {
+ let lorem = vec![
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ ];
+}
```
#### `"Visual"`:
```rust
-let lorem = vec!["ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit"];
+fn main() {
+ let lorem = vec!["ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit"];
+}
```
### Control flow
#### `"Block"` (default):
```rust
-if lorem_ipsum &&
- dolor_sit &&
- amet_consectetur
-{
- // ...
+fn main() {
+ if lorem_ipsum
+ && dolor_sit
+ && amet_consectetur
+ && lorem_sit
+ && dolor_consectetur
+ && amet_ipsum
+ && lorem_consectetur
+ {
+ // ...
+ }
}
```
#### `"Visual"`:
```rust
-if lorem_ipsum &&
- dolor_sit &&
- amet_consectetur {
- // ...
+fn main() {
+ if lorem_ipsum
+ && dolor_sit
+ && amet_consectetur
+ && lorem_sit
+ && dolor_consectetur
+ && amet_ipsum
+ && lorem_consectetur
+ {
+ // ...
+ }
}
```
#### `"Block"` (default):
```rust
-lorem(
- "lorem",
- "ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit",
-);
+fn main() {
+ lorem(
+ "lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ );
+}
```
#### `"Visual"`:
```rust
-lorem("lorem",
- "ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit");
+fn main() {
+ lorem("lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit");
+}
```
### Generics
Amet: Eq = usize,
Adipiscing: Eq = usize,
Consectetur: Eq = usize,
- Elit: Eq = usize
+ Elit: Eq = usize,
>(
ipsum: Ipsum,
dolor: Dolor,
Amet: Eq = usize,
Adipiscing: Eq = usize,
Consectetur: Eq = usize,
- Elit: Eq = usize>
- (ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- adipiscing: Adipiscing,
- consectetur: Consectetur,
- elit: Elit)
- -> T {
+ Elit: Eq = usize>(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ adipiscing: Adipiscing,
+ consectetur: Consectetur,
+ elit: Elit)
+ -> T {
// body
}
```
#### `"Block"` (default):
```rust
-let lorem = Lorem {
- ipsum: dolor,
- sit: amet,
-};
+fn main() {
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+}
```
#### `"Visual"`:
```rust
-let lorem = Lorem { ipsum: dolor,
- sit: amet, };
+fn main() {
+ let lorem = Lorem { ipsum: dolor,
+ sit: amet, };
+}
```
-See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
+See also: [`struct_lit_single_line`](#struct_lit_single_line), [`indent_style`](#indent_style).
### Where predicates
```rust
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
-where
+where
Ipsum: Eq,
Dolor: Eq,
Sit: Eq,
- Amet: Eq
+ Amet: Eq,
{
// body
}
}
```
-See also: [`where_density`](#where_density), [`where_layout`](#where_layout).
-
-## `array_width`
-
-Maximum width of an array literal before falling back to vertical formatting
-
-- **Default value**: `60`
-- **Possible values**: any positive integer
-
-**Note:** A value of `0` results in [`indent_style`](#indent_style) being applied regardless of a line's width.
-
-#### Lines shorter than `array_width`:
-```rust
-let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit"];
-```
-
-#### Lines longer than `array_width`:
-See [`indent_style`](#indent_style).
+## `use_small_heuristics`
-## `attributes_on_same_line_as_field`
-
-Try to put attributes on the same line as fields
+Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
```rust
-struct Lorem {
- #[serde(rename = "Ipsum")] ipsum: usize,
- #[serde(rename = "Dolor")] dolor: usize,
- #[serde(rename = "Amet")] amet: usize,
-}
-```
-
-#### `false`:
-
-```rust
-struct Lorem {
- #[serde(rename = "Ipsum")]
- ipsum: usize,
- #[serde(rename = "Dolor")]
- dolor: usize,
- #[serde(rename = "Amet")]
- amet: usize,
+enum Lorem {
+ Ipsum,
+ Dolor(bool),
+ Sit { amet: Consectetur, adipiscing: Elit },
}
-```
-
-## `attributes_on_same_line_as_variant`
-Try to put attributes on the same line as variants
-
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
+fn main() {
+ lorem(
+ "lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ );
-#### `true` (default):
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+ let lorem = Lorem { ipsum: dolor };
-```rust
-enum Lorem {
- #[serde(skip_serializing)] Ipsum,
- #[serde(skip_serializing)] Dolor,
- #[serde(skip_serializing)] Amet,
+ let lorem = if ipsum { dolor } else { sit };
}
```
```rust
enum Lorem {
- #[serde(skip_serializing)]
Ipsum,
- #[serde(skip_serializing)]
- Dolor,
- #[serde(skip_serializing)]
- Amet,
+ Dolor(bool),
+ Sit {
+ amet: Consectetur,
+ adipiscing: Elit,
+ },
+}
+
+fn main() {
+ lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
+
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+
+ let lorem = if ipsum {
+ dolor
+ } else {
+ sit
+ };
}
```
- **Default value**: `"Front"`
- **Possible values**: `"Front"`, `"Back"`
+- **Stable**: No
#### `"Front"` (default):
```rust
-let or = foo
- || bar
- || foobar;
+fn main() {
+ let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
+ || barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
-let sum = 1234
- + 5678
- + 910;
+ let sum = 123456789012345678901234567890
+ + 123456789012345678901234567890
+ + 123456789012345678901234567890;
-let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
+ let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
+}
```
#### `"Back"`:
```rust
-let or = foo ||
- bar ||
- foobar;
-
-let sum = 1234 +
- 5678 +
- 910;
-
-let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
-```
-
-## `chain_indent`
-
-Indentation of chain
-
-- **Default value**: `"Block"`
-- **Possible values**: `"Block"`, `"Visual"`
-
-#### `"Block"` (default):
-
-```rust
-let lorem = ipsum
- .dolor()
- .sit()
- .amet()
- .consectetur()
- .adipiscing()
- .elit();
-```
-
-#### `"Visual"`:
-
-```rust
-let lorem = ipsum.dolor()
- .sit()
- .amet()
- .consectetur()
- .adipiscing()
- .elit();
-```
-
-See also [`chain_width`](#chain_width).
-
-## `chain_width`
-
-Maximum length of a chain to fit on a single line
-
-- **Default value**: `60`
-- **Possible values**: any positive integer
-
-#### Lines shorter than `chain_width`:
-```rust
-let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
-```
-
-#### Lines longer than `chain_width`:
-See [`chain_indent`](#chain_indent).
-
-## `chain_split_single_child`
-
-Split a chain with a single child if its length exceeds [`chain_width`](#chain_width).
-
-- **Default value**: `false`
-- **Possible values**: `false`, `true`
-
-#### `false` (default):
-
-```rust
-let files = fs::read_dir("tests/coverage/source").expect("Couldn't read source dir");
-```
+fn main() {
+ let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo ||
+ barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
-#### `true`:
+ let sum = 123456789012345678901234567890 +
+ 123456789012345678901234567890 +
+ 123456789012345678901234567890;
-```rust
-let files = fs::read_dir("tests/coverage/source")
- .expect("Couldn't read source dir");
+ let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
+}
```
-See also [`chain_width`](#chain_width).
-
## `combine_control_expr`
Combine control expressions with function calls.
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
- **Default value**: `80`
- **Possible values**: any positive integer
+- **Stable**: No
**Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
-#### Comments shorter than `comment_width`:
+#### `80` (default; comments shorter than `comment_width`):
```rust
// Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```
-#### Comments longer than `comment_width`:
+#### `60` (comments longer than `comment_width`):
```rust
// Lorem ipsum dolor sit amet,
// consectetur adipiscing elit.
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
```rust
-let (lorem, ipsum, _, _) = (1, 2, 3, 4);
+fn main() {
+ let (lorem, ipsum, _, _) = (1, 2, 3, 4);
+ let (lorem, ipsum, ..) = (1, 2, 3, 4);
+}
```
#### `true`:
```rust
-let (lorem, ipsum, ..) = (1, 2, 3, 4);
+fn main() {
+ let (lorem, ipsum, ..) = (1, 2, 3, 4);
+}
```
## `control_brace_style`
- **Default value**: `"AlwaysSameLine"`
- **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
+- **Stable**: No
#### `"AlwaysSameLine"` (default):
```rust
-if lorem {
- println!("ipsum!");
-} else {
- println!("dolor!");
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ } else {
+ println!("dolor!");
+ }
}
```
#### `"AlwaysNextLine"`:
```rust
-if lorem
-{
- println!("ipsum!");
-}
-else
-{
- println!("dolor!");
+fn main() {
+ if lorem
+ {
+ println!("ipsum!");
+ }
+ else
+ {
+ println!("dolor!");
+ }
}
```
#### `"ClosingNextLine"`:
```rust
-if lorem {
- println!("ipsum!");
-}
-else {
- println!("dolor!");
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ }
+ else {
+ println!("dolor!");
+ }
}
```
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
## `error_on_line_overflow`
-Error if unable to get all lines within `max_width`
+Error if Rustfmt is unable to get all lines within `max_width`, except for comments and string
+literals. If this happens, then it is a bug in Rustfmt. You might be able to work around the bug by
+refactoring your code to avoid long/complex expressions, usually by extracting a local variable or
+using a shorter name.
-- **Default value**: `true`
+- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
See also [`max_width`](#max_width).
-## `error_on_line_overflow_comments`
+## `error_on_unformatted`
-Error if unable to get all comment lines within `comment_width`.
+Error if unable to get comments or string literals within `max_width`, or they are left with
+trailing whitespaces.
-- **Default value**: `true`
+- **Default value**: `false`
- **Possible values**: `true`, `false`
-
-See also [`comment_width`](#comment_width).
+- **Stable**: No
## `fn_args_density`
Argument density in functions
- **Default value**: `"Tall"`
-- **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
+- **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
+- **Stable**: No
#### `"Tall"` (default):
}
```
-#### `"CompressedIfEmpty"`:
+#### `"Vertical"`:
```rust
trait Lorem {
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ );
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ ) {
// body
}
fn lorem(
- ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
- adipiscing: Adipiscing, elit: Elit,
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: Consectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
);
fn lorem(
}
```
-#### `"Vertical"`:
-
-```rust
-trait Lorem {
- fn lorem(ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet);
-
- fn lorem(ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet) {
- // body
- }
-
- fn lorem(ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- consectetur: Consectetur,
- adipiscing: Adipiscing,
- elit: Elit);
-
- fn lorem(ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- consectetur: Consectetur,
- adipiscing: Adipiscing,
- elit: Elit) {
- // body
- }
-}
-```
-
## `brace_style`
- **Default value**: `"SameLineWhere"`
- **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
+- **Stable**: No
### Functions
}
struct Dolor<T>
- where T: Eq
+where
+ T: Eq,
{
sit: T,
}
}
struct Dolor<T>
- where T: Eq
+where
+ T: Eq,
{
sit: T,
}
}
struct Dolor<T>
- where T: Eq {
+where
+ T: Eq, {
sit: T,
}
```
-## `fn_call_width`
-
-Maximum width of the args of a function call before falling back to vertical formatting
-
-- **Default value**: `60`
-- **Possible values**: any positive integer
-
-**Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
-
-#### Function call shorter than `fn_call_width`:
-```rust
-lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
-```
-
-#### Function call longer than `fn_call_width`:
-See [`indent_style`](#indent_style).
+## `empty_item_single_line`
-## `fn_empty_single_line`
-
-Put empty-body functions on a single line
+Put empty-body functions and impls on a single line
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
```rust
fn lorem() {}
+
+impl Lorem {}
```
#### `false`:
```rust
fn lorem() {
}
+
+impl Lorem {
+}
```
-See also [`control_brace_style`](#control_brace_style).
+See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
## `fn_single_line`
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
See also [`control_brace_style`](#control_brace_style).
+
+## `where_single_line`
+
+Forces the `where` clause to be laid out on a single line.
+
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `false` (default):
+
+```rust
+impl<T> Lorem for T
+where
+ Option<T>: Ipsum,
+{
+ // body
+}
+```
+
+#### `true`:
+
+```rust
+impl<T> Lorem for T
+where Option<T>: Ipsum
+{
+ // body
+}
+```
+
+See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
+
+
## `force_explicit_abi`
Always print the abi for extern items
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
**Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
}
```
-## `force_format_strings`
-
-Always format string literals
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-
-See [`format_strings`](#format_strings).
-
-See also [`max_width`](#max_width).
-
## `format_strings`
Format string literals where necessary
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
```rust
-let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
+fn main() {
+ let lorem =
+ "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing";
+}
```
#### `true`:
```rust
-let lorem =
- "ipsum dolor sit amet consectetur \
- adipiscing elit lorem ipsum dolor sit";
+fn main() {
+ let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet \
+ consectetur adipiscing";
+}
```
-See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
+See also [`max_width`](#max_width).
## `hard_tabs`
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
#### `false` (default):
See also: [`tab_spaces`](#tab_spaces).
-## `impl_empty_single_line`
-Put empty-body implementations on a single line
+## `imports_indent`
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
+Indent style of imports
-#### `true` (default):
+- **Default Value**: `"Visual"`
+- **Possible values**: `"Block"`, `"Visual"`
+- **Stable**: No
+
+#### `"Visual"` (default):
```rust
-impl Lorem {}
+use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
+ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
```
-#### `false`:
-
-```rust
-impl Lorem {
-}
-```
-
-See also [`brace_style`](#brace_style).
-
-## `indent_match_arms`
-
-Indent match arms instead of keeping them at the same indentation level as the match keyword
-
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
-
-#### `true` (default):
-
-```rust
-match lorem {
- Lorem::Ipsum => (),
- Lorem::Dolor => (),
- Lorem::Sit => (),
- Lorem::Amet => (),
-}
-```
-
-#### `false`:
-
-```rust
-match lorem {
-Lorem::Ipsum => (),
-Lorem::Dolor => (),
-Lorem::Sit => (),
-Lorem::Amet => (),
-}
-```
-
-See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
-
-## `imports_indent`
-
-Indent style of imports
-
-- **Default Value**: `"Visual"`
-- **Possible values**: `"Block"`, `"Visual"`
-
-#### `"Visual"` (default):
-
-```rust
-use foo::{xxx,
- yyy,
- zzz};
-```
-
-#### `"Block"`:
+#### `"Block"`:
```rust
use foo::{
- xxx,
- yyy,
- zzz,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
+ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
};
```
- **Default value**: "Mixed"
- **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
+- **Stable**: No
#### `"Mixed"` (default):
```rust
-use foo::{xxx, yyy, zzz};
+use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
-use foo::{aaa, bbb, ccc,
- ddd, eee, fff};
+use foo::{
+ aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
+ eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
+};
```
#### `"Horizontal"`:
-**Note**: This option forces to put everything on one line and may exceeds `max_width`.
+**Note**: This option forces all imports onto one line and may exceed `max_width`.
```rust
use foo::{xxx, yyy, zzz};
#### `"HorizontalVertical"`:
```rust
-use foo::{xxx, yyy, zzz};
+use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
-use foo::{aaa,
- bbb,
- ccc,
- ddd,
- eee,
- fff};
+use foo::{
+ aaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbb,
+ cccccccccccccccccc,
+ dddddddddddddddddd,
+ eeeeeeeeeeeeeeeeee,
+ ffffffffffffffffff,
+};
```
#### `"Vertical"`:
```rust
-use foo::{xxx,
- yyy,
- zzz};
+use foo::{
+ xxx,
+ yyy,
+ zzz,
+};
-use foo::{aaa,
- bbb,
- ccc,
- ddd,
- eee,
- fff};
+use foo::{
+ aaa,
+ bbb,
+ ccc,
+ ddd,
+ eee,
+ fff,
+};
```
-## `match_arm_forces_newline`
+## `merge_imports`
-Consistently put match arms (block based or not) in a newline.
+Merge multiple imports into a single nested import.
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
```rust
-match x {
- // a non-empty block
- X0 => {
- f();
- }
- // an empty block
- X1 => {}
- // a non-block
- X2 => println!("ok"),
-}
+use foo::{a, c, d};
+use foo::{b, g};
+use foo::{e, f};
```
#### `true`:
```rust
-match x {
- // a non-empty block
- X0 => {
- f();
- }
- // an empty block
- X1 =>
- {}
- // a non-block
- X2 => {
- println!("ok")
- }
-}
+use foo::{a, b, c, d, e, f, g};
```
-See also: [`wrap_match_arms`](#wrap_match_arms).
## `match_block_trailing_comma`
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
```rust
-match lorem {
- Lorem::Ipsum => {
- println!("ipsum");
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ }
+ Lorem::Dolor => println!("dolor"),
}
- Lorem::Dolor => println!("dolor"),
}
```
#### `true`:
```rust
-match lorem {
- Lorem::Ipsum => {
- println!("ipsum");
- },
- Lorem::Dolor => println!("dolor"),
-}
-```
-
-See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
-
-## `match_pattern_separator_break_point`
-
-Put a match sub-patterns' separator (`|`) in front or back.
-
-- **Default value**: `"Back"`
-- **Possible values**: `"Back"`, `"Front"`
-
-#### `"Back"` (default):
-
-```rust
-match m {
- Variant::Tag |
- Variant::Tag2 |
- Variant::Tag3 |
- Variant::Tag4 |
- Variant::Tag5 |
- Variant::Tag6 => {}
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ },
+ Lorem::Dolor => println!("dolor"),
+ }
}
```
-#### `Front`:
-
-```rust
-match m {
- Variant::Tag
- | Variant::Tag2
- | Variant::Tag3
- | Variant::Tag4
- | Variant::Tag5
- | Variant::Tag6 => {}
-}
-```
+See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
## `max_width`
- **Default value**: `100`
- **Possible values**: any positive integer
+- **Stable**: Yes
See also [`error_on_line_overflow`](#error_on_line_overflow).
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
#### `true` (default):
pub enum Foo {}
```
-## `multiline_closure_forces_block`
+## `force_multiline_blocks`
-Force multiline closure bodies to be wrapped in a block
+Force multiline closure and match arm bodies to be wrapped in a block
- **Default value**: `false`
- **Possible values**: `false`, `true`
+- **Stable**: No
#### `false` (default):
```rust
-result.and_then(|maybe_value| match maybe_value {
- None => ...,
- Some(value) => ...,
-})
-```
-
-#### `true`:
-
-```rust
+fn main() {
+ result.and_then(|maybe_value| match maybe_value {
+ None => foo(),
+ Some(value) => bar(),
+ });
-result.and_then(|maybe_value| {
- match maybe_value {
- None => ...,
- Some(value) => ...,
+ match lorem {
+ None => if ipsum {
+ println!("Hello World");
+ },
+ Some(dolor) => foo(),
}
-})
-```
-
-## `multiline_match_arm_forces_block`
-
-Force multiline match arm bodies to be wrapped in a block
-
-- **Default value**: `false`
-- **Possible values**: `false`, `true`
-
-#### `false` (default):
-
-```rust
-match lorem {
- None => if ipsum {
- println!("Hello World");
- },
- Some(dolor) => ...,
}
```
#### `true`:
```rust
-match lorem {
- None => {
- if ipsum {
- println!("Hello World");
+fn main() {
+ result.and_then(|maybe_value| {
+ match maybe_value {
+ None => foo(),
+ Some(value) => bar(),
+ }
+ });
+
+ match lorem {
+ None => {
+ if ipsum {
+ println!("Hello World");
+ }
}
+ Some(dolor) => foo(),
}
- Some(dolor) => ...,
}
```
+
## `newline_style`
Unix or Windows line endings
- **Default value**: `"Unix"`
- **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
+- **Stable**: Yes
## `normalize_comments`
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
fn adipiscing() -> usize {}
```
-## `reorder_imported_names`
+## `remove_nested_parens`
-Reorder lists of names in import statements alphabetically
+Remove nested parens.
-- **Default value**: `false`
+- **Default value**: `true`,
- **Possible values**: `true`, `false`
+- **Stable**: Yes
-#### `false` (default):
+#### `true` (default):
```rust
-use super::{lorem, ipsum, dolor, sit};
+fn main() {
+ (foo());
+}
```
-#### `true`:
-
+#### `false`:
```rust
-use super::{dolor, ipsum, lorem, sit};
+fn main() {
+ ((((foo()))));
+}
```
-See also [`reorder_imports`](#reorder_imports).
## `reorder_imports`
-Reorder import statements alphabetically
+Reorder import and extern crate statements alphabetically in groups (a group is
+separated by a newline).
-- **Default value**: `false`
+- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
-#### `false` (default):
-
-```rust
-use lorem;
-use ipsum;
-use dolor;
-use sit;
-```
-
-#### `true`:
+#### `true` (default):
```rust
use dolor;
use sit;
```
-See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
-
-## `reorder_imports_in_group`
-
-Reorder import statements in group
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-
-**Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
-
-#### `false` (default):
+#### `false`:
```rust
-use std::mem;
-use std::io;
-
use lorem;
use ipsum;
use dolor;
use sit;
```
-#### `true`:
-```rust
-use std::io;
-use std::mem;
+## `reorder_modules`
-use dolor;
-use ipsum;
-use lorem;
-use sit;
-```
-
-See also [`reorder_imports`](#reorder_imports).
-
-## `reorder_extern_crates`
-
-Reorder `extern crate` statements alphabetically
+Reorder `mod` declarations alphabetically in group.
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
-#### `true` (default):
+#### `true` (default)
```rust
-extern crate dolor;
-extern crate ipsum;
-extern crate lorem;
-extern crate sit;
+mod a;
+mod b;
+
+mod dolor;
+mod ipsum;
+mod lorem;
+mod sit;
```
-#### `false`:
+#### `false`
```rust
-extern crate lorem;
-extern crate ipsum;
-extern crate dolor;
-extern crate sit;
+mod b;
+mod a;
+
+mod lorem;
+mod ipsum;
+mod dolor;
+mod sit;
```
-See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
+**Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantic
+of the original source code.
-## `reorder_extern_crates_in_group`
+## `reorder_impl_items`
-Reorder `extern crate` statements in group
+Reorder impl items. `type` and `const` are put first, then macros and methods.
-- **Default value**: `true`
+- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
-**Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
-
-#### `true` (default):
+#### `false` (default)
```rust
-extern crate a;
-extern crate b;
+struct Dummy;
+
+impl Iterator for Dummy {
+ fn next(&mut self) -> Option<Self::Item> {
+ None
+ }
-extern crate dolor;
-extern crate ipsum;
-extern crate lorem;
-extern crate sit;
+ type Item = i32;
+}
```
-#### `false`:
+#### `true`
```rust
-extern crate b;
-extern crate a;
+struct Dummy;
-extern crate lorem;
-extern crate ipsum;
-extern crate dolor;
-extern crate sit;
-```
+impl Iterator for Dummy {
+ type Item = i32;
-See also [`reorder_extern_crates`](#reorder_extern_crates).
+ fn next(&mut self) -> Option<Self::Item> {
+ None
+ }
+}
+```
## `report_todo`
- **Default value**: `"Never"`
- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
+- **Stable**: No
Warns about any comments containing `TODO` in them when set to `"Always"`. If
it contains a `#X` (with `X` being a number) in parentheses following the
- **Default value**: `"Never"`
- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
+- **Stable**: No
Warns about any comments containing `FIXME` in them when set to `"Always"`. If
it contains a `#X` (with `X` being a number) in parentheses following the
See also [`report_todo`](#report_todo).
-## `single_line_if_else_max_width`
-
-Maximum line length for single line if-else expressions.
-
-- **Default value**: `50`
-- **Possible values**: any positive integer
-
-**Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
-
-#### Lines shorter than `single_line_if_else_max_width`:
-```rust
-let lorem = if ipsum { dolor } else { sit };
-```
-
-#### Lines longer than `single_line_if_else_max_width`:
-```rust
-let lorem = if ipsum {
- dolor
-} else {
- sit
-};
-```
-
-See also: [`control_brace_style`](#control_brace_style).
## `skip_children`
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
## `space_after_colon`
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
- **Default value** : 0
- **Possible values**: any positive integer
+- **Stable**: No
#### `0` (default):
}
```
-```
-
## `spaces_around_ranges`
-Put spaces around the .. and ... range operators
+Put spaces around the .., ..=, and ... range operators
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
```rust
-let lorem = 0..10;
-```
-
-#### `true`:
-
-```rust
-let lorem = 0 .. 10;
-```
-
-## `spaces_within_parens_and_brackets`
-
-Put spaces within non-empty generic arguments
+fn main() {
+ let lorem = 0..10;
+ let ipsum = 0..=10;
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
+ match lorem {
+ 1..5 => foo(),
+ _ => bar,
+ }
-#### `false` (default):
+ match lorem {
+ 1..=5 => foo(),
+ _ => bar,
+ }
-```rust
-fn lorem<T: Eq>(t: T) {
- // body
+ match lorem {
+ 1...5 => foo(),
+ _ => bar,
+ }
}
```
#### `true`:
```rust
-fn lorem< T: Eq >(t: T) {
- // body
-}
-```
-
-See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
+fn main() {
+ let lorem = 0 .. 10;
+ let ipsum = 0 ..= 10;
-## `spaces_within_parens_and_brackets`
-
-Put spaces within non-empty parentheses
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-
-#### `false` (default):
-
-```rust
-fn lorem<T: Eq>(t: T) {
- let lorem = (ipsum, dolor);
-}
-```
+ match lorem {
+ 1 .. 5 => foo(),
+ _ => bar,
+ }
-#### `true`:
+ match lorem {
+ 1 ..= 5 => foo(),
+ _ => bar,
+ }
-```rust
-fn lorem<T: Eq>( t: T ) {
- let lorem = ( ipsum, dolor );
+ match lorem {
+ 1 ... 5 => foo(),
+ _ => bar,
+ }
}
```
-See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
+## `struct_lit_single_line`
-## `spaces_within_parens_and_brackets`
+Put small struct literals on a single line
-Put spaces within non-empty square brackets
-
-- **Default value**: `false`
+- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
-#### `false` (default):
-
-```rust
-let lorem: [usize; 2] = [ipsum, dolor];
-```
-
-#### `true`:
-
-```rust
-let lorem: [ usize; 2 ] = [ ipsum, dolor ];
-```
-
-See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
-
-## `struct_lit_multiline_style`
-
-Multiline style on literal structs
-
-- **Default value**: `"PreferSingle"`
-- **Possible values**: `"ForceMulti"`, `"PreferSingle"`
-
-#### `"PreferSingle"` (default):
-
-```rust
-let lorem = Lorem { ipsum: dolor, sit: amet };
-```
-
-#### `"ForceMulti"`:
-
-```rust
-let lorem = Lorem {
- ipsum: dolor,
- sit: amet,
-};
-```
-
-See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
-
-## `struct_lit_width`
-
-Maximum width in the body of a struct lit before falling back to vertical formatting
-
-- **Default value**: `18`
-- **Possible values**: any positive integer
-
-**Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
+#### `true` (default):
-#### Lines shorter than `struct_lit_width`:
```rust
-let lorem = Lorem { ipsum: dolor, sit: amet };
+fn main() {
+ let lorem = Lorem { foo: bar, baz: ofo };
+}
```
-#### Lines longer than `struct_lit_width`:
-See [`indent_style`](#indent_style).
-
-See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
-
-## `struct_variant_width`
-
-Maximum width in the body of a struct variant before falling back to vertical formatting
-
-- **Default value**: `35`
-- **Possible values**: any positive integer
-
-**Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
+#### `false`:
-#### Struct variants shorter than `struct_variant_width`:
```rust
-enum Lorem {
- Ipsum,
- Dolor(bool),
- Sit { amet: Consectetur, adipiscing: Elit },
+fn main() {
+ let lorem = Lorem {
+ foo: bar,
+ baz: ofo,
+ };
}
```
-#### Struct variants longer than `struct_variant_width`:
-```rust
-enum Lorem {
- Ipsum,
- Dolor(bool),
- Sit {
- amet: Consectetur,
- adipiscing: Elit,
- },
-}
-```
+See also: [`indent_style`](#indent_style).
+
## `tab_spaces`
- **Default value**: `4`
- **Possible values**: any positive integer
+- **Stable**: Yes
#### `4` (default):
fn lorem() {
let ipsum = dolor();
let sit = vec![
- "amet consectetur adipiscing elit."
+ "amet consectetur adipiscing elit amet",
+ "consectetur adipiscing elit amet consectetur.",
];
}
```
fn lorem() {
let ipsum = dolor();
let sit = vec![
- "amet consectetur adipiscing elit."
+ "amet consectetur adipiscing elit amet",
+ "consectetur adipiscing elit amet consectetur.",
];
}
```
- **Default value**: `"Vertical"`
- **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
+- **Stable**: No
#### `"Vertical"` (default):
```rust
-let Lorem { ipsum, dolor, sit } = amet;
-let Lorem {
- ipsum,
- dolor,
- sit,
- amet,
- consectetur,
- adipiscing,
-} = elit;
+fn main() {
+ let Lorem { ipsum, dolor, sit } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing,
+ } = elit;
+}
```
#### `"Always"`:
```rust
-let Lorem { ipsum, dolor, sit, } = amet;
-let Lorem {
- ipsum,
- dolor,
- sit,
- amet,
- consectetur,
- adipiscing,
-} = elit;
+fn main() {
+ let Lorem { ipsum, dolor, sit, } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing,
+ } = elit;
+}
```
#### `"Never"`:
```rust
-let Lorem { ipsum, dolor, sit } = amet;
-let Lorem {
- ipsum,
- dolor,
- sit,
- amet,
- consectetur,
- adipiscing
-} = elit;
+fn main() {
+ let Lorem { ipsum, dolor, sit } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing
+ } = elit;
+}
```
See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
```rust
- **Default value**: `"Wide"`
- **Possible values**: `"Compressed"`, `"Wide"`
+- **Stable**: No
#### `"Wide"` (default):
```rust
fn lorem<Ipsum: Dolor + Sit = Amet>() {
- // body
+ // body
}
```
```rust
fn lorem<Ipsum: Dolor+Sit=Amet>() {
- // body
+ // body
}
```
-## `use_try_shorthand`
+## `use_field_init_shorthand`
-Replace uses of the try! macro by the ? shorthand
+Use field initialize shorthand if possible.
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
#### `false` (default):
```rust
-let lorem = try!(ipsum.map(|dolor|dolor.sit()));
+struct Foo {
+ x: u32,
+ y: u32,
+ z: u32,
+}
+
+fn main() {
+ let x = 1;
+ let y = 2;
+ let z = 3;
+ let a = Foo { x: x, y: y, z: z };
+}
```
#### `true`:
```rust
-let lorem = ipsum.map(|dolor| dolor.sit())?;
+struct Foo {
+ x: u32,
+ y: u32,
+ z: u32,
+}
+
+fn main() {
+ let x = 1;
+ let y = 2;
+ let z = 3;
+ let a = Foo { x, y, z };
+}
```
-## `where_density`
+## `use_try_shorthand`
-Density of a where clause.
+Replace uses of the try! macro by the ? shorthand
-- **Default value**: `"Vertical"`
-- **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: Yes
-#### `"Vertical"` (default):
+#### `false` (default):
```rust
-trait Lorem {
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where
- Dolor: Eq;
+fn main() {
+ let lorem = try!(ipsum.map(|dolor| dolor.sit()));
+}
+```
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where
- Dolor: Eq,
- {
- // body
- }
+#### `true`:
+
+```rust
+fn main() {
+ let lorem = ipsum.map(|dolor| dolor.sit())?;
}
```
-**Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
-#### `"CompressedIfEmpty"`:
+## `wrap_comments`
-```rust
-trait Lorem {
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where Dolor: Eq;
+Break comments to fit on the line
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where
- Dolor: Eq,
- {
- // body
- }
-}
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `false` (default):
+
+```rust
+// 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.
```
-#### `"Compressed"`:
+#### `true`:
```rust
-trait Lorem {
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where Dolor: Eq;
+// 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.
+```
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where Dolor: Eq {
- // body
+## `match_arm_blocks`
+
+Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
+
+- **Default value**: `true`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `true` (default):
+
+```rust
+fn main() {
+ match lorem {
+ true => {
+ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
+ }
+ false => println!("{}", sit),
}
}
```
-#### `"Tall"`:
+#### `false`:
```rust
-trait Lorem {
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where
- Dolor: Eq;
-
- fn ipsum<Dolor>(dolor: Dolor) -> Sit
- where
- Dolor: Eq,
- {
- // body
+fn main() {
+ match lorem {
+ true =>
+ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+ false => println!("{}", sit),
}
}
```
-**Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
+See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
-See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
-## `where_layout`
+## `blank_lines_upper_bound`
-Element layout inside a where clause
+Maximum number of blank lines which can be put between items. If more than this number of consecutive empty
+lines are found, they are trimmed down to match this integer.
-- **Default value**: `"Vertical"`
-- **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
+- **Default value**: `1`
+- **Possible values**: *unsigned integer*
+- **Stable**: No
-#### `"Vertical"` (default):
+### Example
+Original Code:
```rust
-fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
- where Ipsum: IpsumDolorSitAmet,
- Dolor: DolorSitAmetConsectetur
-{
- // body
+#![rustfmt::skip]
+
+fn foo() {
+ println!("a");
}
-fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
- where Ipsum: IpsumDolorSitAmet,
- Dolor: DolorSitAmetConsectetur,
- Sit: SitAmetConsecteturAdipiscing,
- Amet: AmetConsecteturAdipiscingElit
-{
- // body
+
+
+fn bar() {
+ println!("b");
+
+
+ println!("c");
}
```
-#### `"Horizontal"`:
-
+#### `1` (default):
```rust
-fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
- where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
-{
- // body
+fn foo() {
+ println!("a");
}
-fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
- where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
-{
- // body
+fn bar() {
+ println!("b");
+
+ println!("c");
}
```
-#### `"HorizontalVertical"`:
-
+#### `2` (default):
```rust
-fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
- where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
-{
- // body
+fn foo() {
+ println!("a");
}
-fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
- where Ipsum: IpsumDolorSitAmet,
- Dolor: DolorSitAmetConsectetur,
- Sit: SitAmetConsecteturAdipiscing,
- Amet: AmetConsecteturAdipiscingElit
-{
- // body
+
+fn bar() {
+ println!("b");
+
+
+ println!("c");
}
```
-#### `"Mixed"`:
+See also: [`blank_lines_lower_bound`](#blank_lines_lower_bound)
+
+## `blank_lines_lower_bound`
+
+Minimum number of blank lines which must be put between items. If two items have fewer blank lines between
+them, additional blank lines are inserted.
+
+- **Default value**: `0`
+- **Possible values**: *unsigned integer*
+- **Stable**: No
+
+### Example
+Original Code (rustfmt will not change it with the default value of `0`):
```rust
-fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
- where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
-{
- // body
+#![rustfmt::skip]
+
+fn foo() {
+ println!("a");
}
+fn bar() {
+ println!("b");
+ println!("c");
+}
+```
-fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
- where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
- Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
-{
- // body
+#### `1`
+```rust
+fn foo() {
+
+ println!("a");
+}
+
+fn bar() {
+
+ println!("b");
+
+ println!("c");
}
```
-See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
-## `wrap_comments`
+## `required_version`
-Break comments to fit on the line
+Require a specific version of rustfmt. If you want to make sure that the
+specific version of rustfmt is used in your CI, use this option.
+
+- **Default value**: `CARGO_PKG_VERSION`
+- **Possible values**: any published version (e.g. `"0.3.8"`)
+- **Stable**: No
+
+## `hide_parse_errors`
+
+Do not show parse errors if the parser failed to parse files.
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
-#### `false` (default):
+## `color`
-```rust
-// 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.
-```
+Whether to use colored output or not.
-#### `true`:
+- **Default value**: `"Auto"`
+- **Possible values**: "Auto", "Always", "Never"
+- **Stable**: No
-```rust
-// 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.
+## `unstable_features`
+
+Enable unstable features on stable channel.
+
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+## `license_template_path`
+
+Check whether beginnings of files match a license template.
+
+- **Default value**: `""``
+- **Possible values**: path to a license template file
+- **Stable**: No
+
+A license template is a plain text file which is matched literally against the
+beginning of each source file, except for `{}`-delimited blocks, which are
+matched as regular expressions. The following license template therefore
+matches strings like `// Copyright 2017 The Rust Project Developers.`, `//
+Copyright 2018 The Rust Project Developers.`, etc.:
+
+```
+// Copyright {\d+} The Rust Project Developers.
```
-## `wrap_match_arms`
+`\{`, `\}` and `\\` match literal braces / backslashes.
-Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
+## `ignore`
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
+Skip formatting the specified files and directories.
-#### `true` (default):
+- **Default value**: format every files
+- **Possible values**: See an example below
+- **Stable**: No
-```rust
-match lorem {
- true => {
- foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
- }
- false => println!("{}", sit),
-}
+### Example
+
+If you want to ignore specific files, put the following to your config file:
+
+```toml
+ignore = [
+ "src/types.rs",
+ "src/foo/bar.rs",
+]
```
-#### `false`:
+If you want to ignore every file under `examples/`, put the following to your config file:
-```rust
-match lorem {
- true =>
- foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
- false => println!("{}", sit),
-}
+```toml
+ignore [
+ "examples",
+]
```
-See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
+## `emit_mode`
-## `write_mode`
+Internal option
-What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
+## `make_backup`
-- **Default value**: `"Overwrite"`
-- **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`
+Internal option, use `--backup`