Skip to content

Commit b8cf07e

Browse files
committed
Improve DefIndex formatting to be more semantic
1 parent 088216f commit b8cf07e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustc/hir/def_id.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,19 @@ impl serialize::UseSpecializedDecodable for CrateNum {
9393
///
9494
/// Since the DefIndex is mostly treated as an opaque ID, you probably
9595
/// don't have to care about these ranges.
96-
#[derive(Clone, Debug, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
96+
#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
9797
RustcDecodable, Hash, Copy)]
9898
pub struct DefIndex(u32);
9999

100+
impl fmt::Debug for DefIndex {
101+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
102+
write!(f,
103+
"DefIndex({}:{})",
104+
self.address_space().index(),
105+
self.as_array_index())
106+
}
107+
}
108+
100109
impl DefIndex {
101110
#[inline]
102111
pub fn new(x: usize) -> DefIndex {

0 commit comments

Comments
 (0)