Skip to content

Commit 3f2bae4

Browse files
committed
rustc: Implement int-to-native casts
1 parent e6b6d1b commit 3f2bae4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/comp/middle/trans.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3585,8 +3585,11 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
35853585
auto t = node_ann_type(cx.fcx.ccx, ann);
35863586
auto lldsttype = type_of(cx.fcx.ccx, t);
35873587
if (!ty.type_is_fp(t)) {
3588+
// TODO: native-to-native casts
35883589
if (ty.type_is_native(ty.expr_ty(e))) {
35893590
e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
3591+
} else if (ty.type_is_native(t)) {
3592+
e_res.val = e_res.bcx.build.IntToPtr(e_res.val, lldsttype);
35903593
} else if (llvm.LLVMGetIntTypeWidth(lldsttype) >
35913594
llvm.LLVMGetIntTypeWidth(llsrctype)) {
35923595
if (ty.type_is_signed(t)) {

0 commit comments

Comments
 (0)