aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-18 18:12:58 -0700
committerPatrick Walton <[email protected]>2011-03-18 18:12:58 -0700
commit8c48fae72631720c8edd8cf0fb58de44e7978538 (patch)
treeeff988bd5761a3bef9d2f35694de946f170e7343 /src
parentrustc: Fix inference for auto slots (forgot to stage changes before) (diff)
downloadrust-8c48fae72631720c8edd8cf0fb58de44e7978538.tar.xz
rust-8c48fae72631720c8edd8cf0fb58de44e7978538.zip
rustc: Do pointer casts when casting native types
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 92b147d2..b30fcefb 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -3596,7 +3596,9 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
auto t = node_ann_type(cx.fcx.ccx, ann);
auto lldsttype = type_of(cx.fcx.ccx, t);
if (!ty.type_is_fp(t)) {
- if (llvm.LLVMGetIntTypeWidth(lldsttype) >
+ if (ty.type_is_native(ty.expr_ty(e))) {
+ e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
+ } else if (llvm.LLVMGetIntTypeWidth(lldsttype) >
llvm.LLVMGetIntTypeWidth(llsrctype)) {
if (ty.type_is_signed(t)) {
// Widening signed cast.