Remove match_arm_forces_newline

This commit is contained in:
Nick Cameron 2017-11-27 16:31:49 +13:00
parent 0e1fa2c244
commit 087f8b5854
5 changed files with 1 additions and 113 deletions

View File

@ -1108,47 +1108,6 @@ use foo::{aaa,
fff};
```
## `match_arm_forces_newline`
Consistently put match arms (block based or not) in a newline.
- **Default value**: `false`
- **Possible values**: `true`, `false`
#### `false` (default):
```rust
match x {
// a non-empty block
X0 => {
f();
}
// an empty block
X1 => {}
// a non-block
X2 => println!("ok"),
}
```
#### `true`:
```rust
match x {
// a non-empty block
X0 => {
f();
}
// an empty block
X1 =>
{}
// a non-block
X2 => {
println!("ok")
}
}
```
See also: [`wrap_match_arms`](#wrap_match_arms).
## `match_block_trailing_comma`

View File

@ -625,8 +625,6 @@ create_config! {
"Force multiline match arm bodies to be wrapped in a block";
match_block_trailing_comma: bool, false, false,
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
match_arm_forces_newline: bool, false, false,
"Force match arm bodies to be in a new lines";
// Spaces around punctuation
binop_separator: SeparatorPlace, SeparatorPlace::Front, false,

View File

@ -1529,11 +1529,6 @@ fn rewrite_match_body(
} else {
(false, false)
};
let extend = if context.config.match_arm_forces_newline() {
is_block
} else {
extend
};
let comma = arm_comma(context.config, body, is_last);
let alt_block_sep = String::from("\n") + &shape.indent.block_only().to_string(context.config);
@ -1606,7 +1601,7 @@ fn rewrite_match_body(
match rewrite {
Some(ref body_str)
if !forbid_same_line && !context.config.match_arm_forces_newline()
if !forbid_same_line
&& (is_block
|| (!body_str.contains('\n') && body_str.len() <= body_shape.width)) =>
{

View File

@ -1,20 +0,0 @@
// rustfmt-match_arm_forces_newline: true
// rustfmt-wrap_match_arms: false
// match_arm_forces_newline puts all match arms bodies in a newline and indents
// them.
fn main() {
match x() {
// a short non-empty block
X0 => { f(); }
// a long non-empty block
X1 => { some.really.long.expression.fooooooooooooooooooooooooooooooooooooooooo().baaaaarrrrrrrrrrrrrrrrrrrrrrrrrr(); }
// an empty block
X2 => {}
// a short non-block
X3 => println!("ok"),
// a long non-block
X4 => foo.bar.baz.test.x.y.z.a.s.d.fasdfasdf.asfads.fasd.fasdfasdf.dfasfdsaf(),
}
}

View File

@ -1,44 +0,0 @@
// rustfmt-match_arm_forces_newline: true
// rustfmt-wrap_match_arms: false
// match_arm_forces_newline puts all match arms bodies in a newline and indents
// them.
fn main() {
match x() {
// a short non-empty block
X0 => {
f();
}
// a long non-empty block
X1 => {
some.really
.long
.expression
.fooooooooooooooooooooooooooooooooooooooooo()
.baaaaarrrrrrrrrrrrrrrrrrrrrrrrrr();
}
// an empty block
X2 =>
{}
// a short non-block
X3 =>
println!("ok"),
// a long non-block
X4 =>
foo.bar
.baz
.test
.x
.y
.z
.a
.s
.d
.fasdfasdf
.asfads
.fasd
.fasdfasdf
.dfasfdsaf(),
}
}