From ded9008e3850463a21d1d0d48ad35a02e42bae7c Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 4 Jul 2011 22:48:08 -0700 Subject: [PATCH] handle fail inside a for loop --- src/comp/middle/trans.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index f0c66803d58b..b23adb62dad3 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -4312,7 +4312,10 @@ fn trans_for(&@block_ctxt cx, &@ast::local local, &@ast::expr seq, auto bcx = copy_val(local_res.bcx, INIT, local_res.val, curr, t).bcx; scope_cx.cleanups += [clean(bind drop_slot(_, local_res.val, t))]; bcx = trans_block(bcx, body, return).bcx; - bcx.build.Br(next_cx.llbb); + if (!bcx.build.is_terminated()) { + bcx.build.Br(next_cx.llbb); + // otherwise, this code is unreachable + } ret rslt(next_cx, C_nil()); } auto next_cx = new_sub_block_ctxt(cx, "next");