diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index ba1665fb5308..636044069e4d 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -263,7 +263,7 @@ impl<'hir> Map<'hir> { #[inline] pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId { - self.tcx.definitions.def_index_to_hir_id(def_id.to_def_id().index) + self.tcx.definitions.def_index_to_hir_id(def_id.local_def_index) } pub fn def_kind(&self, hir_id: HirId) -> Option { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 25c442a82073..9f5197f3db68 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -735,7 +735,7 @@ impl<'a, 'tcx> HashStable> for TypeckTables<'tcx> { let var_owner_def_id = DefId { krate: local_id_root.krate, index: var_path.hir_id.owner }; 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, diff --git a/src/librustc_hir/hir_id.rs b/src/librustc_hir/hir_id.rs index a11638a3bb24..c96807b528b6 100644 --- a/src/librustc_hir/hir_id.rs +++ b/src/librustc_hir/hir_id.rs @@ -24,7 +24,7 @@ impl HirId { } pub fn owner_local_def_id(self) -> LocalDefId { - LocalDefId::from_def_id(DefId::local(self.owner)) + LocalDefId { local_def_index: self.owner } } } diff --git a/src/librustc_span/def_id.rs b/src/librustc_span/def_id.rs index af8d5ce09b52..413e747e0339 100644 --- a/src/librustc_span/def_id.rs +++ b/src/librustc_span/def_id.rs @@ -211,18 +211,20 @@ rustc_data_structures::define_id_collections!(DefIdMap, DefIdSet, DefId); /// and a DefId from a different crate would signify a bug somewhere. This /// is when LocalDefId comes in handy. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -pub struct LocalDefId(DefIndex); +pub struct LocalDefId { + pub local_def_index: DefIndex, +} impl LocalDefId { #[inline] pub fn from_def_id(def_id: DefId) -> LocalDefId { assert!(def_id.is_local()); - LocalDefId(def_id.index) + LocalDefId { local_def_index: def_id.index } } #[inline] pub fn to_def_id(self) -> DefId { - DefId { krate: LOCAL_CRATE, index: self.0 } + DefId { krate: LOCAL_CRATE, index: self.local_def_index } } }