@@ -166,31 +166,24 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
166
166
let cond_val = unpack_result ! ( bcx, expr:: trans( bcx, cond) . to_llbool( ) ) ;
167
167
168
168
// Drop branches that are known to be impossible
169
- if is_const ( cond_val) && !is_undef ( cond_val) {
170
- if const_to_uint ( cond_val) == 1 {
171
- match els {
172
- Some ( elexpr) => {
173
- let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
174
- trans. visit_expr ( & * elexpr) ;
175
- }
176
- None => { }
177
- }
169
+ if let Some ( cv) = const_to_opt_uint ( cond_val) {
170
+ if cv == 1 {
178
171
// if true { .. } [else { .. }]
179
172
bcx = trans_block ( bcx, & * thn, dest) ;
180
173
trans:: debuginfo:: clear_source_location ( bcx. fcx ) ;
174
+
175
+ if let Some ( elexpr) = els {
176
+ let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
177
+ trans. visit_expr ( & * elexpr) ;
178
+ }
181
179
} else {
182
- let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
180
+ // if false { .. } [else { .. }]
181
+ let mut trans = TransItemVisitor { ccx : bcx. fcx . ccx } ;
183
182
trans. visit_block ( & * thn) ;
184
183
185
- match els {
186
- // if false { .. } else { .. }
187
- Some ( elexpr) => {
188
- bcx = expr:: trans_into ( bcx, & * elexpr, dest) ;
189
- trans:: debuginfo:: clear_source_location ( bcx. fcx ) ;
190
- }
191
-
192
- // if false { .. }
193
- None => { }
184
+ if let Some ( elexpr) = els {
185
+ bcx = expr:: trans_into ( bcx, & * elexpr, dest) ;
186
+ trans:: debuginfo:: clear_source_location ( bcx. fcx ) ;
194
187
}
195
188
}
196
189
0 commit comments