From b45a69699aa002e3afd764c3900d52f112855362 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 5 Dec 2017 10:02:49 +0900 Subject: [PATCH 1/2] Add a test for #2157 --- tests/source/chains.rs | 8 ++++++++ tests/target/chains.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/source/chains.rs b/tests/source/chains.rs index 0141326269b..0977212ef21 100644 --- a/tests/source/chains.rs +++ b/tests/source/chains.rs @@ -53,6 +53,14 @@ fn main() { .map(|x| x / 2) .fold(0, |acc, x| acc + x); + body.fold(Body::new(), |mut body, chunk| { + body.extend(chunk); + Ok(body) + }).and_then(move |body| { + let req = Request::from_parts(parts, body); + f(req).map_err(|_| io::Error::new(io::ErrorKind::Other, "")) + }); + aaaaaaaaaaaaaaaa.map(|x| { x += 1; x diff --git a/tests/target/chains.rs b/tests/target/chains.rs index 61ba04347e0..6e1fc809764 100644 --- a/tests/target/chains.rs +++ b/tests/target/chains.rs @@ -54,6 +54,14 @@ fn main() { let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx.map(|x| x + 5).map(|x| x / 2).fold(0, |acc, x| acc + x); + body.fold(Body::new(), |mut body, chunk| { + body.extend(chunk); + Ok(body) + }).and_then(move |body| { + let req = Request::from_parts(parts, body); + f(req).map_err(|_| io::Error::new(io::ErrorKind::Other, "")) + }); + aaaaaaaaaaaaaaaa .map(|x| { x += 1; From 0c1eb20575c6d95ac50a5e732130a15808364656 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 5 Dec 2017 10:03:23 +0900 Subject: [PATCH 2/2] Fix indent of chain with small parent --- src/chains.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chains.rs b/src/chains.rs index 642fb93c3ba..816ce60ad4d 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -150,7 +150,11 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - .collect::>>()?; // Total of all items excluding the last. - let extend_last_subexpr = last_line_extendable(&parent_rewrite) && rewrites.is_empty(); + let extend_last_subexpr = if is_small_parent { + rewrites.len() == 1 && last_line_extendable(&rewrites[0]) + } else { + rewrites.is_empty() && last_line_extendable(&parent_rewrite) + }; let almost_total = if extend_last_subexpr { last_line_width(&parent_rewrite) } else {