From b63e3aaa83e21ab78254d6bf8a1eb58b2bcccce2 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 30 May 2017 20:40:05 +0900 Subject: [PATCH] Put a space between nested tuple field --- src/chains.rs | 8 +++++++- tests/source/tuple.rs | 3 +++ tests/target/tuple.rs | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) 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() {