Skip to content

Commit 2d36a71

Browse files
kevinamarijnh
authored andcommitted
Update pretty printer to print out disr. values.
Partly fixes issue #1510. "rustc --pretty=typed" fails.
1 parent 13b9a16 commit 2d36a71

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/comp/syntax/print/pprust.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,14 @@ fn print_item(s: ps, &&item: @ast::item) {
428428
commasep(s, consistent, v.node.args, print_variant_arg);
429429
pclose(s);
430430
}
431+
alt v.node.disr_expr {
432+
some(expr) {
433+
nbsp(s);
434+
word_nbsp(s, "=");
435+
print_expr(s, expr);
436+
}
437+
_ {}
438+
}
431439
word(s.s, ";");
432440
maybe_print_trailing_comment(s, v.span, none::<uint>);
433441
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// pp-exact
2+
3+
enum color { red = 1; green; blue; imaginary = -1; }
4+
5+
fn main() {
6+
test_color(red, 1, "red");
7+
test_color(green, 2, "green");
8+
test_color(blue, 3, "blue");
9+
test_color(imaginary, -1, "imaginary");
10+
}
11+
12+
fn test_color(color: color, val: int, name: str) unsafe{
13+
assert (color as int == val);
14+
assert (color as float == val as float);
15+
}
16+

0 commit comments

Comments
 (0)