Skip to content

Commit 55ed19f

Browse files
committed
rustc: make LocalDefId's index field public like DefId's is.
1 parent e1762fd commit 55ed19f

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'hir> Map<'hir> {
263263

264264
#[inline]
265265
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
266-
self.tcx.definitions.def_index_to_hir_id(def_id.to_def_id().index)
266+
self.tcx.definitions.def_index_to_hir_id(def_id.local_def_index)
267267
}
268268

269269
pub fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
735735
let var_owner_def_id =
736736
DefId { krate: local_id_root.krate, index: var_path.hir_id.owner };
737737
let closure_def_id =
738-
DefId { krate: local_id_root.krate, index: closure_expr_id.to_def_id().index };
738+
DefId { krate: local_id_root.krate, index: closure_expr_id.local_def_index };
739739
(
740740
hcx.def_path_hash(var_owner_def_id),
741741
var_path.hir_id.local_id,

src/librustc_hir/hir_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl HirId {
2424
}
2525

2626
pub fn owner_local_def_id(self) -> LocalDefId {
27-
LocalDefId::from_def_id(DefId::local(self.owner))
27+
LocalDefId { local_def_index: self.owner }
2828
}
2929
}
3030

src/librustc_span/def_id.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,20 @@ rustc_data_structures::define_id_collections!(DefIdMap, DefIdSet, DefId);
211211
/// and a DefId from a different crate would signify a bug somewhere. This
212212
/// is when LocalDefId comes in handy.
213213
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
214-
pub struct LocalDefId(DefIndex);
214+
pub struct LocalDefId {
215+
pub local_def_index: DefIndex,
216+
}
215217

216218
impl LocalDefId {
217219
#[inline]
218220
pub fn from_def_id(def_id: DefId) -> LocalDefId {
219221
assert!(def_id.is_local());
220-
LocalDefId(def_id.index)
222+
LocalDefId { local_def_index: def_id.index }
221223
}
222224

223225
#[inline]
224226
pub fn to_def_id(self) -> DefId {
225-
DefId { krate: LOCAL_CRATE, index: self.0 }
227+
DefId { krate: LOCAL_CRATE, index: self.local_def_index }
226228
}
227229
}
228230

0 commit comments

Comments
 (0)