Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 086c183

Browse files
committed
Use correct width when formatting type on local statement
1 parent cf44c07 commit 086c183

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/items.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,16 @@ impl Rewrite for ast::Local {
9494

9595
if let Some(ref ty) = self.ty {
9696
let separator = type_annotation_separator(context.config);
97-
let indent = shape.indent + last_line_width(&result) + separator.len();
98-
// 1 = ;
99-
let budget = shape.width.checked_sub(indent.width() + 1)?;
100-
let rewrite = ty.rewrite(context, Shape::legacy(budget, indent))?;
97+
let ty_shape = if pat_str.contains('\n') {
98+
shape.with_max_width(context.config)
99+
} else {
100+
shape
101+
}
102+
.offset_left(last_line_width(&result) + separator.len())?
103+
// 2 = ` =`
104+
.sub_width(2)?;
105+
106+
let rewrite = ty.rewrite(context, ty_shape)?;
101107

102108
infix.push_str(separator);
103109
infix.push_str(&rewrite);

0 commit comments

Comments
 (0)