@@ -4101,47 +4101,29 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond, &ast::block thn,
4101
4101
auto then_cx = new_scope_block_ctxt( cx, "then") ;
4102
4102
auto then_res = trans_block( then_cx, thn, output) ;
4103
4103
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) {
4107
4105
case ( some( ?elexpr) ) {
4108
4106
alt ( elexpr. node) {
4109
4107
case ( ast:: expr_if( _, _, _) ) {
4110
4108
// Synthesize a block here to act as the else block
4111
4109
// containing an if expression. Needed in order for the
4112
4110
// else scope to behave like a normal block scope. A tad
4113
4111
// 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)
4121
4114
}
4122
4115
case ( ast:: expr_block( ?blk) ) {
4123
4116
// Calling trans_block directly instead of trans_expr
4124
4117
// because trans_expr will create another scope block
4125
4118
// context for the block, but we've already got the
4126
4119
// 'else' context
4127
4120
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)
4140
4122
}
4141
4123
}
4142
4124
}
4143
- case ( _) { else_res = res( else_cx, C_nil ( ) ) ; expr_llty = T_nil ( ) ; }
4144
- }
4125
+ case ( _) { res( else_cx, C_nil ( ) ) }
4126
+ } ;
4145
4127
cond_res. bcx. build. CondBr ( cond_res. val, then_cx. llbb, else_cx. llbb) ;
4146
4128
ret res( join_branches( cx, [ then_res, else_res] ) , C_nil ( ) ) ;
4147
4129
}
@@ -4599,18 +4581,6 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr, &vec[ast::arm] arms,
4599
4581
auto default_res =
4600
4582
trans_fail( default_cx, some[ common:: span] ( expr. span) ,
4601
4583
"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
- }
4614
4584
ret res( join_branches( cx, arm_results) , C_nil ( ) ) ;
4615
4585
}
4616
4586
0 commit comments