Skip to content

Commit e0ee751

Browse files
committed
---
yaml --- r: 4036 b: refs/heads/master c: c32f525 h: refs/heads/master v: v3
1 parent e74fdf1 commit e0ee751

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
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: 45748a3be4275258ada5ca23b09c6b2f0122ca3f
2+
refs/heads/master: c32f525f73b90dc30a6d6ff943cc716e43e84d73

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ fn rust_printer(ioivec::writer writer) -> ps {
6969
}
7070

7171
const uint indent_unit = 4u;
72+
const uint alt_indent_unit = 2u;
7273

7374
const uint default_columns = 78u;
7475

@@ -165,12 +166,14 @@ fn bopen(&ps s) {
165166

166167
}
167168

168-
fn bclose(&ps s, codemap::span span) {
169+
fn bclose_(&ps s, codemap::span span, uint indented) {
169170
maybe_print_comment(s, span.hi);
170-
break_offset(s.s, 1u, -(indent_unit as int));
171+
break_offset(s.s, 1u, -(indented as int));
171172
word(s.s, "}");
172173
end(s); // close the outer-box
173-
174+
}
175+
fn bclose(&ps s, codemap::span span) {
176+
bclose_(s, span, indent_unit);
174177
}
175178

176179
fn hardbreak_if_not_bol(&ps s) {
@@ -572,10 +575,11 @@ fn print_stmt(&ps s, &ast::stmt st) {
572575
}
573576

574577
fn print_block(&ps s, &ast::block blk) {
575-
print_possibly_embedded_block(s, blk, false);
578+
print_possibly_embedded_block(s, blk, false, indent_unit);
576579
}
577580

578-
fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded) {
581+
fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded,
582+
uint indented) {
579583
maybe_print_comment(s, blk.span.lo);
580584
auto ann_node = node_block(s, blk);
581585
s.ann.pre(ann_node);
@@ -593,7 +597,7 @@ fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded) {
593597
}
594598
case (_) { }
595599
}
596-
bclose(s, blk.span);
600+
bclose_(s, blk.span, indented);
597601
s.ann.post(ann_node);
598602
}
599603

@@ -603,9 +607,7 @@ fn print_if(&ps s, &@ast::expr test, &ast::block block,
603607
if (chk) {
604608
word_nbsp(s, "check");
605609
}
606-
popen(s);
607610
print_expr(s, test);
608-
pclose(s);
609611
space(s.s);
610612
print_block(s, block);
611613
fn do_else(&ps s, option::t[@ast::expr] els) {
@@ -658,7 +660,7 @@ fn print_mac(&ps s, &ast::mac m) {
658660
word(s.s, ">");
659661
}
660662
case (ast::mac_embed_block(?blk)) {
661-
print_possibly_embedded_block(s, blk, true);
663+
print_possibly_embedded_block(s, blk, true, indent_unit);
662664
}
663665
case (ast::mac_ellipsis) {
664666
word(s.s, "...");
@@ -788,9 +790,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
788790
}
789791
case (ast::expr_while(?test, ?block)) {
790792
head(s, "while");
791-
popen(s);
792793
print_expr(s, test);
793-
pclose(s);
794794
space(s.s);
795795
print_block(s, block);
796796
}
@@ -822,30 +822,30 @@ fn print_expr(&ps s, &@ast::expr expr) {
822822
print_block(s, block);
823823
space(s.s);
824824
word_space(s, "while");
825-
popen(s);
826825
print_expr(s, expr);
827-
pclose(s);
828826
}
829827
case (ast::expr_alt(?expr, ?arms)) {
830-
head(s, "alt");
831-
popen(s);
828+
cbox(s, alt_indent_unit);
829+
ibox(s, 4u);
830+
word_nbsp(s, "alt");
832831
print_expr(s, expr);
833-
pclose(s);
834832
space(s.s);
835833
bopen(s);
836834
for (ast::arm arm in arms) {
837835
space(s.s);
838-
head(s, "case");
836+
cbox(s, alt_indent_unit);
837+
ibox(s, 0u);
839838
auto first = true;
840839
for (@ast::pat p in arm.pats) {
841840
if (first) { first = false; }
842841
else { space(s.s); word_space(s, "|"); }
843842
print_pat(s, p);
844843
}
845844
space(s.s);
846-
print_block(s, arm.block);
845+
print_possibly_embedded_block(s, arm.block, false,
846+
alt_indent_unit);
847847
}
848-
bclose(s, expr.span);
848+
bclose_(s, expr.span, alt_indent_unit);
849849
}
850850
case (ast::expr_fn(?f)) {
851851
head(s, proto_to_str(f.proto));

0 commit comments

Comments
 (0)