Merge pull request #2239 from topecongiro/issue-2157

Fix double indented chained closure
This commit is contained in:
Nick Cameron 2017-12-05 16:56:52 +13:00 committed by GitHub
commit ae51f69de4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -150,7 +150,11 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
.collect::<Option<Vec<_>>>()?;
// 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 {

View file

@ -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

View file

@ -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;