aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-04-07 15:09:45 -0700
committerPatrick Walton <[email protected]>2011-04-07 15:12:48 -0700
commit6dcf6218b1e0e70e60afe8d1a9f336adad060362 (patch)
treedab86aae32f458637665365c286d845a7aa5d2f4 /src/comp
parentrustc: Use the name "opaque_tag", not "tag", for opaque tags (diff)
downloadrust-6dcf6218b1e0e70e60afe8d1a9f336adad060362.tar.xz
rust-6dcf6218b1e0e70e60afe8d1a9f336adad060362.zip
rustc: Pointer cast when autodereferencing boxed tag types
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 877b68e2..a8e75176 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -2934,7 +2934,19 @@ fn autoderef(@block_ctxt cx, ValueRef v, @ty.t t) -> result {
vec(C_int(0),
C_int(abi.box_rc_field_body)));
t1 = mt.ty;
- v1 = load_scalar_or_boxed(cx, body, t1);
+
+ // Since we're changing levels of box indirection, we may have
+ // to cast this pointer, since statically-sized tag types have
+ // different types depending on whether they're behind a box
+ // or not.
+ if (!ty.type_has_dynamic_size(mt.ty)) {
+ auto llty = type_of(cx.fcx.ccx, mt.ty);
+ v1 = cx.build.PointerCast(body, T_ptr(llty));
+ } else {
+ v1 = body;
+ }
+
+ v1 = load_scalar_or_boxed(cx, v1, t1);
}
case (_) {
ret res(cx, v1);