Skip to content

Commit 1b29892

Browse files
msullivanbrson
authored andcommitted
Produce a useful error message in trans when attempting to log an unsupported type.
(Previously, an llvm assert was tripped.)
1 parent d72d504 commit 1b29892

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/comp/middle/trans.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5648,6 +5648,14 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
56485648
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_double,
56495649
[log_bcx.fcx.lltaskptr, C_int(lvl), tmp]);
56505650
}
5651+
} else if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx, e_ty) ||
5652+
ty::type_is_bool(cx.fcx.lcx.ccx.tcx, e_ty)) {
5653+
// FIXME: Handle signedness properly.
5654+
auto llintval = int_cast(log_bcx, T_int(), val_ty(sub.val),
5655+
sub.val, false);
5656+
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_int,
5657+
[log_bcx.fcx.lltaskptr, C_int(lvl),
5658+
llintval]);
56515659
} else {
56525660
alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
56535661
case (ty::ty_str) {
@@ -5656,12 +5664,11 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
56565664
sub.val]);
56575665
}
56585666
case (_) {
5659-
// FIXME: Handle signedness properly.
5660-
auto llintval = int_cast(log_bcx, T_int(), val_ty(sub.val),
5661-
sub.val, false);
5662-
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_int,
5663-
[log_bcx.fcx.lltaskptr, C_int(lvl),
5664-
llintval]);
5667+
// FIXME: Support these types.
5668+
cx.fcx.lcx.ccx.sess.span_err(e.span,
5669+
"log called on unsupported type " +
5670+
ty::ty_to_str(cx.fcx.lcx.ccx.tcx, e_ty));
5671+
fail;
56655672
}
56665673
}
56675674
}

0 commit comments

Comments
 (0)