@@ -18,6 +18,7 @@ use ich::{StableHashingContext, NodeIdHashingMode};
18
18
use util:: nodemap:: { FxHashMap , FxHashSet } ;
19
19
use ty;
20
20
21
+ use std:: fmt;
21
22
use std:: mem;
22
23
use std:: rc:: Rc ;
23
24
use syntax:: codemap;
@@ -96,7 +97,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
96
97
/// placate the same deriving in `ty::FreeRegion`, but we may want to
97
98
/// actually attach a more meaningful ordering to scopes than the one
98
99
/// 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 ) ]
100
105
pub struct Scope {
101
106
pub ( crate ) id : hir:: ItemLocalId ,
102
107
pub ( crate ) code : u32
@@ -152,7 +157,7 @@ pub struct BlockRemainder {
152
157
}
153
158
154
159
#[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , RustcEncodable ,
155
- RustcDecodable , Debug , Copy ) ]
160
+ RustcDecodable , Copy ) ]
156
161
pub struct FirstStatementIndex { pub idx : u32 }
157
162
158
163
impl Idx for FirstStatementIndex {
@@ -166,6 +171,12 @@ impl Idx for FirstStatementIndex {
166
171
}
167
172
}
168
173
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
+
169
180
impl From < ScopeData > for Scope {
170
181
#[ inline]
171
182
fn from ( scope_data : ScopeData ) -> Self {
@@ -180,6 +191,12 @@ impl From<ScopeData> for Scope {
180
191
}
181
192
}
182
193
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
+
183
200
#[ allow( non_snake_case) ]
184
201
impl Scope {
185
202
#[ inline]
0 commit comments