@@ -77,7 +77,7 @@ pub fn trans_if(bcx: @mut Block,
77
77
return with_scope ( bcx, thn. info ( ) , "if_true_then" , |bcx| {
78
78
let bcx_out = trans_block ( bcx, thn, dest) ;
79
79
debuginfo:: clear_source_location ( bcx. fcx ) ;
80
- trans_block_cleanups ( bcx_out, block_cleanups ( bcx ) )
80
+ bcx_out
81
81
} )
82
82
} else {
83
83
let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
@@ -90,9 +90,9 @@ pub fn trans_if(bcx: @mut Block,
90
90
elexpr. info ( ) ,
91
91
"if_false_then" ,
92
92
|bcx| {
93
- let bcx_out = trans_if_else ( bcx, elexpr, dest) ;
93
+ let bcx_out = trans_if_else ( bcx, elexpr, dest, false ) ;
94
94
debuginfo:: clear_source_location ( bcx. fcx ) ;
95
- trans_block_cleanups ( bcx_out, block_cleanups ( bcx ) )
95
+ bcx_out
96
96
} )
97
97
}
98
98
// if false { .. }
@@ -116,7 +116,7 @@ pub fn trans_if(bcx: @mut Block,
116
116
let ( else_bcx_in, next_bcx) = match els {
117
117
Some ( elexpr) => {
118
118
let else_bcx_in = scope_block ( bcx, elexpr. info ( ) , "else" ) ;
119
- let else_bcx_out = trans_if_else ( else_bcx_in, elexpr, dest) ;
119
+ let else_bcx_out = trans_if_else ( else_bcx_in, elexpr, dest, true ) ;
120
120
( else_bcx_in, join_blocks ( bcx, [ then_bcx_out, else_bcx_out] ) )
121
121
}
122
122
_ => {
@@ -138,7 +138,7 @@ pub fn trans_if(bcx: @mut Block,
138
138
139
139
// trans `else [ if { .. } ... | { .. } ]`
140
140
fn trans_if_else ( else_bcx_in : @mut Block , elexpr : @ast:: Expr ,
141
- dest : expr:: Dest ) -> @mut Block {
141
+ dest : expr:: Dest , cleanup : bool ) -> @mut Block {
142
142
let else_bcx_out = match elexpr. node {
143
143
ast:: ExprIf ( _, _, _) => {
144
144
let elseif_blk = ast_util:: block_from_expr ( elexpr) ;
@@ -150,8 +150,12 @@ pub fn trans_if(bcx: @mut Block,
150
150
// would be nice to have a constraint on ifs
151
151
_ => else_bcx_in. tcx ( ) . sess . bug ( "strange alternative in if" )
152
152
} ;
153
- debuginfo:: clear_source_location ( else_bcx_in. fcx ) ;
154
- trans_block_cleanups ( else_bcx_out, block_cleanups ( else_bcx_in) )
153
+ if cleanup {
154
+ debuginfo:: clear_source_location ( else_bcx_in. fcx ) ;
155
+ trans_block_cleanups ( else_bcx_out, block_cleanups ( else_bcx_in) )
156
+ } else {
157
+ else_bcx_out
158
+ }
155
159
}
156
160
}
157
161
0 commit comments