Skip to content

Commit 560b054

Browse files
authored
Merge pull request #2064 from topecongiro/issue-2063
Take width of return type into account for body shape of closure
2 parents 043ddf1 + 7cbdf35 commit 560b054

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,6 @@ fn rewrite_closure_fn_decl(
585585
};
586586
let list_str = write_list(&item_vec, &fmt)?;
587587
let mut prefix = format!("{}|{}|", mover, list_str);
588-
// 1 = space between `|...|` and body.
589-
let extra_offset = extra_offset(&prefix, shape) + 1;
590588

591589
if !ret_str.is_empty() {
592590
if prefix.contains('\n') {
@@ -597,6 +595,8 @@ fn rewrite_closure_fn_decl(
597595
}
598596
prefix.push_str(&ret_str);
599597
}
598+
// 1 = space between `|...|` and body.
599+
let extra_offset = last_line_width(&prefix) + 1;
600600

601601
Some((prefix, extra_offset))
602602
}

tests/source/closure.rs

+6
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,9 @@ fn issue1713() {
165165
|| recurse(right, is_less, Some(pivot), limit),
166166
);
167167
}
168+
169+
fn issue2063() {
170+
|ctx: Ctx<(String, String)>| -> io::Result<Response> {
171+
Ok(Response::new().with_body(ctx.params.0))
172+
}
173+
}

tests/target/closure.rs

+6
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,9 @@ fn issue1713() {
196196
|| recurse(right, is_less, Some(pivot), limit),
197197
);
198198
}
199+
200+
fn issue2063() {
201+
|ctx: Ctx<(String, String)>| -> io::Result<Response> {
202+
Ok(Response::new().with_body(ctx.params.0))
203+
}
204+
}

0 commit comments

Comments
 (0)