reorder_imported_names = true
```
+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-options` to rustfmt.
+
# Configuration Options
Below you find a detailed visual guide on all the supported configuration options of rustfmt:
- **Default value**: `"Block"`
- **Possible values**: `"Block"`, `"Visual"`
+- **Stable**: No
### Array
```rust
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
-where
+where
Ipsum: Eq,
Dolor: Eq,
Sit: Eq,
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
- **Default value**: `"Front"`
- **Possible values**: `"Front"`, `"Back"`
+- **Stable**: No
#### `"Front"` (default):
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();
-```
-
-
-
## `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.
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
- **Default value**: `"AlwaysSameLine"`
- **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
+- **Stable**: No
#### `"AlwaysSameLine"` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
## `error_on_line_overflow`
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
See also [`max_width`](#max_width).
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
See also [`comment_width`](#comment_width).
Argument density in functions
- **Default value**: `"Tall"`
-- **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
+- **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
+- **Stable**: No
#### `"Tall"` (default):
}
```
-#### `"CompressedIfEmpty"`:
-
-```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
- }
-}
-```
-
#### `"Vertical"`:
```rust
- **Default value**: `"SameLineWhere"`
- **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
+- **Stable**: No
### Functions
```
+## `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`
+
+To force single line where layout
+
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `false` (default):
+
+```rust
+impl<T> Lorem for T
+where
+ Option<T>: Ipsum,
+{
+ ...
+}
+```
+
+#### `true`:
+
+```rust
+impl<T> Lorem for T
+where Option<T>: Ipsum {
+ ...
+}
+```
+
+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.
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
- **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
-
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
-
-#### `true` (default):
-
-```rust
-impl Lorem {}
-```
-
-#### `false`:
-
-```rust
-impl Lorem {
-}
-```
-
-See also [`brace_style`](#brace_style).
-
## `imports_indent`
- **Default Value**: `"Visual"`
- **Possible values**: `"Block"`, `"Visual"`
+- **Stable**: No
#### `"Visual"` (default):
- **Default value**: "Mixed"
- **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
+- **Stable**: No
#### `"Mixed"` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
}
```
-See also: [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
+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):
- **Default value**: `false`
- **Possible values**: `false`, `true`
+- **Stable**: No
#### `false` (default):
- **Default value**: `"Unix"`
- **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
+- **Stable**: Yes
## `normalize_comments`
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
#### `false` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
**Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
**Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
- **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
- **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
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
## `spaces_within_parens_and_brackets`
-Put spaces within non-empty generic arguments
+Put spaces within non-empty generic arguments, parentheses, and square brackets
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
```rust
+// generic arguments
fn lorem<T: Eq>(t: T) {
// body
}
-```
-
-#### `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).
-## `spaces_within_parens_and_brackets`
-
-Put spaces within non-empty parentheses
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-
-#### `false` (default):
-
-```rust
+// non-empty parentheses
fn lorem<T: Eq>(t: T) {
let lorem = (ipsum, dolor);
}
+
+// non-empty square brackets
+let lorem: [usize; 2] = [ipsum, dolor];
```
#### `true`:
```rust
+// generic arguments
+fn lorem< T: Eq >(t: T) {
+ // body
+}
+
+// non-empty parentheses
fn lorem<T: Eq>( t: T ) {
let lorem = ( ipsum, dolor );
}
-```
-
-See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
-
-## `spaces_within_parens_and_brackets`
-
-Put spaces within non-empty square brackets
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-#### `false` (default):
-
-```rust
-let lorem: [usize; 2] = [ipsum, dolor];
-```
-
-#### `true`:
-
-```rust
+// non-empty square brackets
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_single_line`
Put small struct literals on a single line
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
- **Default value**: `4`
- **Possible values**: any positive integer
+- **Stable**: Yes
#### `4` (default):
- **Default value**: `"Vertical"`
- **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
+- **Stable**: No
#### `"Vertical"` (default):
- **Default value**: `true`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `true` (default):
```rust
- **Default value**: `"Wide"`
- **Possible values**: `"Compressed"`, `"Wide"`
+- **Stable**: No
#### `"Wide"` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: No
#### `false` (default):
- **Default value**: `false`
- **Possible values**: `true`, `false`
+- **Stable**: Yes
#### `false` (default):
// commodo consequat.
```
-## `wrap_match_arms`
+## `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):
- **Default value**: `"Overwrite"`
- **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`
+- **Stable**: No
+
+## `blank_lines_upper_bound`
+
+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**: `1`
+- **Possible values**: *unsigned integer*
+- **Stable**: No
+
+### Example
+Original Code:
+
+```rust
+fn foo() {
+ println!("a");
+}
+
+
+
+fn bar() {
+ println!("b");
+
+
+ println!("c");
+}
+```
+
+#### `1` (default):
+```rust
+fn foo() {
+ println!("a");
+}
+
+fn bar() {
+ println!("b");
+
+ println!("c");
+}
+```
+
+#### `2` (default):
+```rust
+fn foo() {
+ println!("a");
+}
+
+
+fn bar() {
+ println!("b");
+
+
+ println!("c");
+}
+```
+
+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 foo() {
+ println!("a");
+}
+fn bar() {
+ println!("b");
+ println!("c");
+}
+```
+
+#### `1`
+```rust
+fn foo() {
+
+ println!("a");
+}
+
+fn bar() {
+
+ println!("b");
+
+ println!("c");
+}
+```