mozilla/rust — Issue #1511: C-like tags should be castable to int with or without custom discriminants
Author: nikomatsakis
Created: 2012-01-13 22:51:38+00:00
State: open

This type checks (`tag-disr-val-shape.rs`):

```
enum color {
red = 0;
green = 1;
blue = 2;
black = 3;
white = 4;
}

fn main() {
assert uint::to_str(red as uint, 10u) == #fmt["%?", red];
assert uint::to_str(green as uint, 10u) == #fmt["%?", green];
assert uint::to_str(white as uint, 10u) == #fmt["%?", white];
}
```

but this does not (`tag-auto-disr-val-shape.rs`):

```
enum color { red; green; blue; black; white; }

fn main() {
assert (uint::to_str(red as uint, 10) == #fmt["%?", red]);
assert (uint::to_str(green as uint, 10) == #fmt["%?", green]);
assert (uint::to_str(white as uint, 10) == #fmt["%?", white]);
}
```

However, the two programs are equivalent but for the fact that in one case the discriminants were automatically assigned.

When fixing this bug, please remove the `xfail-test` directives from those two test files!