Skip to content

Commit 5a123c2

Browse files
committed
Add fast path to opt_local_def_id.
1 parent ec4bcaa commit 5a123c2

File tree

1 file changed

+6
-2
lines changed
  • compiler/rustc_middle/src/hir/map

1 file changed

+6
-2
lines changed

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,12 @@ impl<'hir> Map<'hir> {
200200

201201
#[inline]
202202
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId> {
203-
// FIXME(#85914) is this access safe for incr. comp.?
204-
self.tcx.untracked_resolutions.definitions.opt_hir_id_to_local_def_id(hir_id)
203+
if hir_id.local_id == ItemLocalId::new(0) {
204+
Some(hir_id.owner)
205+
} else {
206+
// FIXME(#85914) is this access safe for incr. comp.?
207+
self.tcx.untracked_resolutions.definitions.opt_hir_id_to_local_def_id(hir_id)
208+
}
205209
}
206210

207211
#[inline]

0 commit comments

Comments
 (0)