Tear out ty_str and ty_vec.
This commit is contained in:
parent
0442fd32ee
commit
d884085f43
@ -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(
|
||||
|
@ -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()};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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[");
|
||||
|
@ -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"
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export opt_deref_kind;
|
||||
// pointer adjustment).
|
||||
fn opt_deref_kind(t: ty::t) -> option<deref_kind> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -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| {
|
||||
|
@ -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) }
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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<ast::def_id>) -> 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<ast::def_id>) -> 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<mt> {
|
||||
|
||||
fn index_sty(cx: ctxt, sty: sty) -> option<mt> {
|
||||
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]];
|
||||
|
||||
|
@ -235,7 +235,11 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
|
||||
|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<AC: ast_conv, RS: region_scope copy>(
|
||||
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<AC: ast_conv, RS: region_scope copy>(
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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<AC: ast_conv, RS: region_scope copy>(
|
||||
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| {
|
||||
|
@ -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) {
|
||||
|
@ -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(*) {
|
||||
|
@ -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<C:combine>(
|
||||
}
|
||||
|
||||
(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<C:combine>(
|
||||
}
|
||||
}
|
||||
|
||||
(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))
|
||||
|
@ -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) {
|
||||
|
@ -2,6 +2,6 @@
|
||||
fn main() {
|
||||
let pth = break;
|
||||
|
||||
let rs: {t: str} = {t: pth};
|
||||
let rs: {t: ~str} = {t: pth};
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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<str,str> = map::str_hash::<str>() as map::<str,str>;
|
||||
let y: map<uint,str> = x;
|
||||
let x: map<~str,~str> = map::str_hash::<~str>() as map::<~str,~str>;
|
||||
let y: map<uint,~str> = x;
|
||||
//~^ ERROR mismatched types: expected `std::map::map<uint,~str>`
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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@() {
|
||||
|
@ -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@() {
|
||||
|
@ -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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user