Remove remove_blank_lines_at_start_or_end_of_block

cc #1974
This commit is contained in:
Nick Cameron 2018-05-18 16:56:55 +12:00
parent dd9c15ad01
commit 2ee8b0e4c5
3 changed files with 50 additions and 95 deletions

View file

@ -1991,45 +1991,6 @@ fn bar() {
} }
``` ```
## `remove_blank_lines_at_start_or_end_of_block`
Remove blank lines at the start or the end of a block.
- **Default value**: `true`
- **Possible values**: `true`, `false`
- **Stable**: No
#### `true`
```rust
fn foo() {
let msg = {
let mut str = String::new();
str.push_str("hello, ");
str.push_str("world!");
str
};
println!("{}", msg);
}
```
#### `false`
```rust
fn foo() {
let msg = {
let mut str = String::new();
str.push_str("hello, ");
str.push_str("world!");
str
};
println!("{}", msg);
}
```
## `required_version` ## `required_version`

View file

@ -83,8 +83,6 @@ create_config! {
// Misc. // Misc.
remove_nested_parens: bool, true, true, "Remove nested parens."; remove_nested_parens: bool, true, true, "Remove nested parens.";
remove_blank_lines_at_start_or_end_of_block: bool, true, false,
"Remove blank lines at start or end of a block";
combine_control_expr: bool, true, false, "Combine control expressions with function calls."; combine_control_expr: bool, true, false, "Combine control expressions with function calls.";
struct_field_align_threshold: usize, 0, false, "Align struct fields if their diffs fits within \ struct_field_align_threshold: usize, 0, false, "Align struct fields if their diffs fits within \
threshold."; threshold.";

View file

@ -128,7 +128,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
self.block_indent = self.block_indent.block_indent(self.config); self.block_indent = self.block_indent.block_indent(self.config);
self.push_str("{"); self.push_str("{");
if self.config.remove_blank_lines_at_start_or_end_of_block() {
if let Some(first_stmt) = b.stmts.first() { if let Some(first_stmt) = b.stmts.first() {
let attr_lo = inner_attrs let attr_lo = inner_attrs
.and_then(|attrs| inner_attributes(attrs).first().map(|attr| attr.span.lo())) .and_then(|attrs| inner_attributes(attrs).first().map(|attr| attr.span.lo()))
@ -168,7 +167,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
self.last_pos = self.last_pos + BytePos::from_usize(len); self.last_pos = self.last_pos + BytePos::from_usize(len);
} }
} }
}
// Format inner attributes if available. // Format inner attributes if available.
let skip_rewrite = if let Some(attrs) = inner_attrs { let skip_rewrite = if let Some(attrs) = inner_attrs {
@ -195,7 +193,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
} }
let mut remove_len = BytePos(0); let mut remove_len = BytePos(0);
if self.config.remove_blank_lines_at_start_or_end_of_block() {
if let Some(stmt) = b.stmts.last() { if let Some(stmt) = b.stmts.last() {
let snippet = self.snippet(mk_sp( let snippet = self.snippet(mk_sp(
stmt.span.hi(), stmt.span.hi(),
@ -214,7 +211,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
remove_len = BytePos::from_usize(len); remove_len = BytePos::from_usize(len);
} }
} }
}
let unindent_comment = (self.is_if_else_block && !b.stmts.is_empty()) && { let unindent_comment = (self.is_if_else_block && !b.stmts.is_empty()) && {
let end_pos = source!(self, b.span).hi() - brace_compensation - remove_len; let end_pos = source!(self, b.span).hi() - brace_compensation - remove_len;