Skip to content

Commit 7bb0923

Browse files
committed
fix Debug impls
1 parent c10b23e commit 7bb0923

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/librustc/middle/region.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use ich::{StableHashingContext, NodeIdHashingMode};
1818
use util::nodemap::{FxHashMap, FxHashSet};
1919
use ty;
2020

21+
use std::fmt;
2122
use std::mem;
2223
use std::rc::Rc;
2324
use syntax::codemap;
@@ -96,7 +97,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
9697
/// placate the same deriving in `ty::FreeRegion`, but we may want to
9798
/// actually attach a more meaningful ordering to scopes than the one
9899
/// generated via deriving here.
99-
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, RustcEncodable, RustcDecodable)]
100+
///
101+
/// Scope is a bit-packed to save space - if `code` is SCOPE_DATA_REMAINDER_MAX
102+
/// or less, it is a `ScopeData::Remainder`, otherwise it is a type specified
103+
/// by the bitpacking.
104+
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, RustcEncodable, RustcDecodable)]
100105
pub struct Scope {
101106
pub(crate) id: hir::ItemLocalId,
102107
pub(crate) code: u32
@@ -152,7 +157,7 @@ pub struct BlockRemainder {
152157
}
153158

154159
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
155-
RustcDecodable, Debug, Copy)]
160+
RustcDecodable, Copy)]
156161
pub struct FirstStatementIndex { pub idx: u32 }
157162

158163
impl Idx for FirstStatementIndex {
@@ -166,6 +171,12 @@ impl Idx for FirstStatementIndex {
166171
}
167172
}
168173

174+
impl fmt::Debug for FirstStatementIndex {
175+
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
176+
fmt::Debug::fmt(&self.index(), formatter)
177+
}
178+
}
179+
169180
impl From<ScopeData> for Scope {
170181
#[inline]
171182
fn from(scope_data: ScopeData) -> Self {
@@ -180,6 +191,12 @@ impl From<ScopeData> for Scope {
180191
}
181192
}
182193

194+
impl fmt::Debug for Scope {
195+
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
196+
fmt::Debug::fmt(&self.data(), formatter)
197+
}
198+
}
199+
183200
#[allow(non_snake_case)]
184201
impl Scope {
185202
#[inline]

0 commit comments

Comments
 (0)