Skip to content

Commit cbe349f

Browse files
committed
---
yaml --- r: 4845 b: refs/heads/master c: a7e559e h: refs/heads/master i: 4843: 9a1bbeb v: v3
1 parent cb0973d commit cbe349f

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
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: cc2ebbec92230fa3e377550e42cab4d964bb866d
2+
refs/heads/master: a7e559ee2e04799adfb92b0d8a54758678c170dc

trunk/src/comp/middle/trans.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,8 +3737,7 @@ fn trans_for_each(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr,
37373737
ast::expr_call(f, args) {
37383738
let pair =
37393739
create_real_fn_pair(cx, iter_body_llty, lliterbody, llenv.ptr);
3740-
r = trans_call(cx, f, some::<ValueRef>(cx.build.Load(pair)), args,
3741-
seq.id);
3740+
r = trans_call(cx, f, some(pair), args, seq.id);
37423741
ret rslt(r.bcx, C_nil());
37433742
}
37443743
}
@@ -4626,7 +4625,17 @@ fn trans_args(cx: &@block_ctxt, llenv: ValueRef,
46264625
llargs += lltydescs;
46274626

46284627
// ... then possibly an lliterbody argument.
4629-
alt lliterbody { none. { } some(lli) { llargs += ~[lli]; } }
4628+
alt lliterbody {
4629+
none. { }
4630+
some(lli) {
4631+
let lli = if (ty::type_contains_params(bcx_tcx(cx), retty)) {
4632+
let body_ty = ty::mk_iter_body_fn(bcx_tcx(cx), retty);
4633+
let body_llty = type_of_inner(bcx_ccx(cx), cx.sp, body_ty);
4634+
bcx.build.PointerCast(lli, T_ptr(body_llty))
4635+
} else { lli };
4636+
llargs += ~[cx.build.Load(lli)];
4637+
}
4638+
}
46304639

46314640
// ... then explicit args.
46324641

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
iter iter2<@T>() -> T { }
2+
fn main() {
3+
for each i: int in iter2() { }
4+
}

0 commit comments

Comments
 (0)