From 566803f288f18d37f05b17bbbdc746eb634af488 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 11:23:04 +0200 Subject: [PATCH] Implement raw ptr -> usize, fn ptr -> usize, usize -> raw ptr casts --- src/base.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index c26249157ca..ea607370ebd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -379,10 +379,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & | (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { + (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) + | (TypeVariants::TyFnPtr(..), TypeVariants::TyUint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { + lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); + } + (TypeVariants::TyUint(_), TypeVariants::TyRawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } (TypeVariants::TyChar, TypeVariants::TyUint(_)) + | (TypeVariants::TyUint(_), TypeVariants::TyChar) | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx);