Skip to content

Commit 21a0f1b

Browse files
committed
Clarify indent calcs in compute_budget_for_args
1 parent fdd7bae commit 21a0f1b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/items.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ impl<'a> FmtVisitor<'a> {
136136
debug!("rewrite_fn: one_line_budget: {}, multi_line_budget: {}, arg_indent: {}",
137137
one_line_budget, multi_line_budget, arg_indent);
138138

139+
// Check if vertical layout was forced by compute_budget_for_args.
139140
if one_line_budget <= 0 {
140141
if config!(fn_args_paren_newline) {
141142
result.push('\n');
142143
result.push_str(&make_indent(arg_indent));
143-
arg_indent = arg_indent + 1;
144+
arg_indent = arg_indent + 1; // extra space for `(`
144145
result.push('(');
145146
} else {
146147
result.push_str("(\n");
@@ -378,15 +379,14 @@ impl<'a> FmtVisitor<'a> {
378379

379380
// Didn't work. we must force vertical layout and put args on a newline.
380381
if let None = budgets {
381-
// 6 = new indent + `()`
382-
let used_space = indent + 6;
382+
let new_indent = indent + 4;
383+
let used_space = new_indent + 2; // account for `(` and `)`
383384
let max_space = config!(ideal_width) + config!(leeway);
384385
if used_space > max_space {
385386
// Whoops! bankrupt.
386387
// TODO take evasive action, perhaps kill the indent or something.
387388
} else {
388-
// 5 = new indent + `(`
389-
budgets = Some((0, max_space - used_space, indent + 4));
389+
budgets = Some((0, max_space - used_space, new_indent));
390390
}
391391
}
392392

0 commit comments

Comments
 (0)