Merge pull request from marcusklaas/box-syntax

Preserve box syntax
This commit is contained in:
Nick Cameron 2015-07-24 10:30:15 +12:00
commit 0fc8c37836
3 changed files with 10 additions and 2 deletions
src
tests
source
target

@ -378,11 +378,13 @@ fn rewrite_unary_op(context: &RewriteContext,
-> Option<String> {
// For some reason, an UnOp is not spanned like BinOp!
let operator_str = match *op {
ast::UnOp::UnUniq => "&",
ast::UnOp::UnUniq => "box ",
ast::UnOp::UnDeref => "*",
ast::UnOp::UnNot => "!",
ast::UnOp::UnNeg => "-"
};
Some(format!("{}{}", operator_str, try_opt!(expr.rewrite(context, width - 1, offset))))
let subexpr = try_opt!(expr.rewrite(context, width - operator_str.len(), offset));
Some(format!("{}{}", operator_str, subexpr))
}

@ -1,6 +1,9 @@
// Test expressions
fn foo() -> bool {
let boxed: Box<i32> = box 5;
let referenced = &5;
let very_long_variable_name = ( a + first + simple + test );
let very_long_variable_name = (a + first + simple + test + AAAAAAAAAAAAA + BBBBBBBBBBBBBBBBB + b + c);

@ -1,6 +1,9 @@
// Test expressions
fn foo() -> bool {
let boxed: Box<i32> = box 5;
let referenced = &5;
let very_long_variable_name = (a + first + simple + test);
let very_long_variable_name = (a + first + simple + test + AAAAAAAAAAAAA + BBBBBBBBBBBBBBBBB +
b + c);