Add fast path to opt_local_def_id.

This commit is contained in:
Camille GILLOT 2021-12-05 11:18:16 +01:00
parent ec4bcaac45
commit 5a123c265b

View file

@ -200,8 +200,12 @@ impl<'hir> Map<'hir> {
#[inline] #[inline]
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId> { pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId> {
// FIXME(#85914) is this access safe for incr. comp.? if hir_id.local_id == ItemLocalId::new(0) {
self.tcx.untracked_resolutions.definitions.opt_hir_id_to_local_def_id(hir_id) Some(hir_id.owner)
} else {
// FIXME(#85914) is this access safe for incr. comp.?
self.tcx.untracked_resolutions.definitions.opt_hir_id_to_local_def_id(hir_id)
}
} }
#[inline] #[inline]