Skip to content

Commit

Permalink
Register reads on the corrent HIR item
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Jul 11, 2016
1 parent 37d5c06 commit fd2b65e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/librustc_trans/trans_item.rs
Expand Up @@ -111,8 +111,14 @@ impl<'a, 'tcx> TransItem<'tcx> {
tcx.map.local_def_id(node_id)
}
TransItem::Fn(instance) => {
if instance.def.is_local() {
instance.def
if let Some(node) = tcx.map.as_local_node_id(instance.def) {
if let hir_map::Node::NodeItem(_) = tcx.map.get(node) {
// This already is a "real" item
instance.def
} else {
// Get the enclosing item and register a read on it
tcx.map.get_parent_did(node)
}
} else {
// Translating an inlined item from another crate? Don't track anything.
return;
Expand Down

0 comments on commit fd2b65e

Please sign in to comment.