Implement raw ptr -> usize, fn ptr -> usize, usize -> raw ptr casts

This commit is contained in:
bjorn3 2018-08-09 11:23:04 +02:00
parent 9a2b1d4ac3
commit 566803f288

View File

@ -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);