about summary refs log tree commit diff
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2017-05-30 20:40:05 +0900
committertopecongiro <seuchida@gmail.com>2017-05-30 20:40:05 +0900
commitb63e3aaa83e21ab78254d6bf8a1eb58b2bcccce2 (patch)
treeb49e8f7c0ef4845f166ce0c5bc1cc37b71d88146
parentb79094262f9737b3fd0379fdd2cb0fc6e23008ad (diff)
Put a space between nested tuple field
-rw-r--r--src/chains.rs8
-rw-r--r--tests/source/tuple.rs3
-rw-r--r--tests/target/tuple.rs3
3 files changed, 13 insertions, 1 deletions
diff --git a/src/chains.rs b/src/chains.rs
index 1c66306022d..752e7110655 100644
--- a/src/chains.rs
+++ b/src/chains.rs
@@ -454,7 +454,13 @@ fn rewrite_chain_subexpr(expr: &ast::Expr,
             rewrite_method_call(method_name.node, types, expressions, span, context, shape)
         }
         ast::ExprKind::Field(_, ref field) => rewrite_element(format!(".{}", field.node)),
-        ast::ExprKind::TupField(_, ref field) => rewrite_element(format!(".{}", field.node)),
+        ast::ExprKind::TupField(ref expr, ref field) => {
+            let space = match expr.node {
+                ast::ExprKind::TupField(..) => " ",
+                _ => "",
+            };
+            rewrite_element(format!("{}.{}", space, field.node))
+        }
         ast::ExprKind::Try(_) => rewrite_element(String::from("?")),
         _ => unreachable!(),
     }
diff --git a/tests/source/tuple.rs b/tests/source/tuple.rs
index d47777734bb..fcfcff3a39b 100644
--- a/tests/source/tuple.rs
+++ b/tests/source/tuple.rs
@@ -12,6 +12,9 @@ fn foo() {
     let b = (// This is a comment
              b, // Comment
              b /* Trailing comment */);
+
+    // #1063
+    foo(x.0 .0);
 }
 
 fn a() {
diff --git a/tests/target/tuple.rs b/tests/target/tuple.rs
index 2d3b52da72a..16fc3df020f 100644
--- a/tests/target/tuple.rs
+++ b/tests/target/tuple.rs
@@ -12,6 +12,9 @@ fn foo() {
     let b = (// This is a comment
              b, // Comment
              b /* Trailing comment */);
+
+    // #1063
+    foo(x.0 .0);
 }
 
 fn a() {