Skip to content

Commit f07dec3

Browse files
authored
Merge pull request #1940 from topecongiro/issue-1934
Avoid rewriting big block twice
2 parents 3f3d925 + 68da44e commit f07dec3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/expr.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,11 +855,17 @@ impl Rewrite for ast::Block {
855855
}
856856

857857
let prefix = try_opt!(block_prefix(context, self, shape));
858-
if let rw @ Some(_) = rewrite_single_line_block(context, &prefix, self, shape) {
859-
return rw;
858+
859+
let result = rewrite_block_with_visitor(context, &prefix, self, shape);
860+
if let Some(ref result_str) = result {
861+
if result_str.lines().count() <= 3 {
862+
if let rw @ Some(_) = rewrite_single_line_block(context, &prefix, self, shape) {
863+
return rw;
864+
}
865+
}
860866
}
861867

862-
rewrite_block_with_visitor(context, &prefix, self, shape)
868+
result
863869
}
864870
}
865871

0 commit comments

Comments
 (0)