From 01ea0647bb9773f44a8100c461af30046c3293aa Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 12 Jul 2011 18:19:39 -0700 Subject: [PATCH] rustc: Remove some exterior vectors from ty.rs --- src/comp/middle/ty.rs | 57 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 678821f0cdea..b44386553eed 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -3,7 +3,6 @@ import std::int; import std::ivec; import std::str; import std::uint; -import std::vec; import std::box; import std::ufindivec; import std::map; @@ -1039,24 +1038,16 @@ 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) { - // TODO: Remove this vec->ivec conversion. - auto args = ~[]; - for (ty::t arg in variant.args) { args += ~[arg]; } + auto tup_ty = mk_imm_tup(cx, variant.args); - auto tup_ty = mk_imm_tup(cx, args); // Perform any type parameter substitutions. - tup_ty = substitute_type_params(cx, tps, tup_ty); if (type_has_pointers(cx, tup_ty)) { result = true; } } } case (ty_res(?did, ?inner, ?tps)) { - // FIXME: Remove this vec->ivec conversion. - auto tps_ivec = ~[]; - for (ty::t tp in tps) { tps_ivec += ~[tp]; } - - result = type_has_pointers - (cx, substitute_type_params(cx, tps_ivec, inner)); + result = type_has_pointers(cx, + substitute_type_params(cx, tps, inner)); } case (_) { result = true; } } @@ -1221,11 +1212,7 @@ 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) { - // TODO: Remove this vec->ivec conversion. - auto args = ~[]; - for (ty::t arg in variant.args) { args += ~[arg]; } - - auto tup_ty = mk_imm_tup(cx, args); + auto tup_ty = mk_imm_tup(cx, variant.args); // Perform any type parameter substitutions. tup_ty = substitute_type_params(cx, tps, tup_ty); @@ -1243,12 +1230,8 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool { } } case (ty_res(_, ?inner, ?tps)) { - // FIXME: Remove this vec->ivec conversion. - auto tps_ivec = ~[]; - for (ty::t tp in tps) { tps_ivec += ~[tp]; } - - result = type_owns_heap_mem - (cx, substitute_type_params(cx, tps_ivec, inner)); + result = type_owns_heap_mem(cx, + substitute_type_params(cx, tps, inner)); } case (ty_ptr(_)) { result = false; } @@ -1279,11 +1262,7 @@ fn type_autoderef(&ctxt cx, &ty::t t) -> ty::t { alt (struct(cx, t1)) { case (ty::ty_box(?mt)) { t1 = mt.ty; } case (ty::ty_res(_, ?inner, ?tps)) { - // FIXME: Remove this vec->ivec conversion. - auto tps_ivec = ~[]; - for (ty::t tp in tps) { tps_ivec += ~[tp]; } - - t1 = substitute_type_params(cx, tps_ivec, inner); + t1 = substitute_type_params(cx, tps, inner); } case (ty::ty_tag(?did, ?tps)) { auto variants = tag_variants(cx, did); @@ -1763,13 +1742,7 @@ fn ty_param_substs_opt_and_ty_to_monotype(&ctxt cx, t { alt (tpot._0) { case (none) { ret tpot._1; } - case (some(?tps)) { - // FIXME: Remove this vec->ivec conversion. - auto tps_ivec = ~[]; - for (ty::t tp in tps) { tps_ivec += ~[tp]; } - - ret substitute_type_params(cx, tps_ivec, tpot._1); - } + case (some(?tps)) { ret substitute_type_params(cx, tps, tpot._1); } } } @@ -2979,13 +2952,13 @@ fn is_binopable(&ctxt cx, t ty, ast::binop op) -> bool { /*. add, shift, bit . sub, rel, logic . mult, eq, */ - auto tbl = [[f, f, f, f, t, t, f, f], /*other*/ - [f, f, f, f, t, t, t, t], /*bool*/ - [t, t, t, t, t, t, t, f], /*int*/ - [t, t, t, f, t, t, f, f], /*float*/ - [t, f, f, f, t, t, f, f], /*str*/ - [t, f, f, f, t, t, f, f], /*vec*/ - [f, f, f, f, t, t, f, f]];/*struct*/ + auto tbl = ~[~[f, f, f, f, t, t, f, f], /*other*/ + ~[f, f, f, f, t, t, t, t], /*bool*/ + ~[t, t, t, t, t, t, t, f], /*int*/ + ~[t, t, t, f, t, t, f, f], /*float*/ + ~[t, f, f, f, t, t, f, f], /*str*/ + ~[t, f, f, f, t, t, f, f], /*vec*/ + ~[f, f, f, f, t, t, f, f]];/*struct*/ ret tbl.(tycat(cx, ty)).(opcat(op)); }