Skip to content

Commit 9d0a505

Browse files
committed
Terminate fail blocks by making their ends unreachable.
This will make implementing default alt arms simpler.
1 parent 4f90c88 commit 9d0a505

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/comp/middle/trans.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3852,7 +3852,6 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base,
38523852

38533853
// fail: bad bounds check.
38543854
auto fail_res = trans_fail(fail_cx, sp, "bounds check");
3855-
fail_res.bcx.build.Br(next_cx.llbb);
38563855

38573856
auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_data)));
38583857
auto elt;
@@ -4916,7 +4915,6 @@ fn trans_check_expr(@block_ctxt cx, @ast.expr e) -> result {
49164915
auto fail_res = trans_fail(fail_cx, e.span, expr_str);
49174916

49184917
auto next_cx = new_sub_block_ctxt(cx, "next");
4919-
fail_res.bcx.build.Br(next_cx.llbb);
49204918
cond_res.bcx.build.CondBr(cond_res.val,
49214919
next_cx.llbb,
49224920
fail_cx.llbb);
@@ -4929,7 +4927,9 @@ fn trans_fail(@block_ctxt cx, common.span sp, str fail_str) -> result {
49294927
auto V_line = sp.lo.line as int;
49304928
auto args = vec(V_fail_str, V_filename, C_int(V_line));
49314929

4932-
ret trans_upcall(cx, "upcall_fail", args);
4930+
auto sub = trans_upcall(cx, "upcall_fail", args);
4931+
sub.bcx.build.Unreachable();
4932+
ret res(sub.bcx, C_nil());
49334933
}
49344934

49354935
fn trans_put(@block_ctxt cx, &option.t[@ast.expr] e) -> result {

0 commit comments

Comments
 (0)