diff --git a/src/expr.rs b/src/expr.rs index 74d5522cc59..155553a7615 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1108,9 +1108,14 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext, } StructLitField::Base(ref expr) => { // 2 = .. - expr.rewrite(inner_context, h_budget - 2, indent + 2) - .map(|s| format!("..{}", s)) - .unwrap_or(context.snippet(expr.span)) + format!("..{}", + h_budget.checked_sub(2) + .and_then(|h_budget| { + expr.rewrite(inner_context, + h_budget, + indent + 2) + }) + .unwrap_or(context.snippet(expr.span))) } } }, diff --git a/tests/source/expr.rs b/tests/source/expr.rs index faa0d3775c7..4b5e262bd26 100644 --- a/tests/source/expr.rs +++ b/tests/source/expr.rs @@ -173,3 +173,11 @@ fn arrays() { [ 1 + 3, 4 , 5, 6, 7, 7, fncall::>(3-1)] } + +fn struct_exprs() { + Foo + { a : 1, b:f( 2)}; + Foo{a:1,b:f(2),..g(3)}; + // FIXME: should be wrapped (#231) + LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct { ..base }; +} diff --git a/tests/target/expr.rs b/tests/target/expr.rs index bb629f12126..7b579960d53 100644 --- a/tests/target/expr.rs +++ b/tests/target/expr.rs @@ -183,3 +183,10 @@ fn arrays() { [1 + 3, 4, 5, 6, 7, 7, fncall::>(3 - 1)] } + +fn struct_exprs() { + Foo { a: 1, b: f(2) }; + Foo { a: 1, b: f(2), ..g(3) }; + // FIXME: should be wrapped (#231) + LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct { ..base }; +}