Skip to content

Commit a341ff9

Browse files
committed
---
yaml --- r: 4366 b: refs/heads/master c: 13f8b3f h: refs/heads/master v: v3
1 parent ab78013 commit a341ff9

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
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: 7c34550931a457dd830173fc4a3c467a2ba2e784
2+
refs/heads/master: 13f8b3f2a67a4e3a7a26b0e238e1b6ce9e1f3573

trunk/src/comp/middle/trans.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,6 +3592,18 @@ fn trans_if(cx: &@block_ctxt, cond: &@ast::expr, thn: &ast::blk,
35923592
els: &option::t[@ast::expr], id: ast::node_id,
35933593
output: &out_method) -> result {
35943594
let cond_res = trans_expr(cx, cond);
3595+
3596+
if (ty::type_is_bot(bcx_tcx(cx), ty::expr_ty(bcx_tcx(cx), cond))) {
3597+
// No need to generate code for comparison,
3598+
// since the cond diverges.
3599+
if (!cx.build.is_terminated()) {
3600+
ret rslt(cx, cx.build.Unreachable());
3601+
}
3602+
else {
3603+
ret rslt(cx, C_nil());
3604+
}
3605+
}
3606+
35953607
let then_cx = new_scope_block_ctxt(cx, "then");
35963608
let then_res = trans_block(then_cx, thn, output);
35973609
let else_cx = new_scope_block_ctxt(cx, "else");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// error-pattern:quux
2+
fn my_err(s: str) -> ! { log_err s; fail "quux"; }
3+
fn main() { if my_err("bye") { } }

0 commit comments

Comments
 (0)