Remove tuple support from the compiler

This commit is contained in:
Marijn Haverbeke 2011-07-26 15:17:04 +02:00
parent bc9db454a0
commit 2c1250780d
17 changed files with 24 additions and 344 deletions

View file

@ -226,13 +226,6 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
case ('a') { ret ty::mk_task(st.tcx); }
case ('P') { ret ty::mk_port(st.tcx, parse_ty(st, sd)); }
case ('C') { ret ty::mk_chan(st.tcx, parse_ty(st, sd)); }
case ('T') {
assert (next(st) as char == '[');
let ty::mt[] params = ~[];
while (peek(st) as char != ']') { params += ~[parse_mt(st, sd)]; }
st.pos = st.pos + 1u;
ret ty::mk_tup(st.tcx, params);
}
case ('R') {
assert (next(st) as char == '[');
let ty::field[] fields = ~[];

View file

@ -128,11 +128,6 @@ fn enc_sty(&ioivec::writer w, &@ctxt cx, &ty::sty st) {
case (ty::ty_ivec(?mt)) { w.write_char('I'); enc_mt(w, cx, mt); }
case (ty::ty_port(?t)) { w.write_char('P'); enc_ty(w, cx, t); }
case (ty::ty_chan(?t)) { w.write_char('C'); enc_ty(w, cx, t); }
case (ty::ty_tup(?mts)) {
w.write_str("T[");
for (ty::mt mt in mts) { enc_mt(w, cx, mt); }
w.write_char(']');
}
case (ty::ty_rec(?fields)) {
w.write_str("R[");
for (ty::field field in fields) {

View file

@ -558,10 +558,6 @@ fn expr_root(&ctx cx, @ast::expr ex, bool autoderef) ->
maybe_auto_unbox(cx, ty::expr_ty(cx.tcx, base));
auto mut = false;
alt (ty::struct(cx.tcx, auto_unbox.t)) {
case (ty::ty_tup(?fields)) {
auto fnm = ty::field_num(cx.tcx.sess, ex.span, ident);
mut = fields.(fnm).mut != ast::imm;
}
case (ty::ty_rec(?fields)) {
for (ty::field fld in fields) {
if (str::eq(ident, fld.ident)) {
@ -654,14 +650,6 @@ fn ty_can_unsafely_include(&ctx cx, ty::t needle, ty::t haystack, bool mut) ->
ty::ty_box(?mt) | ty::ty_vec(?mt) | ty::ty_ptr(?mt) {
ret helper(tcx, needle, mt.ty, get_mut(mut, mt));
}
ty::ty_tup(?mts) {
for (ty::mt mt in mts) {
if (helper(tcx, needle, mt.ty, get_mut(mut, mt))) {
ret true;
}
}
ret false;
}
ty::ty_rec(?fields) {
for (ty::field f in fields) {
if (helper(tcx, needle, f.mt.ty, get_mut(mut, f.mt))) {

View file

@ -239,13 +239,6 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
llty = T_ptr(T_chan(type_of_inner(cx, sp, t)));
}
case (ty::ty_task) { llty = T_taskptr(*cx); }
case (ty::ty_tup(?elts)) {
let TypeRef[] tys = ~[];
for (ty::mt elt in elts) {
tys += ~[type_of_inner(cx, sp, elt.ty)];
}
llty = T_struct(tys);
}
case (ty::ty_rec(?fields)) {
let TypeRef[] tys = ~[];
for (ty::field f in fields) {
@ -610,11 +603,6 @@ fn dynamic_size_of(&@block_ctxt cx, ty::t t) -> result {
field_of_tydesc(cx, t, false, abi::tydesc_field_size);
ret rslt(szptr.bcx, szptr.bcx.build.Load(szptr.val));
}
case (ty::ty_tup(?elts)) {
let ty::t[] tys = ~[];
for (ty::mt mt in elts) { tys += ~[mt.ty]; }
ret align_elements(cx, tys);
}
case (ty::ty_rec(?flds)) {
let ty::t[] tys = ~[];
for (ty::field f in flds) { tys += ~[f.mt.ty]; }
@ -667,16 +655,6 @@ fn dynamic_align_of(&@block_ctxt cx, &ty::t t) -> result {
field_of_tydesc(cx, t, false, abi::tydesc_field_align);
ret rslt(aptr.bcx, aptr.bcx.build.Load(aptr.val));
}
case (ty::ty_tup(?elts)) {
auto a = C_int(1);
auto bcx = cx;
for (ty::mt e in elts) {
auto align = align_of(bcx, e.ty);
bcx = align.bcx;
a = umax(bcx, a, align.val);
}
ret rslt(bcx, a);
}
case (ty::ty_rec(?flds)) {
auto a = C_int(1);
auto bcx = cx;
@ -2003,18 +1981,6 @@ fn iter_structural_ty_full(&@block_ctxt cx, ValueRef av, ValueRef bv,
let result r = rslt(cx, C_nil());
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
case (ty::ty_tup(?args)) {
let int i = 0;
for (ty::mt arg in args) {
r = GEP_tup_like(r.bcx, t, av, ~[0, i]);
auto elt_a = r.val;
r = GEP_tup_like(r.bcx, t, bv, ~[0, i]);
auto elt_b = r.val;
r = f(r.bcx, load_if_immediate(r.bcx, elt_a, arg.ty),
load_if_immediate(r.bcx, elt_b, arg.ty), arg.ty);
i += 1;
}
}
case (ty::ty_rec(?fields)) {
let int i = 0;
for (ty::field fld in fields) {
@ -4196,11 +4162,6 @@ fn trans_field(&@block_ctxt cx, &span sp, ValueRef v, &ty::t t0,
auto r = autoderef(cx, v, t0);
auto t = r.ty;
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
case (ty::ty_tup(_)) {
let uint ix = ty::field_num(cx.fcx.lcx.ccx.sess, sp, field);
auto v = GEP_tup_like(r.bcx, t, r.val, ~[0, ix as int]);
ret lval_mem(v.bcx, v.val);
}
case (ty::ty_rec(?fields)) {
let uint ix =
ty::field_idx(cx.fcx.lcx.ccx.sess, sp, field, fields);
@ -5082,25 +5043,6 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f, &option::t[ValueRef] lliterbody,
ret rslt(bcx, retval);
}
fn trans_tup(&@block_ctxt cx, &ast::elt[] elts, ast::node_id id) -> result {
auto bcx = cx;
auto t = node_id_type(bcx.fcx.lcx.ccx, id);
auto tup_res = alloc_ty(bcx, t);
auto tup_val = tup_res.val;
bcx = tup_res.bcx;
add_clean_temp(cx, tup_val, t);
let int i = 0;
for (ast::elt e in elts) {
auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e.expr);
auto src = trans_lval(bcx, e.expr);
bcx = src.res.bcx;
auto dst_res = GEP_tup_like(bcx, t, tup_val, ~[0, i]);
bcx = move_val_if_temp(dst_res.bcx, INIT, dst_res.val, src, e_ty).bcx;
i += 1;
}
ret rslt(bcx, tup_val);
}
fn trans_vec(&@block_ctxt cx, &(@ast::expr)[] args, ast::node_id id) ->
result {
auto t = node_id_type(cx.fcx.lcx.ccx, id);
@ -5457,7 +5399,6 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
case (ast::expr_vec(?args, _, ast::sk_unique)) {
ret trans_ivec(cx, args, e.id);
}
case (ast::expr_tup(?args)) { ret trans_tup(cx, args, e.id); }
case (ast::expr_rec(?args, ?base)) {
ret trans_rec(cx, args, base, e.id);
}

View file

@ -175,9 +175,9 @@ fn mk_spawn_wrapper(&@block_ctxt cx, &@ast::expr func, &ty::t args_ty) ->
// unpack the arguments
alt (ty::struct(fcx.lcx.ccx.tcx, args_ty)) {
case (ty::ty_tup(?elements)) {
case (ty::ty_rec(?fields)) {
auto i = 0;
for (ty::mt m in elements) {
for (ty::field f in fields) {
auto src = fbcx.build.GEP(arg, ~[C_int(0), C_int(i)]);
i += 1;
auto child_arg = fbcx.build.Load(src);

View file

@ -334,9 +334,6 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
case (expr_vec(?args, _, _)) {
find_pre_post_exprs(fcx, args, e.id);
}
case (expr_tup(?elts)) {
find_pre_post_exprs(fcx, elt_exprs(elts), e.id);
}
case (expr_path(?p)) {
auto rslt = expr_pp(fcx.ccx, e);
clear_pp(rslt);

View file

@ -293,10 +293,6 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
case (expr_vec(?elts, _, _)) {
ret find_pre_post_state_exprs(fcx, pres, e.id, elts, return);
}
case (expr_tup(?elts)) {
ret find_pre_post_state_exprs(fcx, pres, e.id,
elt_exprs(elts), return);
}
case (expr_call(?operator, ?operands)) {
ret find_pre_post_state_call
(fcx, pres, operator, e.id, operands,

View file

@ -47,7 +47,6 @@ export expr_ty;
export fold_ty;
export field;
export field_idx;
export field_num;
export fm_general;
export get_element_type;
export hash_ty;
@ -69,7 +68,6 @@ export mk_ctxt;
export mk_float;
export mk_fn;
export mk_imm_box;
export mk_imm_tup;
export mk_imm_vec;
export mk_int;
export mk_istr;
@ -84,10 +82,10 @@ export mk_param;
export mk_port;
export mk_ptr;
export mk_rec;
export mk_imm_tup;
export mk_str;
export mk_tag;
export mk_task;
export mk_tup;
export mk_type;
export mk_uint;
export mk_var;
@ -144,7 +142,6 @@ export ty_rec;
export ty_str;
export ty_tag;
export ty_task;
export ty_tup;
export ty_type;
export ty_uint;
export ty_var;
@ -265,7 +262,6 @@ tag sty {
ty_port(t);
ty_chan(t);
ty_task;
ty_tup(mt[]);
ty_rec(field[]);
ty_fn(ast::proto, arg[], t, controlflow, (@constr)[]);
ty_native_fn(ast::native_abi, arg[], t);
@ -291,8 +287,6 @@ tag type_err {
terr_controlflow_mismatch;
terr_box_mutability;
terr_vec_mutability;
terr_tuple_size(uint, uint);
terr_tuple_mutability;
terr_record_size(uint, uint);
terr_record_mutability;
terr_record_fields(ast::ident, ast::ident);
@ -473,11 +467,6 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] in_cname) -> @raw_t {
case (ty_ptr(?m)) { derive_flags_mt(cx, has_params, has_vars, m); }
case (ty_port(?tt)) { derive_flags_t(cx, has_params, has_vars, tt); }
case (ty_chan(?tt)) { derive_flags_t(cx, has_params, has_vars, tt); }
case (ty_tup(?mts)) {
for (mt m in mts) {
derive_flags_mt(cx, has_params, has_vars, m);
}
}
case (ty_rec(?flds)) {
for (field f in flds) {
derive_flags_mt(cx, has_params, has_vars, f.mt);
@ -585,18 +574,19 @@ fn mk_chan(&ctxt cx, &t ty) -> t { ret gen_ty(cx, ty_chan(ty)); }
fn mk_task(&ctxt cx) -> t { ret gen_ty(cx, ty_task); }
fn mk_tup(&ctxt cx, &mt[] tms) -> t { ret gen_ty(cx, ty_tup(tms)); }
fn mk_rec(&ctxt cx, &field[] fs) -> t { ret gen_ty(cx, ty_rec(fs)); }
fn mk_imm_tup(&ctxt cx, &t[] tys) -> t {
// TODO: map
let ty::mt[] mts = ~[];
for (t typ in tys) { mts += ~[rec(ty=typ, mut=ast::imm)]; }
ret mk_tup(cx, mts);
auto fields = ~[];
auto i = 0u;
for (t typ in tys) {
fields += ~[rec(ident=#fmt("_%u", i),
mt=rec(ty=typ, mut=ast::imm))];
i += 1u;
}
ret gen_ty(cx, ty_rec(fields));
}
fn mk_rec(&ctxt cx, &field[] fs) -> t { ret gen_ty(cx, ty_rec(fs)); }
fn mk_constr(&ctxt cx, &t t, &(@type_constr)[] cs) -> t {
ret gen_ty(cx, ty_constr(t, cs));
}
@ -665,9 +655,6 @@ fn walk_ty(&ctxt cx, ty_walk walker, t ty) {
case (ty_tag(?tid, ?subtys)) {
for (t subty in subtys) { walk_ty(cx, walker, subty); }
}
case (ty_tup(?mts)) {
for (mt tm in mts) { walk_ty(cx, walker, tm.ty); }
}
case (ty_rec(?fields)) {
for (field fl in fields) { walk_ty(cx, walker, fl.mt.ty); }
}
@ -765,14 +752,6 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
}
ty = copy_cname(cx, mk_tag(cx, tid, new_subtys), ty);
}
case (ty_tup(?mts)) {
let mt[] new_mts = ~[];
for (mt tm in mts) {
auto new_subty = fold_ty(cx, fld, tm.ty);
new_mts += ~[rec(ty=new_subty, mut=tm.mut)];
}
ty = copy_cname(cx, mk_tup(cx, new_mts), ty);
}
case (ty_rec(?fields)) {
let field[] new_fields = ~[];
for (field fl in fields) {
@ -896,7 +875,6 @@ fn type_is_chan(&ctxt cx, &t ty) -> bool {
fn type_is_structural(&ctxt cx, &t ty) -> bool {
alt (struct(cx, ty)) {
case (ty_tup(_)) { ret true; }
case (ty_rec(_)) { ret true; }
case (ty_tag(_, _)) { ret true; }
case (ty_fn(_, _, _, _, _)) { ret true; }
@ -964,7 +942,6 @@ fn sequence_element_type(&ctxt cx, &t ty) -> t {
fn type_is_tup_like(&ctxt cx, &t ty) -> bool {
alt (struct(cx, ty)) {
case (ty_box(_)) { ret true; }
case (ty_tup(_)) { ret true; }
case (ty_rec(_)) { ret true; }
case (ty_tag(_, _)) { ret true; }
case (_) { ret false; }
@ -973,7 +950,6 @@ fn type_is_tup_like(&ctxt cx, &t ty) -> bool {
fn get_element_type(&ctxt cx, &t ty, uint i) -> t {
alt (struct(cx, ty)) {
case (ty_tup(?mts)) { ret mts.(i).ty; }
case (ty_rec(?flds)) { ret flds.(i).mt.ty; }
case (_) {
cx.sess.bug("get_element_type called on type "
@ -1039,11 +1015,6 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
case (ty_char) { /* no-op */ }
case (ty_type) { /* no-op */ }
case (ty_native(_)) { /* no-op */ }
case (ty_tup(?elts)) {
for (mt m in elts) {
if (type_has_pointers(cx, m.ty)) { result = true; }
}
}
case (ty_rec(?flds)) {
for (field f in flds) {
if (type_has_pointers(cx, f.mt.ty)) { result = true; }
@ -1052,11 +1023,11 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
case (ty_tag(?did, ?tps)) {
auto variants = tag_variants(cx, did);
for (variant_info variant in variants) {
auto tup_ty = mk_imm_tup(cx, variant.args);
// Perform any type parameter substitutions.
tup_ty = substitute_type_params(cx, tps, tup_ty);
if (type_has_pointers(cx, tup_ty)) { result = true; }
for (t aty in variant.args) {
// Perform any type parameter substitutions.
auto arg_ty = substitute_type_params(cx, tps, aty);
if (type_has_pointers(cx, arg_ty)) { result = true; }
}
}
}
case (ty_res(?did, ?inner, ?tps)) {
@ -1107,14 +1078,6 @@ fn type_has_dynamic_size(&ctxt cx, &t ty) -> bool {
case (ty_port(_)) { ret false; }
case (ty_chan(_)) { ret false; }
case (ty_task) { ret false; }
case (ty_tup(?mts)) {
auto i = 0u;
while (i < ivec::len[mt](mts)) {
if (type_has_dynamic_size(cx, mts.(i).ty)) { ret true; }
i += 1u;
}
ret false;
}
case (ty_rec(?fields)) {
auto i = 0u;
while (i < ivec::len[field](fields)) {
@ -1227,16 +1190,11 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
case (ty_tag(?did, ?tps)) {
auto variants = tag_variants(cx, did);
for (variant_info variant in variants) {
auto tup_ty = mk_imm_tup(cx, variant.args);
// Perform any type parameter substitutions.
tup_ty = substitute_type_params(cx, tps, tup_ty);
if (type_owns_heap_mem(cx, tup_ty)) { result = true; }
}
}
case (ty_tup(?elts)) {
for (mt m in elts) {
if (type_owns_heap_mem(cx, m.ty)) { result = true; }
for (t aty in variant.args) {
// Perform any type parameter substitutions.
auto arg_ty = substitute_type_params(cx, tps, aty);
if (type_owns_heap_mem(cx, arg_ty)) { result = true; }
}
}
}
case (ty_rec(?flds)) {
@ -1377,11 +1335,6 @@ fn hash_type_structure(&sty st) -> uint {
case (ty_port(?typ)) { ret hash_subty(22u, typ); }
case (ty_chan(?typ)) { ret hash_subty(23u, typ); }
case (ty_task) { ret 24u; }
case (ty_tup(?mts)) {
auto h = 25u;
for (mt tm in mts) { h += h << 5u + hash_ty(tm.ty); }
ret h;
}
case (ty_rec(?fields)) {
auto h = 26u;
for (field f in fields) { h += h << 5u + hash_ty(f.mt.ty); }
@ -1599,21 +1552,6 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_task) {
alt (b) { case (ty_task) { ret true; } case (_) { ret false; } }
}
case (ty_tup(?mts_a)) {
alt (b) {
case (ty_tup(?mts_b)) {
auto len = ivec::len[mt](mts_a);
if (len != ivec::len[mt](mts_b)) { ret false; }
auto i = 0u;
while (i < len) {
if (!equal_mt(mts_a.(i), mts_b.(i))) { ret false; }
i += 1u;
}
ret true;
}
case (_) { ret false; }
}
}
case (ty_rec(?flds_a)) {
alt (b) {
case (ty_rec(?flds_b)) {
@ -1921,34 +1859,6 @@ fn stmt_node_id(&@ast::stmt s) -> ast::node_id {
}
}
// Expression utilities
fn field_num(&session::session sess, &span sp, &ast::ident id) -> uint {
let uint accum = 0u;
let uint i = 0u;
for (u8 c in id) {
if (i == 0u) {
if (c != '_' as u8) {
sess.span_fatal(sp,
"bad numeric field on tuple: " +
"missing leading underscore");
}
} else {
if ('0' as u8 <= c && c <= '9' as u8) {
accum *= 10u;
accum += (c as uint) - ('0' as uint);
} else {
auto s = "";
s += str::unsafe_from_byte(c);
sess.span_fatal(sp,
"bad numeric field on tuple: " +
" non-digit character: " + s);
}
}
i += 1u;
}
ret accum;
}
fn field_idx(&session::session sess, &span sp, &ast::ident id,
&field[] fields) -> uint {
let uint i = 0u;
@ -2428,9 +2338,7 @@ mod unify {
expected_id.node != actual_id.node) {
ret ures_err(terr_mismatch);
}
// TODO: factor this cruft out, see the TODO in the
// ty::ty_tup case
// TODO: factor this cruft out
let t[] result_tps = ~[];
auto i = 0u;
auto expected_len = ivec::len[t](expected_tps);
@ -2597,49 +2505,6 @@ mod unify {
case (_) { ret ures_err(terr_mismatch); }
}
}
case (ty::ty_tup(?expected_elems)) {
alt (struct(cx.tcx, actual)) {
case (ty::ty_tup(?actual_elems)) {
auto expected_len = ivec::len[ty::mt](expected_elems);
auto actual_len = ivec::len[ty::mt](actual_elems);
if (expected_len != actual_len) {
auto err =
terr_tuple_size(expected_len, actual_len);
ret ures_err(err);
}
// TODO: implement an iterator that can iterate over
// two arrays simultaneously.
let ty::mt[] result_elems = ~[];
auto i = 0u;
while (i < expected_len) {
auto expected_elem = expected_elems.(i);
auto actual_elem = actual_elems.(i);
auto mut;
alt (unify_mut(expected_elem.mut,
actual_elem.mut)) {
case (none) {
ret ures_err(terr_tuple_mutability);
}
case (some(?m)) { mut = m; }
}
auto result =
unify_step(cx, expected_elem.ty,
actual_elem.ty);
alt (result) {
case (ures_ok(?rty)) {
auto mt = rec(ty=rty, mut=mut);
result_elems += ~[mt];
}
case (_) { ret result; }
}
i += 1u;
}
ret ures_ok(mk_tup(cx.tcx, result_elems));
}
case (_) { ret ures_err(terr_mismatch); }
}
}
case (ty::ty_rec(?expected_fields)) {
alt (struct(cx.tcx, actual)) {
case (ty::ty_rec(?actual_fields)) {
@ -2837,14 +2702,6 @@ fn type_err_to_str(&ty::type_err err) -> str {
ret "boxed values differ in mutability";
}
case (terr_vec_mutability) { ret "vectors differ in mutability"; }
case (terr_tuple_size(?e_sz, ?a_sz)) {
ret "expected a tuple with " + uint::to_str(e_sz, 10u) +
" elements but found one with " + uint::to_str(a_sz, 10u)
+ " elements";
}
case (terr_tuple_mutability) {
ret "tuple elements differ in mutability";
}
case (terr_record_size(?e_sz, ?a_sz)) {
ret "expected a record with " + uint::to_str(e_sz, 10u) +
" fields but found one with " + uint::to_str(a_sz, 10u) +
@ -3093,7 +2950,6 @@ fn is_binopable(&ctxt cx, t ty, ast::binop op) -> bool {
case (ty_istr) { tycat_str }
case (ty_vec(_)) { tycat_vec }
case (ty_ivec(_)) { tycat_vec }
case (ty_tup(_)) { tycat_struct }
case (ty_rec(_)) { tycat_struct }
case (ty_tag(_, _)) { tycat_struct }
case (_) { tycat_other }

View file

@ -329,10 +329,6 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
case (ast::ty_chan(?t)) {
typ = ty::mk_chan(tcx, ast_ty_to_ty(tcx, getter, t));
}
case (ast::ty_tup(?fields)) {
auto flds = ivec::map(bind ast_mt_to_mt(tcx, getter, _), fields);
typ = ty::mk_tup(tcx, flds);
}
case (ast::ty_rec(?fields)) {
let field[] flds = ~[];
for (ast::ty_field f in fields) {
@ -2208,17 +2204,6 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
}
write::ty_only_fixup(fcx, id, typ);
}
case (ast::expr_tup(?elts)) {
let ty::mt[] elts_mt = ~[];
ivec::reserve(elts_mt, ivec::len(elts));
for (ast::elt e in elts) {
check_expr(fcx, e.expr);
auto ety = expr_ty(fcx.ccx.tcx, e.expr);
elts_mt += ~[rec(ty=ety, mut=e.mut)];
}
auto typ = ty::mk_tup(fcx.ccx.tcx, elts_mt);
write::ty_only_fixup(fcx, id, typ);
}
case (ast::expr_rec(?fields, ?base)) {
alt (base) {
case (none) {/* no-op */ }
@ -2278,15 +2263,6 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
auto base_t = expr_ty(fcx.ccx.tcx, base);
base_t = do_autoderef(fcx, expr.span, base_t);
alt (structure_of(fcx, expr.span, base_t)) {
case (ty::ty_tup(?args)) {
let uint ix =
ty::field_num(fcx.ccx.tcx.sess, expr.span, field);
if (ix >= ivec::len[ty::mt](args)) {
fcx.ccx.tcx.sess.span_fatal(expr.span,
"bad index on tuple");
}
write::ty_only_fixup(fcx, id, args.(ix).ty);
}
case (ty::ty_rec(?fields)) {
let uint ix =
ty::field_idx(fcx.ccx.tcx.sess, expr.span, field,

View file

@ -283,7 +283,6 @@ type expr = rec(node_id id,
tag expr_ {
expr_vec((@expr)[], mutability, seq_kind);
expr_tup(elt[]);
expr_rec(field[], option::t[@expr]);
expr_call(@expr, (@expr)[]);
expr_self_method(ident);
@ -446,7 +445,6 @@ tag ty_ {
ty_task;
ty_port(@ty);
ty_chan(@ty);
ty_tup(mt[]);
ty_rec(ty_field[]);
ty_fn(proto, ty_arg[], @ty, controlflow, (@constr)[]);
ty_obj(ty_method[]);

View file

@ -40,7 +40,7 @@ fn expand_expr(&hashmap[str, base::syntax_extension] exts,
= ext(ext_cx, pth.span, args, body);
exts.insert(named_extension.ident,
named_extension.ext);
ast::expr_tup(~[])
ast::expr_rec(~[], none)
}
}
}

View file

@ -308,10 +308,6 @@ fn noop_fold_decl(&decl_ d, ast_fold fld) -> decl_ {
}
fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
fn fold_elt_(&elt elt, ast_fold fld) -> elt {
ret rec(mut=elt.mut, expr=fld.fold_expr(elt.expr));
}
auto fold_elt = bind fold_elt_(_,fld);
fn fold_field_(&field field, ast_fold fld) -> field {
ret rec(node=rec(mut=field.node.mut,
ident=fld.fold_ident(field.node.ident),
@ -345,9 +341,6 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
case (expr_vec(?exprs, ?mut, ?seq_kind)) {
expr_vec(fld.map_exprs(fld.fold_expr, exprs), mut, seq_kind)
}
case (expr_tup(?elts)) {
expr_tup(ivec::map(fold_elt, elts))
}
case (expr_rec(?fields, ?maybe_expr)) {
expr_rec(ivec::map(fold_field, fields),
option::map(fld.fold_expr, maybe_expr))

View file

@ -564,12 +564,6 @@ fn parse_ty(&parser p) -> @ast::ty {
t = ast::ty_vec(parse_mt(p));
hi = p.get_hi_pos();
expect(p, token::RBRACKET);
} else if (eat_word(p, "tup")) {
auto elems =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_mt, p);
hi = elems.span.hi;
t = ast::ty_tup(elems.node);
} else if (eat_word(p, "rec")) {
auto elems =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
@ -837,16 +831,6 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
ret parse_spawn_expr(p);
} else if (eat_word(p, "fn")) {
ret parse_fn_expr(p);
} else if (eat_word(p, "tup")) {
fn parse_elt(&parser p) -> ast::elt {
auto m = parse_mutability(p);
auto e = parse_expr(p);
ret rec(mut=m, expr=e);
}
auto es = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_elt, p);
hi = es.span.hi;
ex = ast::expr_tup(es.node);
} else if (p.peek() == token::LBRACKET) {
p.bump();
auto mut = parse_mutability(p);
@ -1737,7 +1721,6 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
case (ast::stmt_expr(?e, _)) {
ret alt (e.node) {
case (ast::expr_vec(_, _, _)) { true }
case (ast::expr_tup(_)) { true }
case (ast::expr_rec(_, _)) { true }
case (ast::expr_call(_, _)) { true }
case (ast::expr_self_method(_)) { false }

View file

@ -294,12 +294,6 @@ fn print_type(&ps s, &ast::ty ty) {
print_type(s, *t);
word(s.s, "]");
}
case (ast::ty_tup(?elts)) {
word(s.s, "tup");
popen(s);
commasep(s, inconsistent, elts, print_mt);
pclose(s);
}
case (ast::ty_rec(?fields)) {
word(s.s, "{");
fn print_field(&ps s, &ast::ty_field f) {
@ -689,19 +683,6 @@ fn print_expr(&ps s, &@ast::expr expr) {
word(s.s, "]");
end(s);
}
case (ast::expr_tup(?exprs)) {
fn printElt(&ps s, &ast::elt elt) {
ibox(s, indent_unit);
if (elt.mut == ast::mut) { word_nbsp(s, "mutable"); }
print_expr(s, elt.expr);
end(s);
}
fn get_span(&ast::elt elt) -> codemap::span { ret elt.expr.span; }
word(s.s, "tup");
popen(s);
commasep_cmnt(s, inconsistent, exprs, printElt, get_span);
pclose(s);
}
case (ast::expr_rec(?fields, ?wth)) {
fn print_field(&ps s, &ast::field field) {
ibox(s, indent_unit);

View file

@ -154,9 +154,6 @@ fn visit_ty[E](&@ty t, &E e, &vt[E] v) {
case (ty_port(?t)) { v.visit_ty(t, e, v); }
case (ty_chan(?t)) { v.visit_ty(t, e, v); }
case (ty_task) { /* no-op */ }
case (ty_tup(?mts)) {
for (mt mt in mts) { v.visit_ty(mt.ty, e, v); }
}
case (ty_rec(?flds)) {
for (ty_field f in flds) { v.visit_ty(f.node.mt.ty, e, v); }
}
@ -279,9 +276,6 @@ fn visit_mac[E](mac m, &E e, &vt[E] v) {
fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
alt (ex.node) {
case (expr_vec(?es, _, _)) { visit_exprs(es, e, v); }
case (expr_tup(?elts)) {
for (elt el in elts) { v.visit_expr(el.expr, e, v); }
}
case (expr_rec(?flds, ?base)) {
for (field f in flds) { v.visit_expr(f.node.expr, e, v); }
visit_expr_opt(base, e, v);

View file

@ -154,9 +154,6 @@ fn walk_ty(&ast_visitor v, @ast::ty t) {
case (ast::ty_task) { }
case (ast::ty_port(?t)) { walk_ty(v, t); }
case (ast::ty_chan(?t)) { walk_ty(v, t); }
case (ast::ty_tup(?mts)) {
for (ast::mt mt in mts) { walk_ty(v, mt.ty); }
}
case (ast::ty_rec(?flds)) {
for (ast::ty_field f in flds) { walk_ty(v, f.node.mt.ty); }
}
@ -286,9 +283,6 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
v.visit_expr_pre(e);
alt (e.node) {
case (ast::expr_vec(?es, _, _)) { walk_exprs(v, es); }
case (ast::expr_tup(?elts)) {
for (ast::elt e in elts) { walk_expr(v, e.expr); }
}
case (ast::expr_rec(?flds, ?base)) {
for (ast::field f in flds) { walk_expr(v, f.node.expr); }
walk_expr_opt(v, base);

View file

@ -103,11 +103,6 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
case (ty_chan(?t)) { s += "chan[" + ty_to_str(cx, t) + "]"; }
case (ty_type) { s += "type"; }
case (ty_task) { s += "task"; }
case (ty_tup(?elems)) {
let str[] strs = ~[];
for (mt tm in elems) { strs += ~[mt_to_str(cx, tm)]; }
s += "tup(" + str::connect_ivec(strs, ",") + ")";
}
case (ty_rec(?elems)) {
let str[] strs = ~[];
for (field fld in elems) { strs += ~[field_to_str(cx, fld)]; }