Skip to content

Commit e5bc5c7

Browse files
committed
improve Scope to print node-ids etc
1 parent 8fa5f09 commit e5bc5c7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/librustc/middle/region.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use middle::ty::{self, Ty};
2424

2525
use std::cell::RefCell;
2626
use std::collections::hash_map::Entry;
27+
use std::fmt;
2728
use std::mem;
2829
use syntax::codemap::{self, Span};
2930
use syntax::ast::{self, NodeId};
@@ -34,9 +35,25 @@ use rustc_front::hir::{Block, Item, FnDecl, Arm, Pat, Stmt, Expr, Local};
3435
use rustc_front::util::stmt_id;
3536

3637
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
37-
RustcDecodable, Debug, Copy)]
38+
RustcDecodable, Copy)]
3839
pub 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).
4259
pub const ROOT_CODE_EXTENT : CodeExtent = CodeExtent(0);

0 commit comments

Comments
 (0)