Skip to content

Commit e123366

Browse files
committed
Make the pretty-printer output new-style syntax for records
1 parent ce808bb commit e123366

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/comp/syntax/print/pprust.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,18 +301,18 @@ fn print_type(&ps s, &ast::ty ty) {
301301
pclose(s);
302302
}
303303
case (ast::ty_rec(?fields)) {
304-
word(s.s, "rec");
305-
popen(s);
304+
word(s.s, "{");
306305
fn print_field(&ps s, &ast::ty_field f) {
307306
cbox(s, indent_unit);
308-
print_mt(s, f.node.mt);
309-
space(s.s);
307+
print_mutability(s, f.node.mt.mut);
310308
word(s.s, f.node.ident);
309+
word_space(s, ":");
310+
print_type(s, *f.node.mt.ty);
311311
end(s);
312312
}
313313
fn get_span(&ast::ty_field f) -> codemap::span { ret f.span; }
314314
commasep_cmnt(s, consistent, fields, print_field, get_span);
315-
pclose(s);
315+
word(s.s, "}");
316316
}
317317
case (ast::ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) {
318318
print_ty_fn(s, proto, none[str], inputs, output, cf, constrs);
@@ -707,15 +707,14 @@ fn print_expr(&ps s, &@ast::expr expr) {
707707
ibox(s, indent_unit);
708708
if (field.node.mut == ast::mut) { word_nbsp(s, "mutable"); }
709709
word(s.s, field.node.ident);
710-
word(s.s, "=");
710+
word_space(s, ":");
711711
print_expr(s, field.node.expr);
712712
end(s);
713713
}
714714
fn get_span(&ast::field field) -> codemap::span {
715715
ret field.span;
716716
}
717-
word(s.s, "rec");
718-
popen(s);
717+
word(s.s, "{");
719718
commasep_cmnt(s, consistent, fields, print_field, get_span);
720719
alt (wth) {
721720
case (some(?expr)) {
@@ -727,7 +726,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
727726
}
728727
case (_) { }
729728
}
730-
pclose(s);
729+
word(s.s, "}");
731730
}
732731
case (ast::expr_call(?func, ?args)) {
733732
print_expr(s, func);

0 commit comments

Comments
 (0)