diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 828e4bcc65c..5ca14b63bce 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -660,9 +660,11 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, (CastTy::Float, CastTy::Float) => { llvm::LLVMConstFPCast(v, llty.to_ref()) } + (CastTy::Float, CastTy::Int(IntTy::I)) => { + llvm::LLVMConstFPToSI(v, llty.to_ref()) + } (CastTy::Float, CastTy::Int(_)) => { - if ty::type_is_signed(t_expr) { llvm::LLVMConstFPToSI(v, llty.to_ref()) } - else { llvm::LLVMConstFPToUI(v, llty.to_ref()) } + llvm::LLVMConstFPToUI(v, llty.to_ref()) } (CastTy::Ptr(_), CastTy::Ptr(_)) | (CastTy::FnPtr, CastTy::Ptr(_)) | (CastTy::RPtr(_), CastTy::Ptr(_)) => { diff --git a/src/test/run-pass/cast-rfc0401.rs b/src/test/run-pass/cast-rfc0401.rs index ec4c84a1a6b..7c64c34fae5 100644 --- a/src/test/run-pass/cast-rfc0401.rs +++ b/src/test/run-pass/cast-rfc0401.rs @@ -75,7 +75,6 @@ fn main() assert_eq!(9.223372036854775e18f64 as i64, 0x7ffffffffffffc00i64); assert_eq!(-9.223372036854776e18f64 as i64, 0x8000000000000000u64 as i64); - // addr-ptr-cast/ptr-addr-cast (thin ptr) let p: *const [u8; 1] = lsz as *const [u8; 1]; assert_eq!(p as usize, lsz);