Skip to content

Preserve box syntax #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
3 changes: 3 additions & 0 deletions tests/source/expr.rs
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
3 changes: 3 additions & 0 deletions tests/target/expr.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down