rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup

This commit is contained in:
Vadim Petrochenkov
2023-11-24 19:28:19 +03:00
parent 9529a5d265
commit c697927f44
110 changed files with 189 additions and 199 deletions

View File

@@ -107,12 +107,12 @@ impl<'tcx> DocContext<'tcx> {
r
}
/// Like `hir().local_def_id_to_hir_id()`, but skips calling it on fake DefIds.
/// Like `tcx.local_def_id_to_hir_id()`, but skips calling it on fake DefIds.
/// (This avoids a slice-index-out-of-bounds panic.)
pub(crate) fn as_local_hir_id(tcx: TyCtxt<'_>, item_id: ItemId) -> Option<HirId> {
match item_id {
ItemId::DefId(real_id) => {
real_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
real_id.as_local().map(|def_id| tcx.local_def_id_to_hir_id(def_id))
}
// FIXME: Can this be `Some` for `Auto` or `Blanket`?
_ => None,