use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
-use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex, LOCAL_CRATE};
+use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
use rustc_hir::{HirId, Node, TraitCandidate};
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
use rustc_index::vec::{Idx, IndexVec};
mut_access: bool,
) {
if let Some(local_id_root) = local_id_root {
- if hir_id.owner != local_id_root.index {
+ if hir_id.owner.to_def_id() != local_id_root {
ty::tls::with(|tcx| {
bug!(
"node {} with HirId::owner {:?} cannot be placed in \
TypeckTables with local_id_root {:?}",
tcx.hir().node_to_string(hir_id),
- DefId::local(hir_id.owner),
+ hir_id.owner,
local_id_root
)
});
let local_id_root = local_id_root.expect("trying to hash invalid TypeckTables");
- let var_owner_def_id =
- DefId { krate: local_id_root.krate, index: var_path.hir_id.owner };
+ let var_owner_def_id = DefId {
+ krate: local_id_root.krate,
+ index: var_path.hir_id.owner.local_def_index,
+ };
let closure_def_id =
- DefId { krate: local_id_root.krate, index: closure_expr_id.to_def_id().index };
+ DefId { krate: local_id_root.krate, index: closure_expr_id.local_def_index };
(
hcx.def_path_hash(var_owner_def_id),
var_path.hir_id.local_id,
/// Map indicating what traits are in scope for places where this
/// is relevant; generated by resolve.
- trait_map: FxHashMap<DefIndex, FxHashMap<ItemLocalId, StableVec<TraitCandidate>>>,
+ trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, StableVec<TraitCandidate>>>,
/// Export map produced by name resolution.
export_map: FxHashMap<DefId, Vec<Export<hir::HirId>>>,
}
pub fn def_key(self, id: DefId) -> hir_map::DefKey {
- if id.is_local() { self.hir().def_key(id) } else { self.cstore.def_key(id) }
+ if let Some(id) = id.as_local() { self.hir().def_key(id) } else { self.cstore.def_key(id) }
}
/// Converts a `DefId` into its fully expanded `DefPath` (every
/// Note that if `id` is not local to this crate, the result will
/// be a non-local `DefPath`.
pub fn def_path(self, id: DefId) -> hir_map::DefPath {
- if id.is_local() { self.hir().def_path(id) } else { self.cstore.def_path(id) }
+ if let Some(id) = id.as_local() {
+ self.hir().def_path(id)
+ } else {
+ self.cstore.def_path(id)
+ }
}
/// Returns whether or not the crate with CrateNum 'cnum'
#[inline]
pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash {
- if def_id.is_local() {
- self.definitions.def_path_hash(def_id.index)
+ if let Some(def_id) = def_id.as_local() {
+ self.definitions.def_path_hash(def_id)
} else {
self.cstore.def_path_hash(def_id)
}
};
providers.lookup_stability = |tcx, id| {
- assert_eq!(id.krate, LOCAL_CRATE);
- let id = tcx.hir().definitions().def_index_to_hir_id(id.index);
+ let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
tcx.stability().local_stability(id)
};
providers.lookup_const_stability = |tcx, id| {
- assert_eq!(id.krate, LOCAL_CRATE);
- let id = tcx.hir().definitions().def_index_to_hir_id(id.index);
+ let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
tcx.stability().local_const_stability(id)
};
providers.lookup_deprecation_entry = |tcx, id| {
- assert_eq!(id.krate, LOCAL_CRATE);
- let id = tcx.hir().definitions().def_index_to_hir_id(id.index);
+ let id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
tcx.stability().local_deprecation_entry(id)
};
providers.extern_mod_stmt_cnum = |tcx, id| {