From 797856cbdefaff84072a39bb92fc8dbc0950e96e Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 18 Jun 2012 14:51:50 -0700 Subject: [PATCH] Use unboxed vecs for string shape glue. --- src/rt/rust_shape.h | 1 + src/rustc/middle/trans/shape.rs | 10 +--------- .../run-pass/log-knows-the-names-of-variants-in-std.rs | 2 +- src/test/run-pass/log-knows-the-names-of-variants.rs | 2 +- src/test/run-pass/log-str.rs | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index a1108272eaa..5c83c997e2d 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -43,6 +43,7 @@ const uint8_t SHAPE_I64 = 7u; const uint8_t SHAPE_F32 = 8u; const uint8_t SHAPE_F64 = 9u; const uint8_t SHAPE_BOX = 10u; +// FIXME: remove after snapshot (6/18/12) const uint8_t SHAPE_VEC = 11u; const uint8_t SHAPE_TAG = 12u; const uint8_t SHAPE_STRUCT = 17u; diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 1d35d6548ae..61f82997e93 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -78,7 +78,6 @@ const shape_i64: u8 = 7u8; const shape_f32: u8 = 8u8; const shape_f64: u8 = 9u8; const shape_box: u8 = 10u8; -const shape_vec: u8 = 11u8; const shape_enum: u8 = 12u8; const shape_struct: u8 = 17u8; const shape_box_fn: u8 = 18u8; @@ -226,14 +225,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { ty::ty_float(ast::ty_f64) { [shape_f64] } ty::ty_estr(ty::vstore_uniq) | ty::ty_str { - // FIXME: we want to emit this as a unique pointer to an unboxed vec, - // but it doesn't work at the moment, since trans doesn't put - // tydescs in string boxes... - let mut s = [shape_vec]; - add_bool(s, true); // type is POD - let unit_ty = ty::mk_mach_uint(ccx.tcx, ast::ty_u8); - add_substr(s, shape_of(ccx, unit_ty)); - s + shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t)) } ty::ty_enum(did, substs) { alt enum_kind(ccx, did) { diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index c6c1b44df48..31f6b31fa37 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -12,7 +12,7 @@ fn check_log(exp: str, v: T) { fn main() { let x = list::from_vec([a(22u), b("hi")]); - let exp = "@cons(a(22), @cons(b(\"hi\"), @nil))"; + let exp = "@cons(a(22), @cons(b(~\"hi\"), @nil))"; assert #fmt["%?", x] == exp; check_log(exp, x); } diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index 78902cf2520..4df6d588209 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -6,6 +6,6 @@ enum foo { fn main() { assert "a(22)" == #fmt["%?", a(22u)]; - assert "b(\"hi\")" == #fmt["%?", b("hi")]; + assert "b(~\"hi\")" == #fmt["%?", b("hi")]; assert "c" == #fmt["%?", c]; } diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs index 80157c0e938..0c32e92f71f 100644 --- a/src/test/run-pass/log-str.rs +++ b/src/test/run-pass/log-str.rs @@ -1,4 +1,4 @@ fn main() { assert "~[1, 2, 3]" == sys::log_str([1, 2, 3]); - assert #fmt["%?/%5?", [1, 2, 3], "hi"] == "~[1, 2, 3]/ \"hi\""; + assert #fmt["%?/%6?", [1, 2, 3], "hi"] == "~[1, 2, 3]/ ~\"hi\""; }