Skip to content

Commit 051b401

Browse files
committed
Handle _|_ - typed things in the bodies of do-while loops
The resulting code is strange, but perhaps someone else can fix it. The obvious things, like returning body_res, all resulted in completely incomprehensible LLVM errors. Closes #814
1 parent 19bbd02 commit 051b401

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Diff for: src/comp/middle/trans.rs

+5
Original file line numberDiff line numberDiff line change
@@ -3802,6 +3802,11 @@ fn trans_do_while(cx: &@block_ctxt, body: &ast::blk, cond: &@ast::expr) ->
38023802
new_loop_scope_block_ctxt(cx, option::none[@block_ctxt], next_cx,
38033803
"do-while loop body");
38043804
let body_res = trans_block(body_cx, body, return);
3805+
if is_terminated(body_res.bcx) {
3806+
// This is kind of ridiculous, but no permutations
3807+
// involving body_res or body_cx.val worked.
3808+
ret trans_block(cx, body, return);
3809+
}
38053810
let cond_res = trans_expr(body_res.bcx, cond);
38063811
cond_res.bcx.build.CondBr(cond_res.val, body_cx.llbb, next_cx.llbb);
38073812
cx.build.Br(body_cx.llbb);

Diff for: src/test/run-fail/do-while-body-fails.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// error-pattern:quux
2+
fn main() {
3+
let x: int = do { fail "quux" } while (true);
4+
}

0 commit comments

Comments
 (0)