1
Fork 0

Infallible version of def_span.

This commit is contained in:
Camille GILLOT 2020-12-23 10:32:00 +01:00
parent a4cbb44ae2
commit 064a351953
3 changed files with 39 additions and 37 deletions

View file

@ -15,6 +15,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
use rustc_hir::*;
use rustc_index::vec::IndexVec;
use rustc_span::DUMMY_SP;
pub struct Owner<'tcx> {
parent: HirId,
@ -77,6 +78,7 @@ pub fn provide(providers: &mut Providers) {
};
providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature;
providers.hir_owner_nodes = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_deref();
providers.def_span = |tcx, def_id| tcx.hir().span_if_local(def_id).unwrap_or(DUMMY_SP);
providers.fn_arg_names = |tcx, id| {
let hir = tcx.hir();
let hir_id = hir.local_def_id_to_hir_id(id.expect_local());