diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 454a9429eede..ee31ae3e3569 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -4409,12 +4409,22 @@ fn trans_fail_expr(cx: &@block_ctxt, sp_opt: &option::t, let e_ty = ty::expr_ty(tcx, expr); bcx = expr_res.bcx; - if ty::type_is_str(tcx, e_ty) { - let elt = - GEP(bcx, expr_res.val, - [C_int(0), C_int(abi::vec_elt_data)]); - ret trans_fail_value(bcx, sp_opt, elt); + let is_istr = alt ty::struct(tcx, e_ty) { + ty::ty_istr. { true } + _ { false } + }; + if !is_istr { + let elt = + GEP(bcx, expr_res.val, + [C_int(0), C_int(abi::vec_elt_data)]); + ret trans_fail_value(bcx, sp_opt, elt); + } else { + let data = ivec::get_dataptr( + bcx, expr_res.val, + type_of_or_i8(bcx, ty::mk_mach(tcx, ast::ty_u8))); + ret trans_fail_value(bcx, sp_opt, data); + } } else { bcx_ccx(cx).sess.span_bug(expr.span, ~"fail called with unsupported type " diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 74fff2e82bd6..c6e11bf722de 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1860,7 +1860,15 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier, bot = true; alt expr_opt { none. {/* do nothing */ } - some(e) { check_expr_with(fcx, e, ty::mk_str(tcx)); } + some(e) { + // FIXME: istr transitional. Should be: + // check_expr_with(fcx, e, ty::mk_str(tcx)); + check_expr(fcx, e); + if !are_compatible(fcx, expr_ty(tcx, e), ty::mk_str(tcx)) + && !are_compatible(fcx, expr_ty(tcx, e), ty::mk_istr(tcx)) { + check_expr_with(fcx, e, ty::mk_str(tcx)); + } + } } write::bot_ty(tcx, id); } diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index b45e443759c5..56937260b54e 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -1,3 +1,3 @@ // error-pattern:wooooo // no-valgrind -fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; } +fn main() { let a = 1; if 1 == 1 { a = 2; } fail ~"woooo" + ~"o"; }