File tree Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: cc96eeafca395ae2889ddfea8dc3194f2ad1c80d
2
+ refs/heads/master: 2de1a4bb1b5acc63a280a18701cdfd14168d143e
Original file line number Diff line number Diff line change @@ -587,28 +587,42 @@ fn print_expr(&ps s, &@ast::expr expr) {
587
587
print_type ( s, * ty) ;
588
588
}
589
589
case ( ast:: expr_if ( ?test, ?block, ?elseopt, _) ) {
590
+
590
591
head ( s, "if" ) ;
591
592
popen ( s) ;
592
593
print_expr ( s, test) ;
593
594
pclose ( s) ;
594
595
space ( s. s ) ;
595
596
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-1 u) ;
602
- ibox ( s. s , 0 u) ;
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-1 u) ;
604
+ ibox ( s. s , 0 u) ;
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-1 u) ;
616
+ ibox ( s. s , 0 u) ;
617
+ word ( s. s , " else " ) ;
618
+ print_block ( s, b) ;
619
+ }
607
620
}
608
621
}
622
+ case ( _) { /* fall through */ }
609
623
}
610
- case ( _) { /* fall through */ }
611
624
}
625
+ do_else ( s, elseopt) ;
612
626
}
613
627
case ( ast:: expr_while ( ?test, ?block, _) ) {
614
628
head ( s, "while" ) ;
You can’t perform that action at this time.
0 commit comments