Skip to content

Commit 4399b2c

Browse files
committed
rustc: make LocalDefId's index field public like DefId's is.
1 parent d2d0302 commit 4399b2c

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/librustc/hir/def_id.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,24 @@ impl rustc_serialize::UseSpecializedDecodable for DefId {}
162162
/// and a DefId from a different crate would signify a bug somewhere. This
163163
/// is when LocalDefId comes in handy.
164164
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
165-
pub struct LocalDefId(DefIndex);
165+
pub struct LocalDefId {
166+
pub index: DefIndex,
167+
}
166168

167169
impl LocalDefId {
168170
#[inline]
169171
pub fn from_def_id(def_id: DefId) -> LocalDefId {
170172
assert!(def_id.is_local());
171-
LocalDefId(def_id.index)
173+
LocalDefId {
174+
index: def_id.index,
175+
}
172176
}
173177

174178
#[inline]
175179
pub fn to_def_id(self) -> DefId {
176180
DefId {
177181
krate: LOCAL_CRATE,
178-
index: self.0
182+
index: self.index
179183
}
180184
}
181185
}

src/librustc/hir/map/mod.rs

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

318318
#[inline]
319319
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
320-
self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
320+
self.definitions.def_index_to_hir_id(def_id.index)
321321
}
322322

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

src/librustc/hir/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ impl HirId {
8585
}
8686

8787
pub fn owner_local_def_id(self) -> LocalDefId {
88-
LocalDefId::from_def_id(DefId::local(self.owner))
88+
LocalDefId {
89+
index: self.owner,
90+
}
8991
}
9092
}
9193

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
797797
};
798798
let closure_def_id = DefId {
799799
krate: local_id_root.krate,
800-
index: closure_expr_id.to_def_id().index,
800+
index: closure_expr_id.index,
801801
};
802802
(hcx.def_path_hash(var_owner_def_id),
803803
var_path.hir_id.local_id,

0 commit comments

Comments
 (0)