diff options
| author | Brian Anderson <[email protected]> | 2011-03-27 20:20:12 -0400 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-03-28 21:14:08 -0700 |
| commit | 8f2a97a562916a882ec0818e6295d41971aad5f1 (patch) | |
| tree | ffe8982b5f86bea44766186e68dbcca0a1482f99 /src/comp | |
| parent | Add an XFAILed test for if expressions resulting in boxes (diff) | |
| download | rust-8f2a97a562916a882ec0818e6295d41971aad5f1.tar.xz rust-8f2a97a562916a882ec0818e6295d41971aad5f1.zip | |
Add partial support for if expressions resulting in generic types
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 433a8012..3995e1de 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3046,11 +3046,14 @@ fn trans_if(@block_ctxt cx, @ast.expr cond, // If we have an else expression, then the entire // if expression can have a non-nil type. - // FIXME: Handle dynamic type sizes auto expr_ty = ty.expr_ty(elexpr); - expr_llty = type_of(else_res.bcx.fcx.ccx, expr_ty); - if (ty.type_is_structural(expr_ty)) { - expr_llty = T_ptr(expr_llty); + if (ty.type_has_dynamic_size(expr_ty)) { + expr_llty = T_typaram_ptr(cx.fcx.ccx.tn); + } else { + expr_llty = type_of(else_res.bcx.fcx.ccx, expr_ty); + if (ty.type_is_structural(expr_ty)) { + expr_llty = T_ptr(expr_llty); + } } } case (_) { |