@@ -260,37 +260,24 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
260
260
let r_t_out = CastTy :: from_ty ( cast_ty) . expect ( "bad output type for cast" ) ;
261
261
let ll_t_in = type_of:: immediate_type_of ( bcx. ccx , operand. ty ) ;
262
262
let ll_t_out = type_of:: immediate_type_of ( bcx. ccx , cast_ty) ;
263
- let ( llval, signed) = if let CastTy :: Int ( IntTy :: CEnum ) = r_t_in {
264
- let l = bcx. ccx . layout_of ( operand. ty ) ;
265
- let discr = match operand. val {
266
- OperandValue :: Immediate ( llval) => llval,
267
- OperandValue :: Ref ( llptr) => {
268
- adt:: trans_get_discr ( & bcx, operand. ty , llptr, None , true )
269
- }
270
- OperandValue :: Pair ( ..) => bug ! ( "Unexpected Pair operand" )
271
- } ;
272
- let ( signed, min, max) = match l {
273
- & Layout :: CEnum { signed, min, max, .. } => {
274
- ( signed, min, max)
275
- }
276
- _ => bug ! ( "CEnum {:?} is not an enum" , operand)
277
- } ;
278
-
263
+ let llval = operand. immediate ( ) ;
264
+ let l = bcx. ccx . layout_of ( operand. ty ) ;
265
+ let signed = if let Layout :: CEnum { signed, min, max, .. } = * l {
279
266
if max > min {
280
267
// We want `table[e as usize]` to not
281
268
// have bound checks, and this is the most
282
269
// convenient place to put the `assume`.
283
270
284
271
base:: call_assume ( & bcx, bcx. icmp (
285
272
llvm:: IntULE ,
286
- discr ,
287
- C_integral ( common:: val_ty ( discr ) , max, false )
288
- ) )
273
+ llval ,
274
+ C_integral ( common:: val_ty ( llval ) , max, false )
275
+ ) ) ;
289
276
}
290
277
291
- ( discr , signed)
278
+ signed
292
279
} else {
293
- ( operand. immediate ( ) , operand . ty . is_signed ( ) )
280
+ operand. ty . is_signed ( )
294
281
} ;
295
282
296
283
let newval = match ( r_t_in, r_t_out) {
0 commit comments