diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-02-18 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-02-18 00:00:00 +0000 |
| commit | bf09e0499e30a39426695c149c8a45c0c06bf715 (patch) | |
| tree | c976049f3ff4985c1029c219211ba7e8b6160f66 | |
| parent | cb2effd44e667d133e31ef334e30d10195218ce6 (diff) | |
| download | rust-bf09e0499e30a39426695c149c8a45c0c06bf715.tar.gz rust-bf09e0499e30a39426695c149c8a45c0c06bf715.zip | |
Implement -Z hir-stats for nested foreign items
An attempt to compute HIR stats for crates with nested foreign items results in an ICE.
```
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.
| -rw-r--r-- | compiler/rustc_passes/src/hir_stats.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index e35ad10968d..177e4e2d08f 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -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) |
