about summary refs log tree commit diff
path: root/src/rustc
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-03-13 17:24:39 -0700
committerBrian Anderson <banderson@mozilla.com>2012-03-13 17:27:17 -0700
commitaeb445b2ea25f9629df1d5d8fbd2906a92c8e719 (patch)
tree4b4a3d85d98c6b394ee95e0dbcbe0158cefc9f31 /src/rustc
parentb87cdd857228e576d0fcccba0d92b0b231375923 (diff)
downloadrust-aeb445b2ea25f9629df1d5d8fbd2906a92c8e719.tar.gz
rust-aeb445b2ea25f9629df1d5d8fbd2906a92c8e719.zip
rustc: Don't make the while loop body's basic block a child of the condition
As a child of the condition, when the body encounters a ret or break it
incorrectly re-runs the cleanups of the condition.
Diffstat (limited to 'src/rustc')
-rw-r--r--src/rustc/middle/trans/base.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs
index e7ab3c39899..67723337cfb 100644
--- a/src/rustc/middle/trans/base.rs
+++ b/src/rustc/middle/trans/base.rs
@@ -2001,10 +2001,12 @@ fn trans_for(cx: block, local: @ast::local, seq: @ast::expr,
 fn trans_while(cx: block, cond: @ast::expr, body: ast::blk)
     -> block {
     let next_cx = sub_block(cx, "while next");
-    let cond_cx = loop_scope_block(cx, cont_self, next_cx,
-                                   "while cond", body.span);
-    let body_cx = scope_block(cond_cx, "while loop body");
-    Br(cx, cond_cx.llbb);
+    let loop_cx = loop_scope_block(cx, cont_self, next_cx,
+                                   "while loop", body.span);
+    let cond_cx = scope_block(loop_cx, "while loop cond");
+    let body_cx = scope_block(loop_cx, "while loop body");
+    Br(cx, loop_cx.llbb);
+    Br(loop_cx, cond_cx.llbb);
     let cond_res = trans_temp_expr(cond_cx, cond);
     let cond_bcx = trans_block_cleanups(cond_res.bcx, cond_cx);
     CondBr(cond_bcx, cond_res.val, body_cx.llbb, next_cx.llbb);