Merge pull request #2147 from topecongiro/audit-options/indent_style
Use 'indent_style' for all indent related settings
This commit is contained in:
commit
bf15438ab4
95 changed files with 428 additions and 557 deletions
|
|
@ -5,7 +5,7 @@ Rustfmt is designed to be very configurable. You can create a TOML file called `
|
|||
A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
|
||||
|
||||
```toml
|
||||
array_indent = "Block"
|
||||
indent_style = "Block"
|
||||
array_width = 80
|
||||
reorder_imported_names = true
|
||||
```
|
||||
|
|
@ -22,7 +22,7 @@ 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 [`array_indent`](#array_indent) being applied regardless of a line's width.
|
||||
**Note:** A value of `0` results in [`indent_style`](#indent_style) being applied regardless of a line's width.
|
||||
|
||||
#### `0` (default):
|
||||
|
||||
|
|
@ -50,13 +50,15 @@ let a = vec![
|
|||
];
|
||||
```
|
||||
|
||||
## `array_indent`
|
||||
## `indent_style`
|
||||
|
||||
Indent on arrays
|
||||
Indent on expressions or items.
|
||||
|
||||
- **Default value**: `"Block"`
|
||||
- **Possible values**: `"Block"`, `"Visual"`
|
||||
|
||||
### Array
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
|
|
@ -83,6 +85,200 @@ let lorem = vec!["ipsum",
|
|||
"elit"];
|
||||
```
|
||||
|
||||
### Control flow
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
if lorem_ipsum &&
|
||||
dolor_sit &&
|
||||
amet_consectetur
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
if lorem_ipsum &&
|
||||
dolor_sit &&
|
||||
amet_consectetur {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
See also: [`control_brace_style`](#control_brace_style).
|
||||
|
||||
### Function arguments
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem() {}
|
||||
|
||||
fn lorem(ipsum: usize) {}
|
||||
|
||||
fn lorem(
|
||||
ipsum: usize,
|
||||
dolor: usize,
|
||||
sit: usize,
|
||||
amet: usize,
|
||||
consectetur: usize,
|
||||
adipiscing: usize,
|
||||
elit: usize,
|
||||
) {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
fn lorem() {}
|
||||
|
||||
fn lorem(ipsum: usize) {}
|
||||
|
||||
fn lorem(ipsum: usize,
|
||||
dolor: usize,
|
||||
sit: usize,
|
||||
amet: usize,
|
||||
consectetur: usize,
|
||||
adipiscing: usize,
|
||||
elit: usize) {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
### Functaion calls
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
lorem(
|
||||
"lorem",
|
||||
"ipsum",
|
||||
"dolor",
|
||||
"sit",
|
||||
"amet",
|
||||
"consectetur",
|
||||
"adipiscing",
|
||||
"elit",
|
||||
);
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
lorem("lorem",
|
||||
"ipsum",
|
||||
"dolor",
|
||||
"sit",
|
||||
"amet",
|
||||
"consectetur",
|
||||
"adipiscing",
|
||||
"elit");
|
||||
```
|
||||
|
||||
### Generics
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem<
|
||||
Ipsum: Eq = usize,
|
||||
Dolor: Eq = usize,
|
||||
Sit: Eq = usize,
|
||||
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 {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum: Eq = usize,
|
||||
Dolor: Eq = usize,
|
||||
Sit: Eq = usize,
|
||||
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 {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### Struct
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
let lorem = Lorem {
|
||||
ipsum: dolor,
|
||||
sit: amet,
|
||||
};
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
let lorem = Lorem { ipsum: dolor,
|
||||
sit: amet, };
|
||||
```
|
||||
|
||||
See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
|
||||
|
||||
### Where predicates
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where
|
||||
Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq
|
||||
{
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: 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
|
||||
|
|
@ -90,7 +286,7 @@ 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 [`array_indent`](#array_indent) being applied regardless of a line's width.
|
||||
**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
|
||||
|
|
@ -98,7 +294,7 @@ let lorem = vec.
|
||||
See [`indent_style`](#indent_style).
|
||||
|
||||
## `attributes_on_same_line_as_field`
|
||||
|
||||
|
|
@ -414,36 +610,6 @@ let (lorem, ipsum, _, _) = (1, 2, 3, 4);
|
|||
let (lorem, ipsum, ..) = (1, 2, 3, 4);
|
||||
```
|
||||
|
||||
## `control_style`
|
||||
|
||||
Indent style for control flow statements
|
||||
|
||||
- **Default value**: `"Rfc"`
|
||||
- **Possible values**: `"Rfc"`, `"Legacy"`
|
||||
|
||||
#### `"Rfc"` (default):
|
||||
|
||||
```rust
|
||||
if lorem_ipsum &&
|
||||
dolor_sit &&
|
||||
amet_consectetur
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Legacy"`:
|
||||
|
||||
```rust
|
||||
if lorem_ipsum &&
|
||||
dolor_sit &&
|
||||
amet_consectetur {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
See also: [`control_brace_style`](#control_brace_style).
|
||||
|
||||
## `control_brace_style`
|
||||
|
||||
Brace style for control flow constructs
|
||||
|
|
@ -640,51 +806,6 @@ trait Lorem {
|
|||
}
|
||||
```
|
||||
|
||||
## `fn_args_indent`
|
||||
|
||||
Layout of function arguments and tuple structs
|
||||
|
||||
- **Default value**: `"Block"`
|
||||
- **Possible values**: `"Block"`, `"Visual"`
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem() {}
|
||||
|
||||
fn lorem(ipsum: usize) {}
|
||||
|
||||
fn lorem(
|
||||
ipsum: usize,
|
||||
dolor: usize,
|
||||
sit: usize,
|
||||
amet: usize,
|
||||
consectetur: usize,
|
||||
adipiscing: usize,
|
||||
elit: usize,
|
||||
) {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
fn lorem() {}
|
||||
|
||||
fn lorem(ipsum: usize) {}
|
||||
|
||||
fn lorem(ipsum: usize,
|
||||
dolor: usize,
|
||||
sit: usize,
|
||||
amet: usize,
|
||||
consectetur: usize,
|
||||
adipiscing: usize,
|
||||
elit: usize) {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
## `fn_args_paren_newline`
|
||||
|
||||
If function argument parenthesis goes on a newline
|
||||
|
|
@ -784,41 +905,6 @@ where
|
|||
}
|
||||
```
|
||||
|
||||
## `fn_call_indent`
|
||||
|
||||
Indentation for function calls, etc.
|
||||
|
||||
- **Default value**: `"Block"`
|
||||
- **Possible values**: `"Block"`, `"Visual"`
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
lorem(
|
||||
"lorem",
|
||||
"ipsum",
|
||||
"dolor",
|
||||
"sit",
|
||||
"amet",
|
||||
"consectetur",
|
||||
"adipiscing",
|
||||
"elit",
|
||||
);
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
lorem("lorem",
|
||||
"ipsum",
|
||||
"dolor",
|
||||
"sit",
|
||||
"amet",
|
||||
"consectetur",
|
||||
"adipiscing",
|
||||
"elit");
|
||||
```
|
||||
|
||||
## `fn_call_width`
|
||||
|
||||
Maximum width of the args of a function call before falling back to vertical formatting
|
||||
|
|
@ -835,7 +921,7 @@ lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "el
|
|||
|
||||
#### Function call longer than `fn_call_width`:
|
||||
|
||||
See [`fn_call_indent`](#fn_call_indent).
|
||||
See [`indent_style`](#indent_style).
|
||||
|
||||
## `fn_empty_single_line`
|
||||
|
||||
|
|
@ -900,7 +986,7 @@ fn lorem(ipsum: Ipsum,
|
|||
|
||||
```
|
||||
|
||||
**Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`.
|
||||
**Note**: This option only takes effect when `indent_style` is set to `"Visual"`.
|
||||
|
||||
## `fn_single_line`
|
||||
|
||||
|
|
@ -994,59 +1080,6 @@ let lorem =
|
|||
|
||||
See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
|
||||
|
||||
## `generics_indent`
|
||||
|
||||
Indentation of generics
|
||||
|
||||
- **Default value**: `"Block"`
|
||||
- **Possible values**: `"Block"`, `"Visual"`
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem<
|
||||
Ipsum: Eq = usize,
|
||||
Dolor: Eq = usize,
|
||||
Sit: Eq = usize,
|
||||
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 {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum: Eq = usize,
|
||||
Dolor: Eq = usize,
|
||||
Sit: Eq = usize,
|
||||
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 {
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
## `hard_tabs`
|
||||
|
||||
Use tab characters for indentation, spaces for alignment
|
||||
|
|
@ -1982,32 +2015,7 @@ let lorem = Lorem {
|
|||
};
|
||||
```
|
||||
|
||||
See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width).
|
||||
|
||||
## `struct_lit_indent`
|
||||
|
||||
Style of struct definition
|
||||
|
||||
- **Default value**: `"Block"`
|
||||
- **Possible values**: `"Block"`, `"Visual"`
|
||||
|
||||
#### `"Block"` (default):
|
||||
|
||||
```rust
|
||||
let lorem = Lorem {
|
||||
ipsum: dolor,
|
||||
sit: amet,
|
||||
};
|
||||
```
|
||||
|
||||
#### `"Visual"`:
|
||||
|
||||
```rust
|
||||
let lorem = Lorem { ipsum: dolor,
|
||||
sit: amet, };
|
||||
```
|
||||
|
||||
See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
|
||||
See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
|
||||
|
||||
## `struct_lit_width`
|
||||
|
||||
|
|
@ -2024,9 +2032,9 @@ let lorem = Lorem { ipsum: dolor, sit: amet };
|
|||
```
|
||||
|
||||
#### Lines longer than `struct_lit_width`:
|
||||
See [`struct_lit_indent`](#struct_lit_indent).
|
||||
See [`indent_style`](#indent_style).
|
||||
|
||||
See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
|
||||
See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
|
||||
|
||||
## `struct_variant_width`
|
||||
|
||||
|
|
@ -2308,7 +2316,7 @@ trait Lorem {
|
|||
|
||||
**Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
|
||||
|
||||
See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
|
||||
See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
|
||||
|
||||
## `where_layout`
|
||||
|
||||
|
|
@ -2389,82 +2397,7 @@ fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Am
|
|||
}
|
||||
```
|
||||
|
||||
**Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
|
||||
|
||||
See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
|
||||
|
||||
## `where_pred_indent`
|
||||
|
||||
Indentation style of a where predicate
|
||||
|
||||
- **Default value**: `"Visual"`
|
||||
- **Possible values**: `"Block"`, `"Visual"`
|
||||
|
||||
#### `"Visual"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq
|
||||
{
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Block"`:
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq
|
||||
{
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
**Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
|
||||
|
||||
See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
|
||||
|
||||
## `where_style`
|
||||
|
||||
Overall strategy for where clauses
|
||||
|
||||
- **Default value**: `"Rfc"`
|
||||
- **Possible values**: `"Rfc"`, `"Legacy"`
|
||||
|
||||
#### `"Rfc"` (default):
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where
|
||||
Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq,
|
||||
{
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
#### `"Legacy"`:
|
||||
|
||||
```rust
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq
|
||||
{
|
||||
// body
|
||||
}
|
||||
```
|
||||
|
||||
See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
|
||||
See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
|
||||
|
||||
## `wrap_comments`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
fn_args_indent = "Visual"
|
||||
array_indent = "Visual"
|
||||
control_style = "Legacy"
|
||||
where_style = "Legacy"
|
||||
generics_indent = "Visual"
|
||||
fn_call_indent = "Visual"
|
||||
indent_style = "Visual"
|
||||
combine_control_expr = false
|
||||
fn_args_paren_newline = true
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
|
||||
// Parent is the first item in the chain, e.g., `foo` in `foo.bar.baz()`.
|
||||
let parent_shape = if is_block_expr(context, &parent, "\n") {
|
||||
match context.config.chain_indent() {
|
||||
match context.config.indent_style() {
|
||||
IndentStyle::Visual => shape.visual_indent(0),
|
||||
IndentStyle::Block => shape,
|
||||
}
|
||||
|
|
@ -105,10 +105,10 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
let (nested_shape, extend) = if !parent_rewrite_contains_newline && is_continuable(&parent) {
|
||||
(
|
||||
chain_indent(context, shape.add_offset(parent_rewrite.len())),
|
||||
context.config.chain_indent() == IndentStyle::Visual || is_small_parent,
|
||||
context.config.indent_style() == IndentStyle::Visual || is_small_parent,
|
||||
)
|
||||
} else if is_block_expr(context, &parent, &parent_rewrite) {
|
||||
match context.config.chain_indent() {
|
||||
match context.config.indent_style() {
|
||||
// Try to put the first child on the same line with parent's last line
|
||||
IndentStyle::Block => (parent_shape.block_indent(context.config.tab_spaces()), true),
|
||||
// The parent is a block, so align the rest of the chain with the closing
|
||||
|
|
@ -127,7 +127,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
let first_child_shape = if extend {
|
||||
let overhead = last_line_width(&parent_rewrite);
|
||||
let offset = trimmed_last_line_width(&parent_rewrite) + prefix_try_num;
|
||||
match context.config.chain_indent() {
|
||||
match context.config.indent_style() {
|
||||
IndentStyle::Visual => parent_shape.offset_left(overhead)?,
|
||||
IndentStyle::Block => parent_shape.block().offset_left(offset)?,
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
} else {
|
||||
other_child_shape
|
||||
};
|
||||
match context.config.chain_indent() {
|
||||
match context.config.indent_style() {
|
||||
IndentStyle::Visual => last_shape.sub_width(shape.rhs_overhead(context.config))?,
|
||||
IndentStyle::Block => last_shape,
|
||||
}
|
||||
|
|
@ -262,7 +262,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
|
||||
let first_connector = if is_small_parent || fits_single_line
|
||||
|| last_line_extendable(&parent_rewrite)
|
||||
|| context.config.chain_indent() == IndentStyle::Visual
|
||||
|| context.config.indent_style() == IndentStyle::Visual
|
||||
{
|
||||
""
|
||||
} else {
|
||||
|
|
@ -272,7 +272,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
let result = if is_small_parent && rewrites.len() > 1 {
|
||||
let second_connector = if fits_single_line || rewrites[1] == "?"
|
||||
|| last_line_extendable(&rewrites[0])
|
||||
|| context.config.chain_indent() == IndentStyle::Visual
|
||||
|| context.config.indent_style() == IndentStyle::Visual
|
||||
{
|
||||
""
|
||||
} else {
|
||||
|
|
@ -295,7 +295,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
|||
)
|
||||
};
|
||||
let result = format!("{}{}", result, repeat_try(suffix_try_num));
|
||||
if context.config.chain_indent() == IndentStyle::Visual {
|
||||
if context.config.indent_style() == IndentStyle::Visual {
|
||||
wrap_str(result, context.config.max_width(), shape)
|
||||
} else {
|
||||
Some(result)
|
||||
|
|
@ -381,7 +381,7 @@ fn make_subexpr_list(expr: &ast::Expr, context: &RewriteContext) -> (ast::Expr,
|
|||
}
|
||||
|
||||
fn chain_indent(context: &RewriteContext, shape: Shape) -> Shape {
|
||||
match context.config.chain_indent() {
|
||||
match context.config.indent_style() {
|
||||
IndentStyle::Visual => shape.visual_indent(0),
|
||||
IndentStyle::Block => shape
|
||||
.block_indent(context.config.tab_spaces())
|
||||
|
|
|
|||
|
|
@ -40,11 +40,6 @@ macro_rules! configuration_option_enum{
|
|||
}
|
||||
}
|
||||
|
||||
configuration_option_enum! { Style:
|
||||
Rfc, // Follow the style RFCs style.
|
||||
Legacy, // Follow the traditional Rustfmt style.
|
||||
}
|
||||
|
||||
configuration_option_enum! { NewlineStyle:
|
||||
Windows, // \r\n
|
||||
Unix, // \n
|
||||
|
|
@ -521,6 +516,7 @@ pub fn get_toml_path(dir: &Path) -> Result<Option<PathBuf>, Error> {
|
|||
|
||||
|
||||
create_config! {
|
||||
indent_style: IndentStyle, IndentStyle::Block, false, "How do we indent expressions or items.";
|
||||
unstable_features: bool, false, true,
|
||||
"Enables unstable features. Only available on nightly channel";
|
||||
verbose: bool, false, false, "Use verbose output";
|
||||
|
|
@ -545,7 +541,6 @@ create_config! {
|
|||
fn_brace_style: BraceStyle, BraceStyle::SameLineWhere, false, "Brace style for functions";
|
||||
item_brace_style: BraceStyle, BraceStyle::SameLineWhere, false,
|
||||
"Brace style for structs and enums";
|
||||
control_style: Style, Style::Rfc, false, "Indent style for control flow statements";
|
||||
control_brace_style: ControlBraceStyle, ControlBraceStyle::AlwaysSameLine, false,
|
||||
"Brace style for control flow constructs";
|
||||
impl_empty_single_line: bool, true, false, "Put empty-body implementations on a single line";
|
||||
|
|
@ -559,16 +554,12 @@ create_config! {
|
|||
"Location of return type in function declaration";
|
||||
fn_args_paren_newline: bool, false, false, "If function argument parenthesis goes on a newline";
|
||||
fn_args_density: Density, Density::Tall, false, "Argument density in functions";
|
||||
fn_args_indent: IndentStyle, IndentStyle::Block, false,
|
||||
"Layout of function arguments and tuple structs";
|
||||
array_indent: IndentStyle, IndentStyle::Block, false, "Indent on arrays";
|
||||
array_width: usize, 60, false,
|
||||
"Maximum width of an array literal before falling back to vertical formatting";
|
||||
array_horizontal_layout_threshold: usize, 0, false,
|
||||
"How many elements array must have before rustfmt uses horizontal layout.";
|
||||
type_punctuation_density: TypeDensity, TypeDensity::Wide, false,
|
||||
"Determines if '+' or '=' are wrapped in spaces in the punctuation of types";
|
||||
where_style: Style, Style::Rfc, false, "Overall strategy for where clauses";
|
||||
// TODO:
|
||||
// 1. Should we at least try to put the where clause on the same line as the rest of the
|
||||
// function decl?
|
||||
|
|
@ -576,18 +567,12 @@ create_config! {
|
|||
where_density: Density, Density::Vertical, false, "Density of a where clause";
|
||||
where_single_line: bool, false, false, "To force single line where layout";
|
||||
where_layout: ListTactic, ListTactic::Vertical, false, "Element layout inside a where clause";
|
||||
where_pred_indent: IndentStyle, IndentStyle::Visual, false,
|
||||
"Indentation style of a where predicate";
|
||||
generics_indent: IndentStyle, IndentStyle::Block, false, "Indentation of generics";
|
||||
struct_lit_indent: IndentStyle, IndentStyle::Block, false, "Style of struct definition";
|
||||
struct_lit_multiline_style: MultilineStyle, MultilineStyle::PreferSingle, false,
|
||||
"Multiline style on literal structs";
|
||||
fn_call_indent: IndentStyle, IndentStyle::Block, false, "Indentation for function calls, etc.";
|
||||
report_todo: ReportTactic, ReportTactic::Never, false,
|
||||
"Report all, none or unnumbered occurrences of TODO in source file comments";
|
||||
report_fixme: ReportTactic, ReportTactic::Never, false,
|
||||
"Report all, none or unnumbered occurrences of FIXME in source file comments";
|
||||
chain_indent: IndentStyle, IndentStyle::Block, false, "Indentation of chain";
|
||||
chain_width: usize, 60, false, "Maximum length of a chain to fit on a single line";
|
||||
chain_split_single_child: bool, false, false, "Split a chain with a single child if its length \
|
||||
exceeds `chain_width`";
|
||||
|
|
|
|||
50
src/expr.rs
50
src/expr.rs
|
|
@ -21,7 +21,7 @@ use closures;
|
|||
use codemap::{LineRangeUtils, SpanUtils};
|
||||
use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
|
||||
rewrite_comment, rewrite_missing_comment, FindUncommented};
|
||||
use config::{Config, ControlBraceStyle, IndentStyle, MultilineStyle, Style};
|
||||
use config::{Config, ControlBraceStyle, IndentStyle, MultilineStyle};
|
||||
use lists::{definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting,
|
||||
struct_lit_shape, struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting,
|
||||
ListItem, ListTactic, Separator, SeparatorPlace, SeparatorTactic};
|
||||
|
|
@ -366,11 +366,11 @@ where
|
|||
|
||||
// We have to use multiple lines.
|
||||
// Re-evaluate the rhs because we have more space now:
|
||||
let mut rhs_shape = match context.config.control_style() {
|
||||
Style::Legacy => shape
|
||||
let mut rhs_shape = match context.config.indent_style() {
|
||||
IndentStyle::Visual => shape
|
||||
.sub_width(pp.suffix.len() + pp.prefix.len())?
|
||||
.visual_indent(pp.prefix.len()),
|
||||
Style::Rfc => {
|
||||
IndentStyle::Block => {
|
||||
// Try to calculate the initial constraint on the right hand side.
|
||||
let rhs_overhead = shape.rhs_overhead(context.config);
|
||||
Shape::indented(shape.indent.block_indent(context.config), context.config)
|
||||
|
|
@ -415,7 +415,7 @@ where
|
|||
1 // "["
|
||||
};
|
||||
|
||||
let nested_shape = match context.config.array_indent() {
|
||||
let nested_shape = match context.config.indent_style() {
|
||||
IndentStyle::Block => shape
|
||||
.block()
|
||||
.block_indent(context.config.tab_spaces())
|
||||
|
|
@ -450,7 +450,7 @@ where
|
|||
.iter()
|
||||
.any(|li| li.item.as_ref().map(|s| s.len() > 10).unwrap_or(false));
|
||||
|
||||
let mut tactic = match context.config.array_indent() {
|
||||
let mut tactic = match context.config.indent_style() {
|
||||
IndentStyle::Block => {
|
||||
// FIXME wrong shape in one-line case
|
||||
match shape.width.checked_sub(2 * bracket_size) {
|
||||
|
|
@ -473,7 +473,7 @@ where
|
|||
DefinitiveListTactic::Mixed
|
||||
},
|
||||
};
|
||||
let ends_with_newline = tactic.ends_with_newline(context.config.array_indent());
|
||||
let ends_with_newline = tactic.ends_with_newline(context.config.indent_style());
|
||||
if context.config.array_horizontal_layout_threshold() > 0
|
||||
&& items.len() > context.config.array_horizontal_layout_threshold()
|
||||
{
|
||||
|
|
@ -485,7 +485,7 @@ where
|
|||
separator: ",",
|
||||
trailing_separator: if trailing_comma {
|
||||
SeparatorTactic::Always
|
||||
} else if context.inside_macro || context.config.array_indent() == IndentStyle::Visual {
|
||||
} else if context.inside_macro || context.config.indent_style() == IndentStyle::Visual {
|
||||
SeparatorTactic::Never
|
||||
} else {
|
||||
SeparatorTactic::Vertical
|
||||
|
|
@ -498,7 +498,7 @@ where
|
|||
};
|
||||
let list_str = write_list(&items, &fmt)?;
|
||||
|
||||
let result = if context.config.array_indent() == IndentStyle::Visual
|
||||
let result = if context.config.indent_style() == IndentStyle::Visual
|
||||
|| tactic == DefinitiveListTactic::Horizontal
|
||||
{
|
||||
if context.config.spaces_within_square_brackets() && !list_str.is_empty() {
|
||||
|
|
@ -677,9 +677,9 @@ pub fn rewrite_cond(context: &RewriteContext, expr: &ast::Expr, shape: Shape) ->
|
|||
match expr.node {
|
||||
ast::ExprKind::Match(ref cond, _) => {
|
||||
// `match `cond` {`
|
||||
let cond_shape = match context.config.control_style() {
|
||||
Style::Legacy => shape.shrink_left(6).and_then(|s| s.sub_width(2))?,
|
||||
Style::Rfc => shape.offset_left(8)?,
|
||||
let cond_shape = match context.config.indent_style() {
|
||||
IndentStyle::Visual => shape.shrink_left(6).and_then(|s| s.sub_width(2))?,
|
||||
IndentStyle::Block => shape.offset_left(8)?,
|
||||
};
|
||||
cond.rewrite(context, cond_shape)
|
||||
}
|
||||
|
|
@ -922,9 +922,9 @@ impl<'a> ControlFlow<'a> {
|
|||
|
||||
let pat_expr_string = match self.cond {
|
||||
Some(cond) => {
|
||||
let cond_shape = match context.config.control_style() {
|
||||
Style::Legacy => constr_shape.shrink_left(offset)?,
|
||||
Style::Rfc => constr_shape.offset_left(offset)?,
|
||||
let cond_shape = match context.config.indent_style() {
|
||||
IndentStyle::Visual => constr_shape.shrink_left(offset)?,
|
||||
IndentStyle::Block => constr_shape.offset_left(offset)?,
|
||||
};
|
||||
rewrite_pat_expr(
|
||||
context,
|
||||
|
|
@ -951,7 +951,7 @@ impl<'a> ControlFlow<'a> {
|
|||
.max_width()
|
||||
.checked_sub(constr_shape.used_width() + offset + brace_overhead)
|
||||
.unwrap_or(0);
|
||||
let force_newline_brace = context.config.control_style() == Style::Rfc
|
||||
let force_newline_brace = context.config.indent_style() == IndentStyle::Block
|
||||
&& (pat_expr_string.contains('\n') || pat_expr_string.len() > one_line_budget)
|
||||
&& !last_line_extendable(&pat_expr_string);
|
||||
|
||||
|
|
@ -1236,9 +1236,9 @@ fn rewrite_match(
|
|||
..shape
|
||||
};
|
||||
// 6 = `match `
|
||||
let cond_shape = match context.config.control_style() {
|
||||
Style::Legacy => cond_shape.shrink_left(6)?,
|
||||
Style::Rfc => cond_shape.offset_left(6)?,
|
||||
let cond_shape = match context.config.indent_style() {
|
||||
IndentStyle::Visual => cond_shape.shrink_left(6)?,
|
||||
IndentStyle::Block => cond_shape.offset_left(6)?,
|
||||
};
|
||||
let cond_str = cond.rewrite(context, cond_shape)?;
|
||||
let alt_block_sep = String::from("\n") + &shape.indent.block_only().to_string(context.config);
|
||||
|
|
@ -1809,7 +1809,7 @@ where
|
|||
let used_width = extra_offset(callee_str, shape);
|
||||
let one_line_width = shape.width.checked_sub(used_width + 2 * paren_overhead)?;
|
||||
|
||||
let nested_shape = shape_from_fn_call_indent(
|
||||
let nested_shape = shape_from_indent_style(
|
||||
context,
|
||||
shape,
|
||||
used_width + 2 * paren_overhead,
|
||||
|
|
@ -2058,7 +2058,7 @@ pub fn can_be_overflowed_expr(context: &RewriteContext, expr: &ast::Expr, args_l
|
|||
match expr.node {
|
||||
ast::ExprKind::Match(..) => {
|
||||
(context.use_block_indent() && args_len == 1)
|
||||
|| (context.config.fn_call_indent() == IndentStyle::Visual && args_len > 1)
|
||||
|| (context.config.indent_style() == IndentStyle::Visual && args_len > 1)
|
||||
}
|
||||
ast::ExprKind::If(..) |
|
||||
ast::ExprKind::IfLet(..) |
|
||||
|
|
@ -2070,7 +2070,7 @@ pub fn can_be_overflowed_expr(context: &RewriteContext, expr: &ast::Expr, args_l
|
|||
}
|
||||
ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => {
|
||||
context.use_block_indent()
|
||||
|| context.config.fn_call_indent() == IndentStyle::Visual && args_len > 1
|
||||
|| context.config.indent_style() == IndentStyle::Visual && args_len > 1
|
||||
}
|
||||
ast::ExprKind::Array(..) |
|
||||
ast::ExprKind::Call(..) |
|
||||
|
|
@ -2319,7 +2319,7 @@ fn rewrite_struct_lit<'a>(
|
|||
let fields_str = wrap_struct_field(context, &fields_str, shape, v_shape, one_line_width);
|
||||
Some(format!("{} {{{}}}", path_str, fields_str))
|
||||
|
||||
// FIXME if context.config.struct_lit_indent() == Visual, but we run out
|
||||
// FIXME if context.config.indent_style() == Visual, but we run out
|
||||
// of space, we should fall back to BlockIndent.
|
||||
}
|
||||
|
||||
|
|
@ -2330,7 +2330,7 @@ pub fn wrap_struct_field(
|
|||
nested_shape: Shape,
|
||||
one_line_width: usize,
|
||||
) -> String {
|
||||
if context.config.struct_lit_indent() == IndentStyle::Block
|
||||
if context.config.indent_style() == IndentStyle::Block
|
||||
&& (fields_str.contains('\n')
|
||||
|| context.config.struct_lit_multiline_style() == MultilineStyle::ForceMulti
|
||||
|| fields_str.len() > one_line_width)
|
||||
|
|
@ -2401,7 +2401,7 @@ pub fn rewrite_field(
|
|||
}
|
||||
}
|
||||
|
||||
fn shape_from_fn_call_indent(
|
||||
fn shape_from_indent_style(
|
||||
context: &RewriteContext,
|
||||
shape: Shape,
|
||||
overhead: usize,
|
||||
|
|
|
|||
44
src/items.rs
44
src/items.rs
|
|
@ -22,7 +22,7 @@ use spanned::Spanned;
|
|||
use codemap::{LineRangeUtils, SpanUtils};
|
||||
use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
|
||||
recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented};
|
||||
use config::{BraceStyle, Config, Density, IndentStyle, ReturnIndent, Style};
|
||||
use config::{BraceStyle, Config, Density, IndentStyle, ReturnIndent};
|
||||
use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs,
|
||||
rewrite_call_inner, ExprType};
|
||||
use lists::{definitive_tactic, itemize_list, write_list, DefinitiveListTactic, ListFormatting,
|
||||
|
|
@ -815,9 +815,9 @@ fn format_impl_ref_and_type(
|
|||
result.push_str("for ");
|
||||
}
|
||||
let budget = context.budget(last_line_width(&result));
|
||||
let type_offset = match context.config.where_style() {
|
||||
Style::Legacy => new_line_offset + trait_ref_overhead,
|
||||
Style::Rfc => new_line_offset,
|
||||
let type_offset = match context.config.indent_style() {
|
||||
IndentStyle::Visual => new_line_offset + trait_ref_overhead,
|
||||
IndentStyle::Block => new_line_offset,
|
||||
};
|
||||
result.push_str(&*self_ty
|
||||
.rewrite(context, Shape::legacy(budget, type_offset))?);
|
||||
|
|
@ -974,8 +974,8 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
|||
let has_body = !trait_items.is_empty();
|
||||
|
||||
let where_density = if (context.config.where_density() == Density::Compressed
|
||||
&& (!result.contains('\n') || context.config.fn_args_indent() == IndentStyle::Block))
|
||||
|| (context.config.fn_args_indent() == IndentStyle::Block && result.is_empty())
|
||||
&& (!result.contains('\n') || context.config.indent_style() == IndentStyle::Block))
|
||||
|| (context.config.indent_style() == IndentStyle::Block && result.is_empty())
|
||||
|| (context.config.where_density() == Density::CompressedIfEmpty && !has_body
|
||||
&& !result.contains('\n'))
|
||||
{
|
||||
|
|
@ -1880,13 +1880,13 @@ fn rewrite_fn_base(
|
|||
} else if context.config.fn_args_paren_newline() {
|
||||
result.push('\n');
|
||||
result.push_str(&arg_indent.to_string(context.config));
|
||||
if context.config.fn_args_indent() == IndentStyle::Visual {
|
||||
if context.config.indent_style() == IndentStyle::Visual {
|
||||
arg_indent = arg_indent + 1; // extra space for `(`
|
||||
}
|
||||
result.push('(');
|
||||
} else {
|
||||
result.push_str("(");
|
||||
if context.config.fn_args_indent() == IndentStyle::Visual {
|
||||
if context.config.indent_style() == IndentStyle::Visual {
|
||||
result.push('\n');
|
||||
result.push_str(&arg_indent.to_string(context.config));
|
||||
}
|
||||
|
|
@ -1933,7 +1933,7 @@ fn rewrite_fn_base(
|
|||
generics_str.contains('\n'),
|
||||
)?;
|
||||
|
||||
let put_args_in_block = match context.config.fn_args_indent() {
|
||||
let put_args_in_block = match context.config.indent_style() {
|
||||
IndentStyle::Block => arg_str.contains('\n') || arg_str.len() > one_line_budget,
|
||||
_ => false,
|
||||
} && !fd.inputs.is_empty();
|
||||
|
|
@ -1974,7 +1974,7 @@ fn rewrite_fn_base(
|
|||
|
||||
// Return type.
|
||||
if let ast::FunctionRetTy::Ty(..) = fd.output {
|
||||
let ret_should_indent = match context.config.fn_args_indent() {
|
||||
let ret_should_indent = match context.config.indent_style() {
|
||||
// If our args are block layout then we surely must have space.
|
||||
IndentStyle::Block if put_args_in_block || fd.inputs.is_empty() => false,
|
||||
_ if args_last_line_contains_comment => false,
|
||||
|
|
@ -2266,7 +2266,7 @@ fn rewrite_args(
|
|||
.and_then(|item| item.post_comment.as_ref())
|
||||
.map_or(false, |s| s.trim().starts_with("//"));
|
||||
|
||||
let (indent, trailing_comma) = match context.config.fn_args_indent() {
|
||||
let (indent, trailing_comma) = match context.config.indent_style() {
|
||||
IndentStyle::Block if fits_in_one_line => {
|
||||
(indent.block_indent(context.config), SeparatorTactic::Never)
|
||||
}
|
||||
|
|
@ -2303,7 +2303,7 @@ fn rewrite_args(
|
|||
},
|
||||
separator_place: SeparatorPlace::Back,
|
||||
shape: Shape::legacy(budget, indent),
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.fn_args_indent()),
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.indent_style()),
|
||||
preserve_newline: true,
|
||||
config: context.config,
|
||||
};
|
||||
|
|
@ -2353,7 +2353,7 @@ fn compute_budgets_for_args(
|
|||
|
||||
if one_line_budget > 0 {
|
||||
// 4 = "() {".len()
|
||||
let (indent, multi_line_budget) = match context.config.fn_args_indent() {
|
||||
let (indent, multi_line_budget) = match context.config.indent_style() {
|
||||
IndentStyle::Block => {
|
||||
let indent = indent.block_indent(context.config);
|
||||
(indent, context.budget(indent.width() + 1))
|
||||
|
|
@ -2371,7 +2371,7 @@ fn compute_budgets_for_args(
|
|||
|
||||
// Didn't work. we must force vertical layout and put args on a newline.
|
||||
let new_indent = indent.block_indent(context.config);
|
||||
let used_space = match context.config.fn_args_indent() {
|
||||
let used_space = match context.config.indent_style() {
|
||||
// 1 = `,`
|
||||
IndentStyle::Block => new_indent.width() + 1,
|
||||
// Account for `)` and possibly ` {`.
|
||||
|
|
@ -2464,7 +2464,7 @@ fn rewrite_generics_inner(
|
|||
}
|
||||
|
||||
pub fn generics_shape_from_config(config: &Config, shape: Shape, offset: usize) -> Option<Shape> {
|
||||
match config.generics_indent() {
|
||||
match config.indent_style() {
|
||||
IndentStyle::Visual => shape.visual_indent(1 + offset).sub_width(offset + 2),
|
||||
IndentStyle::Block => {
|
||||
// 1 = ","
|
||||
|
|
@ -2497,14 +2497,14 @@ where
|
|||
let fmt = ListFormatting {
|
||||
tactic: tactic,
|
||||
separator: ",",
|
||||
trailing_separator: if context.config.generics_indent() == IndentStyle::Visual {
|
||||
trailing_separator: if context.config.indent_style() == IndentStyle::Visual {
|
||||
SeparatorTactic::Never
|
||||
} else {
|
||||
context.config.trailing_comma()
|
||||
},
|
||||
separator_place: SeparatorPlace::Back,
|
||||
shape: shape,
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.generics_indent()),
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.indent_style()),
|
||||
preserve_newline: true,
|
||||
config: context.config,
|
||||
};
|
||||
|
|
@ -2523,7 +2523,7 @@ pub fn wrap_generics_with_angle_brackets(
|
|||
list_str: &str,
|
||||
list_offset: Indent,
|
||||
) -> String {
|
||||
if context.config.generics_indent() == IndentStyle::Block
|
||||
if context.config.indent_style() == IndentStyle::Block
|
||||
&& (list_str.contains('\n') || list_str.ends_with(','))
|
||||
{
|
||||
format!(
|
||||
|
|
@ -2674,7 +2674,7 @@ fn rewrite_where_clause(
|
|||
return Some(String::new());
|
||||
}
|
||||
|
||||
if context.config.where_style() == Style::Rfc {
|
||||
if context.config.indent_style() == IndentStyle::Block {
|
||||
return rewrite_where_clause_rfc_style(
|
||||
context,
|
||||
where_clause,
|
||||
|
|
@ -2689,12 +2689,12 @@ fn rewrite_where_clause(
|
|||
|
||||
let extra_indent = Indent::new(context.config.tab_spaces(), 0);
|
||||
|
||||
let offset = match context.config.where_pred_indent() {
|
||||
let offset = match context.config.indent_style() {
|
||||
IndentStyle::Block => shape.indent + extra_indent.block_indent(context.config),
|
||||
// 6 = "where ".len()
|
||||
IndentStyle::Visual => shape.indent + extra_indent + 6,
|
||||
};
|
||||
// FIXME: if where_pred_indent != Visual, then the budgets below might
|
||||
// FIXME: if indent_style != Visual, then the budgets below might
|
||||
// be out by a char or two.
|
||||
|
||||
let budget = context.config.max_width() - offset.width();
|
||||
|
|
@ -2737,7 +2737,7 @@ fn rewrite_where_clause(
|
|||
trailing_separator: comma_tactic,
|
||||
separator_place: SeparatorPlace::Back,
|
||||
shape: Shape::legacy(budget, offset),
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.where_pred_indent()),
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.indent_style()),
|
||||
preserve_newline: true,
|
||||
config: context.config,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ pub fn struct_lit_shape(
|
|||
prefix_width: usize,
|
||||
suffix_width: usize,
|
||||
) -> Option<(Option<Shape>, Shape)> {
|
||||
let v_shape = match context.config.struct_lit_indent() {
|
||||
let v_shape = match context.config.indent_style() {
|
||||
IndentStyle::Visual => shape
|
||||
.visual_indent(0)
|
||||
.shrink_left(prefix_width)?
|
||||
|
|
@ -766,7 +766,7 @@ pub fn struct_lit_tactic(
|
|||
items: &[ListItem],
|
||||
) -> DefinitiveListTactic {
|
||||
if let Some(h_shape) = h_shape {
|
||||
let prelim_tactic = match (context.config.struct_lit_indent(), items.len()) {
|
||||
let prelim_tactic = match (context.config.indent_style(), items.len()) {
|
||||
(IndentStyle::Visual, 1) => ListTactic::HorizontalVertical,
|
||||
_ => context.config.struct_lit_multiline_style().to_list_tactic(),
|
||||
};
|
||||
|
|
@ -797,7 +797,7 @@ pub fn struct_lit_formatting<'a>(
|
|||
context: &'a RewriteContext,
|
||||
force_no_trailing_comma: bool,
|
||||
) -> ListFormatting<'a> {
|
||||
let ends_with_newline = context.config.struct_lit_indent() != IndentStyle::Visual
|
||||
let ends_with_newline = context.config.indent_style() != IndentStyle::Visual
|
||||
&& tactic == DefinitiveListTactic::Vertical;
|
||||
ListFormatting {
|
||||
tactic: tactic,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl<'a> RewriteContext<'a> {
|
|||
|
||||
/// Return true if we should use block indent style for rewriting function call.
|
||||
pub fn use_block_indent(&self) -> bool {
|
||||
self.config.fn_call_indent() == IndentStyle::Block || self.use_block
|
||||
self.config.indent_style() == IndentStyle::Block || self.use_block
|
||||
}
|
||||
|
||||
pub fn budget(&self, used_width: usize) -> usize {
|
||||
|
|
|
|||
14
src/types.rs
14
src/types.rs
|
|
@ -18,7 +18,7 @@ use syntax::symbol::keywords;
|
|||
|
||||
use spanned::Spanned;
|
||||
use codemap::SpanUtils;
|
||||
use config::{IndentStyle, Style, TypeDensity};
|
||||
use config::{IndentStyle, TypeDensity};
|
||||
use expr::{rewrite_pair, rewrite_tuple, rewrite_unary_prefix, wrap_args_with_parens, PairParts};
|
||||
use items::{format_generics_item_list, generics_shape_from_config};
|
||||
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTactic, Separator,
|
||||
|
|
@ -302,7 +302,7 @@ where
|
|||
// 2 for ()
|
||||
let budget = shape.width.checked_sub(2)?;
|
||||
// 1 for (
|
||||
let offset = match context.config.fn_args_indent() {
|
||||
let offset = match context.config.indent_style() {
|
||||
IndentStyle::Block => {
|
||||
shape
|
||||
.block()
|
||||
|
|
@ -357,14 +357,14 @@ where
|
|||
},
|
||||
separator_place: SeparatorPlace::Back,
|
||||
shape: list_shape,
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.fn_call_indent()),
|
||||
ends_with_newline: tactic.ends_with_newline(context.config.indent_style()),
|
||||
preserve_newline: true,
|
||||
config: context.config,
|
||||
};
|
||||
|
||||
let list_str = write_list(&item_vec, &fmt)?;
|
||||
|
||||
let ty_shape = match context.config.fn_args_indent() {
|
||||
let ty_shape = match context.config.indent_style() {
|
||||
IndentStyle::Block => shape.block().block_indent(context.config.tab_spaces()),
|
||||
IndentStyle::Visual => shape.block_left(4)?,
|
||||
};
|
||||
|
|
@ -447,9 +447,9 @@ impl Rewrite for ast::WherePredicate {
|
|||
}
|
||||
} else {
|
||||
let used_width = type_str.len() + colon.len();
|
||||
let ty_shape = match context.config.where_style() {
|
||||
Style::Legacy => shape.block_left(used_width)?,
|
||||
Style::Rfc => shape,
|
||||
let ty_shape = match context.config.indent_style() {
|
||||
IndentStyle::Visual => shape.block_left(used_width)?,
|
||||
IndentStyle::Block => shape,
|
||||
};
|
||||
let bounds = bounds
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -6,13 +6,10 @@ fn_brace_style = "SameLineWhere"
|
|||
fn_return_indent = "WithArgs"
|
||||
fn_args_paren_newline = true
|
||||
fn_args_density = "Tall"
|
||||
fn_args_indent = "Visual"
|
||||
where_density = "Tall"
|
||||
where_layout = "Vertical"
|
||||
where_pred_indent = "Visual"
|
||||
generics_indent = "Visual"
|
||||
trailing_comma = "Vertical"
|
||||
struct_lit_indent = "Block"
|
||||
indent_style = "Block"
|
||||
report_todo = "Always"
|
||||
report_fixme = "Never"
|
||||
reorder_imports = false
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-where_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// #1357
|
||||
impl<
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
fn test() {
|
||||
let x = my_long_function().my_even_longer_function().my_nested_function().some_random_name().another_function().do_it();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
|
||||
fn test() {
|
||||
let x = my_long_function().my_even_longer_function().my_nested_function().some_random_name().another_function().do_it();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-single_line_if_else_max_width: 0
|
||||
// rustfmt-chain_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Test chain formatting.
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// #1547
|
||||
fuzz_target!(|data: &[u8]| if let Some(first) = data.first() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-array_horizontal_layout_threshold: 1000
|
||||
// rustfmt-array_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
|
||||
const ARRAY: [u8; 2048] =
|
||||
[99, 72, 48, 104, 44, 112, 38, 62, 40, 93, 23, 24, 32, 21, 102, 76, 65, 29, 116,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-array_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Array layout
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-array_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Array layout
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Chain indent
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Chain indent
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Function arguments layout
|
||||
|
||||
fn lorem() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Function arguments layout
|
||||
|
||||
fn lorem() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-error_on_line_overflow: false
|
||||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// rustfmt should not add trailing comma when rewriting macro. See #1528.
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Function call style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-error_on_line_overflow: false
|
||||
// rustfmt-fn_call_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
|
||||
// rustfmt should not add trailing comma when rewriting macro. See #1528.
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Function call style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-fn_call_width: 0
|
||||
// rustfmt-fn_call_indent: block
|
||||
// rustfmt-indent_style: block
|
||||
|
||||
// #1508
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Generics indent
|
||||
|
||||
fn lorem<Ipsum: Eq = usize, Dolor: Eq = usize, Sit: Eq = usize, 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 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-generics_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Generics indent
|
||||
|
||||
fn lorem<Ipsum: Eq = usize, Dolor: Eq = usize, Sit: Eq = usize, 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 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-struct_lit_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Struct literal-style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Struct literal-style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-tab_spaces: 2
|
||||
// rustfmt-max_width: 30
|
||||
// rustfmt-array_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Tab spaces
|
||||
|
||||
fn lorem() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-tab_spaces: 4
|
||||
// rustfmt-max_width: 30
|
||||
// rustfmt-array_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Tab spaces
|
||||
|
||||
fn lorem() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_pred_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Where predicate indent
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_pred_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Where predicate indent
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_style: Legacy
|
||||
// rustfmt-indent_style: Visual
|
||||
// Where style
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
// Where style
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
// rustfmt-array_indent: Block
|
||||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-control_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
// Test expressions with block formatting.
|
||||
|
||||
fn arrays() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-where_layout: Mixed
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-where_layout: HorizontalVertical
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_pred_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-where_density: Compressed
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_args_density: Vertical
|
||||
// rustfmt-fn_brace_style: AlwaysNextLine
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
fn foo() {
|
||||
foo();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent = "block"
|
||||
// rustfmt-indent_style = "block"
|
||||
|
||||
#![feature(pub_restricted)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
fn foo() {
|
||||
Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(f(), b());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-where_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
fn reflow_list_node_with_rule(node: &CompoundNode, rule: &Rule, args: &[Arg], shape: &Shape) where T: FOo, U: Bar {
|
||||
let mut effects = HashMap::new();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-where_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// #1357
|
||||
impl<'a, Select, From, Distinct, Where, Order, Limit, Offset, Groupby, DB> InternalBoxedDsl<'a, DB>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
fn test() {
|
||||
let x = my_long_function()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
|
||||
fn test() {
|
||||
let x = my_long_function().my_even_longer_function()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-single_line_if_else_max_width: 0
|
||||
// rustfmt-chain_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Test chain formatting.
|
||||
|
||||
fn main() {
|
||||
|
|
@ -17,17 +17,15 @@ fn main() {
|
|||
// Test case where first chain element isn't a path, but is shorter than
|
||||
// the size of a tab.
|
||||
x().y(|| match cond() {
|
||||
true => (),
|
||||
false => (),
|
||||
});
|
||||
true => (),
|
||||
false => (),
|
||||
});
|
||||
|
||||
loong_func().quux(move || {
|
||||
if true {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
}
|
||||
});
|
||||
loong_func().quux(move || if true {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
});
|
||||
|
||||
some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
|
||||
let x = c;
|
||||
|
|
@ -45,32 +43,28 @@ fn main() {
|
|||
|
||||
fffffffffffffffffffffffffffffffffff(a, {
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
*root.borrow_mut() = Some(&script_task);
|
||||
});
|
||||
*root.borrow_mut() = Some(&script_task);
|
||||
});
|
||||
});
|
||||
|
||||
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
|
||||
xxxxxxx.map(|x| x + 5)
|
||||
.map(|x| x / 2)
|
||||
.fold(0, |acc, x| acc + x);
|
||||
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx.map(|x| x + 5)
|
||||
.map(|x| x / 2)
|
||||
.fold(0,
|
||||
|acc, x| acc + x);
|
||||
|
||||
aaaaaaaaaaaaaaaa.map(|x| {
|
||||
x += 1;
|
||||
x
|
||||
})
|
||||
x += 1;
|
||||
x
|
||||
})
|
||||
.filter(some_mod::some_filter)
|
||||
}
|
||||
|
||||
fn floaters() {
|
||||
let z = Foo {
|
||||
field1: val1,
|
||||
field2: val2,
|
||||
};
|
||||
let z = Foo { field1: val1,
|
||||
field2: val2, };
|
||||
|
||||
let x = Foo {
|
||||
field1: val1,
|
||||
field2: val2,
|
||||
}.method_call()
|
||||
let x = Foo { field1: val1,
|
||||
field2: val2, }.method_call()
|
||||
.method_call();
|
||||
|
||||
let y = if cond {
|
||||
|
|
@ -83,12 +77,10 @@ fn floaters() {
|
|||
match x {
|
||||
PushParam => {
|
||||
// params are 1-indexed
|
||||
stack.push(
|
||||
mparams[match cur.to_digit(10) {
|
||||
Some(d) => d as usize - 1,
|
||||
None => return Err("bad param number".to_owned()),
|
||||
}].clone(),
|
||||
);
|
||||
stack.push(mparams[match cur.to_digit(10) {
|
||||
Some(d) => d as usize - 1,
|
||||
None => return Err("bad param number".to_owned()),
|
||||
}].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,18 +93,16 @@ fn floaters() {
|
|||
.baz();
|
||||
|
||||
Foo { x: val }.baz(|| {
|
||||
force();
|
||||
multiline();
|
||||
})
|
||||
force();
|
||||
multiline();
|
||||
})
|
||||
.quux();
|
||||
|
||||
Foo {
|
||||
y: i_am_multi_line,
|
||||
z: ok,
|
||||
}.baz(|| {
|
||||
force();
|
||||
multiline();
|
||||
})
|
||||
Foo { y: i_am_multi_line,
|
||||
z: ok, }.baz(|| {
|
||||
force();
|
||||
multiline();
|
||||
})
|
||||
.quux();
|
||||
|
||||
a + match x {
|
||||
|
|
@ -157,10 +147,8 @@ fn issue1434() {
|
|||
for _ in 0..100 {
|
||||
let prototype_id =
|
||||
PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor).chain_err(|| {
|
||||
format!(
|
||||
"could not read prototype ID at offset {:#010x}",
|
||||
current_offset
|
||||
)
|
||||
format!("could not read prototype ID at offset {:#010x}",
|
||||
current_offset)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// #1547
|
||||
fuzz_target!(|data: &[u8]| if let Some(first) = data.first() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-array_horizontal_layout_threshold: 1000
|
||||
// rustfmt-array_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
|
||||
const ARRAY: [u8; 2048] =
|
||||
[99, 72, 48, 104, 44, 112, 38, 62, 40, 93, 23, 24, 32, 21, 102, 76, 65, 29, 116, 21, 18, 37,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-array_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Array layout
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-array_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Array layout
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Chain indent
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-chain_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Chain indent
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-combine_control_expr: false
|
||||
// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-combine_control_expr: true
|
||||
// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-control_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// #1618
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Function arguments layout
|
||||
|
||||
fn lorem() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Function arguments layout
|
||||
|
||||
fn lorem() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-max_width: 80
|
||||
// rustfmt-tab_spaces: 2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-error_on_line_overflow: false
|
||||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
// rustfmt should not add trailing comma when rewriting macro. See #1528.
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Function call style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-error_on_line_overflow: false
|
||||
// rustfmt-fn_call_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
|
||||
// rustfmt should not add trailing comma when rewriting macro. See #1528.
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_call_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Function call style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-fn_call_width: 0
|
||||
// rustfmt-fn_call_indent: block
|
||||
// rustfmt-indent_style: block
|
||||
|
||||
// #1508
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Generics indent
|
||||
|
||||
fn lorem<
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-generics_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Generics indent
|
||||
|
||||
fn lorem<Ipsum: Eq = usize,
|
||||
|
|
@ -14,7 +14,7 @@ fn lorem<Ipsum: Eq = usize,
|
|||
amet: Amet,
|
||||
adipiscing: Adipiscing,
|
||||
consectetur: Consectetur,
|
||||
elit: Elit,
|
||||
) -> T {
|
||||
elit: Elit)
|
||||
-> T {
|
||||
// body
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-struct_lit_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Struct literal-style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Struct literal-style
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-tab_spaces: 2
|
||||
// rustfmt-max_width: 30
|
||||
// rustfmt-array_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Tab spaces
|
||||
|
||||
fn lorem() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-tab_spaces: 4
|
||||
// rustfmt-max_width: 30
|
||||
// rustfmt-array_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Tab spaces
|
||||
|
||||
fn lorem() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_pred_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// Where predicate indent
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
// rustfmt-where_pred_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// Where predicate indent
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
where
|
||||
Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq,
|
||||
where Ipsum: Eq,
|
||||
Dolor: Eq,
|
||||
Sit: Eq,
|
||||
Amet: Eq
|
||||
{
|
||||
// body
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_style: Legacy
|
||||
// rustfmt-indent_style: Visual
|
||||
// Where style
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
// Where style
|
||||
|
||||
fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
// rustfmt-array_indent: Block
|
||||
// rustfmt-fn_call_indent: Block
|
||||
// rustfmt-control_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
// Test expressions with block formatting.
|
||||
|
||||
fn arrays() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-where_layout: Mixed
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-generics_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-where_layout: HorizontalVertical
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-where_pred_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-where_density: Compressed
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_args_density: Vertical
|
||||
// rustfmt-fn_brace_style: AlwaysNextLine
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_brace_style: PreferSameLine
|
||||
// Test different indents.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
fn foo() {
|
||||
foo();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent = "block"
|
||||
// rustfmt-indent_style = "block"
|
||||
|
||||
#![feature(pub_restricted)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-indent_style: Block
|
||||
// rustfmt-fn_args_paren_newline: false
|
||||
|
||||
// #1624
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,47 +1,37 @@
|
|||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// rustfmt-struct_lit_indent: Visual
|
||||
// rustfmt-indent_style: Visual
|
||||
fn foo() {
|
||||
Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(f(), b());
|
||||
|
||||
Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(
|
||||
// Comment
|
||||
foo(), // Comment
|
||||
// Comment
|
||||
bar(), // Comment
|
||||
);
|
||||
Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(// Comment
|
||||
foo(), /* Comment */
|
||||
// Comment
|
||||
bar() /* Comment */);
|
||||
|
||||
Foo(Bar, f());
|
||||
|
||||
Quux(
|
||||
if cond {
|
||||
bar();
|
||||
},
|
||||
baz(),
|
||||
);
|
||||
Quux(if cond {
|
||||
bar();
|
||||
},
|
||||
baz());
|
||||
|
||||
Baz(
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
||||
zzzzz, // test
|
||||
);
|
||||
Baz(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
||||
zzzzz /* test */);
|
||||
|
||||
A(
|
||||
// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit
|
||||
// amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante
|
||||
// hendrerit. Donec et mollis dolor.
|
||||
item(),
|
||||
// Praesent et diam eget libero egestas mattis sit amet vitae augue.
|
||||
// Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
|
||||
Item,
|
||||
);
|
||||
A(// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit
|
||||
// amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante
|
||||
// hendrerit. Donec et mollis dolor.
|
||||
item(),
|
||||
// Praesent et diam eget libero egestas mattis sit amet vitae augue.
|
||||
// Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
|
||||
Item);
|
||||
|
||||
Diagram(
|
||||
// o This graph demonstrates how
|
||||
// / \ significant whitespace is
|
||||
// o o preserved.
|
||||
// /|\ \
|
||||
// o o o o
|
||||
G,
|
||||
)
|
||||
Diagram(// o This graph demonstrates how
|
||||
// / \ significant whitespace is
|
||||
// o o preserved.
|
||||
// /|\ \
|
||||
// o o o o
|
||||
G)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// rustfmt-fn_args_indent: Block
|
||||
// rustfmt-where_style: Rfc
|
||||
// rustfmt-indent_style: Block
|
||||
|
||||
fn reflow_list_node_with_rule(node: &CompoundNode, rule: &Rule, args: &[Arg], shape: &Shape)
|
||||
where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue