Rewrite everything to use [] instead of vec() in value position.

This commit is contained in:
Graydon Hoare 2011-05-16 18:21:22 -07:00
parent ae030c5bf2
commit fbbc1a77d2
87 changed files with 1137 additions and 1134 deletions

View file

@ -358,7 +358,7 @@ type ast_fold[ENV] =
//// Fold drivers.
fn fold_path[ENV](&ENV env, &ast_fold[ENV] fld, &path p) -> path {
let vec[@ast::ty] tys_ = vec();
let vec[@ast::ty] tys_ = [];
for (@ast::ty t in p.node.types) {
_vec::push[@ast::ty](tys_, fold_ty(env, fld, t));
}
@ -398,7 +398,7 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
}
case (ast::ty_tup(?elts)) {
let vec[mt] elts_ = vec();
let vec[mt] elts_ = [];
for (mt elt in elts) {
auto ty_ = fold_ty(env, fld, elt.ty);
_vec::push[mt](elts_, rec(ty=ty_, mut=elt.mut));
@ -407,7 +407,7 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
}
case (ast::ty_rec(?flds)) {
let vec[ast::ty_field] flds_ = vec();
let vec[ast::ty_field] flds_ = [];
for (ast::ty_field f in flds) {
auto ty_ = fold_ty(env, fld, f.mt.ty);
_vec::push[ast::ty_field]
@ -417,7 +417,7 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
}
case (ast::ty_obj(?meths)) {
let vec[ast::ty_method] meths_ = vec();
let vec[ast::ty_method] meths_ = [];
for (ast::ty_method m in meths) {
auto tfn = fold_ty_fn(env_, fld, t.span, m.proto,
m.inputs, m.output);
@ -458,11 +458,11 @@ fn fold_ty_fn[ENV](&ENV env, &ast_fold[ENV] fld, &span sp,
&vec[rec(ast::mode mode, @ty ty)] inputs,
&@ty output) -> @ty {
auto output_ = fold_ty(env, fld, output);
let vec[rec(ast::mode mode, @ty ty)] inputs_ = vec();
let vec[rec(ast::mode mode, @ty ty)] inputs_ = [];
for (rec(ast::mode mode, @ty ty) input in inputs) {
auto ty_ = fold_ty(env, fld, input.ty);
auto input_ = rec(ty=ty_ with input);
inputs_ += vec(input_);
inputs_ += [input_];
}
ret fld.fold_ty_fn(env, sp, proto, inputs_, output_);
}
@ -524,9 +524,9 @@ fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast::pat p) -> @ast::pat {
case (ast::pat_tag(?path, ?pats, ?t)) {
auto ppath = fold_path(env, fld, path);
let vec[@ast::pat] ppats = vec();
let vec[@ast::pat] ppats = [];
for (@ast::pat pat in pats) {
ppats += vec(fold_pat(env_, fld, pat));
ppats += [fold_pat(env_, fld, pat)];
}
ret fld.fold_pat_tag(env_, p.span, ppath, ppats, t);
@ -536,7 +536,7 @@ fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast::pat p) -> @ast::pat {
fn fold_exprs[ENV](&ENV env, &ast_fold[ENV] fld,
&vec[@expr] es) -> vec[@expr] {
let vec[@expr] exprs = vec();
let vec[@expr] exprs = [];
for (@expr e in es) {
_vec::push[@expr](exprs, fold_expr(env, fld, e));
}
@ -568,19 +568,19 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
}
case (ast::expr_tup(?es, ?t)) {
let vec[ast::elt] elts = vec();
let vec[ast::elt] elts = [];
for (ast::elt e in es) {
elts += vec(fold_tup_elt[ENV](env, fld, e));
elts += [fold_tup_elt[ENV](env, fld, e)];
}
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_tup(env_, e.span, elts, t2);
}
case (ast::expr_rec(?fs, ?base, ?t)) {
let vec[ast::field] fields = vec();
let vec[ast::field] fields = [];
let option::t[@expr] b = none[@expr];
for (ast::field f in fs) {
fields += vec(fold_rec_field(env, fld, f));
fields += [fold_rec_field(env, fld, f)];
}
alt (base) {
case (none[@ast::expr]) { }
@ -606,14 +606,14 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
case (ast::expr_bind(?f, ?args_opt, ?t)) {
auto ff = fold_expr(env_, fld, f);
let vec[option::t[@ast::expr]] aargs_opt = vec();
let vec[option::t[@ast::expr]] aargs_opt = [];
for (option::t[@ast::expr] t_opt in args_opt) {
alt (t_opt) {
case (none[@ast::expr]) {
aargs_opt += vec(none[@ast::expr]);
aargs_opt += [none[@ast::expr]];
}
case (some[@ast::expr](?e)) {
aargs_opt += vec(some(fold_expr(env_, fld, e)));
aargs_opt += [some(fold_expr(env_, fld, e))];
}
case (none[@ast::expr]) { /* empty */ }
}
@ -700,9 +700,9 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
case (ast::expr_alt(?expr, ?arms, ?t)) {
auto eexpr = fold_expr(env_, fld, expr);
let vec[ast::arm] aarms = vec();
let vec[ast::arm] aarms = [];
for (ast::arm a in arms) {
aarms += vec(fold_arm(env_, fld, a));
aarms += [fold_arm(env_, fld, a)];
}
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_alt(env_, e.span, eexpr, aarms, t2);
@ -887,7 +887,7 @@ fn fold_block[ENV](&ENV env, &ast_fold[ENV] fld, &block blk) -> block {
ret blk;
}
let vec[@ast::stmt] stmts = vec();
let vec[@ast::stmt] stmts = [];
for (@ast::stmt s in blk.node.stmts) {
auto new_stmt = fold_stmt[ENV](env_, fld, s);
_vec::push[@ast::stmt](stmts, new_stmt);
@ -921,9 +921,9 @@ fn fold_arg[ENV](&ENV env, &ast_fold[ENV] fld, &arg a) -> arg {
fn fold_fn_decl[ENV](&ENV env, &ast_fold[ENV] fld,
&ast::fn_decl decl) -> ast::fn_decl {
let vec[ast::arg] inputs = vec();
let vec[ast::arg] inputs = [];
for (ast::arg a in decl.inputs) {
inputs += vec(fold_arg(env, fld, a));
inputs += [fold_arg(env, fld, a)];
}
auto output = fold_ty[ENV](env, fld, decl.output);
ret fld.fold_fn_decl(env, inputs, output, decl.purity);
@ -953,10 +953,10 @@ fn fold_method[ENV](&ENV env, &ast_fold[ENV] fld,
fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_obj ob) -> ast::_obj {
let vec[ast::obj_field] fields = vec();
let vec[@ast::method] meths = vec();
let vec[ast::obj_field] fields = [];
let vec[@ast::method] meths = [];
for (ast::obj_field f in ob.fields) {
fields += vec(fold_obj_field(env, fld, f));
fields += [fold_obj_field(env, fld, f)];
}
let option::t[@ast::method] dtor = none[@ast::method];
alt (ob.dtor) {
@ -965,7 +965,7 @@ fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_obj ob) -> ast::_obj {
dtor = some[@ast::method](fold_method[ENV](env, fld, m));
}
}
let vec[ast::ty_param] tp = vec();
let vec[ast::ty_param] tp = [];
for (@ast::method m in ob.methods) {
// Fake-up an ast::item for this method.
// FIXME: this is kinda awful. Maybe we should reformulate
@ -990,9 +990,9 @@ fn fold_anon_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::anon_obj ob)
alt (ob.fields) {
case (none[vec[ast::obj_field]]) { }
case (some[vec[ast::obj_field]](?v)) {
let vec[ast::obj_field] fields = vec();
let vec[ast::obj_field] fields = [];
for (ast::obj_field f in v) {
fields += vec(fold_obj_field(env, fld, f));
fields += [fold_obj_field(env, fld, f)];
}
}
}
@ -1007,8 +1007,8 @@ fn fold_anon_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::anon_obj ob)
}
// Methods
let vec[@ast::method] meths = vec();
let vec[ast::ty_param] tp = vec();
let vec[@ast::method] meths = [];
let vec[ast::ty_param] tp = [];
for (@ast::method m in ob.methods) {
// Fake-up an ast::item for this method.
// FIXME: this is kinda awful. Maybe we should reformulate
@ -1089,16 +1089,16 @@ fn fold_item[ENV](&ENV env, &ast_fold[ENV] fld, &@item i) -> @item {
}
case (ast::item_tag(?ident, ?variants, ?ty_params, ?id, ?ann)) {
let vec[ast::variant] new_variants = vec();
let vec[ast::variant] new_variants = [];
for (ast::variant v in variants) {
let vec[ast::variant_arg] new_args = vec();
let vec[ast::variant_arg] new_args = [];
for (ast::variant_arg va in v.node.args) {
auto new_ty = fold_ty[ENV](env_, fld, va.ty);
new_args += vec(rec(ty=new_ty, id=va.id));
new_args += [rec(ty=new_ty, id=va.id)];
}
auto new_v = rec(name=v.node.name, args=new_args,
id=v.node.id, ann=v.node.ann);
new_variants += vec(respan[ast::variant_](v.span, new_v));
new_variants += [respan[ast::variant_](v.span, new_v)];
}
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
ty_params, id, ann);
@ -1116,8 +1116,8 @@ fn fold_item[ENV](&ENV env, &ast_fold[ENV] fld, &@item i) -> @item {
fn fold_mod[ENV](&ENV e, &ast_fold[ENV] fld, &ast::_mod m) -> ast::_mod {
let vec[@view_item] view_items = vec();
let vec[@item] items = vec();
let vec[@view_item] view_items = [];
let vec[@item] items = [];
for (@view_item vi in m.view_items) {
auto new_vi = fold_view_item[ENV](e, fld, vi);
@ -1154,8 +1154,8 @@ fn fold_native_item[ENV](&ENV env, &ast_fold[ENV] fld,
fn fold_native_mod[ENV](&ENV e, &ast_fold[ENV] fld,
&ast::native_mod m) -> ast::native_mod {
let vec[@view_item] view_items = vec();
let vec[@native_item] items = vec();
let vec[@view_item] view_items = [];
let vec[@native_item] items = [];
for (@view_item vi in m.view_items) {
auto new_vi = fold_view_item[ENV](e, fld, vi);

View file

@ -299,8 +299,8 @@ fn add_to_index(&ebml::writer ebml_w,
&vec[str] path,
&mutable vec[tup(str, uint)] index,
&str name) {
auto full_path = path + vec(name);
index += vec(tup(_str::connect(full_path, "::"), ebml_w.writer.tell()));
auto full_path = path + [name];
index += [tup(_str::connect(full_path, "::"), ebml_w.writer.tell())];
}
fn encode_native_module_item_paths(&ebml::writer ebml_w,
@ -353,7 +353,7 @@ fn encode_module_item_paths(&ebml::writer ebml_w,
ebml::start_tag(ebml_w, tag_paths_data_mod);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
encode_module_item_paths(ebml_w, _mod, path + vec(id), index);
encode_module_item_paths(ebml_w, _mod, path + [id], index);
ebml::end_tag(ebml_w);
}
case (ast::item_native_mod(?id, ?nmod, ?did)) {
@ -361,7 +361,7 @@ fn encode_module_item_paths(&ebml::writer ebml_w,
ebml::start_tag(ebml_w, tag_paths_data_mod);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
encode_native_module_item_paths(ebml_w, nmod, path + vec(id),
encode_native_module_item_paths(ebml_w, nmod, path + [id],
index);
ebml::end_tag(ebml_w);
}
@ -400,8 +400,8 @@ fn encode_module_item_paths(&ebml::writer ebml_w,
fn encode_item_paths(&ebml::writer ebml_w, &@ast::crate crate)
-> vec[tup(str, uint)] {
let vec[tup(str, uint)] index = vec();
let vec[str] path = vec();
let vec[tup(str, uint)] index = [];
let vec[str] path = [];
ebml::start_tag(ebml_w, tag_paths);
encode_module_item_paths(ebml_w, crate.node.module, path, index);
ebml::end_tag(ebml_w);
@ -413,7 +413,7 @@ fn encode_item_paths(&ebml::writer ebml_w, &@ast::crate crate)
fn encode_kind(&ebml::writer ebml_w, u8 c) {
ebml::start_tag(ebml_w, tag_items_data_item_kind);
ebml_w.writer.write(vec(c));
ebml_w.writer.write([c]);
ebml::end_tag(ebml_w);
}
@ -470,7 +470,7 @@ fn encode_tag_variant_info(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
&mutable vec[tup(int, uint)] index,
&vec[ast::ty_param] ty_params) {
for (ast::variant variant in variants) {
index += vec(tup(variant.node.id._1, ebml_w.writer.tell()));
index += [tup(variant.node.id._1, ebml_w.writer.tell())];
ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, variant.node.id);
@ -549,7 +549,7 @@ fn encode_info_for_item(@trans::crate_ctxt cx, &ebml::writer ebml_w,
encode_symbol(cx, ebml_w, odid.ctor);
ebml::end_tag(ebml_w);
index += vec(tup(odid.ty._1, ebml_w.writer.tell()));
index += [tup(odid.ty._1, ebml_w.writer.tell())];
ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, odid.ty);
encode_kind(ebml_w, 'y' as u8);
@ -582,16 +582,16 @@ fn encode_info_for_native_item(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
fn encode_info_for_items(&@trans::crate_ctxt cx, &ebml::writer ebml_w)
-> vec[tup(int, uint)] {
let vec[tup(int, uint)] index = vec();
let vec[tup(int, uint)] index = [];
ebml::start_tag(ebml_w, tag_items_data);
for each (@tup(ast::def_id, @ast::item) kvp in cx.items.items()) {
index += vec(tup(kvp._0._1, ebml_w.writer.tell()));
index += [tup(kvp._0._1, ebml_w.writer.tell())];
encode_info_for_item(cx, ebml_w, kvp._1, index);
}
for each (@tup(ast::def_id, @ast::native_item) kvp in
cx.native_items.items()) {
index += vec(tup(kvp._0._1, ebml_w.writer.tell()));
index += [tup(kvp._0._1, ebml_w.writer.tell())];
encode_info_for_native_item(cx, ebml_w, kvp._1);
}
ebml::end_tag(ebml_w);
@ -618,15 +618,15 @@ fn hash_path(&str s) -> uint {
fn create_index[T](&vec[tup(T, uint)] index, fn(&T) -> uint hash_fn)
-> vec[vec[tup(T, uint)]] {
let vec[vec[tup(T, uint)]] buckets = vec();
let vec[vec[tup(T, uint)]] buckets = [];
for each (uint i in _uint::range(0u, 256u)) {
let vec[tup(T, uint)] bucket = vec();
buckets += vec(bucket);
let vec[tup(T, uint)] bucket = [];
buckets += [bucket];
}
for (tup(T, uint) elt in index) {
auto h = hash_fn(elt._0);
buckets.(h % 256u) += vec(elt);
buckets.(h % 256u) += [elt];
}
ret buckets;
@ -638,10 +638,10 @@ fn encode_index[T](&ebml::writer ebml_w, &vec[vec[tup(T, uint)]] buckets,
ebml::start_tag(ebml_w, tag_index);
let vec[uint] bucket_locs = vec();
let vec[uint] bucket_locs = [];
ebml::start_tag(ebml_w, tag_index_buckets);
for (vec[tup(T, uint)] bucket in buckets) {
bucket_locs += vec(ebml_w.writer.tell());
bucket_locs += [ebml_w.writer.tell()];
ebml::start_tag(ebml_w, tag_index_buckets_bucket);
for (tup(T, uint) elt in bucket) {
@ -698,7 +698,7 @@ fn encode_metadata(&@trans::crate_ctxt cx, &@ast::crate crate)
// Pad this, since something (LLVM, presumably) is cutting off the
// remaining % 4 bytes.
buf_w.write(vec(0u8, 0u8, 0u8, 0u8));
buf_w.write([0u8, 0u8, 0u8, 0u8]);
ret C_postr(string_w.get_str());
}
@ -709,7 +709,7 @@ fn write_metadata(&@trans::crate_ctxt cx, &@ast::crate crate) {
llmeta = encode_metadata(cx, crate);
}
auto llconst = trans::C_struct(vec(llmeta));
auto llconst = trans::C_struct([llmeta]);
auto llglobal = llvm::LLVMAddGlobal(cx.llmod, trans::val_ty(llconst),
_str::buf("rust_metadata"));
llvm::LLVMSetInitializer(llglobal, llconst);

View file

@ -253,7 +253,7 @@ fn pop_env_for_item(@mutable list[scope] sc, &@ast::item i) {
}
fn push_env_for_method(@mutable list[scope] sc, &@ast::method m) {
let vec[ast::ty_param] tp = vec();
let vec[ast::ty_param] tp = [];
let @ast::item i = @rec(node=ast::item_fn(m.node.ident,
m.node.meth,
tp,
@ -686,7 +686,7 @@ fn lookup_in_mod(&env e, def m, &ident id, namespace ns, dir dr)
if (defid._0 != ast::local_crate) { // Not in this crate
auto cached = e.ext_cache.find(tup(defid,id,ns));
if (!option::is_none(cached)) { ret cached; }
auto path = vec(id);
auto path = [id];
if (defid._1 != -1) {
path = e.ext_map.get(defid) + path;
}

File diff suppressed because it is too large Load diff

View file

@ -420,9 +420,9 @@ fn mk_tup(&ctxt cx, &vec[mt] tms) -> t { ret gen_ty(cx, ty_tup(tms)); }
fn mk_imm_tup(&ctxt cx, &vec[t] tys) -> t {
// TODO: map
let vec[ty::mt] mts = vec();
let vec[ty::mt] mts = [];
for (t typ in tys) {
mts += vec(rec(ty=typ, mut=ast::imm));
mts += [rec(ty=typ, mut=ast::imm)];
}
ret mk_tup(cx, mts);
}
@ -625,12 +625,12 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
}
case (ty_param(?id)) {
s += "'" + _str::unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
s += "'" + _str::unsafe_from_bytes([('a' as u8) + (id as u8)]);
}
case (ty_bound_param(?id)) {
s += "''" + _str::unsafe_from_bytes(vec(('a' as u8) +
(id as u8)));
s += "''" + _str::unsafe_from_bytes([('a' as u8) +
(id as u8)]);
}
}
@ -693,7 +693,7 @@ fn walk_ty(ctxt cx, ty_walk walker, t ty) {
walk_ty(cx, walker, ret_ty);
}
case (ty_obj(?methods)) {
let vec[method] new_methods = vec();
let vec[method] new_methods = [];
for (method m in methods) {
for (arg a in m.inputs) {
walk_ty(cx, walker, a.ty);
@ -740,58 +740,58 @@ fn fold_ty(ctxt cx, ty_fold fld, t ty_0) -> t {
ty = copy_cname(cx, mk_chan(cx, fold_ty(cx, fld, subty)), ty);
}
case (ty_tag(?tid, ?subtys)) {
let vec[t] new_subtys = vec();
let vec[t] new_subtys = [];
for (t subty in subtys) {
new_subtys += vec(fold_ty(cx, fld, subty));
new_subtys += [fold_ty(cx, fld, subty)];
}
ty = copy_cname(cx, mk_tag(cx, tid, new_subtys), ty);
}
case (ty_tup(?mts)) {
let vec[mt] new_mts = vec();
let vec[mt] new_mts = [];
for (mt tm in mts) {
auto new_subty = fold_ty(cx, fld, tm.ty);
new_mts += vec(rec(ty=new_subty, mut=tm.mut));
new_mts += [rec(ty=new_subty, mut=tm.mut)];
}
ty = copy_cname(cx, mk_tup(cx, new_mts), ty);
}
case (ty_rec(?fields)) {
let vec[field] new_fields = vec();
let vec[field] new_fields = [];
for (field fl in fields) {
auto new_ty = fold_ty(cx, fld, fl.mt.ty);
auto new_mt = rec(ty=new_ty, mut=fl.mt.mut);
new_fields += vec(rec(ident=fl.ident, mt=new_mt));
new_fields += [rec(ident=fl.ident, mt=new_mt)];
}
ty = copy_cname(cx, mk_rec(cx, new_fields), ty);
}
case (ty_fn(?proto, ?args, ?ret_ty)) {
let vec[arg] new_args = vec();
let vec[arg] new_args = [];
for (arg a in args) {
auto new_ty = fold_ty(cx, fld, a.ty);
new_args += vec(rec(mode=a.mode, ty=new_ty));
new_args += [rec(mode=a.mode, ty=new_ty)];
}
ty = copy_cname(cx, mk_fn(cx, proto, new_args,
fold_ty(cx, fld, ret_ty)), ty);
}
case (ty_native_fn(?abi, ?args, ?ret_ty)) {
let vec[arg] new_args = vec();
let vec[arg] new_args = [];
for (arg a in args) {
auto new_ty = fold_ty(cx, fld, a.ty);
new_args += vec(rec(mode=a.mode, ty=new_ty));
new_args += [rec(mode=a.mode, ty=new_ty)];
}
ty = copy_cname(cx, mk_native_fn(cx, abi, new_args,
fold_ty(cx, fld, ret_ty)), ty);
}
case (ty_obj(?methods)) {
let vec[method] new_methods = vec();
let vec[method] new_methods = [];
for (method m in methods) {
let vec[arg] new_args = vec();
let vec[arg] new_args = [];
for (arg a in m.inputs) {
new_args += vec(rec(mode=a.mode,
ty=fold_ty(cx, fld, a.ty)));
new_args += [rec(mode=a.mode,
ty=fold_ty(cx, fld, a.ty))];
}
new_methods += vec(rec(proto=m.proto, ident=m.ident,
new_methods += [rec(proto=m.proto, ident=m.ident,
inputs=new_args,
output=fold_ty(cx, fld, m.output)));
output=fold_ty(cx, fld, m.output))];
}
ty = copy_cname(cx, mk_obj(cx, new_methods), ty);
}
@ -1443,7 +1443,7 @@ fn ann_to_type(&node_type_table ntt, &ast::ann ann) -> t {
fn ann_to_type_params(&node_type_table ntt, &ast::ann ann) -> vec[t] {
alt (ann_to_ty_param_substs_opt_and_ty(ntt, ann)._0) {
case (none[vec[t]]) {
let vec[t] result = vec();
let vec[t] result = [];
ret result;
}
case (some[vec[t]](?tps)) { ret tps; }
@ -1492,14 +1492,14 @@ fn count_ty_params(ctxt cx, t ty) -> uint {
}
}
if (!seen) {
*param_indices += vec(param_idx);
*param_indices += [param_idx];
}
}
case (_) { /* fall through */ }
}
}
let vec[uint] v = vec(); // FIXME: typechecker botch
let vec[uint] v = []; // FIXME: typechecker botch
let @mutable vec[uint] param_indices = @mutable v;
auto f = bind counter(cx, param_indices, _);
walk_ty(cx, f, ty);
@ -1873,7 +1873,7 @@ mod unify {
}
// TODO: as above, we should have an iter2 iterator.
let vec[arg] result_ins = vec();
let vec[arg] result_ins = [];
auto i = 0u;
while (i < expected_len) {
auto expected_input = expected_inputs.(i);
@ -1897,7 +1897,7 @@ mod unify {
alt (result) {
case (ures_ok(?rty)) {
result_ins += vec(rec(mode=result_mode, ty=rty));
result_ins += [rec(mode=result_mode, ty=rty)];
}
case (_) {
@ -1979,7 +1979,7 @@ mod unify {
&t actual,
&vec[method] expected_meths,
&vec[method] actual_meths) -> result {
let vec[method] result_meths = vec();
let vec[method] result_meths = [];
let uint i = 0u;
let uint expected_len = _vec::len[method](expected_meths);
let uint actual_len = _vec::len[method](actual_meths);
@ -2004,9 +2004,9 @@ mod unify {
case (ures_ok(?tfn)) {
alt (struct(cx.tcx, tfn)) {
case (ty_fn(?proto, ?ins, ?out)) {
result_meths += vec(rec(inputs = ins,
result_meths += [rec(inputs = ins,
output = out
with e_meth));
with e_meth)];
}
}
}
@ -2057,10 +2057,10 @@ mod unify {
// Just bind the type variable to the expected type.
auto vlen = _vec::len[vec[t]](cx.types);
if (actual_n < vlen) {
cx.types.(actual_n) += vec(expected);
cx.types.(actual_n) += [expected];
} else {
assert (actual_n == vlen);
cx.types += vec(mutable vec(expected));
cx.types += [mutable [expected]];
}
}
}
@ -2120,7 +2120,7 @@ mod unify {
// TODO: factor this cruft out, see the TODO in the
// ty::ty_tup case
let vec[t] result_tps = vec();
let vec[t] result_tps = [];
auto i = 0u;
auto expected_len = _vec::len[t](expected_tps);
while (i < expected_len) {
@ -2272,7 +2272,7 @@ mod unify {
// TODO: implement an iterator that can iterate over
// two arrays simultaneously.
let vec[ty::mt] result_elems = vec();
let vec[ty::mt] result_elems = [];
auto i = 0u;
while (i < expected_len) {
auto expected_elem = expected_elems.(i);
@ -2294,7 +2294,7 @@ mod unify {
alt (result) {
case (ures_ok(?rty)) {
auto mt = rec(ty=rty, mut=mut);
result_elems += vec(mt);
result_elems += [mt];
}
case (_) {
ret result;
@ -2326,7 +2326,7 @@ mod unify {
// TODO: implement an iterator that can iterate over
// two arrays simultaneously.
let vec[field] result_fields = vec();
let vec[field] result_fields = [];
auto i = 0u;
while (i < expected_len) {
auto expected_field = expected_fields.(i);
@ -2425,10 +2425,10 @@ mod unify {
auto expected_n = get_or_create_set(cx, expected_id);
auto vlen = _vec::len[vec[t]](cx.types);
if (expected_n < vlen) {
cx.types.(expected_n) += vec(actual);
cx.types.(expected_n) += [actual];
} else {
assert (expected_n == vlen);
cx.types += vec(mutable vec(actual));
cx.types += [mutable [actual]];
}
ret ures_ok(expected);
}
@ -2485,13 +2485,13 @@ mod unify {
}
fn unify_sets(&@ctxt cx) -> vec[t] {
let vec[t] throwaway = vec();
let vec[mutable vec[t]] set_types = vec(mutable throwaway);
let vec[t] throwaway = [];
let vec[mutable vec[t]] set_types = [mutable throwaway];
_vec::pop[vec[t]](set_types); // FIXME: botch
for (ufind::node node in cx.sets.nodes) {
let vec[t] v = vec();
set_types += vec(mutable v);
let vec[t] v = [];
set_types += [mutable v];
}
auto i = 0u;
@ -2501,14 +2501,14 @@ mod unify {
i += 1u;
}
let vec[t] result = vec();
let vec[t] result = [];
for (vec[t] types in set_types) {
if (_vec::len[t](types) > 1u) {
log_err "unification of > 1 types in a type set is " +
"unimplemented";
fail;
}
result += vec(types.(0));
result += [types.(0)];
}
ret result;
@ -2518,8 +2518,8 @@ mod unify {
&t actual,
&unify_handler handler,
&ty_ctxt tcx) -> result {
let vec[t] throwaway = vec();
let vec[mutable vec[t]] types = vec(mutable throwaway);
let vec[t] throwaway = [];
let vec[mutable vec[t]] types = [mutable throwaway];
_vec::pop[vec[t]](types); // FIXME: botch
auto cx = @rec(sets=ufind::make(),

View file

@ -37,17 +37,17 @@ fn rc_shape_of(&ty::ctxt tcx, variant_getter getter, ty::t t) -> rc_shape {
case (ty::ty_char) { ret rs_none; }
case (ty::ty_str) { ret rs_none; }
case (ty::ty_tag(?did, ?params)) {
let vec[vec[@rc_shape]] result = vec();
let vec[vec[@rc_shape]] result = [];
auto vinfos = getter(did);
for (variant_info vinfo in vinfos) {
let vec[@rc_shape] variant_rcs = vec();
let vec[@rc_shape] variant_rcs = [];
for (ty::t typ in vinfo.args) {
auto ty_1 = ty::bind_params_in_type(tcx, typ);
ty_1 = ty::substitute_type_params(tcx, params, ty_1);
variant_rcs += vec(@rc_shape_of(tcx, getter, ty_1));
variant_rcs += [@rc_shape_of(tcx, getter, ty_1)];
}
result += vec(variant_rcs);
result += [variant_rcs];
}
ret rs_tag(result);
@ -58,16 +58,16 @@ fn rc_shape_of(&ty::ctxt tcx, variant_getter getter, ty::t t) -> rc_shape {
case (ty::ty_chan(_)) { ret rs_ref; }
case (ty::ty_task) { ret rs_ref; }
case (ty::ty_tup(?mts)) {
let vec[@rc_shape] result = vec();
let vec[@rc_shape] result = [];
for (ty::mt tm in mts) {
result += vec(@rc_shape_of(tcx, getter, tm.ty));
result += [@rc_shape_of(tcx, getter, tm.ty)];
}
ret rs_tup(result);
}
case (ty::ty_rec(?fields)) {
let vec[@rc_shape] result = vec();
let vec[@rc_shape] result = [];
for (ty::field fld in fields) {
result += vec(@rc_shape_of(tcx, getter, fld.mt.ty));
result += [@rc_shape_of(tcx, getter, fld.mt.ty)];
}
ret rs_tup(result);
}

View file

@ -188,10 +188,10 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
auto ty_substs_opt;
auto ty_substs_len = _vec::len[@ast::ty](pth.node.types);
if (ty_substs_len > 0u) {
let vec[ty::t] ty_substs = vec();
let vec[ty::t] ty_substs = [];
auto i = 0u;
while (i < ty_substs_len) {
ty_substs += vec(ast_ty_to_ty_crate(fcx.ccx, pth.node.types.(i)));
ty_substs += [ast_ty_to_ty_crate(fcx.ccx, pth.node.types.(i))];
i += 1u;
}
ty_substs_opt = some[vec[ty::t]](ty_substs);
@ -203,10 +203,10 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
}
} else {
// We will acquire the type parameters through unification.
let vec[ty::t] ty_substs = vec();
let vec[ty::t] ty_substs = [];
auto i = 0u;
while (i < ty_param_count) {
ty_substs += vec(next_ty_var(fcx.ccx));
ty_substs += [next_ty_var(fcx.ccx)];
i += 1u;
}
ty_substs_opt = some[vec[ty::t]](ty_substs);
@ -259,9 +259,9 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
// TODO: Make sure the number of supplied bindings matches the number
// of type parameters in the typedef. Emit a friendly error otherwise.
auto bound_ty = bind_params_in_type(tcx, params_opt_and_ty._1);
let vec[ty::t] param_bindings = vec();
let vec[ty::t] param_bindings = [];
for (@ast::ty ast_ty in args) {
param_bindings += vec(ast_ty_to_ty(tcx, getter, ast_ty));
param_bindings += [ast_ty_to_ty(tcx, getter, ast_ty)];
}
ret ty::substitute_type_params(tcx, param_bindings, bound_ty);
}
@ -294,14 +294,14 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
}
case (ast::ty_tup(?fields)) {
let vec[ty::mt] flds = vec();
let vec[ty::mt] flds = [];
for (ast::mt field in fields) {
_vec::push[ty::mt](flds, ast_mt_to_mt(tcx, getter, field));
}
typ = ty::mk_tup(tcx, flds);
}
case (ast::ty_rec(?fields)) {
let vec[field] flds = vec();
let vec[field] flds = [];
for (ast::ty_field f in fields) {
auto tm = ast_mt_to_mt(tcx, getter, f.mt);
_vec::push[field](flds, rec(ident=f.ident, mt=tm));
@ -336,7 +336,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
}
case (ast::ty_obj(?meths)) {
let vec[ty::method] tmeths = vec();
let vec[ty::method] tmeths = [];
auto f = bind ast_arg_to_arg(tcx, getter, _);
for (ast::ty_method m in meths) {
auto ins = _vec::map[ast::ty_arg, arg](f, m.inputs);
@ -502,7 +502,7 @@ mod collect {
-> ty::ty_param_count_and_ty {
auto t_obj = ty_of_obj(cx, id, obj_info, ty_params);
let vec[arg] t_inputs = vec();
let vec[arg] t_inputs = [];
for (ast::obj_field f in obj_info.fields) {
auto g = bind getter(cx, _);
auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
@ -561,11 +561,11 @@ mod collect {
case (ast::item_tag(_, _, ?tps, ?def_id, _)) {
// Create a new generic polytype.
let vec[ty::t] subtys = vec();
let vec[ty::t] subtys = [];
auto i = 0u;
for (ast::ty_param tp in tps) {
subtys += vec(ty::mk_param(cx.tcx, i));
subtys += [ty::mk_param(cx.tcx, i)];
i += 1u;
}
@ -613,13 +613,13 @@ mod collect {
&vec[ast::variant] variants,
&vec[ast::ty_param] ty_params)
-> vec[ast::variant] {
let vec[ast::variant] result = vec();
let vec[ast::variant] result = [];
// Create a set of parameter types shared among all the variants.
let vec[ty::t] ty_param_tys = vec();
let vec[ty::t] ty_param_tys = [];
auto i = 0u;
for (ast::ty_param tp in ty_params) {
ty_param_tys += vec(ty::mk_param(cx.tcx, i));
ty_param_tys += [ty::mk_param(cx.tcx, i)];
i += 1u;
}
@ -636,10 +636,10 @@ mod collect {
// should be called to resolve named types.
auto f = bind getter(cx, _);
let vec[arg] args = vec();
let vec[arg] args = [];
for (ast::variant_arg va in variant.node.args) {
auto arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
args += vec(rec(mode=ty::mo_alias, ty=arg_ty));
args += [rec(mode=ty::mo_alias, ty=arg_ty)];
}
auto tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
result_ty = ty::mk_fn(cx.tcx, ast::proto_fn, args, tag_t);
@ -653,7 +653,7 @@ mod collect {
);
write_type_only(cx.node_types, ast::ann_tag(variant.node.ann),
result_ty);
result += vec(fold::respan(variant.span, variant_t));
result += [fold::respan(variant.span, variant_t)];
}
ret result;
@ -750,7 +750,7 @@ mod collect {
case (none[@ast::method]) { /* nothing to do */ }
case (some[@ast::method](?m)) {
// TODO: typechecker botch
let vec[arg] no_args = vec();
let vec[arg] no_args = [];
auto t = ty::mk_fn(cx.tcx, ast::proto_fn, no_args,
ty::mk_nil(cx.tcx));
write_type_only(cx.node_types,
@ -795,7 +795,7 @@ mod collect {
auto id_to_ty_item = @common::new_def_hash[any_item]();
let vec[mutable option::t[ty::ty_param_substs_opt_and_ty]] ntt_sub =
vec(mutable);
[mutable];
let node_type_table ntt = @mutable ntt_sub;
auto visit = rec(
@ -837,7 +837,7 @@ mod unify {
&ty::t actual) -> ty::unify::result {
// FIXME: horrid botch
let vec[mutable ty::t] param_substs =
vec(mutable ty::mk_nil(fcx.ccx.tcx));
[mutable ty::mk_nil(fcx.ccx.tcx)];
_vec::pop(param_substs);
ret with_params(fcx, expected, actual, param_substs);
}
@ -884,9 +884,9 @@ mod unify {
}
// TODO: "freeze"
let vec[ty::t] param_substs_1 = vec();
let vec[ty::t] param_substs_1 = [];
for (ty::t subst in param_substs) {
param_substs_1 += vec(subst);
param_substs_1 += [subst];
}
unified_type =
@ -968,13 +968,13 @@ type ty_param_substs_and_ty = tup(vec[ty::t], ty::t);
mod Demand {
fn simple(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual)
-> ty::t {
let vec[ty::t] tps = vec();
let vec[ty::t] tps = [];
ret full(fcx, sp, expected, actual, tps, NO_AUTODEREF)._1;
}
fn autoderef(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual,
autoderef_kind adk) -> ty::t {
let vec[ty::t] tps = vec();
let vec[ty::t] tps = [];
ret full(fcx, sp, expected, actual, tps, adk)._1;
}
@ -996,18 +996,18 @@ mod Demand {
}
let vec[mutable ty::t] ty_param_substs =
vec(mutable ty::mk_nil(fcx.ccx.tcx));
[mutable ty::mk_nil(fcx.ccx.tcx)];
_vec::pop(ty_param_substs); // FIXME: horrid botch
for (ty::t ty_param_subst in ty_param_substs_0) {
ty_param_substs += vec(mutable ty_param_subst);
ty_param_substs += [mutable ty_param_subst];
}
alt (unify::with_params(fcx, expected_1, actual_1, ty_param_substs)) {
case (ures_ok(?t)) {
// TODO: Use "freeze", when we have it.
let vec[ty::t] result_ty_param_substs = vec();
let vec[ty::t] result_ty_param_substs = [];
for (ty::t ty_param_subst in ty_param_substs) {
result_ty_param_substs += vec(ty_param_subst);
result_ty_param_substs += [ty_param_subst];
}
ret tup(result_ty_param_substs,
@ -1042,7 +1042,7 @@ fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
&vec[ty::t] tag_ty_params) -> vec[ty::t] {
auto ty_param_count = _vec::len[ty::t](tag_ty_params);
let vec[ty::t] result = vec();
let vec[ty::t] result = [];
auto tpt = ty::lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, vid);
alt (struct(ccx.tcx, tpt._1)) {
@ -1052,7 +1052,7 @@ fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
auto arg_ty = bind_params_in_type(ccx.tcx, arg.ty);
arg_ty = substitute_ty_params(ccx, arg_ty, ty_param_count,
tag_ty_params, sp);
result += vec(arg_ty);
result += [arg_ty];
}
}
case (_) {
@ -1163,11 +1163,11 @@ mod Pushdown {
auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(fcx.ccx.node_types, ann));
let vec[@ast::expr] es_1 = vec();
let vec[@ast::expr] es_1 = [];
alt (struct(fcx.ccx.tcx, t)) {
case (ty::ty_vec(?mt)) {
for (@ast::expr e_0 in es_0) {
es_1 += vec(pushdown_expr(fcx, mt.ty, e_0));
es_1 += [pushdown_expr(fcx, mt.ty, e_0)];
}
}
case (_) {
@ -1182,14 +1182,14 @@ mod Pushdown {
case (ast::expr_tup(?es_0, ?ann)) {
auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(fcx.ccx.node_types, ann));
let vec[ast::elt] elts_1 = vec();
let vec[ast::elt] elts_1 = [];
alt (struct(fcx.ccx.tcx, t)) {
case (ty::ty_tup(?mts)) {
auto i = 0u;
for (ast::elt elt_0 in es_0) {
auto e_1 = pushdown_expr(fcx, mts.(i).ty,
elt_0.expr);
elts_1 += vec(rec(mut=elt_0.mut, expr=e_1));
elts_1 += [rec(mut=elt_0.mut, expr=e_1)];
i += 1u;
}
}
@ -1207,7 +1207,7 @@ mod Pushdown {
auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(fcx.ccx.node_types, ann));
let vec[ast::field] fields_1 = vec();
let vec[ast::field] fields_1 = [];
alt (struct(fcx.ccx.tcx, t)) {
case (ty::ty_rec(?field_mts)) {
alt (base_0) {
@ -1220,9 +1220,9 @@ mod Pushdown {
pushdown_expr(fcx,
field_mts.(i).mt.ty,
field_0.expr);
fields_1 += vec(rec(mut=field_0.mut,
fields_1 += [rec(mut=field_0.mut,
ident=field_0.ident,
expr=e_1));
expr=e_1)];
i += 1u;
}
}
@ -1231,7 +1231,7 @@ mod Pushdown {
base_1 = some[@ast::expr]
(pushdown_expr(fcx, t, bx));
let vec[field] base_fields = vec();
let vec[field] base_fields = [];
for (ast::field field_0 in fields_0) {
@ -1242,9 +1242,9 @@ mod Pushdown {
pushdown_expr(fcx, ft.mt.ty,
field_0.expr);
fields_1 +=
vec(rec(mut=field_0.mut,
[rec(mut=field_0.mut,
ident=field_0.ident,
expr=e_1));
expr=e_1)];
}
}
}
@ -1479,13 +1479,13 @@ mod Pushdown {
case (ast::expr_alt(?discrim, ?arms_0, ?ann)) {
auto t = expected;
let vec[ast::arm] arms_1 = vec();
let vec[ast::arm] arms_1 = [];
for (ast::arm arm_0 in arms_0) {
auto block_1 = pushdown_block(fcx, expected, arm_0.block);
t = Demand::simple(fcx, e.span, t,
block_ty(fcx.ccx.tcx, fcx.ccx.node_types, block_1));
auto arm_1 = rec(pat=arm_0.pat, block=block_1);
arms_1 += vec(arm_1);
arms_1 += [arm_1];
}
e_1 = ast::expr_alt(discrim, arms_1,
triv_ann(ast::ann_tag(ann), t));
@ -1848,13 +1848,13 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
auto f_0 = check_expr(fcx, f);
// Check the arguments and generate the argument signature.
let vec[option::t[@ast::expr]] args_0 = vec();
let vec[arg] arg_tys_0 = vec();
let vec[option::t[@ast::expr]] args_0 = [];
let vec[arg] arg_tys_0 = [];
for (option::t[@ast::expr] a_opt in args) {
alt (a_opt) {
case (some[@ast::expr](?a)) {
auto a_0 = check_expr(fcx, a);
args_0 += vec(some[@ast::expr](a_0));
args_0 += [some[@ast::expr](a_0)];
auto arg_ty = rec(mode=mo_either,
ty=expr_ty(fcx.ccx.tcx,
@ -1862,7 +1862,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
_vec::push[arg](arg_tys_0, arg_ty);
}
case (none[@ast::expr]) {
args_0 += vec(none[@ast::expr]);
args_0 += [none[@ast::expr]];
auto typ = next_ty_var(fcx.ccx);
_vec::push[arg](arg_tys_0, rec(mode=mo_either, ty=typ));
@ -1920,18 +1920,18 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
-> tup(@ast::expr, vec[@ast::expr]) {
let vec[option::t[@ast::expr]] args_opt_0 = vec();
let vec[option::t[@ast::expr]] args_opt_0 = [];
for (@ast::expr arg in args) {
args_opt_0 += vec(some[@ast::expr](arg));
args_opt_0 += [some[@ast::expr](arg)];
}
// Call the generic checker.
auto result = check_call_or_bind(fcx, f, args_opt_0);
// Pull out the arguments.
let vec[@ast::expr] args_1 = vec();
let vec[@ast::expr] args_1 = [];
for (option::t[@ast::expr] arg in result._1) {
args_1 += vec(option::get[@ast::expr](arg));
args_1 += [option::get[@ast::expr](arg)];
}
ret tup(result._0, args_1);
@ -2397,12 +2397,12 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
auto pattern_ty = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
expr_0);
let vec[@ast::pat] pats = vec();
let vec[@ast::pat] pats = [];
for (ast::arm arm in arms) {
check_pat(fcx, arm.pat);
pattern_ty = Demand::simple(fcx, arm.pat.span, pattern_ty,
pat_ty(fcx.ccx.tcx, fcx.ccx.node_types, arm.pat));
pats += vec(arm.pat);
pats += [arm.pat];
}
for (@ast::pat pat in pats) {
@ -2412,15 +2412,15 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
// Now typecheck the blocks.
auto result_ty = next_ty_var(fcx.ccx);
let vec[ast::block] blocks_0 = vec();
let vec[ast::block] blocks_0 = [];
for (ast::arm arm in arms) {
auto block_0 = check_block(fcx, arm.block);
result_ty = Demand::simple(fcx, block_0.span, result_ty,
block_ty(fcx.ccx.tcx, fcx.ccx.node_types, block_0));
blocks_0 += vec(block_0);
blocks_0 += [block_0];
}
let vec[ast::arm] arms_1 = vec();
let vec[ast::arm] arms_1 = [];
auto i = 0u;
for (ast::block block_0 in blocks_0) {
auto block_1 = Pushdown::pushdown_block(fcx, result_ty,
@ -2428,7 +2428,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
auto pat = pats.(i);
auto arm = arms.(i);
auto arm_1 = rec(pat=pat, block=block_1);
arms_1 += vec(arm_1);
arms_1 += [arm_1];
i += 1u;
}
@ -2464,7 +2464,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
// Pull the argument and return types out.
auto proto_1;
let vec[ty::arg] arg_tys_1 = vec();
let vec[ty::arg] arg_tys_1 = [];
auto rt_1;
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
result._0))) {
@ -2479,7 +2479,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
alt (args.(i)) {
case (some[@ast::expr](_)) { /* no-op */ }
case (none[@ast::expr]) {
arg_tys_1 += vec(arg_tys.(i));
arg_tys_1 += [arg_tys.(i)];
}
}
i += 1u;
@ -2624,7 +2624,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
}
case (ast::expr_vec(?args, ?mut, ?a)) {
let vec[@ast::expr] args_1 = vec();
let vec[@ast::expr] args_1 = [];
let ty::t t;
if (_vec::len[@ast::expr](args) == 0u) {
@ -2650,15 +2650,15 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
}
case (ast::expr_tup(?elts, ?a)) {
let vec[ast::elt] elts_1 = vec();
let vec[ty::mt] elts_mt = vec();
let vec[ast::elt] elts_1 = [];
let vec[ty::mt] elts_mt = [];
for (ast::elt e in elts) {
auto expr_1 = check_expr(fcx, e.expr);
auto expr_t = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
expr_1);
_vec::push[ast::elt](elts_1, rec(expr=expr_1 with e));
elts_mt += vec(rec(ty=expr_t, mut=e.mut));
elts_mt += [rec(ty=expr_t, mut=e.mut)];
}
auto typ = ty::mk_tup(fcx.ccx.tcx, elts_mt);
@ -2678,8 +2678,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
}
}
let vec[ast::field] fields_1 = vec();
let vec[field] fields_t = vec();
let vec[ast::field] fields_1 = [];
let vec[field] fields_t = [];
for (ast::field f in fields) {
auto expr_1 = check_expr(fcx, f.expr);
@ -2705,7 +2705,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
auto bexpr_t = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
bexpr_1);
let vec[field] base_fields = vec();
let vec[field] base_fields = [];
alt (struct(fcx.ccx.tcx, bexpr_t)) {
case (ty::ty_rec(?flds)) {
@ -3000,7 +3000,7 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
}
fn check_block(&@fn_ctxt fcx, &ast::block block) -> ast::block {
let vec[@ast::stmt] stmts = vec();
let vec[@ast::stmt] stmts = [];
for (@ast::stmt s in block.node.stmts) {
_vec::push[@ast::stmt](stmts, check_stmt(fcx, s));
}
@ -3093,10 +3093,10 @@ fn check_item_fn(&@crate_ctxt ccx, &span sp, &ast::ident ident, &ast::_fn f,
// and return type translated to typeck::ty values. We don't need do to it
// again here, we can extract them.
let vec[arg] inputs = vec();
let vec[arg] inputs = [];
for (ast::arg arg in f.decl.inputs) {
auto input_ty = ast_ty_to_ty_crate(ccx, arg.ty);
inputs += vec(rec(mode=ast_mode_to_mode(arg.mode), ty=input_ty));
inputs += [rec(mode=ast_mode_to_mode(arg.mode), ty=input_ty)];
}
auto output_ty = ast_ty_to_ty_crate(ccx, f.decl.output);
@ -3182,7 +3182,7 @@ fn check_crate(&ty::ctxt tcx, &@ast::crate crate) -> typecheck_result {
auto sess = tcx.sess;
auto result = collect::collect_item_types(sess, tcx, crate);
let vec[ast::obj_field] fields = vec();
let vec[ast::obj_field] fields = [];
auto hasher = hash_unify_cache_entry;
auto eqer = eq_unify_cache_entry;

View file

@ -797,10 +797,10 @@ fn find_pre_post_loop(&def_map dm, &fn_info_map fm, &fn_info enclosing,
find_pre_post_expr(dm, fm, enclosing, index);
find_pre_post_block(dm, fm, enclosing, body);
auto loop_precond = declare_var(enclosing, decl_lhs(d),
seq_preconds(enclosing, vec(expr_pp(index),
block_pp(body))));
seq_preconds(enclosing, [expr_pp(index),
block_pp(body)]));
auto loop_postcond = intersect_postconds
(vec(expr_postcond(index), block_postcond(body)));
([expr_postcond(index), block_postcond(body)]);
set_pre_and_post(a, rec(precondition=loop_precond,
postcondition=loop_postcond));
}
@ -897,7 +897,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
// doesn't check that lhs is an lval, but
// that's probably ok
find_pre_post_exprs(dm, fm, enclosing, vec(lhs, rhs), a);
find_pre_post_exprs(dm, fm, enclosing, [lhs, rhs], a);
}
case (expr_recv(?lhs, ?rhs, ?a)) {
alt (lhs.node) {
@ -918,12 +918,12 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
// doesn't check that lhs is an lval, but
// that's probably ok
find_pre_post_exprs(dm, fm, enclosing, vec(lhs, rhs), a);
find_pre_post_exprs(dm, fm, enclosing, [lhs, rhs], a);
}
case (expr_assign_op(_, ?lhs, ?rhs, ?a)) {
/* Different from expr_assign in that the lhs *must*
already be initialized */
find_pre_post_exprs(dm, fm, enclosing, vec(lhs, rhs), a);
find_pre_post_exprs(dm, fm, enclosing, [lhs, rhs], a);
}
case (expr_lit(_,?a)) {
set_pre_and_post(a, empty_pre_post(num_local_vars));
@ -955,8 +955,8 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
alt (maybe_alt) {
case (none[@expr]) {
auto precond_res = seq_preconds(enclosing,
vec(expr_pp(antec),
block_pp(conseq)));
[expr_pp(antec),
block_pp(conseq)]);
set_pre_and_post(a, rec(precondition=precond_res,
postcondition=
expr_poststate(antec)));
@ -965,21 +965,21 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
find_pre_post_expr(dm, fm, enclosing, altern);
auto precond_true_case =
seq_preconds(enclosing,
vec(expr_pp(antec), block_pp(conseq)));
[expr_pp(antec), block_pp(conseq)]);
auto postcond_true_case = union_postconds
(num_local_vars,
vec(expr_postcond(antec), block_postcond(conseq)));
[expr_postcond(antec), block_postcond(conseq)]);
auto precond_false_case = seq_preconds
(enclosing,
vec(expr_pp(antec), expr_pp(altern)));
[expr_pp(antec), expr_pp(altern)]);
auto postcond_false_case = union_postconds
(num_local_vars,
vec(expr_postcond(antec), expr_postcond(altern)));
[expr_postcond(antec), expr_postcond(altern)]);
auto precond_res = union_postconds
(num_local_vars,
vec(precond_true_case, precond_false_case));
[precond_true_case, precond_false_case]);
auto postcond_res = intersect_postconds
(vec(postcond_true_case, postcond_false_case));
([postcond_true_case, postcond_false_case]);
set_pre_and_post(a, rec(precondition=precond_res,
postcondition=postcond_res));
}
@ -988,10 +988,10 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
case (expr_binary(?bop,?l,?r,?a)) {
/* *unless* bop is lazy (e.g. and, or)?
FIXME */
find_pre_post_exprs(dm, fm, enclosing, vec(l, r), a);
find_pre_post_exprs(dm, fm, enclosing, [l, r], a);
}
case (expr_send(?l, ?r, ?a)) {
find_pre_post_exprs(dm, fm, enclosing, vec(l, r), a);
find_pre_post_exprs(dm, fm, enclosing, [l, r], a);
}
case (expr_unary(_,?operand,?a)) {
find_pre_post_expr(dm, fm, enclosing, operand);
@ -1007,18 +1007,18 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
set_pre_and_post(a,
rec(precondition=
seq_preconds(enclosing,
vec(expr_pp(test),
block_pp(body))),
[expr_pp(test),
block_pp(body)]),
postcondition=
intersect_postconds(vec(expr_postcond(test),
block_postcond(body)))));
intersect_postconds([expr_postcond(test),
block_postcond(body)])));
}
case (expr_do_while(?body, ?test, ?a)) {
find_pre_post_block(dm, fm, enclosing, body);
find_pre_post_expr(dm, fm, enclosing, test);
auto loop_postcond = union_postconds(num_local_vars,
vec(block_postcond(body), expr_postcond(test)));
[block_postcond(body), expr_postcond(test)]);
/* conservative approximination: if the body
could break or cont, the test may never be executed */
if (has_nonlocal_exits(body)) {
@ -1027,8 +1027,8 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
set_pre_and_post(a,
rec(precondition=seq_preconds(enclosing,
vec(block_pp(body),
expr_pp(test))),
[block_pp(body),
expr_pp(test)]),
postcondition=loop_postcond));
}
case (expr_for(?d, ?index, ?body, ?a)) {
@ -1038,7 +1038,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
find_pre_post_loop(dm, fm, enclosing, d, index, body, a);
}
case (expr_index(?e, ?sub, ?a)) {
find_pre_post_exprs(dm, fm, enclosing, vec(e, sub), a);
find_pre_post_exprs(dm, fm, enclosing, [e, sub], a);
}
case (expr_alt(?e, ?alts, ?a)) {
find_pre_post_expr(dm, fm, enclosing, e);
@ -1053,7 +1053,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
fn_info enclosing, &pre_and_post pp,
&pre_and_post next) -> pre_and_post {
union(pp.precondition, seq_preconds(enclosing,
vec(antec, next)));
[antec, next]));
intersect(pp.postcondition, next.postcondition);
ret pp;
}
@ -1214,7 +1214,7 @@ fn find_pre_post_block(&def_map dm, &fn_info_map fm, &fn_info enclosing,
auto do_inner = bind do_inner_(dm, fm, enclosing, _);
option::map[@expr, ()](do_inner, b.node.expr);
let vec[pre_and_post] pps = vec();
let vec[pre_and_post] pps = [];
fn get_pp_stmt(&@stmt s) -> pre_and_post {
ret stmt_pp(*s);
@ -1408,8 +1408,8 @@ fn find_pre_post_state_loop(&def_map dm, &fn_info_map fm, &fn_info enclosing,
(poststate of index, poststate of body) */
changed = find_pre_post_state_block(dm, fm, enclosing,
expr_poststate(index), body) || changed;
auto res_p = intersect_postconds(vec(expr_poststate(index),
block_poststate(body)));
auto res_p = intersect_postconds([expr_poststate(index),
block_poststate(body)]);
changed = extend_poststate_ann(a, res_p) || changed;
ret changed;
@ -1603,7 +1603,7 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
changed = find_pre_post_state_expr(dm, fm, enclosing,
expr_poststate(antec), altern) || changed;
auto poststate_res = intersect_postconds
(vec(block_poststate(conseq), expr_poststate(altern)));
([block_poststate(conseq), expr_poststate(altern)]);
changed = extend_poststate_ann(a, poststate_res) || changed;
}
}
@ -1660,8 +1660,8 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
changed = find_pre_post_state_block(dm, fm,
enclosing, expr_poststate(test), body) || changed;
changed = extend_poststate_ann(a,
intersect_postconds(vec(expr_poststate(test),
block_poststate(body)))) || changed;
intersect_postconds([expr_poststate(test),
block_poststate(body)])) || changed;
ret changed;
}
case (expr_do_while(?body, ?test, ?a)) {
@ -2335,7 +2335,7 @@ fn annotate_stmt(&fn_info_map fm, &@stmt s) -> @stmt {
}
}
fn annotate_block(&fn_info_map fm, &block b) -> block {
let vec[@stmt] new_stmts = vec();
let vec[@stmt] new_stmts = [];
for (@stmt s in b.node.stmts) {
auto new_s = annotate_stmt(fm, s);
@ -2357,7 +2357,7 @@ fn annotate_fn(&fn_info_map fm, &ast::_fn f) -> ast::_fn {
ret rec(body=annotate_block(fm, f.body) with f);
}
fn annotate_mod(&fn_info_map fm, &ast::_mod m) -> ast::_mod {
let vec[@item] new_items = vec();
let vec[@item] new_items = [];
for (@item i in m.items) {
auto new_i = annotate_item(fm, i);
@ -2470,7 +2470,7 @@ fn annotate_item(&fn_info_map fm, &@ast::item item) -> @ast::item {
}
fn annotate_module(&fn_info_map fm, &ast::_mod module) -> ast::_mod {
let vec[@item] new_items = vec();
let vec[@item] new_items = [];
for (@item i in module.items) {
auto new_item = annotate_item(fm, i);