Skip to content

Commit dfbc960

Browse files
committed
rustc: replace Repr/UserString impls with Debug/Display ones.
1 parent 17e333d commit dfbc960

File tree

37 files changed

+977
-1896
lines changed

37 files changed

+977
-1896
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ fn parse_builtin_bounds<F>(st: &mut PState, mut _conv: F) -> ty::BuiltinBounds w
898898
fn parse_builtin_bounds_<F>(st: &mut PState, _conv: &mut F) -> ty::BuiltinBounds where
899899
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
900900
{
901-
let mut builtin_bounds = ty::empty_builtin_bounds();
901+
let mut builtin_bounds = ty::BuiltinBounds::empty();
902902

903903
loop {
904904
match next(st) {

src/librustc/middle/implicator.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use util::ppaux::Repr;
2525

2626
// Helper functions related to manipulating region types.
2727

28+
#[derive(Debug)]
2829
pub enum Implication<'tcx> {
2930
RegionSubRegion(Option<Ty<'tcx>>, ty::Region, ty::Region),
3031
RegionSubGeneric(Option<Ty<'tcx>>, ty::Region, GenericKind<'tcx>),
@@ -400,7 +401,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
400401
}
401402

402403
fn fully_normalize<T>(&self, value: &T) -> Result<T,ErrorReported>
403-
where T : TypeFoldable<'tcx> + ty::HasProjectionTypes + Clone + Repr
404+
where T : TypeFoldable<'tcx> + ty::HasProjectionTypes
404405
{
405406
let value =
406407
traits::fully_normalize(self.infcx,
@@ -454,34 +455,3 @@ pub fn object_region_bounds<'tcx>(
454455
let predicates = ty::predicates(tcx, open_ty, &param_bounds);
455456
ty::required_region_bounds(tcx, open_ty, predicates)
456457
}
457-
458-
impl<'tcx> Repr for Implication<'tcx> {
459-
fn repr(&self) -> String {
460-
match *self {
461-
Implication::RegionSubRegion(_, ref r_a, ref r_b) => {
462-
format!("RegionSubRegion({}, {})",
463-
r_a.repr(),
464-
r_b.repr())
465-
}
466-
467-
Implication::RegionSubGeneric(_, ref r, ref p) => {
468-
format!("RegionSubGeneric({}, {})",
469-
r.repr(),
470-
p.repr())
471-
}
472-
473-
Implication::RegionSubClosure(_, ref a, ref b, ref c) => {
474-
format!("RegionSubClosure({}, {}, {})",
475-
a.repr(),
476-
b.repr(),
477-
c.repr())
478-
}
479-
480-
Implication::Predicate(ref def_id, ref p) => {
481-
format!("Predicate({}, {})",
482-
def_id.repr(),
483-
p.repr())
484-
}
485-
}
486-
}
487-
}

src/librustc/middle/infer/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
480480
"{}: {} ({})",
481481
trace.origin,
482482
expected_found_str,
483-
ty::type_err_to_str(self.tcx, terr));
483+
terr);
484484

485485
match trace.origin {
486486
infer::MatchExpressionArm(_, arm_span) =>

src/librustc/middle/infer/higher_ranked/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
518518
binder: &ty::Binder<T>,
519519
snapshot: &CombinedSnapshot)
520520
-> (T, SkolemizationMap)
521-
where T : TypeFoldable<'tcx> + Repr
521+
where T : TypeFoldable<'tcx>
522522
{
523523
/*!
524524
* Replace all regions bound by `binder` with skolemized regions and
@@ -616,7 +616,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
616616
snapshot: &CombinedSnapshot,
617617
value: &T)
618618
-> T
619-
where T : TypeFoldable<'tcx> + Repr
619+
where T : TypeFoldable<'tcx>
620620
{
621621
debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok());
622622

src/librustc/middle/infer/mod.rs

Lines changed: 8 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub enum ValuePairs<'tcx> {
160160
/// encounter an error or subtyping constraint.
161161
///
162162
/// See `error_reporting.rs` for more details.
163-
#[derive(Clone, Debug)]
163+
#[derive(Clone)]
164164
pub struct TypeTrace<'tcx> {
165165
origin: TypeOrigin,
166166
values: ValuePairs<'tcx>,
@@ -708,7 +708,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
708708
value: &ty::Binder<T>,
709709
snapshot: &CombinedSnapshot)
710710
-> (T, SkolemizationMap)
711-
where T : TypeFoldable<'tcx> + Repr
711+
where T : TypeFoldable<'tcx>
712712
{
713713
/*! See `higher_ranked::skolemize_late_bound_regions` */
714714

@@ -733,7 +733,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
733733
snapshot: &CombinedSnapshot,
734734
value: &T)
735735
-> T
736-
where T : TypeFoldable<'tcx> + Repr
736+
where T : TypeFoldable<'tcx>
737737
{
738738
/*! See `higher_ranked::plug_leaks` */
739739

@@ -979,7 +979,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
979979
Some(t) if ty::type_is_error(t) => (),
980980
_ => {
981981
let error_str = err.map_or("".to_string(), |t_err| {
982-
format!(" ({})", ty::type_err_to_str(self.tcx, t_err))
982+
format!(" ({})", t_err)
983983
});
984984

985985
self.tcx.sess.span_err(sp, &format!("{}{}",
@@ -1033,7 +1033,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10331033
lbrct: LateBoundRegionConversionTime,
10341034
value: &ty::Binder<T>)
10351035
-> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
1036-
where T : TypeFoldable<'tcx> + Repr
1036+
where T : TypeFoldable<'tcx>
10371037
{
10381038
ty_fold::replace_late_bound_regions(
10391039
self.tcx,
@@ -1099,9 +1099,9 @@ impl<'tcx> TypeTrace<'tcx> {
10991099
}
11001100
}
11011101

1102-
impl<'tcx> Repr for TypeTrace<'tcx> {
1103-
fn repr(&self) -> String {
1104-
format!("TypeTrace({})", self.origin.repr())
1102+
impl<'tcx> fmt::Debug for TypeTrace<'tcx> {
1103+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1104+
write!(f, "TypeTrace({:?})", self.origin)
11051105
}
11061106
}
11071107

@@ -1123,44 +1123,6 @@ impl TypeOrigin {
11231123
}
11241124
}
11251125

1126-
impl<'tcx> Repr for TypeOrigin {
1127-
fn repr(&self) -> String {
1128-
match *self {
1129-
MethodCompatCheck(a) => {
1130-
format!("MethodCompatCheck({})", a.repr())
1131-
}
1132-
ExprAssignable(a) => {
1133-
format!("ExprAssignable({})", a.repr())
1134-
}
1135-
Misc(a) => format!("Misc({})", a.repr()),
1136-
RelateTraitRefs(a) => {
1137-
format!("RelateTraitRefs({})", a.repr())
1138-
}
1139-
RelateSelfType(a) => {
1140-
format!("RelateSelfType({})", a.repr())
1141-
}
1142-
RelateOutputImplTypes(a) => {
1143-
format!("RelateOutputImplTypes({})", a.repr())
1144-
}
1145-
MatchExpressionArm(a, b) => {
1146-
format!("MatchExpressionArm({}, {})", a.repr(), b.repr())
1147-
}
1148-
IfExpression(a) => {
1149-
format!("IfExpression({})", a.repr())
1150-
}
1151-
IfExpressionWithNoElse(a) => {
1152-
format!("IfExpressionWithNoElse({})", a.repr())
1153-
}
1154-
RangeExpression(a) => {
1155-
format!("RangeExpression({})", a.repr())
1156-
}
1157-
EquatePredicate(a) => {
1158-
format!("EquatePredicate({})", a.repr())
1159-
}
1160-
}
1161-
}
1162-
}
1163-
11641126
impl<'tcx> SubregionOrigin<'tcx> {
11651127
pub fn span(&self) -> Span {
11661128
match *self {
@@ -1190,70 +1152,6 @@ impl<'tcx> SubregionOrigin<'tcx> {
11901152
}
11911153
}
11921154

1193-
impl<'tcx> Repr for SubregionOrigin<'tcx> {
1194-
fn repr(&self) -> String {
1195-
match *self {
1196-
Subtype(ref a) => {
1197-
format!("Subtype({})", a.repr())
1198-
}
1199-
InfStackClosure(a) => {
1200-
format!("InfStackClosure({})", a.repr())
1201-
}
1202-
InvokeClosure(a) => {
1203-
format!("InvokeClosure({})", a.repr())
1204-
}
1205-
DerefPointer(a) => {
1206-
format!("DerefPointer({})", a.repr())
1207-
}
1208-
FreeVariable(a, b) => {
1209-
format!("FreeVariable({}, {})", a.repr(), b)
1210-
}
1211-
IndexSlice(a) => {
1212-
format!("IndexSlice({})", a.repr())
1213-
}
1214-
RelateObjectBound(a) => {
1215-
format!("RelateObjectBound({})", a.repr())
1216-
}
1217-
RelateParamBound(a, b) => {
1218-
format!("RelateParamBound({},{})",
1219-
a.repr(),
1220-
b.repr())
1221-
}
1222-
RelateRegionParamBound(a) => {
1223-
format!("RelateRegionParamBound({})",
1224-
a.repr())
1225-
}
1226-
RelateDefaultParamBound(a, b) => {
1227-
format!("RelateDefaultParamBound({},{})",
1228-
a.repr(),
1229-
b.repr())
1230-
}
1231-
Reborrow(a) => format!("Reborrow({})", a.repr()),
1232-
ReborrowUpvar(a, b) => {
1233-
format!("ReborrowUpvar({},{:?})", a.repr(), b)
1234-
}
1235-
ReferenceOutlivesReferent(_, a) => {
1236-
format!("ReferenceOutlivesReferent({})", a.repr())
1237-
}
1238-
ExprTypeIsNotInScope(a, b) => {
1239-
format!("ExprTypeIsNotInScope({}, {})",
1240-
a.repr(),
1241-
b.repr())
1242-
}
1243-
BindingTypeIsNotValidAtDecl(a) => {
1244-
format!("BindingTypeIsNotValidAtDecl({})", a.repr())
1245-
}
1246-
CallRcvr(a) => format!("CallRcvr({})", a.repr()),
1247-
CallArg(a) => format!("CallArg({})", a.repr()),
1248-
CallReturn(a) => format!("CallReturn({})", a.repr()),
1249-
Operand(a) => format!("Operand({})", a.repr()),
1250-
AddrOf(a) => format!("AddrOf({})", a.repr()),
1251-
AutoBorrow(a) => format!("AutoBorrow({})", a.repr()),
1252-
SafeDestructor(a) => format!("SafeDestructor({})", a.repr()),
1253-
}
1254-
}
1255-
}
1256-
12571155
impl RegionVariableOrigin {
12581156
pub fn span(&self) -> Span {
12591157
match *self {
@@ -1269,33 +1167,3 @@ impl RegionVariableOrigin {
12691167
}
12701168
}
12711169
}
1272-
1273-
impl<'tcx> Repr for RegionVariableOrigin {
1274-
fn repr(&self) -> String {
1275-
match *self {
1276-
MiscVariable(a) => {
1277-
format!("MiscVariable({})", a.repr())
1278-
}
1279-
PatternRegion(a) => {
1280-
format!("PatternRegion({})", a.repr())
1281-
}
1282-
AddrOfRegion(a) => {
1283-
format!("AddrOfRegion({})", a.repr())
1284-
}
1285-
Autoref(a) => format!("Autoref({})", a.repr()),
1286-
Coercion(a) => format!("Coercion({})", a.repr()),
1287-
EarlyBoundRegion(a, b) => {
1288-
format!("EarlyBoundRegion({},{})", a.repr(), b.repr())
1289-
}
1290-
LateBoundRegion(a, b, c) => {
1291-
format!("LateBoundRegion({},{},{:?})", a.repr(), b.repr(), c)
1292-
}
1293-
BoundRegionInCoherence(a) => {
1294-
format!("bound_regionInCoherence({})", a.repr())
1295-
}
1296-
UpvarRegion(a, b) => {
1297-
format!("UpvarRegion({}, {})", a.repr(), b.repr())
1298-
}
1299-
}
1300-
}
1301-
}

0 commit comments

Comments
 (0)