mozilla/rust — Issue #1532: pretty printer for uints sometimes drops the "u" suffix
Author: nikomatsakis
Created: 2012-01-15 18:01:29+00:00
State: open

If I run `rustc --pretty normal` with this input (`tag-disr-val-shape.rs`):

```
// xfail-pretty Issue #1510

tag color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
black = 0x000000;
white = 0xFFFFFF;
}

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];
}
```

then the `10u`s which appear in the asserts become `10`. Looking at the code, it's fairly clear that `ast_util::uint_ty_to_str()` is wrong:

```
fn uint_ty_to_str(t: uint_ty) -> str {
alt t {
ty_u. { "" } ty_u8. { "u8" } ty_u16. { "u16" }
ty_u32. { "u32" } ty_u64. { "u64" }
}
}
```

I was just going to fix this function... but then I found that almost every other example of printing `10u` which I have tried works! I cannot for the life of me figure out why. I *believe* I've even seen the output vary from run to run. So I'm wondering if there is a deeper bug: I've been digging into it but haven't found it yet. I'm getting a bit bored of this bug though and want to get hacking on other things, so I'm filing an issue. Anyhow, maybe someone else has some idea what's going on?