Skip to content

Commit f99b775

Browse files
committed
Rename is_dummy to has_braces
1 parent 1323abf commit f99b775

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/closures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn rewrite_closure_with_block(
131131
rules: ast::BlockCheckMode::Default,
132132
span: body.span,
133133
};
134-
let block = ::expr::rewrite_block_with_visitor(context, "", &block, shape, true)?;
134+
let block = ::expr::rewrite_block_with_visitor(context, "", &block, shape, false)?;
135135
Some(format!("{} {}", prefix, block))
136136
}
137137

src/expr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn format_expr(
116116
rw
117117
} else {
118118
let prefix = block_prefix(context, block, shape)?;
119-
rewrite_block_with_visitor(context, &prefix, block, shape, false)
119+
rewrite_block_with_visitor(context, &prefix, block, shape, true)
120120
}
121121
}
122122
ExprType::SubExpression => block.rewrite(context, shape),
@@ -603,7 +603,7 @@ pub fn rewrite_block_with_visitor(
603603
prefix: &str,
604604
block: &ast::Block,
605605
shape: Shape,
606-
is_dummy: bool,
606+
has_braces: bool,
607607
) -> Option<String> {
608608
if let rw @ Some(_) = rewrite_empty_block(context, block, shape) {
609609
return rw;
@@ -621,7 +621,7 @@ pub fn rewrite_block_with_visitor(
621621
ast::BlockCheckMode::Default => visitor.last_pos = block.span.lo(),
622622
}
623623

624-
visitor.visit_block(block, None, is_dummy);
624+
visitor.visit_block(block, None, has_braces);
625625
Some(format!("{}{}", prefix, visitor.buffer))
626626
}
627627

@@ -636,7 +636,7 @@ impl Rewrite for ast::Block {
636636
let prefix = block_prefix(context, self, shape)?;
637637
let shape = shape.offset_left(last_line_width(&prefix))?;
638638

639-
let result = rewrite_block_with_visitor(context, &prefix, self, shape, false);
639+
let result = rewrite_block_with_visitor(context, &prefix, self, shape, true);
640640
if let Some(ref result_str) = result {
641641
if result_str.lines().count() <= 3 {
642642
if let rw @ Some(_) = rewrite_single_line_block(context, &prefix, self, shape) {
@@ -1067,7 +1067,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
10671067
let mut block_context = context.clone();
10681068
block_context.is_if_else_block = self.else_block.is_some();
10691069
let block_str =
1070-
rewrite_block_with_visitor(&block_context, "", self.block, block_shape, false)?;
1070+
rewrite_block_with_visitor(&block_context, "", self.block, block_shape, true)?;
10711071

10721072
let mut result = format!("{}{}", cond_str, block_str);
10731073

src/visitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'a> FmtVisitor<'a> {
9494
&mut self,
9595
b: &ast::Block,
9696
inner_attrs: Option<&[ast::Attribute]>,
97-
is_dummy: bool,
97+
has_braces: bool,
9898
) {
9999
debug!(
100100
"visit_block: {:?} {:?}",
@@ -103,7 +103,7 @@ impl<'a> FmtVisitor<'a> {
103103
);
104104

105105
// Check if this block has braces.
106-
let brace_compensation = BytePos(if is_dummy { 0 } else { 1 });
106+
let brace_compensation = BytePos(if has_braces { 1 } else { 0 });
107107

108108
self.last_pos = self.last_pos + brace_compensation;
109109
self.block_indent = self.block_indent.block_indent(self.config);
@@ -275,7 +275,7 @@ impl<'a> FmtVisitor<'a> {
275275
}
276276

277277
self.last_pos = source!(self, block.span).lo();
278-
self.visit_block(block, inner_attrs, false)
278+
self.visit_block(block, inner_attrs, true)
279279
}
280280

281281
pub fn visit_item(&mut self, item: &ast::Item) {

0 commit comments

Comments
 (0)