Skip to content

Commit

Permalink
Rollup merge of rust-lang#82258 - tmiasko:foreign-hir-stats, r=davidtwco
Browse files Browse the repository at this point in the history
Implement -Z hir-stats for nested foreign items

An attempt to compute HIR stats for crates with nested foreign items results in an ICE.

```rust
fn main() {
    extern "C" { fn f(); }
}
```

```
thread 'rustc' panicked at 'visit_nested_xxx must be manually implemented in this visitor'
```

Provide required implementation of visitor method.
  • Loading branch information
Dylan-DPC authored Feb 23, 2021
2 parents 547b3ad + bf09e04 commit 2982ba5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_passes/src/hir_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
self.visit_impl_item(nested_impl_item)
}

fn visit_nested_foreign_item(&mut self, id: hir::ForeignItemId) {
let nested_foreign_item = self.krate.unwrap().foreign_item(id);
self.visit_foreign_item(nested_foreign_item);
}

fn visit_nested_body(&mut self, body_id: hir::BodyId) {
let nested_body = self.krate.unwrap().body(body_id);
self.visit_body(nested_body)
Expand Down

0 comments on commit 2982ba5

Please sign in to comment.