Skip to content

Commit e8938f5

Browse files
committed
rustc: Unify over alt expressions
1 parent 6dee1ac commit e8938f5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/comp/middle/typeck.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,20 @@ fn demand_expr_full(&@fn_ctxt fcx, @ty.t expected, @ast.expr e,
14011401
e_1 = ast.expr_chan(es_1, ast.ann_type(t, none[vec[@ty.t]]));
14021402
}
14031403

1404+
case (ast.expr_alt(?discrim, ?arms_0, ?ann)) {
1405+
auto t = expected;
1406+
let vec[ast.arm] arms_1 = vec();
1407+
for (ast.arm arm_0 in arms_0) {
1408+
auto block_1 = demand_block(fcx, expected, arm_0.block);
1409+
t = demand(fcx, e.span, t, block_ty(block_1));
1410+
auto arm_1 = rec(pat=arm_0.pat, block=block_1,
1411+
index=arm_0.index);
1412+
arms_1 += vec(arm_1);
1413+
}
1414+
e_1 = ast.expr_alt(discrim, arms_1,
1415+
ast.ann_type(t, none[vec[@ty.t]]));
1416+
}
1417+
14041418
case (_) {
14051419
fcx.ccx.sess.span_unimpl(e.span,
14061420
"type unification for expression variant");

0 commit comments

Comments
 (0)