@@ -21,6 +21,7 @@ use util::nodemap::{FxHashMap, FxHashSet};
2121use ty;
2222
2323use std:: mem;
24+ use std:: fmt;
2425use rustc_data_structures:: sync:: Lrc ;
2526use syntax:: source_map;
2627use syntax:: ast;
@@ -50,7 +51,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
5051/// `DestructionScope`, but those that are `terminating_scopes` do;
5152/// see discussion with `ScopeTree`.
5253///
53- /// `Remainder(BlockRemainder { block, statement_index }) ` represents
54+ /// `Remainder { block, statement_index }` represents
5455/// the scope of user code running immediately after the initializer
5556/// expression for the indexed statement, until the end of the block.
5657///
@@ -99,12 +100,29 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
99100/// placate the same deriving in `ty::FreeRegion`, but we may want to
100101/// actually attach a more meaningful ordering to scopes than the one
101102/// generated via deriving here.
102- #[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , Debug , Copy , RustcEncodable , RustcDecodable ) ]
103+ #[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , Copy , RustcEncodable , RustcDecodable ) ]
103104pub struct Scope {
104105 pub ( crate ) id : hir:: ItemLocalId ,
105106 pub ( crate ) data : ScopeData ,
106107}
107108
109+ impl fmt:: Debug for Scope {
110+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
111+ match self . data {
112+ ScopeData :: Node => write ! ( fmt, "Node({:?})" , self . id) ,
113+ ScopeData :: CallSite => write ! ( fmt, "CallSite({:?})" , self . id) ,
114+ ScopeData :: Arguments => write ! ( fmt, "Arguments({:?})" , self . id) ,
115+ ScopeData :: Destruction => write ! ( fmt, "Destruction({:?})" , self . id) ,
116+ ScopeData :: Remainder ( fsi) => write ! (
117+ fmt,
118+ "Remainder {{ block: {:?}, first_statement_index: {}}}" ,
119+ self . id,
120+ fsi. as_u32( ) ,
121+ ) ,
122+ }
123+ }
124+ }
125+
108126#[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , Debug , Copy , RustcEncodable , RustcDecodable ) ]
109127pub enum ScopeData {
110128 Node ,
@@ -159,7 +177,7 @@ impl Scope {
159177 #[ inline]
160178 pub fn data ( self ) -> ScopeData {
161179 self . data
162- }
180+ }
163181
164182 #[ inline]
165183 pub fn new ( id : hir:: ItemLocalId , data : ScopeData ) -> Self {
0 commit comments