mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
Clarify indent calcs in compute_budget_for_args
This commit is contained in:
parent
fdd7baeae9
commit
21a0f1b787
10
src/items.rs
10
src/items.rs
@ -136,11 +136,12 @@ impl<'a> FmtVisitor<'a> {
|
||||
debug!("rewrite_fn: one_line_budget: {}, multi_line_budget: {}, arg_indent: {}",
|
||||
one_line_budget, multi_line_budget, arg_indent);
|
||||
|
||||
// Check if vertical layout was forced by compute_budget_for_args.
|
||||
if one_line_budget <= 0 {
|
||||
if config!(fn_args_paren_newline) {
|
||||
result.push('\n');
|
||||
result.push_str(&make_indent(arg_indent));
|
||||
arg_indent = arg_indent + 1;
|
||||
arg_indent = arg_indent + 1; // extra space for `(`
|
||||
result.push('(');
|
||||
} else {
|
||||
result.push_str("(\n");
|
||||
@ -378,15 +379,14 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
// Didn't work. we must force vertical layout and put args on a newline.
|
||||
if let None = budgets {
|
||||
// 6 = new indent + `()`
|
||||
let used_space = indent + 6;
|
||||
let new_indent = indent + 4;
|
||||
let used_space = new_indent + 2; // account for `(` and `)`
|
||||
let max_space = config!(ideal_width) + config!(leeway);
|
||||
if used_space > max_space {
|
||||
// Whoops! bankrupt.
|
||||
// TODO take evasive action, perhaps kill the indent or something.
|
||||
} else {
|
||||
// 5 = new indent + `(`
|
||||
budgets = Some((0, max_space - used_space, indent + 4));
|
||||
budgets = Some((0, max_space - used_space, new_indent));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user