Skip to content

Commit da1faec

Browse files
committed
---
yaml --- r: 213231 b: refs/heads/auto c: 17e333d h: refs/heads/master i: 213229: de63889 213227: 7bc5de5 213223: 0629629 213215: ce5b121 v: v3
1 parent 7d229f2 commit da1faec

File tree

8 files changed

+151
-64
lines changed

8 files changed

+151
-64
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: af7daa0daff91f8a58708f2d98f94d49acc28c6a
13+
refs/heads/auto: 17e333d31b6237c2e3775b254e3808d1137c6b94
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/check_const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use middle::mem_categorization as mc;
3333
use middle::traits;
3434
use middle::ty::{self, Ty};
3535
use util::nodemap::NodeMap;
36-
use util::ppaux::Repr;
3736

3837
use syntax::ast;
3938
use syntax::codemap::Span;
@@ -300,7 +299,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
300299

301300
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
302301
fn visit_item(&mut self, i: &ast::Item) {
303-
debug!("visit_item(item={})", i.repr());
302+
debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id));
304303
match i.node {
305304
ast::ItemStatic(_, ast::MutImmutable, ref expr) => {
306305
self.check_static_type(&**expr);

branches/auto/src/librustc/middle/ty.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,20 +927,64 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Binder<T> {
927927
}
928928

929929
pub mod tls {
930+
use ast_map;
930931
use middle::ty;
931932
use session::Session;
932933

934+
use std::fmt;
935+
use syntax::ast;
936+
use syntax::codemap;
937+
933938
/// Marker type used for the scoped TLS slot.
934939
/// The type context cannot be used directly because the scoped TLS
935940
/// in libstd doesn't allow types generic over lifetimes.
936941
struct ThreadLocalTyCx;
937942

938943
scoped_thread_local!(static TLS_TCX: ThreadLocalTyCx);
939944

945+
fn def_id_debug(def_id: ast::DefId, f: &mut fmt::Formatter) -> fmt::Result {
946+
// Unfortunately, there seems to be no way to attempt to print
947+
// a path for a def-id, so I'll just make a best effort for now
948+
// and otherwise fallback to just printing the crate/node pair
949+
with(|tcx| {
950+
if def_id.krate == ast::LOCAL_CRATE {
951+
match tcx.map.find(def_id.node) {
952+
Some(ast_map::NodeItem(..)) |
953+
Some(ast_map::NodeForeignItem(..)) |
954+
Some(ast_map::NodeImplItem(..)) |
955+
Some(ast_map::NodeTraitItem(..)) |
956+
Some(ast_map::NodeVariant(..)) |
957+
Some(ast_map::NodeStructCtor(..)) => {
958+
return write!(f, "{}", ty::item_path_str(tcx, def_id));
959+
}
960+
_ => {}
961+
}
962+
}
963+
Ok(())
964+
})
965+
}
966+
967+
fn span_debug(span: codemap::Span, f: &mut fmt::Formatter) -> fmt::Result {
968+
with(|tcx| {
969+
write!(f, "{}", tcx.sess.codemap().span_to_string(span))
970+
})
971+
}
972+
940973
pub fn enter<'tcx, F: FnOnce(&ty::ctxt<'tcx>) -> R, R>(tcx: ty::ctxt<'tcx>, f: F)
941974
-> (Session, R) {
942-
let tls_ptr = &tcx as *const _ as *const ThreadLocalTyCx;
943-
let result = TLS_TCX.set(unsafe { &*tls_ptr }, || f(&tcx));
975+
let result = ast::DEF_ID_DEBUG.with(|def_id_dbg| {
976+
codemap::SPAN_DEBUG.with(|span_dbg| {
977+
let original_def_id_debug = def_id_dbg.get();
978+
def_id_dbg.set(def_id_debug);
979+
let original_span_debug = span_dbg.get();
980+
span_dbg.set(span_debug);
981+
let tls_ptr = &tcx as *const _ as *const ThreadLocalTyCx;
982+
let result = TLS_TCX.set(unsafe { &*tls_ptr }, || f(&tcx));
983+
def_id_dbg.set(original_def_id_debug);
984+
span_dbg.set(original_span_debug);
985+
result
986+
})
987+
});
944988
(tcx.sess, result)
945989
}
946990

branches/auto/src/librustc/util/ppaux.rs

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111

12-
use ast_map;
1312
use middle::def;
1413
use middle::region;
1514
use middle::subst::{VecPerParamSpace,Subst};
@@ -34,7 +33,6 @@ use std::rc::Rc;
3433
use syntax::abi;
3534
use syntax::codemap::Span;
3635
use syntax::parse::token;
37-
use syntax::print::pprust;
3836
use syntax::ptr::P;
3937
use syntax::{ast, ast_util};
4038
use syntax::owned_slice::OwnedSlice;
@@ -469,51 +467,43 @@ impl<'tcx> Repr for ty::TraitDef<'tcx> {
469467

470468
impl Repr for ast::Expr {
471469
fn repr(&self) -> String {
472-
format!("expr({}: {})", self.id, pprust::expr_to_string(self))
470+
format!("{:?}", *self)
473471
}
474472
}
475473

476474
impl Repr for ast::Path {
477475
fn repr(&self) -> String {
478-
format!("path({})", pprust::path_to_string(self))
476+
format!("{:?}", *self)
479477
}
480478
}
481479

482480
impl UserString for ast::Path {
483481
fn user_string(&self) -> String {
484-
pprust::path_to_string(self)
482+
format!("{}", *self)
485483
}
486484
}
487485

488486
impl Repr for ast::Ty {
489487
fn repr(&self) -> String {
490-
format!("type({})", pprust::ty_to_string(self))
491-
}
492-
}
493-
494-
impl Repr for ast::Item {
495-
fn repr(&self) -> String {
496-
format!("item({})", ty::tls::with(|tcx| tcx.map.node_to_string(self.id)))
488+
format!("{:?}", *self)
497489
}
498490
}
499491

500492
impl Repr for ast::Lifetime {
501493
fn repr(&self) -> String {
502-
format!("lifetime({}: {})", self.id, pprust::lifetime_to_string(self))
494+
format!("{:?}", *self)
503495
}
504496
}
505497

506498
impl Repr for ast::Stmt {
507499
fn repr(&self) -> String {
508-
format!("stmt({}: {})",
509-
ast_util::stmt_id(self),
510-
pprust::stmt_to_string(self))
500+
format!("{:?}", *self)
511501
}
512502
}
513503

514504
impl Repr for ast::Pat {
515505
fn repr(&self) -> String {
516-
format!("pat({}: {})", self.id, pprust::pat_to_string(self))
506+
format!("{:?}", *self)
517507
}
518508
}
519509

@@ -646,27 +636,7 @@ impl Repr for region::DestructionScopeData {
646636

647637
impl Repr for ast::DefId {
648638
fn repr(&self) -> String {
649-
// Unfortunately, there seems to be no way to attempt to print
650-
// a path for a def-id, so I'll just make a best effort for now
651-
// and otherwise fallback to just printing the crate/node pair
652-
ty::tls::with(|tcx| {
653-
if self.krate == ast::LOCAL_CRATE {
654-
match tcx.map.find(self.node) {
655-
Some(ast_map::NodeItem(..)) |
656-
Some(ast_map::NodeForeignItem(..)) |
657-
Some(ast_map::NodeImplItem(..)) |
658-
Some(ast_map::NodeTraitItem(..)) |
659-
Some(ast_map::NodeVariant(..)) |
660-
Some(ast_map::NodeStructCtor(..)) => {
661-
return format!("{:?}:{}",
662-
*self,
663-
ty::item_path_str(tcx, *self));
664-
}
665-
_ => {}
666-
}
667-
}
668-
format!("{:?}", *self)
669-
})
639+
format!("{:?}", *self)
670640
}
671641
}
672642

@@ -765,13 +735,13 @@ impl<'tcx> Repr for ty::Method<'tcx> {
765735

766736
impl Repr for ast::Name {
767737
fn repr(&self) -> String {
768-
token::get_name(*self).to_string()
738+
format!("{:?}", *self)
769739
}
770740
}
771741

772742
impl UserString for ast::Name {
773743
fn user_string(&self) -> String {
774-
token::get_name(*self).to_string()
744+
format!("{}", *self)
775745
}
776746
}
777747

@@ -878,7 +848,7 @@ impl UserString for ty::BuiltinBound {
878848

879849
impl Repr for Span {
880850
fn repr(&self) -> String {
881-
ty::tls::with(|tcx| tcx.sess.codemap().span_to_string(*self).to_string())
851+
format!("{:?}", *self)
882852
}
883853
}
884854

@@ -1163,7 +1133,7 @@ impl<'tcx> UserString for ty::TyS<'tcx> {
11631133

11641134
impl UserString for ast::Ident {
11651135
fn user_string(&self) -> String {
1166-
token::get_name(self.name).to_string()
1136+
format!("{}", *self)
11671137
}
11681138
}
11691139

branches/auto/src/librustc_typeck/coherence/orphan.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
6666
ast::ItemImpl(_, _, _, None, _, _) => {
6767
// For inherent impls, self type must be a nominal type
6868
// defined in this crate.
69-
debug!("coherence2::orphan check: inherent impl {}", item.repr());
69+
debug!("coherence2::orphan check: inherent impl {}",
70+
self.tcx.map.node_to_string(item.id));
7071
let self_ty = ty::lookup_item_type(self.tcx, def_id).ty;
7172
match self_ty.sty {
7273
ty::TyEnum(def_id, _) |
@@ -208,7 +209,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
208209
}
209210
ast::ItemImpl(_, _, _, Some(_), _, _) => {
210211
// "Trait" impl
211-
debug!("coherence2::orphan check: trait impl {}", item.repr());
212+
debug!("coherence2::orphan check: trait impl {}",
213+
self.tcx.map.node_to_string(item.id));
212214
let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap();
213215
let trait_def_id = trait_ref.def_id;
214216
match traits::orphan_check(self.tcx, def_id) {
@@ -329,7 +331,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
329331
}
330332
ast::ItemDefaultImpl(..) => {
331333
// "Trait" impl
332-
debug!("coherence2::orphan check: default trait impl {}", item.repr());
334+
debug!("coherence2::orphan check: default trait impl {}",
335+
self.tcx.map.node_to_string(item.id));
333336
let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap();
334337
if trait_ref.def_id.krate != ast::LOCAL_CRATE {
335338
span_err!(self.tcx.sess, item.span, E0318,

branches/auto/src/librustc_typeck/variance.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> {
518518

519519
impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> {
520520
fn visit_item(&mut self, item: &ast::Item) {
521-
debug!("add_inferreds for item {}", item.repr());
521+
debug!("add_inferreds for item {}", self.tcx.map.node_to_string(item.id));
522522

523523
match item.node {
524524
ast::ItemEnum(_, ref generics) |
@@ -600,8 +600,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
600600
let did = ast_util::local_def(item.id);
601601
let tcx = self.terms_cx.tcx;
602602

603-
debug!("visit_item item={}",
604-
item.repr());
603+
debug!("visit_item item={}", tcx.map.node_to_string(item.id));
605604

606605
match item.node {
607606
ast::ItemEnum(ref enum_definition, _) => {

0 commit comments

Comments
 (0)