Skip to content

Commit bf09e04

Browse files
committed
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.
1 parent cb2effd commit bf09e04

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_passes/src/hir_stats.rs

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
114114
self.visit_impl_item(nested_impl_item)
115115
}
116116

117+
fn visit_nested_foreign_item(&mut self, id: hir::ForeignItemId) {
118+
let nested_foreign_item = self.krate.unwrap().foreign_item(id);
119+
self.visit_foreign_item(nested_foreign_item);
120+
}
121+
117122
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
118123
let nested_body = self.krate.unwrap().body(body_id);
119124
self.visit_body(nested_body)

0 commit comments

Comments
 (0)