We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37d5c06 commit fd2b65eCopy full SHA for fd2b65e
src/librustc_trans/trans_item.rs
@@ -111,8 +111,14 @@ impl<'a, 'tcx> TransItem<'tcx> {
111
tcx.map.local_def_id(node_id)
112
}
113
TransItem::Fn(instance) => {
114
- if instance.def.is_local() {
115
- instance.def
+ if let Some(node) = tcx.map.as_local_node_id(instance.def) {
+ 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
+ }
122
} else {
123
// Translating an inlined item from another crate? Don't track anything.
124
return;
0 commit comments