File tree 1 file changed +2
-3
lines changed
1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change 3
3
use crate :: hir;
4
4
use crate :: hir:: def_id:: DefId ;
5
5
use crate :: infer:: canonical:: Canonical ;
6
- use crate :: mir:: interpret:: ConstValue ;
6
+ use crate :: mir:: interpret:: { ConstValue , truncate } ;
7
7
use crate :: middle:: region;
8
8
use polonius_engine:: Atom ;
9
9
use rustc_data_structures:: indexed_vec:: Idx ;
@@ -2118,8 +2118,7 @@ impl<'tcx> Const<'tcx> {
2118
2118
let size = tcx. layout_of ( ty) . unwrap_or_else ( |e| {
2119
2119
panic ! ( "could not compute layout for {:?}: {:?}" , ty, e)
2120
2120
} ) . size ;
2121
- let shift = 128 - size. bits ( ) ;
2122
- let truncated = ( bits << shift) >> shift;
2121
+ let truncated = truncate ( bits, size) ;
2123
2122
assert_eq ! ( truncated, bits, "from_bits called with untruncated value" ) ;
2124
2123
Self :: from_scalar ( Scalar :: Bits { bits, size : size. bytes ( ) as u8 } , ty. value )
2125
2124
}
You can’t perform that action at this time.
0 commit comments