about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2012-06-18 12:50:09 -0700
committerMichael Sullivan <sully@msully.net>2012-06-18 15:54:37 -0700
commit30dd32d4db0834a9bb965cfceaee3211f09a5344 (patch)
tree40202fb654183cef4ecd4ac693551617e48c54e4
parent797856cbdefaff84072a39bb92fc8dbc0950e96e (diff)
downloadrust-30dd32d4db0834a9bb965cfceaee3211f09a5344.tar.gz
rust-30dd32d4db0834a9bb965cfceaee3211f09a5344.zip
Fix generation of str/@. Closes #2638.
-rw-r--r--src/rt/rust_upcall.cpp5
-rw-r--r--src/rustc/middle/trans/tvec.rs4
-rw-r--r--src/rustc/middle/trans/type_of.rs4
3 files changed, 9 insertions, 4 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index ea938d386f4..3803f60c045 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -373,8 +373,9 @@ upcall_s_str_new_shared(s_str_new_shared_args *args) {
     size_t str_fill = args->len + 1;
     size_t str_alloc = str_fill;
     args->retval = (rust_opaque_box *)
-        task->boxed.malloc(&str_body_tydesc, str_fill);
-    rust_str *str = (rust_str *)box_body(args->retval);
+        task->boxed.malloc(&str_body_tydesc,
+                           str_fill + sizeof(rust_vec));
+    rust_str *str = (rust_str *)args->retval;
     str->body.fill = str_fill;
     str->body.alloc = str_alloc;
     memcpy(&str->body.data, args->cstr, args->len);
diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs
index 3a543b968b7..72e82a96709 100644
--- a/src/rustc/middle/trans/tvec.rs
+++ b/src/rustc/middle/trans/tvec.rs
@@ -290,7 +290,9 @@ fn trans_estr(bcx: block, s: @str, vstore: ast::vstore,
       ast::vstore_box {
         let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
         let len = C_uint(ccx, str::len(*s));
-        Call(bcx, ccx.upcalls.str_new_shared, [cs, len])
+        let c = Call(bcx, ccx.upcalls.str_new_shared, [cs, len]);
+        PointerCast(bcx, c,
+                    T_box_ptr(T_box(ccx, T_vec(ccx, T_i8()))))
       }
     };
 
diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs
index 0d6ef8c6d12..c0f3014cf96 100644
--- a/src/rustc/middle/trans/type_of.rs
+++ b/src/rustc/middle/trans/type_of.rs
@@ -93,7 +93,9 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
             T_unique_ptr(T_unique(cx, T_vec(cx, T_i8())))
           }
           ty::ty_enum(did, _) { type_of_enum(cx, did, t) }
-          ty::ty_estr(ty::vstore_box) { T_box_ptr(T_box(cx, T_i8())) }
+          ty::ty_estr(ty::vstore_box) {
+            T_box_ptr(T_box(cx, T_vec(cx, T_i8())))
+          }
           ty::ty_evec(mt, ty::vstore_box) {
             T_box_ptr(T_box(cx, T_vec(cx, type_of(cx, mt.ty))))
           }