From d884085f43f87213e3045e474c39908d6555153a Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Sat, 14 Jul 2012 12:19:36 -0700 Subject: [PATCH] Tear out ty_str and ty_vec. --- src/libstd/rope.rs | 2 +- src/rustc/front/test.rs | 6 +- src/rustc/metadata/tydecode.rs | 2 - src/rustc/metadata/tyencode.rs | 2 - src/rustc/middle/borrowck.rs | 4 +- src/rustc/middle/borrowck/categorization.rs | 5 +- src/rustc/middle/trans/alt.rs | 2 +- src/rustc/middle/trans/base.rs | 18 ++-- src/rustc/middle/trans/reflect.rs | 2 - src/rustc/middle/trans/shape.rs | 8 +- src/rustc/middle/trans/tvec.rs | 1 - src/rustc/middle/trans/type_of.rs | 6 +- src/rustc/middle/ty.rs | 99 +++++-------------- src/rustc/middle/typeck/astconv.rs | 64 ++---------- src/rustc/middle/typeck/check.rs | 8 +- src/rustc/middle/typeck/coherence.rs | 4 +- src/rustc/middle/typeck/infer.rs | 20 +--- src/rustc/util/ppaux.rs | 6 +- src/test/compile-fail/break-outside-loop.rs | 2 +- src/test/compile-fail/issue-2063.rs | 2 +- src/test/compile-fail/issue-2590.rs | 2 +- src/test/compile-fail/map-types.rs | 4 +- .../compile-fail/mutable-huh-variance-vec3.rs | 4 +- .../tstate-unsat-in-called-fn-expr.rs | 2 +- .../compile-fail/tstate-unsat-in-fn-expr.rs | 2 +- .../compile-fail/writing-to-immutable-vec.rs | 2 +- 26 files changed, 77 insertions(+), 202 deletions(-) diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index dbca5ae4e76..e9568a13df0 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -1242,7 +1242,7 @@ mod tests { node::empty { ret ~"" } node::content(x) { let str = @mut ~""; - fn aux(str: @mut str, node: @node::node) unsafe { + fn aux(str: @mut ~str, node: @node::node) unsafe { alt(*node) { node::leaf(x) { *str += str::slice( diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 17b92f6925e..be0d66519dc 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -272,7 +272,7 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { node: ast::ty_vec(vec_mt), span: dummy_sp()}; ret @{id: cx.sess.next_node_id(), - node: ast::ty_vstore(inner_ty, ast::vstore_uniq), + node: ast::ty_uniq({ty: inner_ty, mutbl: ast::m_imm}), span: dummy_sp()}; } @@ -411,14 +411,14 @@ fn mk_main(cx: test_ctxt) -> @ast::item { node: ast::ty_path(str_pt, cx.sess.next_node_id()), span: dummy_sp()}; let str_ty = @{id: cx.sess.next_node_id(), - node: ast::ty_vstore(str_ty_inner, ast::vstore_uniq), + node: ast::ty_uniq({ty: str_ty_inner, mutbl: ast::m_imm}), span: dummy_sp()}; let args_mt = {ty: str_ty, mutbl: ast::m_imm}; let args_ty_inner = @{id: cx.sess.next_node_id(), node: ast::ty_vec(args_mt), span: dummy_sp()}; let args_ty = {id: cx.sess.next_node_id(), - node: ast::ty_vstore(args_ty_inner, ast::vstore_uniq), + node: ast::ty_uniq({ty: args_ty_inner, mutbl: ast::m_imm}), span: dummy_sp()}; diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index c0420f49a09..122a29eb34f 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -277,7 +277,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } } 'c' { ret ty::mk_char(st.tcx); } - 'S' { ret ty::mk_str(st.tcx); } 't' { assert (next(st) == '['); let def = parse_def(st, conv); @@ -307,7 +306,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { let mt = parse_mt(st, conv); ret ty::mk_rptr(st.tcx, r, mt); } - 'I' { ret ty::mk_vec(st.tcx, parse_mt(st, conv)); } 'U' { ret ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)); } 'V' { let mt = parse_mt(st, conv); diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 6cb430c519f..cb8881fdf2a 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -214,7 +214,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { ty_f64 { w.write_str(&"MF"); } } } - ty::ty_str { w.write_char('S'); } ty::ty_enum(def, substs) { w.write_str(&"t["); w.write_str(cx.ds(def)); @@ -251,7 +250,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { w.write_char('v'); enc_vstore(w, cx, v); } - ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); } ty::ty_unboxed_vec(mt) { w.write_char('U'); enc_mt(w, cx, mt); } ty::ty_rec(fields) { w.write_str(&"R["); diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 4db8ae6705d..4d5fb239d9e 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -516,11 +516,11 @@ impl to_str_methods for borrowck_ctxt { cat_comp(_, comp_variant(_)) { ~"enum content" } cat_comp(_, comp_index(t, _)) { alt ty::get(t).struct { - ty::ty_vec(*) | ty::ty_evec(*) { + ty::ty_evec(*) { mut_str + ~" vec content" } - ty::ty_str | ty::ty_estr(*) { + ty::ty_estr(*) { mut_str + ~" str content" } diff --git a/src/rustc/middle/borrowck/categorization.rs b/src/rustc/middle/borrowck/categorization.rs index 1a2b4d7834e..e0b6d10ca36 100644 --- a/src/rustc/middle/borrowck/categorization.rs +++ b/src/rustc/middle/borrowck/categorization.rs @@ -44,7 +44,7 @@ export opt_deref_kind; // pointer adjustment). fn opt_deref_kind(t: ty::t) -> option { alt ty::get(t).struct { - ty::ty_uniq(*) | ty::ty_vec(*) | ty::ty_str | + ty::ty_uniq(*) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) { some(deref_ptr(uniq_ptr)) @@ -100,8 +100,7 @@ impl public_methods for borrowck_ctxt { // a borrowed expression must be either an @, ~, or a vec/@, vec/~ let expr_ty = ty::expr_ty(self.tcx, expr); alt ty::get(expr_ty).struct { - ty::ty_vec(*) | ty::ty_evec(*) | - ty::ty_str | ty::ty_estr(*) { + ty::ty_evec(*) | ty::ty_estr(*) { self.cat_index(expr, expr) } diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 0b7053a2c2b..4e71231da26 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -51,7 +51,7 @@ fn trans_opt(bcx: block, o: opt) -> opt_result { ast::expr_vstore(@{node: ast::expr_lit( @{node: ast::lit_str(s), _}), _}, ast::vstore_uniq) { - let strty = ty::mk_str(bcx.tcx()); + let strty = ty::mk_estr(bcx.tcx(), ty::vstore_uniq); let cell = empty_dest_cell(); bcx = tvec::trans_estr(bcx, s, ast::vstore_uniq, by_val(cell)); add_clean_temp(bcx, *cell, strty); diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 066b4cc57e6..e82e20b9b9c 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -626,7 +626,6 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { Store(bcx, val, v); bcx } - ty::ty_vec(_) | ty::ty_str | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) { let {bcx, val} = tvec::duplicate_uniq(bcx, Load(bcx, v), t); Store(bcx, val, v); @@ -704,8 +703,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { uniq::make_free_glue(bcx, v, t) } ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) | - ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) | - ty::ty_vec(_) | ty::ty_str { + ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) { make_free_glue(bcx, v, tvec::expand_boxed_vec_ty(bcx.tcx(), t)); ret; @@ -769,7 +767,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { ty::ty_estr(ty::vstore_box) | ty::ty_evec(_, ty::vstore_box) { decr_refcnt_maybe_free(bcx, Load(bcx, v0), t) } - ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str | + ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) { free_ty(bcx, Load(bcx, v0), t) } @@ -1235,7 +1233,7 @@ fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { let _icx = bcx.insn_ctxt(~"drop_ty_immediate"); alt ty::get(t).struct { - ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str | + ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) { free_ty(bcx, v, t) @@ -1261,7 +1259,6 @@ fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { ty::ty_uniq(_) { uniq::duplicate(bcx, v, t) } - ty::ty_str | ty::ty_vec(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) { tvec::duplicate_uniq(bcx, v, t) @@ -2972,9 +2969,7 @@ fn adapt_borrowed_value(lv: lval_result, ret {lv: lval_temp(bcx, body_ptr), ty: rptr_ty}; } - ty::ty_str | ty::ty_vec(_) | - ty::ty_estr(_) | - ty::ty_evec(_, _) { + ty::ty_estr(_) | ty::ty_evec(_, _) { let ccx = bcx.ccx(); let val = alt lv.kind { temporary { lv.val } @@ -4997,10 +4992,11 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef, takes_argv: bool) -> ValueRef { - let unit_ty = ty::mk_str(ccx.tcx); + let unit_ty = ty::mk_estr(ccx.tcx, ty::vstore_uniq); let vecarg_ty: ty::arg = {mode: ast::expl(ast::by_val), - ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mutbl: ast::m_imm})}; + ty: ty::mk_evec(ccx.tcx, {ty: unit_ty, mutbl: ast::m_imm}, + ty::vstore_uniq)}; let nt = ty::mk_nil(ccx.tcx); let llfty = type_of_fn(ccx, ~[vecarg_ty], nt); let llfdecl = decl_fn(ccx.llmod, ~"_rust_main", diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 56ad6f13632..d71151316a1 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -132,9 +132,7 @@ impl methods for reflector { ty::ty_float(ast::ty_f) { self.leaf(~"float") } ty::ty_float(ast::ty_f32) { self.leaf(~"f32") } ty::ty_float(ast::ty_f64) { self.leaf(~"f64") } - ty::ty_str { self.leaf(~"str") } - ty::ty_vec(mt) { self.visit(~"vec", self.c_mt(mt)) } ty::ty_unboxed_vec(mt) { self.visit(~"vec", self.c_mt(mt)) } ty::ty_estr(vst) { do self.vstore_name_and_extra(t, vst) |name, extra| { diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 24a1591a6c8..801c642570c 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -228,8 +228,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { ty::ty_int(ast::ty_i64) { ~[shape_i64] } ty::ty_float(ast::ty_f32) { ~[shape_f32] } ty::ty_float(ast::ty_f64) { ~[shape_f64] } - ty::ty_estr(ty::vstore_uniq) | - ty::ty_str { + ty::ty_estr(ty::vstore_uniq) { shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t)) } ty::ty_enum(did, substs) { @@ -268,8 +267,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { add_substr(s, shape_of(ccx, mt.ty)); s } - ty::ty_evec(mt, ty::vstore_uniq) | - ty::ty_vec(mt) { + ty::ty_evec(mt, ty::vstore_uniq) { shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t)) } @@ -716,7 +714,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { } fn simplifier(tcx: ty::ctxt, typ: ty::t) -> ty::t { alt ty::get(typ).struct { - ty::ty_box(_) | ty::ty_opaque_box | ty::ty_uniq(_) | ty::ty_vec(_) | + ty::ty_box(_) | ty::ty_opaque_box | ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_uniq) | ty::ty_estr(ty::vstore_box) | ty::ty_ptr(_) | ty::ty_rptr(_,_) { nilptr(tcx) } diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 0c233d2c1bc..0037db16b6f 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -20,7 +20,6 @@ fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { let unit_ty = ty::sequence_element_type(tcx, t); let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty); alt ty::get(t).struct { - ty::ty_vec(_) | ty::ty_str | ty::ty_estr(ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_uniq) { ty::mk_imm_uniq(tcx, unboxed_vec_ty) } diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index aac6f2d97ba..dc122034709 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -89,8 +89,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_int(t) { T_int_ty(cx, t) } ty::ty_uint(t) { T_uint_ty(cx, t) } ty::ty_float(t) { T_float_ty(cx, t) } - ty::ty_estr(ty::vstore_uniq) | - ty::ty_str { + ty::ty_estr(ty::vstore_uniq) { T_unique_ptr(T_unique(cx, T_vec(cx, T_i8()))) } ty::ty_enum(did, _) { type_of_enum(cx, did, t) } @@ -103,8 +102,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_box(mt) { T_box_ptr(T_box(cx, type_of(cx, mt.ty))) } ty::ty_opaque_box { T_box_ptr(T_box(cx, T_i8())) } ty::ty_uniq(mt) { T_unique_ptr(T_unique(cx, type_of(cx, mt.ty))) } - ty::ty_evec(mt, ty::vstore_uniq) | - ty::ty_vec(mt) { + ty::ty_evec(mt, ty::vstore_uniq) { T_unique_ptr(T_unique(cx, T_vec(cx, type_of(cx, mt.ty)))) } ty::ty_unboxed_vec(mt) { diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index c3bcefb9fa5..badfee1fd1c 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -85,10 +85,8 @@ export ty_fn, fn_ty, mk_fn; export ty_fn_proto, ty_fn_ret, ty_fn_ret_style, tys_in_fn_ty; export ty_int, mk_int, mk_mach_int, mk_char; export mk_i8, mk_u8, mk_i16, mk_u16, mk_i32, mk_u32, mk_i64, mk_u64; -export ty_str, mk_str, type_is_str; -export ty_vec, mk_vec, type_is_vec; -export ty_estr, mk_estr; -export ty_evec, mk_evec; +export ty_estr, mk_estr, type_is_str; +export ty_evec, mk_evec, type_is_vec; export ty_unboxed_vec, mk_unboxed_vec, mk_mut_unboxed_vec; export vstore, vstore_fixed, vstore_uniq, vstore_box, vstore_slice; export ty_nil, mk_nil, type_is_nil; @@ -124,7 +122,6 @@ export operators; export type_err, terr_vstore_kind; export type_err_to_str; export type_needs_drop; -export type_allows_implicit_copy; export type_is_integral; export type_is_numeric; export type_is_pod; @@ -364,12 +361,10 @@ enum sty { ty_int(ast::int_ty), ty_uint(ast::uint_ty), ty_float(ast::float_ty), - ty_str, ty_estr(vstore), ty_enum(def_id, substs), ty_box(mt), ty_uniq(mt), - ty_vec(mt), ty_evec(mt, vstore), ty_ptr(mt), ty_rptr(region, mt), @@ -586,7 +581,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option) -> t { flags |= get(mt.ty).flags; } ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | - ty_str | ty_estr(_) | ty_type | ty_opaque_closure_ptr(_) | + ty_estr(_) | ty_type | ty_opaque_closure_ptr(_) | ty_opaque_box {} ty_param(_, _) { flags |= has_params as uint; } ty_var(_) | ty_var_integral(_) { flags |= needs_infer as uint; } @@ -594,7 +589,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option) -> t { ty_enum(_, substs) | ty_class(_, substs) | ty_trait(_, substs) { flags |= sflags(substs); } - ty_box(m) | ty_uniq(m) | ty_vec(m) | ty_evec(m, _) | + ty_box(m) | ty_uniq(m) | ty_evec(m, _) | ty_ptr(m) | ty_unboxed_vec(m) { flags |= get(m.ty).flags; } @@ -658,8 +653,6 @@ fn mk_mach_float(cx: ctxt, tm: ast::float_ty) -> t { mk_t(cx, ty_float(tm)) } fn mk_char(cx: ctxt) -> t { mk_t(cx, ty_int(ast::ty_char)) } -fn mk_str(cx: ctxt) -> t { mk_estr(cx, vstore_uniq) } - fn mk_estr(cx: ctxt, t: vstore) -> t { mk_t(cx, ty_estr(t)) } @@ -693,8 +686,6 @@ fn mk_nil_ptr(cx: ctxt) -> t { mk_ptr(cx, {ty: mk_nil(cx), mutbl: ast::m_imm}) } -fn mk_vec(cx: ctxt, tm: mt) -> t { mk_evec(cx, tm, vstore_uniq) } - fn mk_evec(cx: ctxt, tm: mt, t: vstore) -> t { mk_t(cx, ty_evec(tm, t)) } @@ -779,11 +770,11 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { if !f(ty) { ret; } alt get(ty).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | - ty_str | ty_estr(_) | ty_type | ty_opaque_box | ty_self | + ty_estr(_) | ty_type | ty_opaque_box | ty_self | ty_opaque_closure_ptr(_) | ty_var(_) | ty_var_integral(_) | ty_param(_, _) { } - ty_box(tm) | ty_vec(tm) | ty_evec(tm, _) | ty_unboxed_vec(tm) | + ty_box(tm) | ty_evec(tm, _) | ty_unboxed_vec(tm) | ty_ptr(tm) | ty_rptr(_, tm) { maybe_walk_ty(tm.ty, f); } @@ -825,9 +816,6 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty { ty_ptr(tm) { ty_ptr({ty: fldop(tm.ty), mutbl: tm.mutbl}) } - ty_vec(tm) { - ty_vec({ty: fldop(tm.ty), mutbl: tm.mutbl}) - } ty_unboxed_vec(tm) { ty_unboxed_vec({ty: fldop(tm.ty), mutbl: tm.mutbl}) } @@ -870,7 +858,7 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty { ty_class(did, fold_substs(substs, fldop)) } ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | - ty_str | ty_estr(_) | ty_type | ty_opaque_closure_ptr(_) | + ty_estr(_) | ty_type | ty_opaque_closure_ptr(_) | ty_opaque_box | ty_var(_) | ty_var_integral(_) | ty_param(*) | ty_self { sty } @@ -1101,22 +1089,22 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool { fn type_is_sequence(ty: t) -> bool { alt get(ty).struct { - ty_str | ty_estr(_) | ty_vec(_) | ty_evec(_, _) { true } + ty_estr(_) | ty_evec(_, _) { true } _ { false } } } fn type_is_str(ty: t) -> bool { alt get(ty).struct { - ty_str | ty_estr(_) { true } + ty_estr(_) { true } _ { false } } } fn sequence_element_type(cx: ctxt, ty: t) -> t { alt get(ty).struct { - ty_str | ty_estr(_) { ret mk_mach_uint(cx, ast::ty_u8); } - ty_vec(mt) | ty_evec(mt, _) | ty_unboxed_vec(mt) { ret mt.ty; } + ty_estr(_) { ret mk_mach_uint(cx, ast::ty_u8); } + ty_evec(mt, _) | ty_unboxed_vec(mt) { ret mt.ty; } _ { cx.sess.bug( ~"sequence_element_type called on non-sequence value"); } @@ -1176,8 +1164,8 @@ pure fn type_is_unsafe_ptr(ty: t) -> bool { pure fn type_is_vec(ty: t) -> bool { ret alt get(ty).struct { - ty_vec(_) | ty_evec(_, _) | ty_unboxed_vec(_) { true } - ty_str | ty_estr(_) { true } + ty_evec(_, _) | ty_unboxed_vec(_) { true } + ty_estr(_) { true } _ { false } }; } @@ -1185,8 +1173,8 @@ pure fn type_is_vec(ty: t) -> bool { pure fn type_is_unique(ty: t) -> bool { alt get(ty).struct { ty_uniq(_) { ret true; } - ty_vec(_) | ty_evec(_, vstore_uniq) { true } - ty_str | ty_estr(vstore_uniq) { true } + ty_evec(_, vstore_uniq) { true } + ty_estr(vstore_uniq) { true } _ { ret false; } } } @@ -1315,7 +1303,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, } !needs_unwind_cleanup } - ty_uniq(_) | ty_str | ty_vec(_) | + ty_uniq(_) | ty_estr(vstore_uniq) | ty_estr(vstore_box) | ty_evec(_, vstore_uniq) | @@ -1493,7 +1481,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) { kind_implicitly_sendable() | kind_const() } // Implicit copyability of strs is configurable - ty_str | ty_estr(vstore_uniq) { + ty_estr(vstore_uniq) { if cx.vecs_implicitly_copyable { kind_implicitly_sendable() | kind_const() } else { kind_sendable() | kind_const() } @@ -1523,7 +1511,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { remove_implicit(mutable_type_kind(cx, tm)) } // Implicit copyability of vecs is configurable - ty_vec(tm) | ty_evec(tm, vstore_uniq) { + ty_evec(tm, vstore_uniq) { if cx.vecs_implicitly_copyable { mutable_type_kind(cx, tm) } else { remove_implicit(mutable_type_kind(cx, tm)) } @@ -1650,7 +1638,6 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_int(_) | ty_uint(_) | ty_float(_) | - ty_str | ty_estr(_) | ty_fn(_) | ty_var(_) | @@ -1661,8 +1648,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_opaque_box | ty_opaque_closure_ptr(_) | ty_evec(_, _) | - ty_unboxed_vec(_) | - ty_vec(_) { + ty_unboxed_vec(_) { false } @@ -1778,36 +1764,11 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> } } -// Returns true for noncopyable types and types where a copy of a value can be -// distinguished from the value itself. I.e. types with mut content that's -// not shared through a pointer. -fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool { - ret !type_structurally_contains(cx, ty, |sty| { - alt sty { - ty_param(_, _) { true } - - ty_evec(_, _) | ty_estr(_) { - cx.sess.unimpl(~"estr/evec in type_allows_implicit_copy"); - } - - ty_vec(mt) { - mt.mutbl != ast::m_imm - } - ty_rec(fields) { - vec::any(fields, |f| f.mt.mutbl != ast::m_imm) - } - _ { false } - } - }) && type_kind(cx, ty) != kind_noncopyable(); -} - fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool { ret type_structurally_contains(cx, ty, |sty| { alt sty { ty_uniq(_) | - ty_vec(_) | ty_evec(_, vstore_uniq) | - ty_str | ty_estr(vstore_uniq) { true } _ { false } } @@ -1848,7 +1809,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_type | ty_ptr(_) { result = true; } // Boxed types - ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) | + ty_box(_) | ty_uniq(_) | ty_fn(_) | ty_estr(vstore_uniq) | ty_estr(vstore_box) | ty_evec(_, vstore_uniq) | ty_evec(_, vstore_box) | ty_trait(_, _) | ty_rptr(_,_) | ty_opaque_box { result = false; } @@ -1974,8 +1935,8 @@ fn index(cx: ctxt, t: t) -> option { fn index_sty(cx: ctxt, sty: sty) -> option { alt sty { - ty_vec(mt) | ty_evec(mt, _) { some(mt) } - ty_str | ty_estr(_) { some({ty: mk_u8(cx), mutbl: ast::m_imm}) } + ty_evec(mt, _) { some(mt) } + ty_estr(_) { some({ty: mk_u8(cx), mutbl: ast::m_imm}) } _ { none } } } @@ -2050,14 +2011,12 @@ fn hash_type_structure(st: sty) -> uint { alt t { ast::ty_f { 13u } ast::ty_f32 { 14u } ast::ty_f64 { 15u } } } ty_estr(_) { 16u } - ty_str { 17u } ty_enum(did, substs) { let mut h = hash_def(18u, did); hash_substs(h, substs) } ty_box(mt) { hash_subty(19u, mt.ty) } ty_evec(mt, _) { hash_subty(20u, mt.ty) } - ty_vec(mt) { hash_subty(21u, mt.ty) } ty_unboxed_vec(mt) { hash_subty(22u, mt.ty) } ty_tup(ts) { hash_subtys(25u, ts) } ty_rec(fields) { @@ -2405,7 +2364,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { fn ty_sort_str(cx: ctxt, t: t) -> ~str { alt get(t).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | - ty_uint(_) | ty_float(_) | ty_estr(_) | ty_str | + ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_opaque_closure_ptr(_) { ty_to_str(cx, t) } @@ -2413,7 +2372,7 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str { ty_enum(id, _) { #fmt["enum %s", item_path_str(cx, id)] } ty_box(_) { ~"@-ptr" } ty_uniq(_) { ~"~-ptr" } - ty_evec(_, _) | ty_vec(_) { ~"vector" } + ty_evec(_, _) { ~"vector" } ty_unboxed_vec(_) { ~"unboxed vector" } ty_ptr(_) { ~"*-ptr" } ty_rptr(_, _) { ~"&-ptr" } @@ -2917,10 +2876,8 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { const tycat_bool: int = 1; const tycat_int: int = 2; const tycat_float: int = 3; - const tycat_str: int = 4; - const tycat_vec: int = 5; - const tycat_struct: int = 6; - const tycat_bot: int = 7; + const tycat_struct: int = 4; + const tycat_bot: int = 5; const opcat_add: int = 0; const opcat_sub: int = 1; @@ -2959,8 +2916,6 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { ty_bool { tycat_bool } ty_int(_) | ty_uint(_) | ty_var_integral(_) { tycat_int } ty_float(_) { tycat_float } - ty_str { tycat_str } - ty_vec(_) { tycat_vec } ty_rec(_) | ty_tup(_) | ty_enum(_, _) { tycat_struct } ty_bot { tycat_bot } _ { tycat_other } @@ -2978,8 +2933,6 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { /*bool*/ ~[f, f, f, f, t, t, t, t], /*int*/ ~[t, t, t, t, t, t, t, f], /*float*/ ~[t, t, t, f, t, t, f, f], - /*str*/ ~[f, f, f, f, t, t, f, f], - /*vec*/ ~[f, f, f, f, t, t, f, f], /*bot*/ ~[f, f, f, f, t, t, f, f], /*struct*/ ~[t, t, t, t, t, t, t, t]]; diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index 7d09c57dc92..df267170c36 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -235,7 +235,11 @@ fn ast_ty_to_ty( |tmt| ty::mk_uniq(tcx, tmt)) } ast::ty_vec(mt) { - ty::mk_vec(tcx, ast_mt_to_mt(self, rscope, mt)) + tcx.sess.span_err(ast_ty.span, + ~"bare `[]` is not a type"); + // return /something/ so they can at least get more errors + ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), + ty::vstore_uniq) } ast::ty_ptr(mt) { ty::mk_ptr(tcx, ast_mt_to_mt(self, rscope, mt)) @@ -288,19 +292,10 @@ fn ast_ty_to_ty( ty::mk_mach_float(tcx, ft) } ast::ty_str { - check_path_args(tcx, path, NO_TPS); - // This is a bit of a hack, but basically &str needs to be - // converted into a vstore: - alt path.rp { - none { - ty::mk_str(tcx) - } - some(ast_r) { - let r = ast_region_to_region(self, rscope, - ast_ty.span, ast_r); - ty::mk_estr(tcx, ty::vstore_slice(r)) - } - } + tcx.sess.span_err(ast_ty.span, + ~"bare `str` is not a type"); + // return /something/ so they can at least get more errors + ty::mk_estr(tcx, ty::vstore_uniq) } } } @@ -321,43 +316,6 @@ fn ast_ty_to_ty( } } } - // This is awful and repetitive but will go away - ast::ty_vstore(a_t, ast::vstore_slice(a_r)) { - let r = ast_region_to_region(self, rscope, ast_ty.span, a_r); - mk_maybe_vstore(self, in_anon_rscope(rscope, r), - {ty: a_t, mutbl: ast::m_imm}, - ty::vstore_slice(r), - |ty| { - tcx.sess.span_err( - a_t.span, - #fmt["bound not allowed on a %s", - ty::ty_sort_str(tcx, ty.ty)]); - ty.ty - }) - - } - ast::ty_vstore(a_t, ast::vstore_uniq) { - mk_maybe_vstore(self, rscope, {ty: a_t, mutbl: ast::m_imm}, - ty::vstore_uniq, - |ty| { - tcx.sess.span_err( - a_t.span, - #fmt["bound not allowed on a %s", - ty::ty_sort_str(tcx, ty.ty)]); - ty.ty - }) - } - ast::ty_vstore(a_t, ast::vstore_box) { - mk_maybe_vstore(self, rscope, {ty: a_t, mutbl: ast::m_imm}, - ty::vstore_box, - |ty| { - tcx.sess.span_err( - a_t.span, - #fmt["bound not allowed on a %s", - ty::ty_sort_str(tcx, ty.ty)]); - ty.ty - }) - } ast::ty_vstore(a_t, ast::vstore_fixed(some(u))) { mk_maybe_vstore(self, rscope, {ty: a_t, mutbl: ast::m_imm}, ty::vstore_fixed(u), @@ -374,11 +332,9 @@ fn ast_ty_to_ty( ast_ty.span, ~"implied fixed length for bound"); } -/* ast::ty_vstore(_, _) { - tcx.sess.span_bug(ast_ty.span, "some BS"); + tcx.sess.span_bug(ast_ty.span, ~"vstore in type??"); } -*/ ast::ty_constr(t, cs) { let mut out_cs = ~[]; for cs.each |constr| { diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index fa43449f30e..4df32eb662d 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -611,7 +611,7 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t { let tcx = fcx.ccx.tcx; alt lit.node { - ast::lit_str(_) { ty::mk_str(tcx) } + ast::lit_str(_) { ty::mk_estr(tcx, ty::vstore_uniq) } ast::lit_int(_, t) { ty::mk_mach_int(tcx, t) } ast::lit_uint(_, t) { ty::mk_mach_uint(tcx, t) } ast::lit_int_unsuffixed(_) { @@ -1311,7 +1311,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, bot = true; alt expr_opt { none {/* do nothing */ } - some(e) { check_expr_with(fcx, e, ty::mk_str(tcx)); } + some(e) { check_expr_with(fcx, e, + ty::mk_estr(tcx, ty::vstore_uniq)); } } fcx.write_bot(id); } @@ -1522,7 +1523,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_vec(args, mutbl) { let t: ty::t = fcx.infcx.next_ty_var(); for args.each |e| { bot |= check_expr_with(fcx, e, t); } - let typ = ty::mk_vec(tcx, {ty: t, mutbl: mutbl}); + let typ = ty::mk_evec(tcx, {ty: t, mutbl: mutbl}, + ty::vstore_uniq); fcx.write_ty(id, typ); } ast::expr_tup(elts) { diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index d563a4a9916..ecc114cfc85 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -6,7 +6,7 @@ import middle::ty::{get, t, ty_box, ty_uniq, ty_ptr, ty_rptr, ty_enum}; import middle::ty::{ty_class, ty_nil, ty_bot, ty_bool, ty_int, ty_uint}; -import middle::ty::{ty_float, ty_str, ty_estr, ty_vec, ty_evec, ty_rec}; +import middle::ty::{ty_float, ty_estr, ty_evec, ty_rec}; import middle::ty::{ty_fn, ty_trait, ty_tup, ty_var, ty_var_integral}; import middle::ty::{ty_param, ty_self, ty_constr, ty_type, ty_opaque_box}; import middle::ty::{ty_opaque_closure_ptr, ty_unboxed_vec, new_ty_hash}; @@ -171,7 +171,7 @@ class CoherenceChecker { } ty_nil | ty_bot | ty_bool | ty_int(*) | ty_uint(*) | ty_float(*) | - ty_str | ty_estr(*) | ty_vec(*) | ty_evec(*) | ty_rec(*) | + ty_estr(*) | ty_evec(*) | ty_rec(*) | ty_fn(*) | ty_tup(*) | ty_var(*) | ty_var_integral(*) | ty_param(*) | ty_self | ty_constr(*) | ty_type | ty_opaque_box | ty_opaque_closure_ptr(*) | ty_unboxed_vec(*) { diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index da28e657758..e88aecb6d5d 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -1417,11 +1417,6 @@ impl assignment for infer_ctxt { let nr_b = ty::mk_estr(self.tcx, vs_a); self.crosspollinate(anmnt, a, nr_b, m_imm, r_b) } - (ty::ty_str, - ty::ty_estr(ty::vstore_slice(r_b))) { - let nr_b = ty::mk_str(self.tcx); - self.crosspollinate(anmnt, a, nr_b, m_imm, r_b) - } (ty::ty_evec(mt_a, vs_a), ty::ty_evec(mt_b, ty::vstore_slice(r_b))) @@ -1430,12 +1425,6 @@ impl assignment for infer_ctxt { mutbl: m_const}, vs_a); self.crosspollinate(anmnt, a, nr_b, mt_b.mutbl, r_b) } - (ty::ty_vec(mt_a), - ty::ty_evec(mt_b, ty::vstore_slice(r_b))) { - let nr_b = ty::mk_vec(self.tcx, {ty: mt_b.ty, - mutbl: m_const}); - self.crosspollinate(anmnt, a, nr_b, mt_b.mutbl, r_b) - } _ { self.sub_tys(a, b) } @@ -1760,8 +1749,7 @@ fn super_tys( } (ty::ty_nil, _) | - (ty::ty_bool, _) | - (ty::ty_str, _) { + (ty::ty_bool, _) { let cfg = tcx.sess.targ_cfg; if ty::mach_sty(cfg, a) == ty::mach_sty(cfg, b) { ok(a) @@ -1807,12 +1795,6 @@ fn super_tys( } } - (ty::ty_vec(a_mt), ty::ty_vec(b_mt)) { - do self.mts(a_mt, b_mt).chain |mt| { - ok(ty::mk_vec(tcx, mt)) - } - } - (ty::ty_ptr(a_mt), ty::ty_ptr(b_mt)) { do self.mts(a_mt, b_mt).chain |mt| { ok(ty::mk_ptr(tcx, mt)) diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 5d62bc31450..3ed871dc701 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -6,9 +6,9 @@ import middle::ty::{mt, re_bound, re_free, re_scope, re_var, region, t}; import middle::ty::{ty_bool, ty_bot, ty_box, ty_class, ty_constr, ty_enum}; import middle::ty::{ty_estr, ty_evec, ty_float, ty_fn, ty_trait, ty_int}; import middle::ty::{ty_nil, ty_opaque_box, ty_opaque_closure_ptr, ty_param}; -import middle::ty::{ty_ptr, ty_rec, ty_rptr, ty_self, ty_str, ty_tup}; +import middle::ty::{ty_ptr, ty_rec, ty_rptr, ty_self, ty_tup}; import middle::ty::{ty_type, ty_uniq, ty_uint, ty_var, ty_var_integral}; -import middle::ty::{ty_vec, ty_unboxed_vec, vid}; +import middle::ty::{ty_unboxed_vec, vid}; import metadata::encoder; import syntax::codemap; import syntax::print::pprust; @@ -186,7 +186,6 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_uint(t) { ast_util::uint_ty_to_str(t) } ty_float(ast::ty_f) { ~"float" } ty_float(t) { ast_util::float_ty_to_str(t) } - ty_str { ~"str" } ty_box(tm) { ~"@" + mt_to_str(cx, tm) } ty_uniq(tm) { ~"~" + mt_to_str(cx, tm) } ty_ptr(tm) { ~"*" + mt_to_str(cx, tm) } @@ -198,7 +197,6 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { rs + ~"/" + mt_to_str(cx, tm) } } - ty_vec(tm) { ~"[" + mt_to_str(cx, tm) + ~"]" } ty_unboxed_vec(tm) { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } ty_type { ~"type" } ty_rec(elems) { diff --git a/src/test/compile-fail/break-outside-loop.rs b/src/test/compile-fail/break-outside-loop.rs index 37f8700973a..1f1b5275ef8 100644 --- a/src/test/compile-fail/break-outside-loop.rs +++ b/src/test/compile-fail/break-outside-loop.rs @@ -2,6 +2,6 @@ fn main() { let pth = break; - let rs: {t: str} = {t: pth}; + let rs: {t: ~str} = {t: pth}; } diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index 07b7d1ad3f4..1fbc6691c74 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -7,7 +7,7 @@ enum t = @t; //~ ERROR this type cannot be instantiated // the compiler to attempt autoderef and then // try to resolve the method. impl methods for t { - fn to_str() -> str { "t" } + fn to_str() -> ~str { "t" } } fn new_t(x: t) { diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs index d6e3022acc3..5aba0e50fd6 100644 --- a/src/test/compile-fail/issue-2590.rs +++ b/src/test/compile-fail/issue-2590.rs @@ -5,7 +5,7 @@ type parser = { }; impl parser for parser { - fn parse() -> [mut int] { + fn parse() -> ~[mut int] { dvec::unwrap(self.tokens) //~ ERROR illegal move from self } } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index b929ab0a1ce..4b3649e30e8 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -6,7 +6,7 @@ import std::map::map; // Test that iface types printed in error msgs include the type arguments. fn main() { - let x: map = map::str_hash::() as map::; - let y: map = x; + let x: map<~str,~str> = map::str_hash::<~str>() as map::<~str,~str>; + let y: map = x; //~^ ERROR mismatched types: expected `std::map::map` } diff --git a/src/test/compile-fail/mutable-huh-variance-vec3.rs b/src/test/compile-fail/mutable-huh-variance-vec3.rs index fde3d8a152a..0fd0586500a 100644 --- a/src/test/compile-fail/mutable-huh-variance-vec3.rs +++ b/src/test/compile-fail/mutable-huh-variance-vec3.rs @@ -2,10 +2,10 @@ fn main() { // Note: explicit type annot is required here // because otherwise the inference gets smart // and assigns a type of ~[mut ~[const int]]. - let v: [mut[mut[int]]] = [mut [mut [0]]]; + let v: ~[mut ~[mut ~[int]]] = ~[mut ~[mut ~[0]]]; fn f(&&v: ~[mut ~[mut ~[const int]]]) { - v[0][1] = [mut 3] + v[0][1] = ~[mut 3] } f(v); //~ ERROR (values differ in mutability) diff --git a/src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs b/src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs index e19393c40f5..3caee2475a8 100644 --- a/src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs +++ b/src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs @@ -1,4 +1,4 @@ -fn foo(v: [int]) : vec::is_empty(v) { #debug("%d", v[0]); } +fn foo(v: ~[int]) : vec::is_empty(v) { #debug("%d", v[0]); } fn main() { let f = fn@() { diff --git a/src/test/compile-fail/tstate-unsat-in-fn-expr.rs b/src/test/compile-fail/tstate-unsat-in-fn-expr.rs index c56662f8562..ffc1e87bcc5 100644 --- a/src/test/compile-fail/tstate-unsat-in-fn-expr.rs +++ b/src/test/compile-fail/tstate-unsat-in-fn-expr.rs @@ -1,4 +1,4 @@ -fn foo(v: [int]) : vec::is_empty(v) { #debug("%d", v[0]); } +fn foo(v: ~[int]) : vec::is_empty(v) { #debug("%d", v[0]); } fn main() { let f = fn@() { diff --git a/src/test/compile-fail/writing-to-immutable-vec.rs b/src/test/compile-fail/writing-to-immutable-vec.rs index 8b740218815..2502664a999 100644 --- a/src/test/compile-fail/writing-to-immutable-vec.rs +++ b/src/test/compile-fail/writing-to-immutable-vec.rs @@ -1,2 +1,2 @@ // error-pattern:assigning to immutable vec content -fn main() { let v: [int] = [1, 2, 3]; v[1] = 4; } +fn main() { let v: ~[int] = ~[1, 2, 3]; v[1] = 4; }