Skip to content

Take width of return type into account for body shape of closure #2064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ fn rewrite_closure_fn_decl(
};
let list_str = write_list(&item_vec, &fmt)?;
let mut prefix = format!("{}|{}|", mover, list_str);
// 1 = space between `|...|` and body.
let extra_offset = extra_offset(&prefix, shape) + 1;

if !ret_str.is_empty() {
if prefix.contains('\n') {
Expand All @@ -597,6 +595,8 @@ fn rewrite_closure_fn_decl(
}
prefix.push_str(&ret_str);
}
// 1 = space between `|...|` and body.
let extra_offset = last_line_width(&prefix) + 1;

Some((prefix, extra_offset))
}
Expand Down
6 changes: 6 additions & 0 deletions tests/source/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,9 @@ fn issue1713() {
|| recurse(right, is_less, Some(pivot), limit),
);
}

fn issue2063() {
|ctx: Ctx<(String, String)>| -> io::Result<Response> {
Ok(Response::new().with_body(ctx.params.0))
}
}
6 changes: 6 additions & 0 deletions tests/target/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,9 @@ fn issue1713() {
|| recurse(right, is_less, Some(pivot), limit),
);
}

fn issue2063() {
|ctx: Ctx<(String, String)>| -> io::Result<Response> {
Ok(Response::new().with_body(ctx.params.0))
}
}