Skip to content

Commit 648f0cb

Browse files
committed
---
yaml --- r: 5189 b: refs/heads/master c: db15591 h: refs/heads/master i: 5187: 6473f12 v: v3
1 parent 7400237 commit 648f0cb

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
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: 3ac59b0ee0eb2b174444ea1fd7eb980db4b59246
2+
refs/heads/master: db15591d897a08d16156e7934c0e675c271f54bf

trunk/src/comp/middle/trans.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,13 +2478,19 @@ fn trans_for(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr,
24782478
fn inner(cx: &@block_ctxt, local: @ast::local, curr: ValueRef, t: ty::t,
24792479
body: &ast::blk, outer_next_cx: @block_ctxt) -> @block_ctxt {
24802480
let next_cx = new_sub_block_ctxt(cx, "next");
2481-
let bcx = new_loop_scope_block_ctxt(cx, option::some(next_cx),
2482-
outer_next_cx, "for loop scope");
2483-
Br(cx, bcx.llbb);
2484-
let val = PointerCast(bcx, curr, T_ptr(type_of_or_i8(cx, t)));
2485-
let bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat, val,
2481+
let scope_cx =
2482+
new_loop_scope_block_ctxt(cx,
2483+
option::some::<@block_ctxt>(next_cx),
2484+
outer_next_cx, "for loop scope");
2485+
Br(cx, scope_cx.llbb);
2486+
let {bcx, val: dst} = alloc_local(scope_cx, local);
2487+
let val = load_if_immediate(bcx, PointerCast(bcx, curr,
2488+
val_ty(dst)), t);
2489+
let bcx = copy_val(bcx, INIT, dst, val, t);
2490+
add_clean(scope_cx, dst, t);
2491+
let bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat, dst,
24862492
cx.fcx.lllocals, false);
2487-
let bcx = trans_block(bcx, body, return).bcx;
2493+
bcx = trans_block(bcx, body, return).bcx;
24882494
if !is_terminated(bcx) {
24892495
Br(bcx, next_cx.llbb);
24902496
// otherwise, this code is unreachable

0 commit comments

Comments
 (0)