Skip to content

Commit 8040fd8

Browse files
committed
Call the correct type formatting function for more typecheck diagnostics. Closes #2652.
1 parent 60a6582 commit 8040fd8

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/rustc/middle/typeck/check.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
13341334
tcx.sess.span_fatal(
13351335
expr.span, #fmt("a loop function's last argument \
13361336
should return `bool`, not `%s`",
1337-
ty_to_str(tcx, fty.output)));
1337+
fcx.infcx.ty_to_str(fty.output)));
13381338
}
13391339
}
13401340
(ty::mk_fn(tcx, {output: ty::mk_nil(tcx) with fty}), fty.proto)
@@ -1471,12 +1471,12 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
14711471
_ {
14721472
if ty::type_is_nil(t_e) {
14731473
tcx.sess.span_err(expr.span, "cast from nil: " +
1474-
ty_to_str(tcx, t_e) + " as " +
1475-
ty_to_str(tcx, t_1));
1474+
fcx.infcx.ty_to_str(t_e) + " as " +
1475+
fcx.infcx.ty_to_str(t_1));
14761476
} else if ty::type_is_nil(t_1) {
14771477
tcx.sess.span_err(expr.span, "cast to nil: " +
1478-
ty_to_str(tcx, t_e) + " as " +
1479-
ty_to_str(tcx, t_1));
1478+
fcx.infcx.ty_to_str(t_e) + " as " +
1479+
fcx.infcx.ty_to_str(t_1));
14801480
}
14811481

14821482
let t_1_is_scalar = type_is_scalar(fcx, expr.span, t_1);
@@ -1490,8 +1490,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
14901490
*/
14911491
tcx.sess.span_err(expr.span,
14921492
"non-scalar cast: " +
1493-
ty_to_str(tcx, t_e) + " as " +
1494-
ty_to_str(tcx, t_1));
1493+
fcx.infcx.ty_to_str(t_e) + " as " +
1494+
fcx.infcx.ty_to_str(t_1));
14951495
}
14961496
}
14971497
}
@@ -1639,7 +1639,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
16391639
let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t);
16401640
let msg = #fmt["attempted access of field %s on type %s, but \
16411641
no public field or method with that name was found",
1642-
*field, ty_to_str(tcx, t_err)];
1642+
*field, fcx.infcx.ty_to_str(t_err)];
16431643
tcx.sess.span_err(expr.span, msg);
16441644
// NB: Adding a bogus type to allow typechecking to continue
16451645
fcx.write_ty(id, fcx.infcx.next_ty_var());
@@ -1667,7 +1667,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
16671667
_ {
16681668
tcx.sess.span_fatal(
16691669
expr.span, "cannot index a value of type `" +
1670-
ty_to_str(tcx, base_t) + "`");
1670+
fcx.infcx.ty_to_str(base_t) + "`");
16711671
}
16721672
}
16731673
}
@@ -1708,7 +1708,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
17081708
none {
17091709
let t_err = fcx.infcx.resolve_type_vars_if_possible(p_ty);
17101710
let msg = #fmt["no `alloc()` method found for type `%s`",
1711-
ty_to_str(tcx, t_err)];
1711+
fcx.infcx.ty_to_str(t_err)];
17121712
tcx.sess.span_err(expr.span, msg);
17131713
}
17141714
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let z = ();
3+
log(error, z[0]); //! ERROR cannot index a value of type `()`
4+
}

0 commit comments

Comments
 (0)