Skip to content

Commit

Permalink
u64::try_from will now fail if ScalarInt isn't exactly 64 bits, t…
Browse files Browse the repository at this point in the history
…hus we use `to_bits` with the correct size
  • Loading branch information
oli-obk committed Nov 4, 2020
1 parent 97bfff1 commit 6e6c8a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 6e6c8a8

Please sign in to comment.