From 4e0882ea67a785733ab54dbef195cea56211b0db Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 29 Jun 2017 11:00:51 +0900 Subject: [PATCH 1/2] Combine Array --- src/expr.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/expr.rs b/src/expr.rs index 35c028d24db..e771216dee9 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2404,9 +2404,10 @@ pub fn can_be_overflowed_expr(context: &RewriteContext, expr: &ast::Expr, args_l context.use_block_indent() || context.config.fn_call_style() == IndentStyle::Visual && args_len > 1 } + ast::ExprKind::Array(..) | ast::ExprKind::Call(..) | - ast::ExprKind::MethodCall(..) | ast::ExprKind::Mac(..) | + ast::ExprKind::MethodCall(..) | ast::ExprKind::Struct(..) | ast::ExprKind::Tup(..) => context.use_block_indent() && args_len == 1, ast::ExprKind::AddrOf(_, ref expr) | From c762cf9b43966e46910abd22cd78ce3c04bdcd5a Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 29 Jun 2017 11:01:22 +0900 Subject: [PATCH 2/2] Update tests --- tests/target/expr-block.rs | 14 ++++++-------- tests/target/expr.rs | 38 ++++++++++++++++++-------------------- tests/target/tuple.rs | 26 ++++++++++++-------------- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/tests/target/expr-block.rs b/tests/target/expr-block.rs index bbefa62b301..953935baec9 100644 --- a/tests/target/expr-block.rs +++ b/tests/target/expr-block.rs @@ -96,14 +96,12 @@ fn arrays() { 1, ]; - let a = WeightedChoice::new( - &mut [ - Weighted { weight: x, item: 0 }, - Weighted { weight: 1, item: 1 }, - Weighted { weight: x, item: 2 }, - Weighted { weight: 1, item: 3 }, - ], - ); + let a = WeightedChoice::new(&mut [ + Weighted { weight: x, item: 0 }, + Weighted { weight: 1, item: 1 }, + Weighted { weight: x, item: 2 }, + Weighted { weight: 1, item: 3 }, + ]); let z = [ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, diff --git a/tests/target/expr.rs b/tests/target/expr.rs index b6509040714..aad9f6d1b5f 100644 --- a/tests/target/expr.rs +++ b/tests/target/expr.rs @@ -224,26 +224,24 @@ fn arrays() { 1, ]; - let a = WeightedChoice::new( - &mut [ - Weighted { - weightweight: x, - item: 0, - }, - Weighted { - weightweight: 1, - item: 1, - }, - Weighted { - weightweight: x, - item: 2, - }, - Weighted { - weightweight: 1, - item: 3, - }, - ], - ); + let a = WeightedChoice::new(&mut [ + Weighted { + weightweight: x, + item: 0, + }, + Weighted { + weightweight: 1, + item: 1, + }, + Weighted { + weightweight: x, + item: 2, + }, + Weighted { + weightweight: 1, + item: 3, + }, + ]); let z = [ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, diff --git a/tests/target/tuple.rs b/tests/target/tuple.rs index 0b82e482136..954fe011f14 100644 --- a/tests/target/tuple.rs +++ b/tests/target/tuple.rs @@ -62,20 +62,18 @@ fn issue550() { fn issue775() { if indent { - let a = mk_object( - &[ - ("a".to_string(), Boolean(true)), - ( - "b".to_string(), - Array(vec![ - mk_object( - &[("c".to_string(), String("\x0c\r".to_string()))], - ), - mk_object(&[("d".to_string(), String("".to_string()))]), - ]), - ), - ], - ); + let a = mk_object(&[ + ("a".to_string(), Boolean(true)), + ( + "b".to_string(), + Array(vec![ + mk_object( + &[("c".to_string(), String("\x0c\r".to_string()))], + ), + mk_object(&[("d".to_string(), String("".to_string()))]), + ]), + ), + ]); } }