@@ -24,6 +24,7 @@ use middle::ty::{self, Ty};
2424
2525use std:: cell:: RefCell ;
2626use std:: collections:: hash_map:: Entry ;
27+ use std:: fmt;
2728use std:: mem;
2829use syntax:: codemap:: { self , Span } ;
2930use syntax:: ast:: { self , NodeId } ;
@@ -34,9 +35,25 @@ use rustc_front::hir::{Block, Item, FnDecl, Arm, Pat, Stmt, Expr, Local};
3435use rustc_front:: util:: stmt_id;
3536
3637#[ derive( Clone , PartialEq , PartialOrd , Eq , Ord , Hash , RustcEncodable ,
37- RustcDecodable , Debug , Copy ) ]
38+ RustcDecodable , Copy ) ]
3839pub struct CodeExtent ( u32 ) ;
3940
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+
4057/// The root of everything. I should be using NonZero or profiling
4158/// instead of this (probably).
4259pub const ROOT_CODE_EXTENT : CodeExtent = CodeExtent ( 0 ) ;
0 commit comments