@@ -21,6 +21,7 @@ use util::nodemap::{FxHashMap, FxHashSet};
21
21
use ty;
22
22
23
23
use std:: mem;
24
+ use std:: fmt;
24
25
use rustc_data_structures:: sync:: Lrc ;
25
26
use syntax:: source_map;
26
27
use syntax:: ast;
@@ -50,7 +51,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
50
51
/// `DestructionScope`, but those that are `terminating_scopes` do;
51
52
/// see discussion with `ScopeTree`.
52
53
///
53
- /// `Remainder(BlockRemainder { block, statement_index }) ` represents
54
+ /// `Remainder { block, statement_index }` represents
54
55
/// the scope of user code running immediately after the initializer
55
56
/// expression for the indexed statement, until the end of the block.
56
57
///
@@ -99,12 +100,29 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
99
100
/// placate the same deriving in `ty::FreeRegion`, but we may want to
100
101
/// actually attach a more meaningful ordering to scopes than the one
101
102
/// 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 ) ]
103
104
pub struct Scope {
104
105
pub ( crate ) id : hir:: ItemLocalId ,
105
106
pub ( crate ) data : ScopeData ,
106
107
}
107
108
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
+
108
126
#[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , Debug , Copy , RustcEncodable , RustcDecodable ) ]
109
127
pub enum ScopeData {
110
128
Node ,
@@ -159,7 +177,7 @@ impl Scope {
159
177
#[ inline]
160
178
pub fn data ( self ) -> ScopeData {
161
179
self . data
162
- }
180
+ }
163
181
164
182
#[ inline]
165
183
pub fn new ( id : hir:: ItemLocalId , data : ScopeData ) -> Self {
0 commit comments