rustc: Make AST tuple types use interior vectors

This commit is contained in:
Patrick Walton 2011-07-06 15:53:47 -07:00
parent 401b6362d7
commit aad0bcc8d5
4 changed files with 5 additions and 9 deletions

View file

@ -315,11 +315,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
typ = ty::mk_chan(tcx, ast_ty_to_ty(tcx, getter, t)); typ = ty::mk_chan(tcx, ast_ty_to_ty(tcx, getter, t));
} }
case (ast::ty_tup(?fields)) { case (ast::ty_tup(?fields)) {
let ty::mt[] flds = ~[]; auto flds = ivec::map(bind ast_mt_to_mt(tcx, getter, _), fields);
ivec::reserve(flds, vec::len(fields));
for (ast::mt field in fields) {
flds += ~[ast_mt_to_mt(tcx, getter, field)];
}
typ = ty::mk_tup(tcx, flds); typ = ty::mk_tup(tcx, flds);
} }
case (ast::ty_rec(?fields)) { case (ast::ty_rec(?fields)) {

View file

@ -401,7 +401,7 @@ tag ty_ {
ty_task; ty_task;
ty_port(@ty); ty_port(@ty);
ty_chan(@ty); ty_chan(@ty);
ty_tup(vec[mt]); ty_tup(mt[]);
ty_rec(vec[ty_field]); ty_rec(vec[ty_field]);
ty_fn(proto, vec[ty_arg], @ty, controlflow, vec[@constr]); ty_fn(proto, vec[ty_arg], @ty, controlflow, vec[@constr]);
ty_obj(vec[ty_method]); ty_obj(vec[ty_method]);

View file

@ -520,8 +520,8 @@ fn parse_ty(&parser p) -> @ast::ty {
expect(p, token::RBRACKET); expect(p, token::RBRACKET);
} else if (eat_word(p, "tup")) { } else if (eat_word(p, "tup")) {
auto elems = auto elems =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_mt, p); parse_mt, p);
hi = elems.span.hi; hi = elems.span.hi;
t = ast::ty_tup(elems.node); t = ast::ty_tup(elems.node);
} else if (eat_word(p, "rec")) { } else if (eat_word(p, "rec")) {

View file

@ -301,7 +301,7 @@ fn print_type(&ps s, &ast::ty ty) {
case (ast::ty_tup(?elts)) { case (ast::ty_tup(?elts)) {
word(s.s, "tup"); word(s.s, "tup");
popen(s); popen(s);
commasep(s, inconsistent, elts, print_mt); commasep_ivec(s, inconsistent, elts, print_mt);
pclose(s); pclose(s);
} }
case (ast::ty_rec(?fields)) { case (ast::ty_rec(?fields)) {