Skip to content

Commit fd2b65e

Browse files
Register reads on the corrent HIR item
1 parent 37d5c06 commit fd2b65e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/librustc_trans/trans_item.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,14 @@ impl<'a, 'tcx> TransItem<'tcx> {
111111
tcx.map.local_def_id(node_id)
112112
}
113113
TransItem::Fn(instance) => {
114-
if instance.def.is_local() {
115-
instance.def
114+
if let Some(node) = tcx.map.as_local_node_id(instance.def) {
115+
if let hir_map::Node::NodeItem(_) = tcx.map.get(node) {
116+
// This already is a "real" item
117+
instance.def
118+
} else {
119+
// Get the enclosing item and register a read on it
120+
tcx.map.get_parent_did(node)
121+
}
116122
} else {
117123
// Translating an inlined item from another crate? Don't track anything.
118124
return;

0 commit comments

Comments
 (0)