Skip to content

Commit c5a8878

Browse files
committed
Continue formatting function calls even if it does not fit in a single line
We may be able to format it using multiple lines.
1 parent 093633e commit c5a8878

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

rustfmt-core/src/expr.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,12 +1908,16 @@ where
19081908
1
19091909
};
19101910
let used_width = extra_offset(callee_str, shape);
1911-
let one_line_width = shape.width.checked_sub(used_width + 2 * paren_overhead)?;
1911+
let one_line_width = shape
1912+
.width
1913+
.checked_sub(used_width + 2 * paren_overhead)
1914+
.unwrap_or(0);
19121915

19131916
// 1 = "(" or ")"
19141917
let one_line_shape = shape
1915-
.offset_left(last_line_width(callee_str) + 1)?
1916-
.sub_width(1)?;
1918+
.offset_left(last_line_width(callee_str) + 1)
1919+
.and_then(|shape| shape.sub_width(1))
1920+
.unwrap_or(Shape { width: 0, ..shape });
19171921
let nested_shape = shape_from_indent_style(
19181922
context,
19191923
shape,
@@ -1950,7 +1954,13 @@ where
19501954
);
19511955
}
19521956

1953-
let args_shape = shape.sub_width(last_line_width(callee_str))?;
1957+
let args_shape = Shape {
1958+
width: shape
1959+
.width
1960+
.checked_sub(last_line_width(callee_str))
1961+
.unwrap_or(0),
1962+
..shape
1963+
};
19541964
Some(format!(
19551965
"{}{}",
19561966
callee_str,

0 commit comments

Comments
 (0)