Skip to content

Commit 16f7309

Browse files
committed
---
yaml --- r: 4367 b: refs/heads/master c: 948f809 h: refs/heads/master i: 4365: 38aff13 4363: 9015829 4359: 3e92553 4351: 280c87a v: v3
1 parent 749f578 commit 16f7309

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 13f8b3f2a67a4e3a7a26b0e238e1b6ce9e1f3573
2+
refs/heads/master: 948f8090ae66ea9207473bf97d5c0dfaee4244ed

trunk/src/comp/middle/trans_alt.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,18 @@ fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &ast::arm[],
425425
id: ast::node_id, output: &trans::out_method) -> result {
426426
let bodies = ~[];
427427
let match: match = ~[];
428+
let er = trans::trans_expr(cx, expr);
429+
if (ty::type_is_bot(bcx_tcx(cx), ty::expr_ty(bcx_tcx(cx), expr))) {
430+
// No need to generate code for alt,
431+
// since the disc diverges.
432+
if (!cx.build.is_terminated()) {
433+
ret rslt(cx, cx.build.Unreachable());
434+
}
435+
else {
436+
ret rslt(cx, C_nil());
437+
}
438+
}
439+
428440
for a: ast::arm in arms {
429441
let body = new_scope_block_ctxt(cx, "case_body");
430442
bodies += ~[body];
@@ -445,7 +457,6 @@ fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &ast::arm[],
445457
}
446458

447459
let exit_map = ~[];
448-
let er = trans::trans_expr(cx, expr);
449460
let t = trans::node_id_type(cx.fcx.lcx.ccx, expr.id);
450461
let v = trans::spill_if_immediate(er.bcx, er.val, t);
451462
compile_submatch(er.bcx, match, ~[v],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// error-pattern:quux
2+
fn f() -> ! { fail "quux" }
3+
fn g() -> int { alt f() { true { 1 } false { 0 } }; }
4+
fn main() { g(); }

0 commit comments

Comments
 (0)