about summary refs log tree commit diff
path: root/src/expr.rs
diff options
context:
space:
mode:
authorBen Brittain <ben@brittain.org>2018-07-29 08:45:31 -0700
committerBen Brittain <ben@brittain.org>2018-07-29 08:55:36 -0700
commitfedde3790c32c4956b06ae45699f0f76b4502865 (patch)
tree704003056f507e40c97b8e322763faea5da6bc6b /src/expr.rs
parent0b25f602fd60dc0961d8e507919328889ceeb32e (diff)
Add tests for async & async move
Diffstat (limited to 'src/expr.rs')
-rw-r--r--src/expr.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 05020a419a9..65284182cb2 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -345,17 +345,28 @@ pub fn format_expr(
         }
         // FIXME(#2743)
         ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(),
-        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)
-            {
+        ast::ExprKind::Async(capture_by, _node_id, ref block) => {
+            let mover = if capture_by == ast::CaptureBy::Value {
+                "move "
+            } else {
+                ""
+            };
+            if let rw @ Some(_) = rewrite_single_line_block(
+                context,
+                format!("{}{}", "async ", mover).as_str(),
+                block,
+                Some(&expr.attrs),
+                None,
+                shape,
+            ) {
                 rw
             } else {
                 // 6 = `async `
                 let budget = shape.width.saturating_sub(6);
                 Some(format!(
-                    "{}{}",
+                    "{}{}{}",
                     "async ",
+                    mover,
                     rewrite_block(
                         block,
                         Some(&expr.attrs),