@@ -306,7 +306,7 @@ pub fn trans_get_discr(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
306
306
-> ValueRef {
307
307
match * r {
308
308
CEnum ( min, max) => load_discr ( bcx, scrutinee, min, max) ,
309
- Univariant ( * ) => C_uint ( bcx. ccx ( ) , 0 ) ,
309
+ Univariant ( * ) => C_disr ( bcx. ccx ( ) , 0 ) ,
310
310
General ( ref cases) => load_discr ( bcx, scrutinee, 0 , ( cases. len ( ) - 1 ) as Disr ) ,
311
311
NullablePointer { nonnull : ref nonnull, nndiscr, ptrfield, _ } => {
312
312
ZExt ( bcx, nullable_bitdiscr ( bcx, nonnull, nndiscr, ptrfield, scrutinee) ,
@@ -351,13 +351,13 @@ fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: Disr, max: Disr)
351
351
pub fn trans_case ( bcx : @mut Block , r : & Repr , discr : Disr ) -> _match:: opt_result {
352
352
match * r {
353
353
CEnum ( * ) => {
354
- _match:: single_result ( rslt ( bcx, C_uint ( bcx. ccx ( ) , discr /*bad*/ as uint ) ) )
354
+ _match:: single_result ( rslt ( bcx, C_disr ( bcx. ccx ( ) , discr) ) )
355
355
}
356
356
Univariant ( * ) => {
357
357
bcx. ccx ( ) . sess . bug ( "no cases for univariants or structs" )
358
358
}
359
359
General ( * ) => {
360
- _match:: single_result ( rslt ( bcx, C_uint ( bcx. ccx ( ) , discr /*bad*/ as uint ) ) )
360
+ _match:: single_result ( rslt ( bcx, C_disr ( bcx. ccx ( ) , discr) ) )
361
361
}
362
362
NullablePointer { _ } => {
363
363
assert ! ( discr == 0 || discr == 1 ) ;
@@ -375,7 +375,7 @@ pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr) {
375
375
match * r {
376
376
CEnum ( min, max) => {
377
377
assert ! ( min <= discr && discr <= max) ;
378
- Store ( bcx, C_uint ( bcx. ccx ( ) , discr/*bad*/ as uint ) , GEPi ( bcx, val, [ 0 , 0 ] ) )
378
+ Store ( bcx, C_disr ( bcx. ccx ( ) , discr) , GEPi ( bcx, val, [ 0 , 0 ] ) )
379
379
}
380
380
Univariant ( ref st, true ) => {
381
381
assert_eq ! ( discr, 0 ) ;
@@ -386,7 +386,7 @@ pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr) {
386
386
assert_eq ! ( discr, 0 ) ;
387
387
}
388
388
General ( * ) => {
389
- Store ( bcx, C_uint ( bcx. ccx ( ) , discr/*bad*/ as uint ) , GEPi ( bcx, val, [ 0 , 0 ] ) )
389
+ Store ( bcx, C_disr ( bcx. ccx ( ) , discr) , GEPi ( bcx, val, [ 0 , 0 ] ) )
390
390
}
391
391
NullablePointer { nonnull : ref nonnull, nndiscr, ptrfield, _ } => {
392
392
if discr != nndiscr {
@@ -501,7 +501,7 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
501
501
CEnum ( min, max) => {
502
502
assert_eq ! ( vals. len( ) , 0 ) ;
503
503
assert ! ( min <= discr && discr <= max) ;
504
- C_uint ( ccx, discr/*bad*/ as uint )
504
+ C_disr ( ccx, discr)
505
505
}
506
506
Univariant ( ref st, _dro) => {
507
507
assert_eq ! ( discr, 0 ) ;
@@ -510,7 +510,7 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
510
510
General ( ref cases) => {
511
511
let case = & cases[ discr] ;
512
512
let max_sz = cases. iter ( ) . map ( |x| x. size ) . max ( ) . unwrap ( ) ;
513
- let discr_ty = C_uint ( ccx, discr/*bad*/ as uint ) ;
513
+ let discr_ty = C_disr ( ccx, discr) ;
514
514
let contents = build_const_struct ( ccx, case,
515
515
~[ discr_ty] + vals) ;
516
516
C_struct ( contents + & [ padding ( max_sz - case. size ) ] )
@@ -645,3 +645,7 @@ pub fn is_newtypeish(r: &Repr) -> bool {
645
645
_ => false
646
646
}
647
647
}
648
+
649
+ fn C_disr ( cx : & CrateContext , i : Disr ) -> ValueRef {
650
+ return C_integral ( cx. int_type , i, false ) ;
651
+ }
0 commit comments