Skip to content

Commit 9ae843a

Browse files
committed
Print parens on unops when necessary. 'make reformat' output now builds to stage3.
1 parent a1edf91 commit 9ae843a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/comp/front/parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ fn parse_binops(&parser p) -> @ast::expr {
12651265
ret parse_more_binops(p, parse_prefix_expr(p), 0);
12661266
}
12671267

1268+
const int unop_prec = 100;
12681269
const int as_prec = 5;
12691270

12701271
fn parse_more_binops(&parser p, @ast::expr lhs, int min_prec)

src/comp/pretty/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
551551
}
552552
case (ast::expr_unary(?op,?expr,_)) {
553553
word(s.s, ast::unop_to_str(op));
554-
print_expr(s, expr);
554+
print_maybe_parens(s, expr, front::parser::unop_prec);
555555
}
556556
case (ast::expr_lit(?lit,_)) {
557557
print_literal(s, lit);

0 commit comments

Comments
 (0)