From e038e8e52bebe33ca2d949122bf876bbb2d97936 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 12 Jul 2011 16:35:02 -0700 Subject: [PATCH] rustc: Move ppaux away from exterior vectors --- src/comp/syntax/fold.rs | 2 -- src/comp/syntax/print/pprust.rs | 8 ++------ src/comp/util/ppaux.rs | 26 ++++++++++++-------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index a7692490bccf..929f0bc3f10f 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -2,9 +2,7 @@ import syntax::codemap::span; import ast::*; import std::ivec; -import std::vec; import std::option; -import vec::map; export ast_fold_precursor; export ast_fold; diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index d4510a9c2933..8875208e2a8f 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1548,12 +1548,8 @@ fn constr_arg_to_str[T](&fn(&T) -> str f, &ast::constr_arg_general_[T] c) -> fn uint_to_str(&uint i) -> str { ret uint::str(i); } fn ast_constr_to_str(&@ast::constr c) -> str { - // TODO: Remove this vec->ivec conversion. - auto cags = ~[]; - for (@ast::constr_arg_general[uint] cag in c.node.args) { - cags += ~[cag]; - } - ret ast::path_to_str(c.node.path) + constr_args_to_str(uint_to_str, cags); + ret ast::path_to_str(c.node.path) + + constr_args_to_str(uint_to_str, c.node.args); } fn ast_constrs_str(&(@ast::constr)[] constrs) -> str { diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs index 381b595435b7..a2e95cdd5ca9 100644 --- a/src/comp/util/ppaux.rs +++ b/src/comp/util/ppaux.rs @@ -1,6 +1,5 @@ import std::io; import std::ivec; -import std::vec; import std::str; import std::int; import std::option; @@ -107,23 +106,23 @@ fn ty_to_str(&ctxt cx, &t typ) -> str { case (ty_type) { s += "type"; } case (ty_task) { s += "task"; } case (ty_tup(?elems)) { - let vec[str] strs = []; - for (mt tm in elems) { strs += [mt_to_str(cx, tm)]; } - s += "tup(" + str::connect(strs, ",") + ")"; + 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 vec[str] strs = []; - for (field fld in elems) { strs += [field_to_str(cx, fld)]; } - s += "rec(" + str::connect(strs, ",") + ")"; + let str[] strs = ~[]; + for (field fld in elems) { strs += ~[field_to_str(cx, fld)]; } + s += "rec(" + str::connect_ivec(strs, ",") + ")"; } case (ty_tag(?id, ?tps)) { // The user should never see this if the cname is set properly! s += ""; if (ivec::len[t](tps) > 0u) { - let vec[str] strs = []; - for (t typ in tps) { strs += [ty_to_str(cx, typ)]; } - s += "[" + str::connect(strs, ",") + "]"; + let str[] strs = ~[]; + for (t typ in tps) { strs += ~[ty_to_str(cx, typ)]; } + s += "[" + str::connect_ivec(strs, ",") + "]"; } } case (ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) { @@ -134,10 +133,9 @@ fn ty_to_str(&ctxt cx, &t typ) -> str { ast::return, ~[]); } case (ty_obj(?meths)) { - // TODO: Remove this ivec->vec conversion. - auto strs = []; - for (method m in meths) { strs += [method_to_str(cx, m)]; } - s += "obj {\n\t" + str::connect(strs, "\n\t") + "\n}"; + auto strs = ~[]; + for (method m in meths) { strs += ~[method_to_str(cx, m)]; } + s += "obj {\n\t" + str::connect_ivec(strs, "\n\t") + "\n}"; } case (ty_res(?id, _, _)) { s += "";