Skip to content

Commit ce1877d

Browse files
committed
Add parens, as needed, around else-if conditions.
1 parent 2c6eba0 commit ce1877d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/comp/syntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ fn print_if(s: ps, test: @ast::expr, blk: ast::blk,
625625
cbox(s, indent_unit - 1u);
626626
ibox(s, 0u);
627627
word(s.s, " else if ");
628-
print_expr(s, i);
628+
print_maybe_parens_discrim(s, i);
629629
space(s.s);
630630
print_block(s, t);
631631
do_else(s, e);

src/test/run-pass/wierd-exprs.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ fn what() {
2121
}
2222

2323
fn zombiejesus() {
24-
do { while (ret) { if (ret) { alt (ret) { _ { ret ? ret : ret } } } } }
25-
while ret
24+
do {
25+
while (ret) {
26+
if (ret) {
27+
alt (ret) { _ { ret ? ret : ret } };
28+
} else if (ret) {
29+
ret;
30+
}
31+
}
32+
} while ret
2633
}
2734

2835
fn notsure() {

0 commit comments

Comments
 (0)