File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1824,10 +1824,13 @@ impl<'tcx> Const<'tcx> {
1824
1824
ty : ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
1825
1825
) -> & ' tcx Self {
1826
1826
let ty = tcx. global_tcx ( ) . lift ( & ty) . unwrap ( ) ;
1827
- let defined = tcx. global_tcx ( ) . layout_of ( ty) . unwrap_or_else ( |e| {
1827
+ let size = tcx. global_tcx ( ) . layout_of ( ty) . unwrap_or_else ( |e| {
1828
1828
panic ! ( "could not compute layout for {:?}: {:?}" , ty, e)
1829
- } ) . size . bits ( ) as u8 ;
1830
- Self :: from_scalar ( tcx, Scalar :: Bits { bits, defined } , ty. value )
1829
+ } ) . size ;
1830
+ let amt = 128 - size. bits ( ) ;
1831
+ let truncated = ( bits << amt) >> amt;
1832
+ assert_eq ! ( truncated, bits, "from_bits called with untruncated value" ) ;
1833
+ Self :: from_scalar ( tcx, Scalar :: Bits { bits, defined : size. bits ( ) as u8 } , ty. value )
1831
1834
}
1832
1835
1833
1836
#[ inline]
You can’t perform that action at this time.
0 commit comments