Skip to content

Commit f6601f0

Browse files
committed
---
yaml --- r: 3792 b: refs/heads/master c: 4d325b1 h: refs/heads/master v: v3
1 parent 3ac8aa5 commit f6601f0

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
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: 1e965412d8d765a6b0af65aa660279520639ef62
2+
refs/heads/master: 4d325b1a15126c6aa9f97d510a11d93d4ac2ad53

trunk/src/comp/middle/trans.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4843,24 +4843,18 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
48434843
}
48444844

48454845
fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
4846-
bool bind_alias) -> result {
4846+
bool is_mem) -> result {
48474847
alt (pat.node) {
48484848
case (ast::pat_wild) { ret rslt(cx, llval); }
48494849
case (ast::pat_lit(_)) { ret rslt(cx, llval); }
48504850
case (ast::pat_bind(?name)) {
4851-
if (bind_alias) {
4852-
cx.fcx.lllocals.insert(pat.id, llval);
4853-
ret rslt(cx, llval);
4854-
} else {
4855-
auto t = node_id_type(cx.fcx.lcx.ccx, pat.id);
4856-
auto rslt = alloc_ty(cx, t);
4857-
auto dst = rslt.val;
4858-
auto bcx = rslt.bcx;
4859-
maybe_name_value(cx.fcx.lcx.ccx, dst, name);
4860-
bcx.fcx.lllocals.insert(pat.id, dst);
4861-
add_clean(bcx, dst, t);
4862-
ret copy_val(bcx, INIT, dst, llval, t);
4851+
auto val = llval;
4852+
if (!is_mem) {
4853+
val = spill_if_immediate
4854+
(cx, llval, node_id_type(cx.fcx.lcx.ccx, pat.id));
48634855
}
4856+
cx.fcx.lllocals.insert(pat.id, val);
4857+
ret rslt(cx, val);
48644858
}
48654859
case (ast::pat_tag(_, ?subpats)) {
48664860
if (std::ivec::len[@ast::pat](subpats) == 0u) {
@@ -4911,11 +4905,11 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr, &ast::arm[] arms,
49114905
auto next_cx = new_sub_block_ctxt(expr_res.bcx, "next");
49124906
auto match_res =
49134907
trans_pat_match(this_cx, arm.pat, expr_res.val, next_cx);
4914-
auto binding_cx = new_scope_block_ctxt(match_res.bcx, "binding");
4915-
match_res.bcx.build.Br(binding_cx.llbb);
49164908
auto binding_res =
4917-
trans_pat_binding(binding_cx, arm.pat, expr_res.val, false);
4918-
auto block_res = trans_block(binding_res.bcx, arm.block, output);
4909+
trans_pat_binding(match_res.bcx, arm.pat, expr_res.val, false);
4910+
auto block_cx = new_scope_block_ctxt(match_res.bcx, "case block");
4911+
binding_res.bcx.build.Br(block_cx.llbb);
4912+
auto block_res = trans_block(block_cx, arm.block, output);
49194913
arm_results += ~[block_res];
49204914
this_cx = next_cx;
49214915
}

0 commit comments

Comments
 (0)