File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -769,7 +769,6 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
769
769
770
770
let discr_type = repr. discr_type ( ) ;
771
771
let discr_int = Integer :: from_attr ( dl, discr_type) ;
772
- let bits = discr_int. size ( ) . bits ( ) ;
773
772
// Because we can only represent one range of valid values, we'll look for the
774
773
// largest range of invalid values and pick everything else as the range of valid
775
774
// values.
@@ -780,7 +779,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
780
779
. map ( |( _, val) | {
781
780
if discr_type. is_signed ( ) {
782
781
// sign extend the raw representation to be an i128
783
- ( val << ( 128 - bits) ) >> ( 128 - bits)
782
+ // FIXME: do this at the discriminant iterator creation sites
783
+ discr_int. size ( ) . sign_extend ( val as u128 )
784
784
} else {
785
785
val
786
786
}
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ use crate::ty::{
32
32
33
33
#[ derive( Copy , Clone , Debug ) ]
34
34
pub struct Discr < ' tcx > {
35
- /// Bit representation of the discriminant (e.g., `-128i8 ` is `0xFF_u128`).
35
+ /// Bit representation of the discriminant (e.g., `-1i8 ` is `0xFF_u128`).
36
36
pub val : u128 ,
37
37
pub ty : Ty < ' tcx > ,
38
38
}
You can’t perform that action at this time.
0 commit comments