Skip to content

Commit a372755

Browse files
committed
rustc: use the TLS type context in Repr and UserString.
1 parent 1f70a2e commit a372755

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1991
-1933
lines changed

src/librustc/middle/astconv_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
6363
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
6464
None => {
6565
tcx.sess.span_bug(ast_ty.span,
66-
&format!("unbound path {}", path.repr(tcx)))
66+
&format!("unbound path {}", path.repr()))
6767
}
6868
Some(d) => d.full_def()
6969
};

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ fn decode_side_tables(dcx: &DecodeContext,
16241624
c::tag_table_node_type => {
16251625
let ty = val_dsr.read_ty(dcx);
16261626
debug!("inserting ty for node {}: {}",
1627-
id, ty.repr(dcx.tcx));
1627+
id, ty.repr());
16281628
dcx.tcx.node_type_insert(id, ty);
16291629
}
16301630
c::tag_table_item_subst => {

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
300300

301301
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
302302
fn visit_item(&mut self, i: &ast::Item) {
303-
debug!("visit_item(item={})", i.repr(self.tcx));
303+
debug!("visit_item(item={})", i.repr());
304304
match i.node {
305305
ast::ItemStatic(_, ast::MutImmutable, ref expr) => {
306306
self.check_static_type(&**expr);

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
210210
// We know the type is inhabited, so this must be wrong
211211
span_err!(cx.tcx.sess, ex.span, E0002,
212212
"non-exhaustive patterns: type {} is non-empty",
213-
pat_ty.user_string(cx.tcx));
213+
pat_ty.user_string());
214214
}
215215
// If the type *is* empty, it's vacuously exhaustive
216216
return;
@@ -243,11 +243,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
243243
span_warn!(cx.tcx.sess, p.span, E0170,
244244
"pattern binding `{}` is named the same as one \
245245
of the variants of the type `{}`",
246-
&token::get_ident(ident.node), pat_ty.user_string(cx.tcx));
246+
&token::get_ident(ident.node), pat_ty.user_string());
247247
fileline_help!(cx.tcx.sess, p.span,
248248
"if you meant to match on a variant, \
249249
consider making the path in the pattern qualified: `{}::{}`",
250-
pat_ty.user_string(cx.tcx), &token::get_ident(ident.node));
250+
pat_ty.user_string(), &token::get_ident(ident.node));
251251
}
252252
}
253253
}

src/librustc/middle/check_rvalues.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
5959
span: Span,
6060
cmt: mc::cmt<'tcx>,
6161
_: euv::ConsumeMode) {
62-
debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr(self.tcx));
62+
debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr());
6363
if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) {
6464
span_err!(self.tcx.sess, span, E0161,
6565
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
66-
cmt.ty.user_string(self.tcx));
66+
cmt.ty.user_string());
6767
}
6868
}
6969

src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
10311031
Vec::new()));
10321032
let trait_substs = tcx.mk_substs(trait_substs);
10331033
debug!("resolve_trait_associated_const: trait_substs={}",
1034-
trait_substs.repr(tcx));
1034+
trait_substs.repr());
10351035
let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id,
10361036
substs: trait_substs });
10371037

@@ -1055,7 +1055,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
10551055
&format!("Encountered error `{}` when trying \
10561056
to select an implementation for \
10571057
constant trait item reference.",
1058-
e.repr(tcx)))
1058+
e.repr()))
10591059
}
10601060
};
10611061

src/librustc/middle/effect.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
6767
_ => return
6868
};
6969
debug!("effect: checking index with base type {}",
70-
base_type.repr(self.tcx));
70+
base_type.repr());
7171
match base_type.sty {
7272
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
7373
span_err!(self.tcx.sess, e.span, E0134,
@@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
143143
let method_call = MethodCall::expr(expr.id);
144144
let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty;
145145
debug!("effect: method call case, base type is {}",
146-
base_type.repr(self.tcx));
146+
base_type.repr());
147147
if type_is_unsafe_function(base_type) {
148148
self.require_unsafe(expr.span,
149149
"invocation of unsafe method")
@@ -152,15 +152,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
152152
ast::ExprCall(ref base, _) => {
153153
let base_type = ty::node_id_to_type(self.tcx, base.id);
154154
debug!("effect: call case, base type is {}",
155-
base_type.repr(self.tcx));
155+
base_type.repr());
156156
if type_is_unsafe_function(base_type) {
157157
self.require_unsafe(expr.span, "call to unsafe function")
158158
}
159159
}
160160
ast::ExprUnary(ast::UnDeref, ref base) => {
161161
let base_type = ty::node_id_to_type(self.tcx, base.id);
162162
debug!("effect: unary case, base type is {}",
163-
base_type.repr(self.tcx));
163+
base_type.repr());
164164
if let ty::TyRawPtr(_) = base_type.sty {
165165
self.require_unsafe(expr.span, "dereference of raw pointer")
166166
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
363363
consume_span: Span,
364364
cmt: mc::cmt<'tcx>) {
365365
debug!("delegate_consume(consume_id={}, cmt={})",
366-
consume_id, cmt.repr(self.tcx()));
366+
consume_id, cmt.repr());
367367

368368
let mode = copy_or_move(self.typer, &cmt, DirectRefMove);
369369
self.delegate.consume(consume_id, consume_span, cmt, mode);
@@ -376,7 +376,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
376376
}
377377

378378
pub fn consume_expr(&mut self, expr: &ast::Expr) {
379-
debug!("consume_expr(expr={})", expr.repr(self.tcx()));
379+
debug!("consume_expr(expr={})", expr.repr());
380380

381381
let cmt = return_if_err!(self.mc.cat_expr(expr));
382382
self.delegate_consume(expr.id, expr.span, cmt);
@@ -398,7 +398,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
398398
bk: ty::BorrowKind,
399399
cause: LoanCause) {
400400
debug!("borrow_expr(expr={}, r={}, bk={})",
401-
expr.repr(self.tcx()), r.repr(self.tcx()), bk.repr(self.tcx()));
401+
expr.repr(), r.repr(), bk.repr());
402402

403403
let cmt = return_if_err!(self.mc.cat_expr(expr));
404404
self.delegate.borrow(expr.id, expr.span, cmt, r, bk, cause);
@@ -414,7 +414,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
414414
}
415415

416416
pub fn walk_expr(&mut self, expr: &ast::Expr) {
417-
debug!("walk_expr(expr={})", expr.repr(self.tcx()));
417+
debug!("walk_expr(expr={})", expr.repr());
418418

419419
self.walk_adjustment(expr);
420420

@@ -619,7 +619,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
619619
fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
620620
let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee));
621621
debug!("walk_callee: callee={} callee_ty={}",
622-
callee.repr(self.tcx()), callee_ty.repr(self.tcx()));
622+
callee.repr(), callee_ty.repr());
623623
let call_scope = region::CodeExtent::from_node_id(call.id);
624624
match callee_ty.sty {
625625
ty::TyBareFn(..) => {
@@ -637,7 +637,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
637637
None => {
638638
self.tcx().sess.span_bug(
639639
callee.span,
640-
&format!("unexpected callee type {}", callee_ty.repr(self.tcx())))
640+
&format!("unexpected callee type {}", callee_ty.repr()))
641641
}
642642
};
643643
match overloaded_call_type {
@@ -811,7 +811,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
811811
fn walk_autoderefs(&mut self,
812812
expr: &ast::Expr,
813813
autoderefs: usize) {
814-
debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(self.tcx()), autoderefs);
814+
debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(), autoderefs);
815815

816816
for i in 0..autoderefs {
817817
let deref_id = ty::MethodCall::autoderef(expr.id, i as u32);
@@ -829,7 +829,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
829829
ty::TyRef(r, ref m) => (m.mutbl, r),
830830
_ => self.tcx().sess.span_bug(expr.span,
831831
&format!("bad overloaded deref type {}",
832-
method_ty.repr(self.tcx())))
832+
method_ty.repr()))
833833
};
834834
let bk = ty::BorrowKind::from_mutbl(m);
835835
self.delegate.borrow(expr.id, expr.span, cmt,
@@ -843,8 +843,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
843843
expr: &ast::Expr,
844844
adj: &ty::AutoDerefRef<'tcx>) {
845845
debug!("walk_autoderefref expr={} adj={}",
846-
expr.repr(self.tcx()),
847-
adj.repr(self.tcx()));
846+
expr.repr(),
847+
adj.repr());
848848

849849
self.walk_autoderefs(expr, adj.autoderefs);
850850

@@ -877,7 +877,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
877877
{
878878
debug!("walk_autoref(expr.id={} cmt_derefd={} opt_autoref={:?})",
879879
expr.id,
880-
cmt_base.repr(self.tcx()),
880+
cmt_base.repr(),
881881
opt_autoref);
882882

883883
let cmt_base_ty = cmt_base.ty;
@@ -903,7 +903,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
903903
ty::AutoUnsafe(m) => {
904904
debug!("walk_autoref: expr.id={} cmt_base={}",
905905
expr.id,
906-
cmt_base.repr(self.tcx()));
906+
cmt_base.repr());
907907

908908
// Converting from a &T to *T (or &mut T to *mut T) is
909909
// treated as borrowing it for the enclosing temporary
@@ -1011,8 +1011,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
10111011
cmt_discr: mc::cmt<'tcx>,
10121012
pat: &ast::Pat,
10131013
mode: &mut TrackMatchMode) {
1014-
debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(self.tcx()),
1015-
pat.repr(self.tcx()));
1014+
debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(),
1015+
pat.repr());
10161016
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
10171017
let tcx = self.tcx();
10181018
let def_map = &self.tcx().def_map;
@@ -1043,8 +1043,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
10431043
cmt_discr: mc::cmt<'tcx>,
10441044
pat: &ast::Pat,
10451045
match_mode: MatchMode) {
1046-
debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(self.tcx()),
1047-
pat.repr(self.tcx()));
1046+
debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(),
1047+
pat.repr());
10481048

10491049
let mc = &self.mc;
10501050
let typer = self.typer;
@@ -1055,8 +1055,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
10551055
let tcx = typer.tcx();
10561056

10571057
debug!("binding cmt_pat={} pat={} match_mode={:?}",
1058-
cmt_pat.repr(tcx),
1059-
pat.repr(tcx),
1058+
cmt_pat.repr(),
1059+
pat.repr(),
10601060
match_mode);
10611061

10621062
// pat_ty: the type of the binding being produced.
@@ -1161,8 +1161,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11611161
};
11621162

11631163
debug!("variant downcast_cmt={} pat={}",
1164-
downcast_cmt.repr(tcx),
1165-
pat.repr(tcx));
1164+
downcast_cmt.repr(),
1165+
pat.repr());
11661166

11671167
delegate.matched_pat(pat, downcast_cmt, match_mode);
11681168
}
@@ -1173,8 +1173,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11731173
// e.g. patterns for unit structs).
11741174

11751175
debug!("struct cmt_pat={} pat={}",
1176-
cmt_pat.repr(tcx),
1177-
pat.repr(tcx));
1176+
cmt_pat.repr(),
1177+
pat.repr());
11781178

11791179
delegate.matched_pat(pat, cmt_pat, match_mode);
11801180
}
@@ -1194,7 +1194,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11941194
if !tcx.sess.has_errors() {
11951195
let msg = format!("Pattern has unexpected type: {:?} and type {}",
11961196
def,
1197-
cmt_pat.ty.repr(tcx));
1197+
cmt_pat.ty.repr());
11981198
tcx.sess.span_bug(pat.span, &msg)
11991199
}
12001200
}
@@ -1211,7 +1211,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
12111211
if !tcx.sess.has_errors() {
12121212
let msg = format!("Pattern has unexpected def: {:?} and type {}",
12131213
def,
1214-
cmt_pat.ty.repr(tcx));
1214+
cmt_pat.ty.repr());
12151215
tcx.sess.span_bug(pat.span, &msg[..])
12161216
}
12171217
}
@@ -1237,7 +1237,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
12371237
}
12381238

12391239
fn walk_captures(&mut self, closure_expr: &ast::Expr) {
1240-
debug!("walk_captures({})", closure_expr.repr(self.tcx()));
1240+
debug!("walk_captures({})", closure_expr.repr());
12411241

12421242
ty::with_freevars(self.tcx(), closure_expr.id, |freevars| {
12431243
for freevar in freevars {

src/librustc/middle/free_region.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl FreeRegionMap {
3333
implications: &[Implication<'tcx>])
3434
{
3535
for implication in implications {
36-
debug!("implication: {}", implication.repr(tcx));
36+
debug!("implication: {}", implication.repr());
3737
match *implication {
3838
Implication::RegionSubRegion(_, ty::ReFree(free_a), ty::ReFree(free_b)) => {
3939
self.relate_free_regions(free_a, free_b);
@@ -50,7 +50,7 @@ impl FreeRegionMap {
5050
pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
5151
tcx: &ty::ctxt<'tcx>,
5252
predicates: &[ty::Predicate<'tcx>]) {
53-
debug!("relate_free_regions_from_predicates(predicates={})", predicates.repr(tcx));
53+
debug!("relate_free_regions_from_predicates(predicates={})", predicates.repr());
5454
for predicate in predicates {
5555
match *predicate {
5656
ty::Predicate::Projection(..) |
@@ -69,8 +69,8 @@ impl FreeRegionMap {
6969
// All named regions are instantiated with free regions.
7070
tcx.sess.bug(
7171
&format!("record_region_bounds: non free region: {} / {}",
72-
r_a.repr(tcx),
73-
r_b.repr(tcx)));
72+
r_a.repr(),
73+
r_b.repr()));
7474
}
7575
}
7676
}

0 commit comments

Comments
 (0)