diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-09-09 16:26:53 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-09-09 16:53:45 +0200 |
| commit | db15591d897a08d16156e7934c0e675c271f54bf (patch) | |
| tree | 5f702982ecaf461f5ae4de9399b77b3576161c56 | |
| parent | 3ac59b0ee0eb2b174444ea1fd7eb980db4b59246 (diff) | |
Revert "Make for loops alias the vec elements, rather than copy them"
This reverts commit 985ef59efd971f1d6b9bf4b5e484b75733e00444.
| -rw-r--r-- | src/comp/middle/trans.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index e19c028e6dc..893614cac9a 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2478,13 +2478,19 @@ fn trans_for(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr, fn inner(cx: &@block_ctxt, local: @ast::local, curr: ValueRef, t: ty::t, body: &ast::blk, outer_next_cx: @block_ctxt) -> @block_ctxt { let next_cx = new_sub_block_ctxt(cx, "next"); - let bcx = new_loop_scope_block_ctxt(cx, option::some(next_cx), - outer_next_cx, "for loop scope"); - Br(cx, bcx.llbb); - let val = PointerCast(bcx, curr, T_ptr(type_of_or_i8(cx, t))); - let bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat, val, + let scope_cx = + new_loop_scope_block_ctxt(cx, + option::some::<@block_ctxt>(next_cx), + outer_next_cx, "for loop scope"); + Br(cx, scope_cx.llbb); + let {bcx, val: dst} = alloc_local(scope_cx, local); + let val = load_if_immediate(bcx, PointerCast(bcx, curr, + val_ty(dst)), t); + let bcx = copy_val(bcx, INIT, dst, val, t); + add_clean(scope_cx, dst, t); + let bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat, dst, cx.fcx.lllocals, false); - let bcx = trans_block(bcx, body, return).bcx; + bcx = trans_block(bcx, body, return).bcx; if !is_terminated(bcx) { Br(bcx, next_cx.llbb); // otherwise, this code is unreachable |
