diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-10-31 20:48:13 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-03-19 11:15:35 +0200 |
| commit | 55ed19fe1bba25251f110c0bf2bc6e42d50f3129 (patch) | |
| tree | cbac40c11d90ce3206708bf7313221039aa5d5d0 | |
| parent | e1762fdad12cd2577da0f3b0794c875648adde59 (diff) | |
| download | rust-55ed19fe1bba25251f110c0bf2bc6e42d50f3129.tar.gz rust-55ed19fe1bba25251f110c0bf2bc6e42d50f3129.zip | |
rustc: make LocalDefId's index field public like DefId's is.
| -rw-r--r-- | src/librustc/hir/map/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/context.rs | 2 | ||||
| -rw-r--r-- | src/librustc_hir/hir_id.rs | 2 | ||||
| -rw-r--r-- | src/librustc_span/def_id.rs | 8 |
4 files changed, 8 insertions, 6 deletions
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index ba1665fb530..636044069e4 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<DefKind> { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 25c442a8207..9f5197f3db6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -735,7 +735,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> 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 a11638a3bb2..c96807b528b 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 af8d5ce09b5..413e747e033 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 } } } |
