Skip to content

Conversation

@spernsteiner
Copy link
Contributor

This code produces an ICE:

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

(playpen)

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.

This reverts commit f97f65f.

Conflicts:
	src/librustc/middle/trans/base.rs
	src/librustc/middle/trans/foreign.rs
	src/librustc/middle/trans/monomorphize.rs
@steveklabnik
Copy link
Contributor

This PR has some kind of conflict, and can't be merged. It'll need a rebase.

@spernsteiner
Copy link
Contributor Author

OK, rebased it.

bors added a commit that referenced this pull request Aug 13, 2014
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.
@bors bors closed this Aug 13, 2014
@bors bors merged commit 0f847ba into rust-lang:master Aug 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants