u64::try_from will now fail if ScalarInt isn't exactly 64 bits, thus we use to_bits with the correct size

This commit is contained in:
oli 2020-11-04 13:59:11 +00:00
parent 5fa1c8f91a
commit 6e96e10f93

View File

@ -261,7 +261,7 @@ impl<'tcx> CValue<'tcx> {
fx
.bcx
.ins()
.iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64)
.iconst(clif_ty, const_val.to_bits(layout.size).unwrap() as i64)
}
ty::Float(FloatTy::F32) => {
fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(const_val).unwrap()))