Skip to content

Commit 3bd3a70

Browse files
committed
---
yaml --- r: 2861 b: refs/heads/master c: 2de1a4b h: refs/heads/master i: 2859: 95082d1 v: v3
1 parent 845b87f commit 3bd3a70

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cc96eeafca395ae2889ddfea8dc3194f2ad1c80d
2+
refs/heads/master: 2de1a4bb1b5acc63a280a18701cdfd14168d143e

trunk/src/comp/pretty/pprust.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -587,28 +587,42 @@ fn print_expr(&ps s, &@ast::expr expr) {
587587
print_type(s, *ty);
588588
}
589589
case (ast::expr_if(?test,?block,?elseopt,_)) {
590+
590591
head(s, "if");
591592
popen(s);
592593
print_expr(s, test);
593594
pclose(s);
594595
space(s.s);
595596
print_block(s, block);
596-
alt (elseopt) {
597-
case (option::some[@ast::expr](?_else)) {
598-
// NB: we can't use 'head' here since
599-
// it builds a block that starts in the
600-
// wrong column.
601-
cbox(s.s, indent_unit-1u);
602-
ibox(s.s, 0u);
603-
word(s.s, " else ");
604-
alt (_else.node) {
605-
case (ast::expr_block(?b, _)) {
606-
print_block(s, block);
597+
fn do_else(&ps s, option::t[@ast::expr] els) {
598+
alt (els) {
599+
case (option::some[@ast::expr](?_else)) {
600+
alt (_else.node) {
601+
// "another else-if"
602+
case (ast::expr_if(?i,?t,?e,_)) {
603+
cbox(s.s, indent_unit-1u);
604+
ibox(s.s, 0u);
605+
word(s.s, " else if ");
606+
popen(s);
607+
print_expr(s, i);
608+
pclose(s);
609+
space(s.s);
610+
print_block(s, t);
611+
do_else(s, e);
612+
}
613+
// "final else"
614+
case (ast::expr_block(?b, _)) {
615+
cbox(s.s, indent_unit-1u);
616+
ibox(s.s, 0u);
617+
word(s.s, " else ");
618+
print_block(s, b);
619+
}
607620
}
608621
}
622+
case (_) { /* fall through */ }
609623
}
610-
case (_) { /* fall through */ }
611624
}
625+
do_else(s, elseopt);
612626
}
613627
case (ast::expr_while(?test,?block,_)) {
614628
head(s, "while");

0 commit comments

Comments
 (0)