Skip to content

Commit 74f38dd

Browse files
brsongraydon
authored andcommitted
---
yaml --- r: 1903 b: refs/heads/master c: aced4ce h: refs/heads/master i: 1901: aee1013 1899: 007ce04 1895: 82bda26 1887: 55260c6 v: v3
1 parent 9929f32 commit 74f38dd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
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: a5a319fa047b04b525066d560115ad93a18e4a4f
2+
refs/heads/master: aced4ce145bf23cc945c58a6c9c1bc1f33359a06

trunk/src/comp/middle/trans.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,6 +3049,9 @@ fn trans_if(@block_ctxt cx, @ast.expr cond,
30493049
// FIXME: Handle dynamic type sizes
30503050
auto expr_ty = ty.expr_ty(elexpr);
30513051
expr_llty = type_of(else_res.bcx.fcx.ccx, expr_ty);
3052+
if (ty.type_is_structural(expr_ty)) {
3053+
expr_llty = T_ptr(expr_llty);
3054+
}
30523055
}
30533056
case (_) {
30543057
else_res = res(else_cx, C_nil());
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// xfail-boot
2+
// -*- rust -*-
3+
4+
// Tests for if as expressions returning structural types
5+
6+
fn test_rec() {
7+
auto res = if (true) { rec(i = 100) } else { rec(i = 101) };
8+
check (res == rec(i = 100));
9+
}
10+
11+
fn test_tag() {
12+
tag mood {
13+
happy;
14+
sad;
15+
}
16+
17+
auto res = if (true) { happy } else { sad };
18+
check (res == happy);
19+
}
20+
21+
fn main() {
22+
test_rec();
23+
test_tag();
24+
}

0 commit comments

Comments
 (0)