From bbfdb12c3e5f7445f00b0cf4231f1eadeed370a2 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 8 Nov 2017 11:52:14 +0900 Subject: [PATCH 1/3] Add a test for #2125 --- tests/source/structs.rs | 3 +++ tests/target/structs.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tests/source/structs.rs b/tests/source/structs.rs index acae17befdd4..6dfb565e80bf 100644 --- a/tests/source/structs.rs +++ b/tests/source/structs.rs @@ -266,3 +266,6 @@ pub(crate) struct Foo{} pub(in self) struct Foo(); pub(super) struct Foo(); pub(crate) struct Foo(); + +// #2125 +pub struct ReadinessCheckRegistry(Mutex, Box ReadinessCheck + Sync + Send>>>); diff --git a/tests/target/structs.rs b/tests/target/structs.rs index e29647c71fbb..1628c96f5552 100644 --- a/tests/target/structs.rs +++ b/tests/target/structs.rs @@ -308,3 +308,8 @@ pub(crate) struct Foo {} pub(self) struct Foo(); pub(super) struct Foo(); pub(crate) struct Foo(); + +// #2125 +pub struct ReadinessCheckRegistry( + Mutex, Box ReadinessCheck + Sync + Send>>>, +); From 19a3b0b5ca863ea842c479d05ea343504acdcc77 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 8 Nov 2017 11:52:25 +0900 Subject: [PATCH 2/3] Use struct prefix as a callee --- src/items.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/items.rs b/src/items.rs index 731ce2343886..6cfcc3dd4b11 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1282,16 +1282,15 @@ fn format_tuple_struct( result.push(')'); } else { // 1 = "," - let body = rewrite_call_inner( + result = rewrite_call_inner( context, - "", + &result, &fields.iter().map(|field| field).collect::>()[..], span, Shape::indented(offset, context.config).sub_width(1)?, context.config.fn_call_width(), false, )?; - result.push_str(&body); } if !where_clause_str.is_empty() && !where_clause_str.contains('\n') From 9337760dd9d8f0a7b2b9cdff38685e2e0db193ec Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 8 Nov 2017 11:53:13 +0900 Subject: [PATCH 3/3] Refactor: use less vertical lines --- src/items.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/items.rs b/src/items.rs index 6cfcc3dd4b11..f311da0afeea 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1281,16 +1281,10 @@ fn format_tuple_struct( } result.push(')'); } else { - // 1 = "," - result = rewrite_call_inner( - context, - &result, - &fields.iter().map(|field| field).collect::>()[..], - span, - Shape::indented(offset, context.config).sub_width(1)?, - context.config.fn_call_width(), - false, - )?; + let shape = Shape::indented(offset, context.config); + let fields = &fields.iter().map(|field| field).collect::>()[..]; + let one_line_width = context.config.fn_call_width(); + result = rewrite_call_inner(context, &result, fields, span, shape, one_line_width, false)?; } if !where_clause_str.is_empty() && !where_clause_str.contains('\n')