From 4ca169ce84ad717df78bd2e876149b5d59153a46 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 22 May 2018 15:19:55 +0200 Subject: [PATCH] Use the target types bitsize instead of the source type's --- src/librustc_mir/interpret/cast.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 6c0a26e1f23b..a2eede82acd4 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -92,29 +92,29 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { match dest_ty.sty { // float -> uint TyUint(t) => { - let width = t.bit_width().unwrap_or(self.memory.pointer_size().bytes() as usize * 8); + let width = t.bit_width().unwrap_or(self.memory.pointer_size().bits() as usize); match fty { FloatTy::F32 => Ok(Scalar::Bits { bits: Single::from_bits(bits).to_u128(width).value, - defined: 32, + defined: width as u8, }), FloatTy::F64 => Ok(Scalar::Bits { bits: Double::from_bits(bits).to_u128(width).value, - defined: 64, + defined: width as u8, }), } }, // float -> int TyInt(t) => { - let width = t.bit_width().unwrap_or(self.memory.pointer_size().bytes() as usize * 8); + let width = t.bit_width().unwrap_or(self.memory.pointer_size().bits() as usize); match fty { FloatTy::F32 => Ok(Scalar::Bits { bits: Single::from_bits(bits).to_i128(width).value as u128, - defined: 32, + defined: width as u8, }), FloatTy::F64 => Ok(Scalar::Bits { bits: Double::from_bits(bits).to_i128(width).value as u128, - defined: 64, + defined: width as u8, }), } },