提交 87eaf91b 编写于 作者: E Eric Holk

Replaced almost all vector+ in rustc (#2719)

Didn't update shape because the changes were causing segfaults.
上级 54713afa
......@@ -490,7 +490,9 @@ fn mangle(ss: path) -> str {
}
fn exported_name(path: path, hash: @str, vers: @str) -> str {
ret mangle(path + [path_name(hash)]/~ + [path_name(vers)]/~);
ret mangle(
vec::append_one(vec::append_one(path, path_name(hash)),
path_name(vers)));
}
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str {
......@@ -508,7 +510,7 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
flav: @str) -> str {
ret mangle(path + [path_name(@ccx.names(*flav))]/~);
ret mangle(vec::append_one(path, path_name(@ccx.names(*flav))));
}
fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str {
......@@ -577,8 +579,10 @@ fn rmext(filename: str) -> str {
// The invocations of cc share some flags across platforms
let mut cc_args =
[stage]/~ + sess.targ_cfg.target_strs.cc_args +
["-o", output, obj_filename]/~;
vec::append([stage]/~, sess.targ_cfg.target_strs.cc_args);
vec::push(cc_args, "-o");
vec::push(cc_args, output);
vec::push(cc_args, obj_filename);
let mut lib_cmd;
let os = sess.targ_cfg.os;
......
......@@ -29,7 +29,7 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> [str]/~ {
let libs = cstore::get_used_crate_files(sess.cstore);
// We don't currently rpath native libraries, but we know
// where rustrt is and we know every rust program needs it
let libs = libs + [get_sysroot_absolute_rt_lib(sess)]/~;
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));
let target_triple = sess.opts.target_triple;
let rpaths = get_rpaths(os, cwd, sysroot, output, libs, target_triple);
......@@ -37,10 +37,10 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> [str]/~ {
}
fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path {
let path = [sess.filesearch.sysroot()]/~
+ filesearch::relative_target_lib_path(
sess.opts.target_triple)
+ [os::dll_filename("rustrt")]/~;
let mut path = vec::append([sess.filesearch.sysroot()]/~,
filesearch::relative_target_lib_path(
sess.opts.target_triple));
vec::push(path, os::dll_filename("rustrt"));
path::connect_many(path)
}
......@@ -83,7 +83,9 @@ fn log_rpaths(desc: str, rpaths: [str]/~) {
log_rpaths("absolute", abs_rpaths);
log_rpaths("fallback", fallback_rpaths);
let rpaths = rel_rpaths + abs_rpaths + fallback_rpaths;
let mut rpaths = rel_rpaths;
vec::push_all(rpaths, abs_rpaths);
vec::push_all(rpaths, fallback_rpaths);
// Remove duplicates
let rpaths = minimize_rpaths(rpaths);
......@@ -142,7 +144,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
let mut path = []/~;
for uint::range(start_idx, len1 - 1u) {|_i| vec::push(path, ".."); };
path += vec::slice(split2, start_idx, len2 - 1u);
vec::push_all(path, vec::view(split2, start_idx, len2 - 1u));
if check vec::is_not_empty(path) {
ret path::connect_many(path);
......@@ -174,8 +176,9 @@ fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str {
fail "rustc compiled without CFG_PREFIX environment variable";
}
let path = [install_prefix]/~
+ filesearch::relative_target_lib_path(target_triple);
let path = vec::append(
[install_prefix]/~,
filesearch::relative_target_lib_path(target_triple));
get_absolute(cwd, path::connect_many(path))
}
......@@ -184,7 +187,7 @@ fn minimize_rpaths(rpaths: [str]/~) -> [str]/~ {
let mut minimized = []/~;
for rpaths.each {|rpath|
if !set.contains_key(rpath) {
minimized += [rpath]/~;
vec::push(minimized, rpath);
set.insert(rpath, ());
}
}
......
......@@ -36,7 +36,7 @@ fn decl(llmod: ModuleRef, prefix: str, name: str,
tys: [TypeRef]/~, rv: TypeRef) ->
ValueRef {
let mut arg_tys: [TypeRef]/~ = []/~;
for tys.each {|t| arg_tys += [t]/~; }
for tys.each {|t| vec::push(arg_tys, t); }
let fn_ty = T_fn(arg_tys, rv);
ret base::decl_cdecl_fn(llmod, prefix + name, fn_ty);
}
......
......@@ -73,7 +73,7 @@ fn build_configuration(sess: session, argv0: str, input: input) ->
[attr::mk_word_item(@"test")]/~
} else { []/~ }
};
ret user_cfg + gen_cfg + default_cfg;
ret vec::append(vec::append(user_cfg, gen_cfg), default_cfg);
}
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
......@@ -414,8 +414,8 @@ fn build_session_options(match: getopts::match,
let parse_only = opt_present(match, "parse-only");
let no_trans = opt_present(match, "no-trans");
let lint_flags = (getopts::opt_strs(match, "W")
+ getopts::opt_strs(match, "warn"));
let lint_flags = vec::append(getopts::opt_strs(match, "W"),
getopts::opt_strs(match, "warn"));
let lint_dict = lint::get_lint_dict();
let lint_opts = vec::map(lint_flags) {|flag|
alt lint::lookup_lint(lint_dict, flag) {
......
......@@ -131,8 +131,8 @@ fn run_compiler(args: [str]/~, demitter: diagnostic::emitter) {
ret;
}
let lint_flags = (getopts::opt_strs(match, "W")
+ getopts::opt_strs(match, "warn"));
let lint_flags = vec::append(getopts::opt_strs(match, "W"),
getopts::opt_strs(match, "warn"));
if lint_flags.contains("help") {
describe_warnings();
ret;
......
......@@ -41,7 +41,7 @@ fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
vis: ast::public,
span: dummy_sp()};
let vis = [vi1, vi2]/~ + crate.node.module.view_items;
let vis = vec::append([vi1, vi2]/~, crate.node.module.view_items);
ret @{node: {module: { view_items: vis with crate.node.module }
with crate.node} with *crate }
......
......@@ -22,7 +22,7 @@ fn inject_intrinsic(sess: session,
}
};
let items = [item]/~ + crate.node.module.items;
let items = vec::append([item]/~, crate.node.module.items);
ret @{node: {module: { items: items with crate.node.module }
with crate.node} with *crate }
......
......@@ -98,7 +98,7 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
@ast::item {
cx.path += [i.ident]/~;
vec::push(cx.path, i.ident);
#debug("current path: %s", ast_util::path_name_i(cx.path));
if is_test_fn(i) {
......@@ -161,7 +161,7 @@ fn should_fail(i: @ast::item) -> bool {
fn add_test_module(cx: test_ctxt, m: ast::_mod) -> ast::_mod {
let testmod = mk_test_module(cx);
ret {items: m.items + [testmod]/~ with m};
ret {items: vec::append_one(m.items, testmod) with m};
}
/*
......@@ -252,7 +252,8 @@ fn mk_path(cx: test_ctxt, path: [ast::ident]/~) -> [ast::ident]/~ {
_ { false }
}
};
(if is_std { []/~ } else { [@"std"]/~ }) + path
if is_std { path }
else { vec::append([@"std"]/~, path) }
}
// The ast::ty of [std::test::test_desc]/~
......@@ -278,7 +279,7 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
#debug("building test vector from %u tests", cx.testfns.len());
let mut descs = []/~;
for cx.testfns.each {|test|
descs += [mk_test_desc_rec(cx, test)]/~;
vec::push(descs, mk_test_desc_rec(cx, test));
}
let inner_expr = @{id: cx.sess.next_node_id(),
......
......@@ -991,7 +991,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef]/~, ty: TypeRef) ->
_ {}
}
let outer = outer0 + [ty]/~;
let outer = vec::append_one(outer0, ty);
let kind = llvm::LLVMGetTypeKind(ty);
......
......@@ -164,7 +164,7 @@ fn metas_with(ident: ast::ident, key: ast::ident,
metas: [@ast::meta_item]/~) -> [@ast::meta_item]/~ {
let name_items = attr::find_meta_items_by_name(metas, *key);
if name_items.is_empty() {
metas + [attr::mk_name_value_item_str(key, *ident)]/~
vec::append_one(metas, attr::mk_name_value_item_str(key, *ident))
} else {
metas
}
......
......@@ -88,7 +88,7 @@ fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
// FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace.
[ast_map::path_mod(@cdata.name)]/~ + path
vec::append([ast_map::path_mod(@cdata.name)]/~, path)
}
enum found_ast {
......
......@@ -134,7 +134,7 @@ fn get_used_libraries(cstore: cstore) -> [str]/~ {
}
fn add_used_link_args(cstore: cstore, args: str) {
p(cstore).used_link_args += str::split_char(args, ' ');
vec::push_all(p(cstore).used_link_args, str::split_char(args, ' '));
}
fn get_used_link_args(cstore: cstore) -> [str]/~ {
......
......@@ -611,9 +611,9 @@ fn get_attributes(md: ebml::doc) -> [ast::attribute]/~ {
// an attribute
assert (vec::len(meta_items) == 1u);
let meta_item = meta_items[0];
attrs +=
[{node: {style: ast::attr_outer, value: *meta_item},
span: ast_util::dummy_sp()}]/~;
vec::push(attrs,
{node: {style: ast::attr_outer, value: *meta_item},
span: ast_util::dummy_sp()});
};
}
option::none { }
......
......@@ -119,9 +119,11 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant]/~,
}
}
fn add_to_index(ebml_w: ebml::writer, path: [ident]/~, &index: [entry<str>]/~,
fn add_to_index(ebml_w: ebml::writer, path: [ident]/&, &index: [entry<str>]/~,
name: ident) {
let full_path = path + [name]/~;
let mut full_path = []/~;
vec::push_all(full_path, path);
vec::push(full_path, name);
vec::push(index, {val: ast_util::path_name_i(full_path),
pos: ebml_w.writer.tell()});
}
......@@ -171,15 +173,16 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
ebml_w.wr_tag(tag_paths_data_mod) {||
encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_module_item_paths(ebml_w, ecx, _mod,
path + [it.ident]/~,
vec::append_one(path, it.ident),
index);
}
}
item_foreign_mod(nmod) {
ebml_w.wr_tag(tag_paths_data_mod) {||
encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_foreign_module_item_paths(ebml_w, nmod,
path + [it.ident]/~, index);
encode_foreign_module_item_paths(
ebml_w, nmod,
vec::append_one(path, it.ident), index);
}
}
item_ty(_, tps, _) {
......@@ -197,7 +200,8 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
add_to_index(ebml_w, path, index, it.ident);
encode_named_def_id(ebml_w, it.ident,
local_def(ctor.node.id));
encode_class_item_paths(ebml_w, items, path + [it.ident]/~,
encode_class_item_paths(ebml_w, items,
vec::append_one(path, it.ident),
index);
}
}
......@@ -451,11 +455,12 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()});
vec::push(*global_index,
{val: m.id, pos: ebml_w.writer.tell()});
let impl_path = path + [ast_map::path_name(m.ident)]/~;
let impl_path = vec::append_one(path,
ast_map::path_name(m.ident));
#debug("encode_info_for_class: doing %s %d", *m.ident, m.id);
encode_info_for_method(ecx, ebml_w, impl_path,
should_inline(m.attrs), id, m,
class_tps + m.tps);
vec::append(class_tps, m.tps));
}
_ { /* don't encode private methods */ }
}
......@@ -709,11 +714,13 @@ fn add_to_index_(item: @item, ebml_w: ebml::writer,
encode_path(ebml_w, path, ast_map::path_name(item.ident));
ebml_w.end_tag();
let impl_path = path + [ast_map::path_name(item.ident)]/~;
let impl_path = vec::append_one(path,
ast_map::path_name(item.ident));
for methods.each {|m|
vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()});
encode_info_for_method(ecx, ebml_w, impl_path,
should_inline(m.attrs), item.id, m, tps + m.tps);
should_inline(m.attrs), item.id, m,
vec::append(tps, m.tps));
}
}
item_iface(tps, rp, ms) {
......@@ -786,8 +793,8 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
item_class(tps, _, _, ctor, m_dtor, _) {
#debug("encoding info for ctor %s %d", *i.ident,
ctor.node.id);
*index +=
[{val: ctor.node.id, pos: ebml_w.writer.tell()}]/~;
vec::push(*index,
{val: ctor.node.id, pos: ebml_w.writer.tell()});
encode_info_for_fn(ecx, ebml_w, ctor.node.id, i.ident,
*pt, if tps.len() > 0u {
some(ii_ctor(ctor, i.ident, tps,
......@@ -933,7 +940,7 @@ fn synthesize_link_attr(ecx: @encode_ctxt, items: [@meta_item]/~) ->
attr::remove_meta_items_by_name(tmp, @"vers")
};
let meta_items = [name_item, vers_item]/~ + other_items;
let meta_items = vec::append([name_item, vers_item]/~, other_items);
let link_item = attr::mk_list_item(@"link", meta_items);
ret attr::mk_attr(link_item);
......@@ -942,18 +949,19 @@ fn synthesize_link_attr(ecx: @encode_ctxt, items: [@meta_item]/~) ->
let mut attrs: [attribute]/~ = []/~;
let mut found_link_attr = false;
for crate.node.attrs.each {|attr|
attrs +=
vec::push(
attrs,
if *attr::get_attr_name(attr) != "link" {
[attr]/~
attr
} else {
alt attr.node.value.node {
meta_list(n, l) {
found_link_attr = true;;
[synthesize_link_attr(ecx, l)]/~
synthesize_link_attr(ecx, l)
}
_ { [attr]/~ }
_ { attr }
}
};
});
}
if !found_link_attr { vec::push(attrs, synthesize_link_attr(ecx, []/~)); }
......
......@@ -39,16 +39,19 @@ fn mk_filesearch(maybe_sysroot: option<path>,
impl of filesearch for filesearch_impl {
fn sysroot() -> path { self.sysroot }
fn lib_search_paths() -> [path]/~ {
self.addl_lib_search_paths
+ [make_target_lib_path(self.sysroot, self.target_triple)]/~
+ alt get_cargo_lib_path_nearest() {
result::ok(p) { [p]/~ }
result::err(p) { []/~ }
}
+ alt get_cargo_lib_path() {
result::ok(p) { [p]/~ }
result::err(p) { []/~ }
}
let mut paths = self.addl_lib_search_paths;
vec::push(paths,
make_target_lib_path(self.sysroot, self.target_triple));
alt get_cargo_lib_path_nearest() {
result::ok(p) { vec::push(paths, p) }
result::err(p) { }
}
alt get_cargo_lib_path() {
result::ok(p) { vec::push(paths, p) }
result::err(p) { }
}
paths
}
fn get_target_lib_path() -> path {
make_target_lib_path(self.sysroot, self.target_triple)
......@@ -91,7 +94,8 @@ fn relative_target_lib_path(target_triple: str) -> [path]/~ {
fn make_target_lib_path(sysroot: path,
target_triple: str) -> path {
let path = [sysroot]/~ + relative_target_lib_path(target_triple);
let path = vec::append([sysroot]/~,
relative_target_lib_path(target_triple));
let path = path::connect_many(path);
ret path;
}
......
......@@ -47,7 +47,7 @@ fn check_arms(tcx: ty::ctxt, arms: [arm]/~) {
}
_ {}
}
if option::is_none(arm.guard) { seen += [v]/~; }
if option::is_none(arm.guard) { vec::push(seen, v); }
}
}
}
......@@ -220,7 +220,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
let mut found = []/~;
for m.each {|r|
option::iter(pat_ctor_id(tcx, r[0])) {|id|
if !vec::contains(found, id) { found += [id]/~; }
if !vec::contains(found, id) { vec::push(found, id); }
}
}
let variants = ty::enum_variants(tcx, eid);
......@@ -274,14 +274,15 @@ fn specialize(tcx: ty::ctxt, r: [@pat]/~, ctor_id: ctor, arity: uint,
left_ty: ty::t) -> option<[@pat]/~> {
let r0 = raw_pat(r[0]);
alt r0.node {
pat_wild { some(vec::from_elem(arity, wild()) + vec::tail(r)) }
pat_wild { some(vec::append(vec::from_elem(arity, wild()),
vec::tail(r))) }
pat_ident(_, _) {
alt tcx.def_map.find(r0.id) {
some(def_variant(_, id)) {
if variant(id) == ctor_id { some(vec::tail(r)) }
else { none }
}
_ { some(vec::from_elem(arity, wild()) + vec::tail(r)) }
_ { some(vec::append(vec::from_elem(arity, wild()), vec::tail(r))) }
}
}
pat_enum(_, args) {
......@@ -291,7 +292,7 @@ fn specialize(tcx: ty::ctxt, r: [@pat]/~, ctor_id: ctor, arity: uint,
some(args) { args }
none { vec::from_elem(arity, wild()) }
};
some(args + vec::tail(r))
some(vec::append(args, vec::tail(r)))
}
def_variant(_, _) { none }
}
......@@ -305,10 +306,10 @@ fn specialize(tcx: ty::ctxt, r: [@pat]/~, ctor_id: ctor, arity: uint,
some(f) { f.pat } _ { wild() }
}
});
some(args + vec::tail(r))
some(vec::append(args, vec::tail(r)))
}
pat_tup(args) { some(args + vec::tail(r)) }
pat_box(a) | pat_uniq(a) { some([a]/~ + vec::tail(r)) }
pat_tup(args) { some(vec::append(args, vec::tail(r))) }
pat_box(a) | pat_uniq(a) { some(vec::append([a]/~, vec::tail(r))) }
pat_lit(expr) {
let e_v = eval_const_expr(tcx, expr);
let match = alt check ctor_id {
......
......@@ -64,8 +64,8 @@ fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
if i == depth { // Made it to end of loop
let dnum = ast_util::def_id_of_def(def).node;
if !seen.contains_key(dnum) {
*refs += [@{def:def, span:expr.span}]/~;
seen.insert(dnum, ());
vec::push(*refs, @{def:def, span:expr.span});
seen.insert(dnum, ());
}
}
}
......
......@@ -274,7 +274,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
let ifce_bounds =
ty::lookup_item_type(cx.tcx, ifce_id).bounds;
let mth = ty::iface_methods(cx.tcx, ifce_id)[n_mth];
@(*ifce_bounds + *mth.tps)
@(vec::append(*ifce_bounds, *mth.tps))
}
}
}
......
......@@ -358,7 +358,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
decl: ast::fn_decl) {
let tys = vec::map(decl.inputs) {|a| a.ty };
for vec::each(tys + [decl.output]/~) {|ty|
for vec::each(vec::append_one(tys, decl.output)) {|ty|
alt ty.node {
ast::ty_path(_, id) {
alt cx.def_map.get(id) {
......
......@@ -242,7 +242,7 @@ fn relevant_def(def: def) -> option<relevant_def> {
fn add_live_node(lnk: live_node_kind) -> live_node {
let ln = live_node(self.num_live_nodes);
self.lnks += [lnk]/~;
vec::push(self.lnks, lnk);
self.num_live_nodes += 1u;
#debug["%s is of kind %?", ln.to_str(), lnk];
......@@ -259,7 +259,7 @@ fn add_live_node_for_node(node_id: node_id, lnk: live_node_kind) {
fn add_variable(vk: var_kind) -> variable {
let v = variable(self.num_vars);
self.var_kinds += [vk]/~;
vec::push(self.var_kinds, vk);
self.num_vars += 1u;
alt vk {
......@@ -444,7 +444,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) {
cap_move | cap_drop {true} // var must be dead afterwards
cap_copy | cap_ref {false} // var can still be used
};
call_caps += [{ln: cv_ln, is_move: is_move, rv: rv}]/~;
vec::push(call_caps, {ln: cv_ln, is_move: is_move, rv: rv});
}
none {}
}
......
......@@ -51,6 +51,6 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat,
fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> [node_id]/~ {
let mut found = []/~;
pat_bindings(dm, pat) {|b_id, _sp, _pt| found += [b_id]/~; };
pat_bindings(dm, pat) {|b_id, _sp, _pt| vec::push(found, b_id); };
ret found;
}
......@@ -221,7 +221,7 @@ fn ancestors_of(region_map: region_map, scope: ast::node_id)
alt region_map.find(scope) {
none { ret result; }
some(superscope) {
result += [superscope]/~;
vec::push(result, superscope);
scope = superscope;
}
}
......
......@@ -243,7 +243,8 @@ fn index_vi(e: @env, i: @ast::view_item, &&sc: scopes, _v: vt<scopes>) {
ast::view_path_list(mod_path, idents, _) {
for idents.each {|ident|
let t = todo(ident.node.name,
@(mod_path.idents + [ident.node.name]/~),
@(vec::append_one(mod_path.idents,
ident.node.name)),
ident.span, sc);
e.imports.insert(ident.node.id, t);
}
......@@ -305,7 +306,7 @@ fn link_glob(e: @env, vi: @ast::view_item, &&sc: scopes, _v: vt<scopes>) {
}
scope_block(b, _, _) {
let globs = alt e.block_map.find(b.node.id) {
some(globs) { globs + [glob]/~ }
some(globs) { vec::append_one(globs, glob) }
none { [glob]/~ }
};
e.block_map.insert(b.node.id, globs);
......@@ -557,7 +558,8 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
v.visit_ty(sty, sc, v);
for methods.each {|m|
v.visit_ty_params(m.tps, sc, v);
let msc = @cons(scope_method(m.self_id, tps + m.tps), sc);
let msc = @cons(scope_method(m.self_id, vec::append(tps, m.tps)),
sc);
v.visit_fn(visit::fk_method(m.ident, []/~, m),
m.decl, m.body, m.span, m.id, msc, v);
}
......@@ -567,7 +569,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
let isc = @cons(scope_method(i.id, tps), sc);
for methods.each {|m|
v.visit_ty_params(m.tps, isc, v);
let msc = @cons(scope_method(i.id, tps + m.tps), sc);
let msc = @cons(scope_method(i.id, vec::append(tps, m.tps)), sc);
for m.decl.inputs.each {|a| v.visit_ty(a.ty, msc, v); }
v.visit_ty(m.decl.output, msc, v);
}
......@@ -600,7 +602,8 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
for members.each {|cm|
alt cm.node {
class_method(m) {
let msc = @cons(scope_method(m.self_id, tps + m.tps),
let msc = @cons(scope_method(m.self_id,
vec::append(tps, m.tps)),
class_scope);
visit_fn_with_scope(e,
visit::fk_item_fn(m.ident, tps), m.decl, m.body,
......@@ -911,7 +914,8 @@ fn find_fn_or_mod_scope(sc: scopes) -> option<scope> {
path = @(e.mod_map.get(did.node).path + *path);
} else if did.node != ast::crate_node_id {
let paths = e.ext_map.get(did);
path = @str::connect((paths + [path]/~).map({|x|*x}), "::");
path = @str::connect(vec::append_one(paths, path).map({|x|*x}),
"::");
}
}
}
......@@ -1372,7 +1376,7 @@ fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace,
if !is_none(cached) { ret cached; }
let mut path = [name]/~;
if defid.node != ast::crate_node_id {
path = cstore::get_path(e.cstore, defid) + path;
path = vec::append(cstore::get_path(e.cstore, defid), path);
}
alt lookup_external(e, defid.crate, path, ns) {
some(df) {
......@@ -1990,7 +1994,8 @@ fn add_export(e: @env, export_id: node_id, target_id: def_id,
some(f) { f } none { []/~ }
};
e.exp_map.insert(export_id,
found + [{reexp: reexp, id: target_id}]/~);
vec::append_one(found,
{reexp: reexp, id: target_id}));
}
fn check_export(e: @env, ident: ident, _mod: @indexed_mod,
......@@ -2186,7 +2191,9 @@ fn lookup_imported_impls(e: env, id: node_id,
@{ident: name with *imp});
}
}
if vec::len(found) > 0u { impls += found; }
if vec::len(found) > 0u {
vec::push_all(impls, found);
}
}
}
}
......@@ -2201,7 +2208,9 @@ fn lookup_imported_impls(e: env, id: node_id,
ast::view_path_list(base, names, _) {
for names.each {|nm|
lookup_imported_impls(e, nm.node.id) {|is| impls += *is; }
lookup_imported_impls(e, nm.node.id) {|is|
vec::push_all(impls, *is);
}
}
}
......
......@@ -101,7 +101,7 @@ fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) {
} else {
[]/~
};
cache.insert(mdtag, existing + [val]/~);
cache.insert(mdtag, vec::append_one(existing, val));
}
type metadata<T> = {node: ValueRef, data: T};
......
......@@ -382,11 +382,11 @@ fn x86_64_ty(ty: TypeRef,
StructRetAttribute);
let sret = option::is_some(ret_attr);
if sret {
arg_tys = [ret_ty]/~ + arg_tys;
arg_tys = vec::append([ret_ty]/~, arg_tys);
ret_ty = { cast: false,
ty: T_void()
};
attrs = [ret_attr]/~ + attrs;
attrs = vec::append([ret_attr]/~, attrs);
} else if !ret_def {
ret_ty = { cast: false,
ty: T_void()
......@@ -450,7 +450,7 @@ fn c_arg_and_ret_lltys(ccx: @crate_ctxt,
fn c_stack_tys(ccx: @crate_ctxt,
id: ast::node_id) -> @c_stack_tys {
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, id);
let bundle_ty = T_struct(llargtys + [T_ptr(llretty)]/~);
let bundle_ty = T_struct(vec::append_one(llargtys, T_ptr(llretty)));
let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty);
let x86_64 = if ccx.sess.targ_cfg.arch == arch_x86_64 {
option::some(x86_64_tys(llargtys, llretty, ret_def))
......@@ -933,7 +933,7 @@ fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path,
let _icx = ccx.insn_ctxt("foreign::extern::build_rust_fn");
let t = ty::node_id_to_type(ccx.tcx, id);
let ps = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name(@"__rust_abi")]/~);
ccx, vec::append_one(path, ast_map::path_name(@"__rust_abi")));
let llty = type_of_fn_from_ty(ccx, t);
let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty);
trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id);
......@@ -970,7 +970,8 @@ fn build_ret(_bcx: block, _tys: @c_stack_tys,
}
let shim_name = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name(@"__rust_stack_shim")]/~);
ccx, vec::append_one(path,
ast_map::path_name(@"__rust_stack_shim")));
ret build_shim_fn_(ccx, shim_name, llrustfn, tys,
lib::llvm::CCallConv,
build_args, build_ret);
......
......@@ -77,7 +77,8 @@ fn bracketed_t(bracket_name: str, t: ty::t, extra: [ValueRef]/~) {
fn bracketed_mt(bracket_name: str, mt: ty::mt, extra: [ValueRef]/~) {
self.bracketed_t(bracket_name, mt.ty,
[self.c_uint(mt.mutbl as uint)]/~ + extra);
vec::append([self.c_uint(mt.mutbl as uint)]/~,
extra));
}
fn vstore_name_and_extra(t: ty::t,
......@@ -85,7 +86,8 @@ fn vstore_name_and_extra(t: ty::t,
f: fn(str,[ValueRef]/~)) {
alt vstore {
ty::vstore_fixed(n) {
let extra = [self.c_uint(n)]/~ + self.c_size_and_align(t);
let extra = vec::append([self.c_uint(n)]/~,
self.c_size_and_align(t));
f("fixed", extra)
}
ty::vstore_slice(_) { f("slice", []/~) }
......@@ -142,8 +144,8 @@ fn visit_ty(t: ty::t) {
ty::ty_rptr(_, mt) { self.bracketed_mt("rptr", mt, []/~) }
ty::ty_rec(fields) {
let extra = ([self.c_uint(vec::len(fields))]/~
+ self.c_size_and_align(t));
let extra = (vec::append([self.c_uint(vec::len(fields))]/~,
self.c_size_and_align(t)));
self.visit("enter_rec", extra);
for fields.eachi {|i, field|
self.bracketed_mt("rec_field", field.mt,
......@@ -154,8 +156,8 @@ fn visit_ty(t: ty::t) {
}
ty::ty_tup(tys) {
let extra = ([self.c_uint(vec::len(tys))]/~
+ self.c_size_and_align(t));
let extra = (vec::append([self.c_uint(vec::len(tys))]/~,
self.c_size_and_align(t)));
self.visit("enter_tup", extra);
for tys.eachi {|i, t|
self.bracketed_t("tup_field", t, [self.c_uint(i)]/~);
......@@ -214,8 +216,8 @@ fn visit_ty(t: ty::t) {
let bcx = self.bcx;
let tcx = bcx.ccx().tcx;
let fields = ty::class_items_as_fields(tcx, did, substs);
let extra = ([self.c_uint(vec::len(fields))]/~
+ self.c_size_and_align(t));
let extra = vec::append([self.c_uint(vec::len(fields))]/~,
self.c_size_and_align(t));
self.visit("enter_class", extra);
for fields.eachi {|i, field|
......@@ -234,8 +236,8 @@ fn visit_ty(t: ty::t) {
let bcx = self.bcx;
let tcx = bcx.ccx().tcx;
let variants = ty::substd_enum_variants(tcx, did, substs);
let extra = ([self.c_uint(vec::len(variants))]/~
+ self.c_size_and_align(t));
let extra = vec::append([self.c_uint(vec::len(variants))]/~,
self.c_size_and_align(t));
self.visit("enter_enum", extra);
for variants.eachi {|i, v|
......
......@@ -24,7 +24,7 @@ fn collect_ids_stmt(s: @stmt, rs: @mut [node_id]/~) {
}
fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mut [node_id]/~) {
*rs += pat_binding_ids(tcx.def_map, l.node.pat);
vec::push_all(*rs, pat_binding_ids(tcx.def_map, l.node.pat));
}
fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut [node_id]/~) {
......
......@@ -474,11 +474,11 @@ fn node_id_to_def(ccx: crate_ctxt, id: node_id) -> option<def> {
fn norm_a_constraint(id: def_id, c: constraint) -> [norm_constraint]/~ {
let mut rslt: [norm_constraint]/~ = []/~;
for (*c.descs).each {|pd|
rslt +=
[{bit_num: pd.node.bit_num,
c: respan(pd.span, {path: c.path,
def_id: id,
args: pd.node.args})}]/~;
vec::push(rslt,
{bit_num: pd.node.bit_num,
c: respan(pd.span, {path: c.path,
def_id: id,
args: pd.node.args})});
}
ret rslt;
}
......@@ -489,7 +489,7 @@ fn norm_a_constraint(id: def_id, c: constraint) -> [norm_constraint]/~ {
fn constraints(fcx: fn_ctxt) -> [norm_constraint]/~ {
let mut rslt: [norm_constraint]/~ = []/~;
for fcx.enclosing.constrs.each {|key, val|
rslt += norm_a_constraint(key, val);
vec::push_all(rslt, norm_a_constraint(key, val));
};
ret rslt;
}
......@@ -887,22 +887,23 @@ fn args_to_constr_args(tcx: ty::ctxt, args: [arg]/~,
let mut actuals: [@constr_arg_use]/~ = []/~;
let num_args = vec::len(args);
for indices.each {|a|
actuals +=
[@respan(a.span,
alt a.node {
carg_base { carg_base }
carg_ident(i) {
if i < num_args {
carg_ident({ident: args[i].ident,
node: args[i].id})
} else {
tcx.sess.span_bug(a.span,
"index out of bounds in \
constraint arg");
}
}
carg_lit(l) { carg_lit(l) }
})]/~;
vec::push(
actuals,
@respan(a.span,
alt a.node {
carg_base { carg_base }
carg_ident(i) {
if i < num_args {
carg_ident({ident: args[i].ident,
node: args[i].id})
} else {
tcx.sess.span_bug(a.span,
"index out of bounds in \
constraint arg");
}
}
carg_lit(l) { carg_lit(l) }
}));
}
ret actuals;
}
......
......@@ -253,12 +253,12 @@ fn to_vec(v: t) -> [uint]/~ {
let mut i: uint = 0u;
let mut rslt: [uint]/~ = []/~;
while i < v.nbits {
rslt +=
[alt tritv_get(v, i) {
dont_care { 2u }
ttrue { 1u }
tfalse { 0u }
}]/~;
vec::push(rslt,
alt tritv_get(v, i) {
dont_care { 2u }
ttrue { 1u }
tfalse { 0u }
});
i += 1u;
}
ret rslt;
......
......@@ -2188,7 +2188,7 @@ fn is_fn_ty(fty: t) -> bool {
// Returns a vec of all the input and output types of fty.
fn tys_in_fn_ty(fty: fn_ty) -> [t]/~ {
fty.inputs.map({|a| a.ty}) + [fty.output]/~
vec::append_one(fty.inputs.map({|a| a.ty}), fty.output)
}
// Just checks whether it's a fn that returns bool,
......@@ -2624,26 +2624,27 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
ast_map::path_name(item.ident)
}
};
*path + [item_elt]/~
vec::append_one(*path, item_elt)
}
ast_map::node_foreign_item(nitem, _, path) {
*path + [ast_map::path_name(nitem.ident)]/~
vec::append_one(*path, ast_map::path_name(nitem.ident))
}
ast_map::node_method(method, _, path) {
*path + [ast_map::path_name(method.ident)]/~
vec::append_one(*path, ast_map::path_name(method.ident))
}
ast_map::node_variant(variant, _, path) {
vec::init(*path) + [ast_map::path_name(variant.node.name)]/~
vec::append_one(vec::init(*path),
ast_map::path_name(variant.node.name))
}
ast_map::node_ctor(nm, _, _, _, path) {
*path + [ast_map::path_name(nm)]/~
vec::append_one(*path, ast_map::path_name(nm))
}
ast_map::node_dtor(_, _, _, path) {
*path + [ast_map::path_name(@"dtor")]/~
vec::append_one(*path, ast_map::path_name(@"dtor"))
}
......
......@@ -403,7 +403,7 @@ fn write_mty_from_candidate(cand: candidate) -> method_map_entry {
}
};
let all_substs = {tps: cand.self_substs.tps + m_substs
let all_substs = {tps: vec::append(cand.self_substs.tps, m_substs)
with cand.self_substs};
self.fcx.write_ty_substs(self.node_id, cand.fty, all_substs);
......
......@@ -204,7 +204,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
let substs = {
self_r: some(dummy_self_r),
self_ty: some(self_ty),
tps: if_substs.tps + dummy_tps
tps: vec::append(if_substs.tps, dummy_tps)
};
let if_fty = ty::mk_fn(tcx, if_m.fty);
ty::subst(tcx, substs, if_fty)
......@@ -286,7 +286,7 @@ fn convert_methods(ccx: @crate_ctxt,
// n.b.: the type of a method is parameterized by both
// the tps on the receiver and those on the method itself
{bounds: @(*rcvr_bounds + *bounds), rp: rp, ty: fty});
{bounds: @(vec::append(*rcvr_bounds, *bounds)), rp: rp, ty: fty});
write_ty_to_tcx(tcx, m.id, fty);
{mty: mty, id: m.id, span: m.span}
}
......
......@@ -133,7 +133,7 @@ fn fn_to_str(cx: ctxt, purity: ast::purity, proto: ast::proto,
alt ident { some(i) { s += " "; s += *i; } _ { } }
s += "(";
let mut strs = []/~;
for inputs.each {|a| strs += [fn_input_to_str(cx, a)]/~; }
for inputs.each {|a| vec::push(strs, fn_input_to_str(cx, a)); }
s += str::connect(strs, ", ");
s += ")";
if ty::get(output).struct != ty_nil {
......@@ -190,12 +190,12 @@ fn field_to_str(cx: ctxt, f: field) -> str {
ty_type { "type" }
ty_rec(elems) {
let mut strs: [str]/~ = []/~;
for elems.each {|fld| strs += [field_to_str(cx, fld)]/~; }
for elems.each {|fld| vec::push(strs, field_to_str(cx, fld)); }
"{" + str::connect(strs, ",") + "}"
}
ty_tup(elems) {
let mut strs = []/~;
for elems.each {|elem| strs += [ty_to_str(cx, elem)]/~; }
for elems.each {|elem| vec::push(strs, ty_to_str(cx, elem)); }
"(" + str::connect(strs, ",") + ")"
}
ty_fn(f) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册