@@ -18,6 +18,7 @@ use ich::{StableHashingContext, NodeIdHashingMode};
1818use util:: nodemap:: { FxHashMap , FxHashSet } ;
1919use ty;
2020
21+ use std:: fmt;
2122use std:: mem;
2223use std:: rc:: Rc ;
2324use 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 ) ]
100105pub 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 ) ]
156161pub struct FirstStatementIndex { pub idx : u32 }
157162
158163impl 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+
169180impl 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) ]
184201impl Scope {
185202 #[ inline]
0 commit comments