Skip to content

Commit 8e597b2

Browse files
committed
rustc: Allow arguments to be captured as upvars. std.rc compiles now, except for the lack of a main fn.
1 parent c710c9a commit 8e597b2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/comp/middle/trans.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,12 @@ fn trans_for_each(@block_ctxt cx,
30023002
auto llbinding;
30033003
alt (cx.fcx.lllocals.find(did)) {
30043004
case (none[ValueRef]) {
3005-
llbinding = cx.fcx.llupvars.get(did);
3005+
alt (cx.fcx.llupvars.find(did)) {
3006+
case (none[ValueRef]) {
3007+
llbinding = cx.fcx.llargs.get(did);
3008+
}
3009+
case (some[ValueRef](?llval)) { llbinding = llval; }
3010+
}
30063011
}
30073012
case (some[ValueRef](?llval)) { llbinding = llval; }
30083013
}
@@ -3384,8 +3389,15 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
33843389
case (some[ast.def](?def)) {
33853390
alt (def) {
33863391
case (ast.def_arg(?did)) {
3387-
check (cx.fcx.llargs.contains_key(did));
3388-
ret lval_mem(cx, cx.fcx.llargs.get(did));
3392+
alt (cx.fcx.llargs.find(did)) {
3393+
case (none[ValueRef]) {
3394+
check (cx.fcx.llupvars.contains_key(did));
3395+
ret lval_mem(cx, cx.fcx.llupvars.get(did));
3396+
}
3397+
case (some[ValueRef](?llval)) {
3398+
ret lval_mem(cx, llval);
3399+
}
3400+
}
33893401
}
33903402
case (ast.def_local(?did)) {
33913403
alt (cx.fcx.lllocals.find(did)) {

0 commit comments

Comments
 (0)