Update pretty printer to print out disr. values.

Partly fixes issue #1510.  "rustc --pretty=typed" fails.
This commit is contained in:
Kevin Atkinson 2012-01-15 19:56:20 -07:00 committed by Marijn Haverbeke
parent 13b9a16a7b
commit 2d36a71aee
2 changed files with 24 additions and 0 deletions

View File

@ -428,6 +428,14 @@ fn print_item(s: ps, &&item: @ast::item) {
commasep(s, consistent, v.node.args, print_variant_arg);
pclose(s);
}
alt v.node.disr_expr {
some(expr) {
nbsp(s);
word_nbsp(s, "=");
print_expr(s, expr);
}
_ {}
}
word(s.s, ";");
maybe_print_trailing_comment(s, v.span, none::<uint>);
}

View File

@ -0,0 +1,16 @@
// pp-exact
enum color { red = 1; green; blue; imaginary = -1; }
fn main() {
test_color(red, 1, "red");
test_color(green, 2, "green");
test_color(blue, 3, "blue");
test_color(imaginary, -1, "imaginary");
}
fn test_color(color: color, val: int, name: str) unsafe{
assert (color as int == val);
assert (color as float == val as float);
}