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> {
769769
770770 let discr_type = repr. discr_type ( ) ;
771771 let discr_int = Integer :: from_attr ( dl, discr_type) ;
772- let bits = discr_int. size ( ) . bits ( ) ;
773772 // Because we can only represent one range of valid values, we'll look for the
774773 // largest range of invalid values and pick everything else as the range of valid
775774 // values.
@@ -780,7 +779,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
780779 . map ( |( _, val) | {
781780 if discr_type. is_signed ( ) {
782781 // 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 )
784784 } else {
785785 val
786786 }
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ use crate::ty::{
3232
3333#[ derive( Copy , Clone , Debug ) ]
3434pub 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`).
3636 pub val : u128 ,
3737 pub ty : Ty < ' tcx > ,
3838}
You can’t perform that action at this time.
0 commit comments