diff options
| author | Ben Brittain <ben@brittain.org> | 2018-07-29 07:37:24 -0700 |
|---|---|---|
| committer | Ben Brittain <ben@brittain.org> | 2018-07-29 08:05:38 -0700 |
| commit | 0b25f602fd60dc0961d8e507919328889ceeb32e (patch) | |
| tree | d943c9d73905a2bb749ac2ec7abd53c0aabe6f31 /src/expr.rs | |
| parent | 69ad879d52606ac03440744efa5b4d8ca8cc7566 (diff) | |
Format Async block and async fn
Diffstat (limited to 'src/expr.rs')
| -rw-r--r-- | src/expr.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/expr.rs b/src/expr.rs index 6814b91e053..05020a419a9 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -345,8 +345,27 @@ pub fn format_expr( } // FIXME(#2743) ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(), - // FIXME(topecongiro) Format async block. - ast::ExprKind::Async(..) => None, + ast::ExprKind::Async(_capture_by, _node_id, ref block) => { + if let rw @ Some(_) = + rewrite_single_line_block(context, "async ", block, Some(&expr.attrs), None, shape) + { + rw + } else { + // 6 = `async ` + let budget = shape.width.saturating_sub(6); + Some(format!( + "{}{}", + "async ", + rewrite_block( + block, + Some(&expr.attrs), + None, + context, + Shape::legacy(budget, shape.indent) + )? + )) + } + } }; expr_rw |
