fix ICE due to untranslated inner items in unreachable code#16452
Merged
bors merged 3 commits intorust-lang:masterfrom Aug 13, 2014
spernsteiner:unreachable-item-ice
Merged
fix ICE due to untranslated inner items in unreachable code#16452bors merged 3 commits intorust-lang:masterfrom spernsteiner:unreachable-item-ice
bors merged 3 commits intorust-lang:masterfrom
spernsteiner:unreachable-item-ice
Conversation
Contributor
|
This PR has some kind of conflict, and can't be merged. It'll need a rebase. |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This code produces an ICE:
(playpen)
The error is "encode_symbol: id not found 18", where 18 is the
NodeIdof the declaration ofMAGIC. The problem is thatrustctries to emit metadata forMAGIC, but some of the information is missing becauseMAGICnever gets translated bytrans_item- the entire body of thematchgets skipped because thematchitself is unreachable.This branch simplifies the handling of inner items by always processing them using the
trans_itemvisitor, instead of sometimes using the visitor and sometimes waiting untiltrans_stmtencounters 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.