Skip to content

Commit b8daf8b

Browse files
committed
---
yaml --- r: 3326 b: refs/heads/master c: b9fc4df h: refs/heads/master v: v3
1 parent 2a663bf commit b8daf8b

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
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: 05c0216654999e3d33373914b10aebf9dd7d4907
2+
refs/heads/master: b9fc4dfc549ba6268a30209cd75f8a043e2f61fc

trunk/src/comp/middle/trans.rs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,47 +4101,29 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond, &ast::block thn,
41014101
auto then_cx = new_scope_block_ctxt(cx, "then");
41024102
auto then_res = trans_block(then_cx, thn, output);
41034103
auto else_cx = new_scope_block_ctxt(cx, "else");
4104-
auto else_res;
4105-
auto expr_llty;
4106-
alt (els) {
4104+
auto else_res = alt (els) {
41074105
case (some(?elexpr)) {
41084106
alt (elexpr.node) {
41094107
case (ast::expr_if(_, _, _)) {
41104108
// Synthesize a block here to act as the else block
41114109
// containing an if expression. Needed in order for the
41124110
// else scope to behave like a normal block scope. A tad
41134111
// ugly.
4114-
4115-
let ast::block_ elseif_blk_ =
4116-
rec(stmts=[],
4117-
expr=some[@ast::expr](elexpr),
4118-
id=elexpr.id);
4119-
auto elseif_blk = rec(node=elseif_blk_, span=elexpr.span);
4120-
else_res = trans_block(else_cx, elseif_blk, output);
4112+
auto elseif_blk = ast::block_from_expr(elexpr);
4113+
trans_block(else_cx, elseif_blk, output)
41214114
}
41224115
case (ast::expr_block(?blk)) {
41234116
// Calling trans_block directly instead of trans_expr
41244117
// because trans_expr will create another scope block
41254118
// context for the block, but we've already got the
41264119
// 'else' context
41274120

4128-
else_res = trans_block(else_cx, blk, output);
4129-
}
4130-
}
4131-
// FIXME: This isn't quite right, particularly re: dynamic types
4132-
4133-
auto expr_ty = ty::node_id_to_type(cx.fcx.lcx.ccx.tcx, id);
4134-
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
4135-
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
4136-
} else {
4137-
expr_llty = type_of(cx.fcx.lcx.ccx, elexpr.span, expr_ty);
4138-
if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
4139-
expr_llty = T_ptr(expr_llty);
4121+
trans_block(else_cx, blk, output)
41404122
}
41414123
}
41424124
}
4143-
case (_) { else_res = res(else_cx, C_nil()); expr_llty = T_nil(); }
4144-
}
4125+
case (_) { res(else_cx, C_nil()) }
4126+
};
41454127
cond_res.bcx.build.CondBr(cond_res.val, then_cx.llbb, else_cx.llbb);
41464128
ret res(join_branches(cx, [then_res, else_res]), C_nil());
41474129
}
@@ -4599,18 +4581,6 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr, &vec[ast::arm] arms,
45994581
auto default_res =
46004582
trans_fail(default_cx, some[common::span](expr.span),
46014583
"non-exhaustive match failure");
4602-
// FIXME: This isn't quite right, particularly re: dynamic types
4603-
4604-
auto expr_ty = ty::node_id_to_type(cx.fcx.lcx.ccx.tcx, id);
4605-
auto expr_llty;
4606-
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
4607-
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
4608-
} else {
4609-
expr_llty = type_of(cx.fcx.lcx.ccx, expr.span, expr_ty);
4610-
if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
4611-
expr_llty = T_ptr(expr_llty);
4612-
}
4613-
}
46144584
ret res(join_branches(cx, arm_results), C_nil());
46154585
}
46164586

0 commit comments

Comments
 (0)