rust-lang/rust — pull request #16452 by epdtry (2014-08-12 16:55:40+00:00)
Title: fix ICE due to untranslated inner items in unreachable code

This code produces an ICE:

```rust
#![crate_type = "rlib"]
fn main() {
if true { return }
// remaining code is unreachable
match () {
() => { static MAGIC: uint = 0; }
}
}
```
([playpen](http://is.gd/iwOISB))

The error is "encode_symbol: id not found 18", where 18 is the `NodeId` of the declaration of `MAGIC`. The problem is that `rustc` tries to emit metadata for `MAGIC`, but some of the information is missing because `MAGIC` never gets translated by `trans_item` - the entire body of the `match` gets skipped because the `match` itself is unreachable.

This branch simplifies the handling of inner items by always processing them using the `trans_item` visitor, instead of sometimes using the visitor and sometimes waiting until `trans_stmt` encounters the item. This fixes the ICE by making the translation of the item no longer depend on the declaration being reachable code. This branch also reverts #16059 and #16359, since the new change to item translation fixes the same problems as those but is simpler.