Skip to content

Commit 0b58fdf

Browse files
committed
rustc: remove Repr and UserString.
1 parent dfbc960 commit 0b58fdf

Some content is hidden

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

103 files changed

+1637
-1802
lines changed

src/librustc/middle/astconv_util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use middle::def;
1818
use middle::ty::{self, Ty};
1919
use syntax::ast;
20-
use util::ppaux::Repr;
2120

2221
pub const NO_REGIONS: usize = 1;
2322
pub const NO_TPS: usize = 2;
@@ -63,7 +62,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
6362
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
6463
None => {
6564
tcx.sess.span_bug(ast_ty.span,
66-
&format!("unbound path {}", path.repr()))
65+
&format!("unbound path {:?}", path))
6766
}
6867
Some(d) => d.full_def()
6968
};

src/librustc/middle/astencode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use middle::privacy::{AllPublic, LastMod};
3131
use middle::subst;
3232
use middle::subst::VecPerParamSpace;
3333
use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin};
34-
use util::ppaux::Repr;
3534

3635
use syntax::{ast, ast_util, codemap, fold};
3736
use syntax::codemap::Span;
@@ -1623,8 +1622,8 @@ fn decode_side_tables(dcx: &DecodeContext,
16231622
}
16241623
c::tag_table_node_type => {
16251624
let ty = val_dsr.read_ty(dcx);
1626-
debug!("inserting ty for node {}: {}",
1627-
id, ty.repr());
1625+
debug!("inserting ty for node {}: {:?}",
1626+
id, ty);
16281627
dcx.tcx.node_type_insert(id, ty);
16291628
}
16301629
c::tag_table_item_subst => {

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use syntax::print::pprust::pat_to_string;
3636
use syntax::parse::token;
3737
use syntax::ptr::P;
3838
use syntax::visit::{self, Visitor, FnKind};
39-
use util::ppaux::UserString;
4039
use util::nodemap::FnvHashMap;
4140

4241
pub const DUMMY_WILD_PAT: &'static Pat = &Pat {
@@ -210,7 +209,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
210209
// We know the type is inhabited, so this must be wrong
211210
span_err!(cx.tcx.sess, ex.span, E0002,
212211
"non-exhaustive patterns: type {} is non-empty",
213-
pat_ty.user_string());
212+
pat_ty);
214213
}
215214
// If the type *is* empty, it's vacuously exhaustive
216215
return;
@@ -243,11 +242,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
243242
span_warn!(cx.tcx.sess, p.span, E0170,
244243
"pattern binding `{}` is named the same as one \
245244
of the variants of the type `{}`",
246-
&token::get_ident(ident.node), pat_ty.user_string());
245+
&token::get_ident(ident.node), pat_ty);
247246
fileline_help!(cx.tcx.sess, p.span,
248247
"if you meant to match on a variant, \
249248
consider making the path in the pattern qualified: `{}::{}`",
250-
pat_ty.user_string(), &token::get_ident(ident.node));
249+
pat_ty, &token::get_ident(ident.node));
251250
}
252251
}
253252
}

src/librustc/middle/check_rvalues.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use middle::expr_use_visitor as euv;
1515
use middle::mem_categorization as mc;
1616
use middle::ty::ParameterEnvironment;
1717
use middle::ty;
18-
use util::ppaux::{Repr, UserString};
1918

2019
use syntax::ast;
2120
use syntax::codemap::Span;
@@ -59,11 +58,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
5958
span: Span,
6059
cmt: mc::cmt<'tcx>,
6160
_: euv::ConsumeMode) {
62-
debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr());
61+
debug!("consume; cmt: {:?}; type: {:?}", *cmt, cmt.ty);
6362
if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) {
6463
span_err!(self.tcx.sess, span, E0161,
6564
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
66-
cmt.ty.user_string());
65+
cmt.ty);
6766
}
6867
}
6968

src/librustc/middle/const_eval.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use middle::pat_util::def_to_path;
2323
use middle::ty::{self, Ty};
2424
use middle::astconv_util::ast_ty_to_prim_ty;
2525
use util::num::ToPrimitive;
26-
use util::ppaux::Repr;
2726

2827
use syntax::ast::{self, Expr};
2928
use syntax::ast_util;
@@ -1030,8 +1029,8 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
10301029
rcvr_self,
10311030
Vec::new()));
10321031
let trait_substs = tcx.mk_substs(trait_substs);
1033-
debug!("resolve_trait_associated_const: trait_substs={}",
1034-
trait_substs.repr());
1032+
debug!("resolve_trait_associated_const: trait_substs={:?}",
1033+
trait_substs);
10351034
let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id,
10361035
substs: trait_substs });
10371036

@@ -1052,10 +1051,10 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
10521051
}
10531052
Err(e) => {
10541053
tcx.sess.span_bug(ti.span,
1055-
&format!("Encountered error `{}` when trying \
1054+
&format!("Encountered error `{:?}` when trying \
10561055
to select an implementation for \
10571056
constant trait item reference.",
1058-
e.repr()))
1057+
e))
10591058
}
10601059
};
10611060

src/librustc/middle/effect.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use self::UnsafeContext::*;
1515
use middle::def;
1616
use middle::ty::{self, Ty};
1717
use middle::ty::MethodCall;
18-
use util::ppaux::Repr;
1918

2019
use syntax::ast;
2120
use syntax::codemap::Span;
@@ -66,8 +65,8 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
6665
ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id),
6766
_ => return
6867
};
69-
debug!("effect: checking index with base type {}",
70-
base_type.repr());
68+
debug!("effect: checking index with base type {:?}",
69+
base_type);
7170
match base_type.sty {
7271
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
7372
span_err!(self.tcx.sess, e.span, E0134,
@@ -142,25 +141,25 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
142141
ast::ExprMethodCall(_, _, _) => {
143142
let method_call = MethodCall::expr(expr.id);
144143
let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty;
145-
debug!("effect: method call case, base type is {}",
146-
base_type.repr());
144+
debug!("effect: method call case, base type is {:?}",
145+
base_type);
147146
if type_is_unsafe_function(base_type) {
148147
self.require_unsafe(expr.span,
149148
"invocation of unsafe method")
150149
}
151150
}
152151
ast::ExprCall(ref base, _) => {
153152
let base_type = ty::node_id_to_type(self.tcx, base.id);
154-
debug!("effect: call case, base type is {}",
155-
base_type.repr());
153+
debug!("effect: call case, base type is {:?}",
154+
base_type);
156155
if type_is_unsafe_function(base_type) {
157156
self.require_unsafe(expr.span, "call to unsafe function")
158157
}
159158
}
160159
ast::ExprUnary(ast::UnDeref, ref base) => {
161160
let base_type = ty::node_id_to_type(self.tcx, base.id);
162-
debug!("effect: unary case, base type is {}",
163-
base_type.repr());
161+
debug!("effect: unary case, base type is {:?}",
162+
base_type);
164163
if let ty::TyRawPtr(_) = base_type.sty {
165164
self.require_unsafe(expr.span, "dereference of raw pointer")
166165
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use middle::ty::{self};
2727
use middle::ty::{MethodCall, MethodObject, MethodTraitObject};
2828
use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam};
2929
use middle::ty::{MethodStatic, MethodStaticClosure};
30-
use util::ppaux::Repr;
3130

3231
use syntax::{ast, ast_util};
3332
use syntax::ptr::P;
@@ -362,8 +361,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
362361
consume_id: ast::NodeId,
363362
consume_span: Span,
364363
cmt: mc::cmt<'tcx>) {
365-
debug!("delegate_consume(consume_id={}, cmt={})",
366-
consume_id, cmt.repr());
364+
debug!("delegate_consume(consume_id={}, cmt={:?})",
365+
consume_id, cmt);
367366

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

378377
pub fn consume_expr(&mut self, expr: &ast::Expr) {
379-
debug!("consume_expr(expr={})", expr.repr());
378+
debug!("consume_expr(expr={:?})", expr);
380379

381380
let cmt = return_if_err!(self.mc.cat_expr(expr));
382381
self.delegate_consume(expr.id, expr.span, cmt);
@@ -397,8 +396,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
397396
r: ty::Region,
398397
bk: ty::BorrowKind,
399398
cause: LoanCause) {
400-
debug!("borrow_expr(expr={}, r={}, bk={})",
401-
expr.repr(), r.repr(), bk.repr());
399+
debug!("borrow_expr(expr={:?}, r={:?}, bk={:?})",
400+
expr, r, bk);
402401

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

416415
pub fn walk_expr(&mut self, expr: &ast::Expr) {
417-
debug!("walk_expr(expr={})", expr.repr());
416+
debug!("walk_expr(expr={:?})", expr);
418417

419418
self.walk_adjustment(expr);
420419

@@ -618,8 +617,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
618617

619618
fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
620619
let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee));
621-
debug!("walk_callee: callee={} callee_ty={}",
622-
callee.repr(), callee_ty.repr());
620+
debug!("walk_callee: callee={:?} callee_ty={:?}",
621+
callee, callee_ty);
623622
let call_scope = region::CodeExtent::from_node_id(call.id);
624623
match callee_ty.sty {
625624
ty::TyBareFn(..) => {
@@ -637,7 +636,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
637636
None => {
638637
self.tcx().sess.span_bug(
639638
callee.span,
640-
&format!("unexpected callee type {}", callee_ty.repr()))
639+
&format!("unexpected callee type {}", callee_ty))
641640
}
642641
};
643642
match overloaded_call_type {
@@ -811,7 +810,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
811810
fn walk_autoderefs(&mut self,
812811
expr: &ast::Expr,
813812
autoderefs: usize) {
814-
debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(), autoderefs);
813+
debug!("walk_autoderefs expr={:?} autoderefs={}", expr, autoderefs);
815814

816815
for i in 0..autoderefs {
817816
let deref_id = ty::MethodCall::autoderef(expr.id, i as u32);
@@ -828,8 +827,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
828827
let (m, r) = match self_ty.sty {
829828
ty::TyRef(r, ref m) => (m.mutbl, r),
830829
_ => self.tcx().sess.span_bug(expr.span,
831-
&format!("bad overloaded deref type {}",
832-
method_ty.repr()))
830+
&format!("bad overloaded deref type {:?}",
831+
method_ty))
833832
};
834833
let bk = ty::BorrowKind::from_mutbl(m);
835834
self.delegate.borrow(expr.id, expr.span, cmt,
@@ -842,9 +841,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
842841
fn walk_autoderefref(&mut self,
843842
expr: &ast::Expr,
844843
adj: &ty::AutoDerefRef<'tcx>) {
845-
debug!("walk_autoderefref expr={} adj={}",
846-
expr.repr(),
847-
adj.repr());
844+
debug!("walk_autoderefref expr={:?} adj={:?}",
845+
expr,
846+
adj);
848847

849848
self.walk_autoderefs(expr, adj.autoderefs);
850849

@@ -875,9 +874,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
875874
opt_autoref: Option<ty::AutoRef<'tcx>>)
876875
-> mc::cmt<'tcx>
877876
{
878-
debug!("walk_autoref(expr.id={} cmt_derefd={} opt_autoref={:?})",
877+
debug!("walk_autoref(expr.id={} cmt_derefd={:?} opt_autoref={:?})",
879878
expr.id,
880-
cmt_base.repr(),
879+
cmt_base,
881880
opt_autoref);
882881

883882
let cmt_base_ty = cmt_base.ty;
@@ -901,9 +900,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
901900
}
902901

903902
ty::AutoUnsafe(m) => {
904-
debug!("walk_autoref: expr.id={} cmt_base={}",
903+
debug!("walk_autoref: expr.id={} cmt_base={:?}",
905904
expr.id,
906-
cmt_base.repr());
905+
cmt_base);
907906

908907
// Converting from a &T to *T (or &mut T to *mut T) is
909908
// treated as borrowing it for the enclosing temporary
@@ -1011,8 +1010,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
10111010
cmt_discr: mc::cmt<'tcx>,
10121011
pat: &ast::Pat,
10131012
mode: &mut TrackMatchMode) {
1014-
debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(),
1015-
pat.repr());
1013+
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr,
1014+
pat);
10161015
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
10171016
let tcx = self.tcx();
10181017
let def_map = &self.tcx().def_map;
@@ -1043,8 +1042,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
10431042
cmt_discr: mc::cmt<'tcx>,
10441043
pat: &ast::Pat,
10451044
match_mode: MatchMode) {
1046-
debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(),
1047-
pat.repr());
1045+
debug!("walk_pat cmt_discr={:?} pat={:?}", cmt_discr,
1046+
pat);
10481047

10491048
let mc = &self.mc;
10501049
let typer = self.typer;
@@ -1054,9 +1053,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
10541053
if pat_util::pat_is_binding(def_map, pat) {
10551054
let tcx = typer.tcx();
10561055

1057-
debug!("binding cmt_pat={} pat={} match_mode={:?}",
1058-
cmt_pat.repr(),
1059-
pat.repr(),
1056+
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}",
1057+
cmt_pat,
1058+
pat,
10601059
match_mode);
10611060

10621061
// pat_ty: the type of the binding being produced.
@@ -1160,9 +1159,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11601159
mc.cat_downcast(pat, cmt_pat, cmt_pat_ty, variant_did)
11611160
};
11621161

1163-
debug!("variant downcast_cmt={} pat={}",
1164-
downcast_cmt.repr(),
1165-
pat.repr());
1162+
debug!("variant downcast_cmt={:?} pat={:?}",
1163+
downcast_cmt,
1164+
pat);
11661165

11671166
delegate.matched_pat(pat, downcast_cmt, match_mode);
11681167
}
@@ -1172,9 +1171,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11721171
// namespace; we encounter the former on
11731172
// e.g. patterns for unit structs).
11741173

1175-
debug!("struct cmt_pat={} pat={}",
1176-
cmt_pat.repr(),
1177-
pat.repr());
1174+
debug!("struct cmt_pat={:?} pat={:?}",
1175+
cmt_pat,
1176+
pat);
11781177

11791178
delegate.matched_pat(pat, cmt_pat, match_mode);
11801179
}
@@ -1192,9 +1191,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11921191
// pattern.
11931192

11941193
if !tcx.sess.has_errors() {
1195-
let msg = format!("Pattern has unexpected type: {:?} and type {}",
1194+
let msg = format!("Pattern has unexpected type: {:?} and type {:?}",
11961195
def,
1197-
cmt_pat.ty.repr());
1196+
cmt_pat.ty);
11981197
tcx.sess.span_bug(pat.span, &msg)
11991198
}
12001199
}
@@ -1209,9 +1208,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
12091208
// reported.
12101209

12111210
if !tcx.sess.has_errors() {
1212-
let msg = format!("Pattern has unexpected def: {:?} and type {}",
1211+
let msg = format!("Pattern has unexpected def: {:?} and type {:?}",
12131212
def,
1214-
cmt_pat.ty.repr());
1213+
cmt_pat.ty);
12151214
tcx.sess.span_bug(pat.span, &msg[..])
12161215
}
12171216
}
@@ -1237,7 +1236,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
12371236
}
12381237

12391238
fn walk_captures(&mut self, closure_expr: &ast::Expr) {
1240-
debug!("walk_captures({})", closure_expr.repr());
1239+
debug!("walk_captures({:?})", closure_expr);
12411240

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

0 commit comments

Comments
 (0)