@@ -24,6 +24,7 @@ use middle::ty::{self, Ty};
24
24
25
25
use std:: cell:: RefCell ;
26
26
use std:: collections:: hash_map:: Entry ;
27
+ use std:: fmt;
27
28
use std:: mem;
28
29
use syntax:: codemap:: { self , Span } ;
29
30
use syntax:: ast:: { self , NodeId } ;
@@ -34,9 +35,25 @@ use rustc_front::hir::{Block, Item, FnDecl, Arm, Pat, Stmt, Expr, Local};
34
35
use rustc_front:: util:: stmt_id;
35
36
36
37
#[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , RustcEncodable ,
37
- RustcDecodable , Debug , Copy ) ]
38
+ RustcDecodable , Copy ) ]
38
39
pub struct CodeExtent ( u32 ) ;
39
40
41
+ impl fmt:: Debug for CodeExtent {
42
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
43
+ try!( write ! ( f, "CodeExtent({:?}" , self . 0 ) ) ;
44
+
45
+ try!( ty:: tls:: with_opt ( |opt_tcx| {
46
+ if let Some ( tcx) = opt_tcx {
47
+ let data = tcx. region_maps . code_extents . borrow ( ) [ self . 0 as usize ] ;
48
+ try!( write ! ( f, "/{:?}" , data) ) ;
49
+ }
50
+ Ok ( ( ) )
51
+ } ) ) ;
52
+
53
+ write ! ( f, ")" )
54
+ }
55
+ }
56
+
40
57
/// The root of everything. I should be using NonZero or profiling
41
58
/// instead of this (probably).
42
59
pub const ROOT_CODE_EXTENT : CodeExtent = CodeExtent ( 0 ) ;
0 commit comments