Skip to content

Commit 8c48fae

Browse files
committed
rustc: Do pointer casts when casting native types
1 parent 9c0c0af commit 8c48fae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3596,7 +3596,9 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
35963596
auto t = node_ann_type(cx.fcx.ccx, ann);
35973597
auto lldsttype = type_of(cx.fcx.ccx, t);
35983598
if (!ty.type_is_fp(t)) {
3599-
if (llvm.LLVMGetIntTypeWidth(lldsttype) >
3599+
if (ty.type_is_native(ty.expr_ty(e))) {
3600+
e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
3601+
} else if (llvm.LLVMGetIntTypeWidth(lldsttype) >
36003602
llvm.LLVMGetIntTypeWidth(llsrctype)) {
36013603
if (ty.type_is_signed(t)) {
36023604
// Widening signed cast.

0 commit comments

Comments
 (0)