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

@ -63,8 +63,8 @@ type upcalls = rec(
fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
fn decl(type_names tn, ModuleRef llmod, str name, vec[TypeRef] tys,
TypeRef rv) -> ValueRef {
let vec[TypeRef] arg_tys = vec(T_taskptr(tn));
for (TypeRef t in tys) { arg_tys += vec(t); }
let vec[TypeRef] arg_tys = [T_taskptr(tn)];
for (TypeRef t in tys) { arg_tys += [t]; }
auto fn_ty = T_fn(arg_tys, rv);
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
}
@ -74,61 +74,61 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
// FIXME: Sigh:.. remove this when I fix the typechecker pushdown.
// --pcwalton
let vec[TypeRef] empty_vec = vec();
let vec[TypeRef] empty_vec = [];
ret @rec(
grow_task=dv("grow_task", vec(T_size_t())),
log_int=dv("log_int", vec(T_i32(), T_i32())),
log_float=dv("log_float", vec(T_i32(), T_f32())),
log_double=dv("log_double", vec(T_i32(), T_ptr(T_f64()))),
log_str=dv("log_str", vec(T_i32(), T_ptr(T_str()))),
trace_word=dv("trace_word", vec(T_int())),
trace_str=dv("trace_str", vec(T_ptr(T_i8()))),
new_port=d("new_port", vec(T_size_t()), T_opaque_port_ptr()),
del_port=dv("del_port", vec(T_opaque_port_ptr())),
new_chan=d("new_chan", vec(T_opaque_port_ptr()), T_opaque_chan_ptr()),
flush_chan=dv("flush_chan", vec(T_opaque_chan_ptr())),
del_chan=dv("del_chan", vec(T_opaque_chan_ptr())),
clone_chan=d("clone_chan", vec(T_taskptr(tn), T_opaque_chan_ptr()),
grow_task=dv("grow_task", [T_size_t()]),
log_int=dv("log_int", [T_i32(), T_i32()]),
log_float=dv("log_float", [T_i32(), T_f32()]),
log_double=dv("log_double", [T_i32(), T_ptr(T_f64())]),
log_str=dv("log_str", [T_i32(), T_ptr(T_str())]),
trace_word=dv("trace_word", [T_int()]),
trace_str=dv("trace_str", [T_ptr(T_i8())]),
new_port=d("new_port", [T_size_t()], T_opaque_port_ptr()),
del_port=dv("del_port", [T_opaque_port_ptr()]),
new_chan=d("new_chan", [T_opaque_port_ptr()], T_opaque_chan_ptr()),
flush_chan=dv("flush_chan", [T_opaque_chan_ptr()]),
del_chan=dv("del_chan", [T_opaque_chan_ptr()]),
clone_chan=d("clone_chan", [T_taskptr(tn), T_opaque_chan_ptr()],
T_opaque_chan_ptr()),
_yield=dv("yield", empty_vec),
sleep=dv("sleep", vec(T_size_t())),
_join=dv("join", vec(T_taskptr(tn))),
send=dv("send", vec(T_opaque_chan_ptr(), T_ptr(T_i8()))),
recv=dv("recv", vec(T_ptr(T_ptr(T_i8())), T_opaque_port_ptr())),
_fail=dv("fail", vec(T_ptr(T_i8()), T_ptr(T_i8()), T_size_t())),
kill=dv("kill", vec(T_taskptr(tn))),
sleep=dv("sleep", [T_size_t()]),
_join=dv("join", [T_taskptr(tn)]),
send=dv("send", [T_opaque_chan_ptr(), T_ptr(T_i8())]),
recv=dv("recv", [T_ptr(T_ptr(T_i8())), T_opaque_port_ptr()]),
_fail=dv("fail", [T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
kill=dv("kill", [T_taskptr(tn)]),
exit=dv("exit", empty_vec),
malloc=d("malloc", vec(T_size_t(), T_ptr(T_tydesc(tn))),
malloc=d("malloc", [T_size_t(), T_ptr(T_tydesc(tn))],
T_ptr(T_i8())),
free=dv("free", vec(T_ptr(T_i8()), T_int())),
mark=d("mark", vec(T_ptr(T_i8())), T_int()),
new_str=d("new_str", vec(T_ptr(T_i8()), T_size_t()), T_ptr(T_str())),
new_vec=d("new_vec", vec(T_size_t(), T_ptr(T_tydesc(tn))),
free=dv("free", [T_ptr(T_i8()), T_int()]),
mark=d("mark", [T_ptr(T_i8())], T_int()),
new_str=d("new_str", [T_ptr(T_i8()), T_size_t()], T_ptr(T_str())),
new_vec=d("new_vec", [T_size_t(), T_ptr(T_tydesc(tn))],
T_opaque_vec_ptr()),
vec_grow=d("vec_grow", vec(T_opaque_vec_ptr(), T_size_t(),
T_ptr(T_int()), T_ptr(T_tydesc(tn))),
vec_grow=d("vec_grow", [T_opaque_vec_ptr(), T_size_t(),
T_ptr(T_int()), T_ptr(T_tydesc(tn))],
T_opaque_vec_ptr()),
require_rust_sym=d("require_rust_sym",
vec(T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
T_size_t(), T_ptr(T_i8()),
T_ptr(T_ptr(T_i8()))),
T_ptr(T_ptr(T_i8()))],
T_int()),
require_c_sym=d("require_c_sym",
vec(T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
T_ptr(T_i8()), T_ptr(T_i8())),
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
T_ptr(T_i8()), T_ptr(T_i8())],
T_int()),
get_type_desc=d("get_type_desc",
vec(T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))),
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
T_ptr(T_tydesc(tn))),
new_task=d("new_task", vec(T_ptr(T_i8())), T_taskptr(tn)),
start_task=d("start_task", vec(T_taskptr(tn), T_int(), T_int(),
T_int(), T_size_t()),
new_task=d("new_task", [T_ptr(T_i8())], T_taskptr(tn)),
start_task=d("start_task", [T_taskptr(tn), T_int(), T_int(),
T_int(), T_size_t()],
T_taskptr(tn)),
new_thread=d("new_thread", vec(T_ptr(T_i8())), T_taskptr(tn)),
start_thread=d("start_thread", vec(T_taskptr(tn), T_int(), T_int(),
T_int(), T_size_t()),
new_thread=d("new_thread", [T_ptr(T_i8())], T_taskptr(tn)),
start_thread=d("start_thread", [T_taskptr(tn), T_int(), T_int(),
T_int(), T_size_t()],
T_taskptr(tn))
);
}

View file

@ -12,78 +12,78 @@ fn wstr(int i) -> str {
}
fn start() -> vec[str] {
ret vec(".cfi_startproc");
ret [".cfi_startproc"];
}
fn end() -> vec[str] {
ret vec(".cfi_endproc");
ret [".cfi_endproc"];
}
fn save_callee_saves() -> vec[str] {
ret vec("pushl %ebp",
ret ["pushl %ebp",
"pushl %edi",
"pushl %esi",
"pushl %ebx");
"pushl %ebx"];
}
fn save_callee_saves_with_cfi() -> vec[str] {
auto offset = 8;
auto t;
t = vec("pushl %ebp");
t += vec(".cfi_def_cfa_offset " + istr(offset));
t += vec(".cfi_offset %ebp, -" + istr(offset));
t = ["pushl %ebp"];
t += [".cfi_def_cfa_offset " + istr(offset)];
t += [".cfi_offset %ebp, -" + istr(offset)];
t += vec("pushl %edi");
t += ["pushl %edi"];
offset += 4;
t += vec(".cfi_def_cfa_offset " + istr(offset));
t += [".cfi_def_cfa_offset " + istr(offset)];
t += vec("pushl %esi");
t += ["pushl %esi"];
offset += 4;
t += vec(".cfi_def_cfa_offset " + istr(offset));
t += [".cfi_def_cfa_offset " + istr(offset)];
t += vec("pushl %ebx");
t += ["pushl %ebx"];
offset += 4;
t += vec(".cfi_def_cfa_offset " + istr(offset));
t += [".cfi_def_cfa_offset " + istr(offset)];
ret t;
}
fn restore_callee_saves() -> vec[str] {
ret vec("popl %ebx",
ret ["popl %ebx",
"popl %esi",
"popl %edi",
"popl %ebp");
"popl %ebp"];
}
fn load_esp_from_rust_sp_first_arg() -> vec[str] {
ret vec("movl " + wstr(abi::task_field_rust_sp) + "(%ecx), %esp");
ret ["movl " + wstr(abi::task_field_rust_sp) + "(%ecx), %esp"];
}
fn load_esp_from_runtime_sp_first_arg() -> vec[str] {
ret vec("movl " + wstr(abi::task_field_runtime_sp) + "(%ecx), %esp");
ret ["movl " + wstr(abi::task_field_runtime_sp) + "(%ecx), %esp"];
}
fn store_esp_to_rust_sp_first_arg() -> vec[str] {
ret vec("movl %esp, " + wstr(abi::task_field_rust_sp) + "(%ecx)");
ret ["movl %esp, " + wstr(abi::task_field_rust_sp) + "(%ecx)"];
}
fn store_esp_to_runtime_sp_first_arg() -> vec[str] {
ret vec("movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%ecx)");
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%ecx)"];
}
fn load_esp_from_rust_sp_second_arg() -> vec[str] {
ret vec("movl " + wstr(abi::task_field_rust_sp) + "(%edx), %esp");
ret ["movl " + wstr(abi::task_field_rust_sp) + "(%edx), %esp"];
}
fn load_esp_from_runtime_sp_second_arg() -> vec[str] {
ret vec("movl " + wstr(abi::task_field_runtime_sp) + "(%edx), %esp");
ret ["movl " + wstr(abi::task_field_runtime_sp) + "(%edx), %esp"];
}
fn store_esp_to_rust_sp_second_arg() -> vec[str] {
ret vec("movl %esp, " + wstr(abi::task_field_rust_sp) + "(%edx)");
ret ["movl %esp, " + wstr(abi::task_field_rust_sp) + "(%edx)"];
}
fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
ret vec("movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%edx)");
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%edx)"];
}
@ -105,7 +105,7 @@ fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
*/
fn rust_activate_glue() -> vec[str] {
ret vec("movl 4(%esp), %ecx # ecx = rust_task")
ret ["movl 4(%esp), %ecx # ecx = rust_task"]
+ save_callee_saves()
+ store_esp_to_runtime_sp_first_arg()
+ load_esp_from_rust_sp_first_arg()
@ -157,7 +157,7 @@ fn rust_activate_glue() -> vec[str] {
* will be a no-op. Esp won't move, and the task's stack won't
* grow.
*/
+ vec("addl $20, " + wstr(abi::task_field_rust_sp) + "(%ecx)")
+ ["addl $20, " + wstr(abi::task_field_rust_sp) + "(%ecx)"]
/*
@ -167,10 +167,10 @@ fn rust_activate_glue() -> vec[str] {
* activating, the task needs to be in the fastcall 2nd parameter
* expected by the rust main function. That's edx.
*/
+ vec("mov %ecx, %edx")
+ ["mov %ecx, %edx"]
+ restore_callee_saves()
+ vec("ret");
+ ["ret"];
}
/* More glue code, this time the 'bottom half' of yielding.
@ -200,13 +200,13 @@ fn rust_activate_glue() -> vec[str] {
*/
fn rust_yield_glue() -> vec[str] {
ret vec("movl 0(%esp), %ecx # ecx = rust_task")
ret ["movl 0(%esp), %ecx # ecx = rust_task"]
+ load_esp_from_rust_sp_first_arg()
+ save_callee_saves()
+ store_esp_to_rust_sp_first_arg()
+ load_esp_from_runtime_sp_first_arg()
+ restore_callee_saves()
+ vec("ret");
+ ["ret"];
}
fn native_glue(int n_args, abi::native_glue_type ngt) -> vec[str] {
@ -239,8 +239,8 @@ fn native_glue(int n_args, abi::native_glue_type ngt) -> vec[str] {
} else {
src_off = wstr(5 + (i as int));
}
auto m = vec("movl " + src_off + "(%ebp),%eax",
"movl %eax," + dst_off + "(%esp)");
auto m = ["movl " + src_off + "(%ebp),%eax",
"movl %eax," + dst_off + "(%esp)"];
ret _str::connect(m, "\n\t");
}
@ -250,24 +250,24 @@ fn native_glue(int n_args, abi::native_glue_type ngt) -> vec[str] {
start()
+ save_callee_saves_with_cfi()
+ vec("movl %esp, %ebp # ebp = rust_sp")
+ vec(".cfi_def_cfa_register %ebp")
+ ["movl %esp, %ebp # ebp = rust_sp"]
+ [".cfi_def_cfa_register %ebp"]
+ store_esp_to_rust_sp_second_arg()
+ load_esp_from_runtime_sp_second_arg()
+ vec("subl $" + wstr(n_args) + ", %esp # esp -= args",
"andl $~0xf, %esp # align esp down")
+ ["subl $" + wstr(n_args) + ", %esp # esp -= args",
"andl $~0xf, %esp # align esp down"]
+ _vec::init_fn[str](carg, (n_args) as uint)
+ vec("movl %edx, %edi # save task from edx to edi",
+ ["movl %edx, %edi # save task from edx to edi",
"call *%ecx # call *%ecx",
"movl %edi, %edx # restore edi-saved task to edx")
"movl %edi, %edx # restore edi-saved task to edx"]
+ load_esp_from_rust_sp_second_arg()
+ restore_callee_saves()
+ vec("ret")
+ ["ret"]
+ end();
}
@ -305,13 +305,13 @@ fn get_module_asm() -> str {
auto prefix = get_symbol_prefix();
auto glues =
vec(decl_glue(align, prefix,
[decl_glue(align, prefix,
abi::activate_glue_name(),
rust_activate_glue()),
decl_glue(align, prefix,
abi::yield_glue_name(),
rust_yield_glue()))
rust_yield_glue())]
+ _vec::init_fn[str](bind decl_native_glue(align, prefix,
abi::ngt_rust, _), (abi::n_native_glues + 1) as uint)

View file

@ -44,7 +44,7 @@ fn default_environment(session::session sess,
}
ret
vec(
[
// Target bindings.
tup("target_os", eval::val_str(std::os::target_os())),
tup("target_arch", eval::val_str("x86")),
@ -53,7 +53,7 @@ fn default_environment(session::session sess,
// Build bindings.
tup("build_compiler", eval::val_str(argv0)),
tup("build_input", eval::val_str(input))
);
];
}
fn parse_input(session::session sess,
@ -205,7 +205,7 @@ fn main(vec[str] args) {
uint_type = common::ty_u32,
float_type = common::ty_f64);
auto opts = vec(optflag("h"), optflag("help"),
auto opts = [optflag("h"), optflag("help"),
optflag("v"), optflag("version"),
optflag("glue"), optflag("emit-llvm"),
optflag("pretty"), optflag("ls"), optflag("parse-only"),
@ -214,7 +214,7 @@ fn main(vec[str] args) {
optflag("save-temps"), optopt("sysroot"),
optflag("stats"),
optflag("time-passes"), optflag("time-llvm-passes"),
optflag("no-typestate"), optflag("noverify"));
optflag("no-typestate"), optflag("noverify")];
auto binary = _vec::shift[str](args);
auto match;
alt (getopts::getopts(args, opts)) {
@ -287,7 +287,7 @@ fn main(vec[str] args) {
auto crate_cache = common::new_int_hash[session::crate_metadata]();
auto target_crate_num = 0;
let vec[@ast::meta_item] md = vec();
let vec[@ast::meta_item] md = [];
auto sess =
session::session(target_crate_num, target_cfg, sopts,
crate_cache, md, front::codemap::new_codemap());
@ -323,13 +323,13 @@ fn main(vec[str] args) {
_vec::pop[str](parts);
saved_out_filename = parts.(0);
alt (output_type) {
case (link::output_type_none) { parts += vec("pp"); }
case (link::output_type_bitcode) { parts += vec("bc"); }
case (link::output_type_assembly) { parts += vec("s"); }
case (link::output_type_none) { parts += ["pp"]; }
case (link::output_type_bitcode) { parts += ["bc"]; }
case (link::output_type_assembly) { parts += ["s"]; }
// Object and exe output both use the '.o' extension here
case (link::output_type_object) { parts += vec("o"); }
case (link::output_type_exe) { parts += vec("o"); }
case (link::output_type_object) { parts += ["o"]; }
case (link::output_type_exe) { parts += ["o"]; }
}
auto ofile = _str::connect(parts, ".");
compile_input(sess, env, ifile, ofile);
@ -353,33 +353,33 @@ fn main(vec[str] args) {
let str exe_suffix = "";
// The invocations of gcc share some flags across platforms
let vec[str] common_cflags = vec("-fno-strict-aliasing", "-fPIC",
"-Wall", "-fno-rtti", "-fno-exceptions", "-g");
let vec[str] common_libs = vec(stage, "-Lrustllvm", "-Lrt",
"-lrustrt", "-lrustllvm", "-lstd", "-lm");
let vec[str] common_cflags = ["-fno-strict-aliasing", "-fPIC",
"-Wall", "-fno-rtti", "-fno-exceptions", "-g"];
let vec[str] common_libs = [stage, "-Lrustllvm", "-Lrt",
"-lrustrt", "-lrustllvm", "-lstd", "-lm"];
alt (sess.get_targ_cfg().os) {
case (session::os_win32) {
exe_suffix = ".exe";
gcc_args = common_cflags + vec(
gcc_args = common_cflags + [
"-march=i686", "-O2",
glu, "-o",
saved_out_filename + exe_suffix,
saved_out_filename + ".o") + common_libs;
saved_out_filename + ".o"] + common_libs;
}
case (session::os_macos) {
gcc_args = common_cflags + vec(
gcc_args = common_cflags + [
"-arch i386", "-O0", "-m32",
glu, "-o",
saved_out_filename + exe_suffix,
saved_out_filename + ".o") + common_libs;
saved_out_filename + ".o"] + common_libs;
}
case (session::os_linux) {
gcc_args = common_cflags + vec(
gcc_args = common_cflags + [
"-march=i686", "-O2", "-m32",
glu, "-o",
saved_out_filename + exe_suffix,
saved_out_filename + ".o") + common_libs;
saved_out_filename + ".o"] + common_libs;
}
}
@ -388,12 +388,12 @@ fn main(vec[str] args) {
// Clean up on Darwin
if (sess.get_targ_cfg().os == session::os_macos) {
run::run_program("dsymutil", vec(saved_out_filename));
run::run_program("dsymutil", [saved_out_filename]);
}
// Remove the temporary object file if we aren't saving temps
if (!save_temps) {
run::run_program("rm", vec(saved_out_filename + ".o"));
run::run_program("rm", [saved_out_filename + ".o"]);
}
}
}

View file

@ -13,14 +13,14 @@ type codemap = @rec(mutable vec[filemap] files);
type loc = rec(str filename, uint line, uint col);
fn new_codemap() -> codemap {
let vec[filemap] files = vec();
let vec[filemap] files = [];
ret @rec(mutable files=files);
}
fn new_filemap(str filename, uint start_pos) -> filemap {
ret @rec(name=filename,
start_pos=start_pos,
mutable lines=vec(0u));
mutable lines=[0u]);
}
fn next_line(filemap file, uint pos) {

View file

@ -90,9 +90,9 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
case ('t') {
assert (next(st) as char == '[');
auto def = parse_def(st, sd);
let vec[ty::t] params = vec();
let vec[ty::t] params = [];
while (peek(st) as char != ']') {
params += vec(parse_ty(st, sd));
params += [parse_ty(st, sd)];
}
st.pos = st.pos + 1u;
ret ty::mk_tag(st.tcx, def, params);
@ -104,23 +104,23 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
case ('C') { ret ty::mk_chan(st.tcx, parse_ty(st, sd)); }
case ('T') {
assert (next(st) as char == '[');
let vec[ty::mt] params = vec();
let vec[ty::mt] params = [];
while (peek(st) as char != ']') {
params += vec(parse_mt(st, sd));
params += [parse_mt(st, sd)];
}
st.pos = st.pos + 1u;
ret ty::mk_tup(st.tcx, params);
}
case ('R') {
assert (next(st) as char == '[');
let vec[ty::field] fields = vec();
let vec[ty::field] fields = [];
while (peek(st) as char != ']') {
auto name = "";
while (peek(st) as char != '=') {
name += _str::unsafe_from_byte(next(st));
}
st.pos = st.pos + 1u;
fields += vec(rec(ident=name, mt=parse_mt(st, sd)));
fields += [rec(ident=name, mt=parse_mt(st, sd))];
}
st.pos = st.pos + 1u;
ret ty::mk_rec(st.tcx, fields);
@ -146,7 +146,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
}
case ('O') {
assert (next(st) as char == '[');
let vec[ty::method] methods = vec();
let vec[ty::method] methods = [];
while (peek(st) as char != ']') {
auto proto;
alt (next(st) as char) {
@ -158,10 +158,10 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
name += _str::unsafe_from_byte(next(st));
}
auto func = parse_ty_fn(st, sd);
methods += vec(rec(proto=proto,
methods += [rec(proto=proto,
ident=name,
inputs=func._0,
output=func._1));
output=func._1)];
}
st.pos += 1u;
ret ty::mk_obj(st.tcx, methods);
@ -242,14 +242,14 @@ fn parse_hex(@pstate st) -> uint {
fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty::arg], ty::t) {
assert (next(st) as char == '[');
let vec[ty::arg] inputs = vec();
let vec[ty::arg] inputs = [];
while (peek(st) as char != ']') {
auto mode = ty::mo_val;
if (peek(st) as char == '&') {
mode = ty::mo_alias;
st.pos = st.pos + 1u;
}
inputs += vec(rec(mode=mode, ty=parse_ty(st, sd)));
inputs += [rec(mode=mode, ty=parse_ty(st, sd))];
}
st.pos = st.pos + 1u;
ret tup(inputs, parse_ty(st, sd));
@ -285,7 +285,7 @@ fn lookup_hash(&ebml::doc d, fn(vec[u8]) -> bool eq_fn, uint hash)
auto pos = ebml::be_uint_from_bytes(d.data, hash_pos, 4u);
auto bucket = ebml::doc_at(d.data, pos);
// Awkward logic because we can't ret from foreach yet
let vec[ebml::doc] result = vec();
let vec[ebml::doc] result = [];
auto belt = metadata::tag_index_buckets_bucket_elt;
for each (ebml::doc elt in ebml::tagged_docs(bucket, belt)) {
auto pos = ebml::be_uint_from_bytes(elt.data, elt.start, 4u);
@ -306,7 +306,7 @@ fn resolve_path(vec[ast::ident] path, vec[u8] data) -> vec[ast::def_id] {
auto md = ebml::new_doc(data);
auto paths = ebml::get_doc(md, metadata::tag_paths);
auto eqer = bind eq_item(_, s);
let vec[ast::def_id] result = vec();
let vec[ast::def_id] result = [];
for (ebml::doc doc in lookup_hash(paths, eqer, metadata::hash_path(s))) {
auto did_doc = ebml::get_doc(doc, metadata::tag_def_id);
_vec::push(result, parse_def_id(ebml::doc_data(did_doc)));
@ -380,7 +380,7 @@ fn item_ty_param_count(&ebml::doc item, int this_cnum) -> uint {
}
fn tag_variant_ids(&ebml::doc item, int this_cnum) -> vec[ast::def_id] {
let vec[ast::def_id] ids = vec();
let vec[ast::def_id] ids = [];
auto v = metadata::tag_items_data_item_variant;
for each (ebml::doc p in ebml::tagged_docs(item, v)) {
auto ext = parse_def_id(ebml::doc_data(p));
@ -544,23 +544,23 @@ fn get_tag_variants(session::session sess, ty::ctxt tcx, ast::def_id def)
auto items = ebml::get_doc(ebml::new_doc(data), metadata::tag_items);
auto item = find_item(def._1, items);
let vec[trans::variant_info] infos = vec();
let vec[trans::variant_info] infos = [];
auto variant_ids = tag_variant_ids(item, external_crate_id);
for (ast::def_id did in variant_ids) {
auto item = find_item(did._1, items);
auto ctor_ty = item_type(item, external_crate_id, tcx);
let vec[ty::t] arg_tys = vec();
let vec[ty::t] arg_tys = [];
alt (ty::struct(tcx, ctor_ty)) {
case (ty::ty_fn(_, ?args, _)) {
for (ty::arg a in args) {
arg_tys += vec(a.ty);
arg_tys += [a.ty];
}
}
case (_) {
// Nullary tag variant.
}
}
infos += vec(rec(args=arg_tys, ctor_ty=ctor_ty, id=did));
infos += [rec(args=arg_tys, ctor_ty=ctor_ty, id=did)];
}
ret infos;

View file

@ -38,7 +38,7 @@ type ctx = @rec(parser p,
mutable uint next_ann);
fn mk_env() -> env {
let env e = vec();
let env e = [];
ret e;
}
@ -249,8 +249,8 @@ fn eval_crate_directives(ctx cx,
fn eval_crate_directives_to_mod(ctx cx, env e,
vec[@ast::crate_directive] cdirs,
str prefix) -> ast::_mod {
let vec[@ast::view_item] view_items = vec();
let vec[@ast::item] items = vec();
let vec[@ast::view_item] view_items = [];
let vec[@ast::item] items = [];
eval_crate_directives(cx, e, cdirs, prefix,
view_items, items);
@ -356,7 +356,7 @@ fn eval_crate_directive(ctx cx,
case (ast::cdir_let(?id, ?x, ?cdirs)) {
auto v = eval_expr(cx, e, x);
auto e0 = vec(tup(id, v)) + e;
auto e0 = [tup(id, v)] + e;
eval_crate_directives(cx, e0, cdirs, prefix,
view_items, items);
}
@ -379,7 +379,7 @@ fn eval_crate_directive(ctx cx,
auto full_path = prefix + std::fs::path_sep() + file_path;
if (cx.mode == mode_depend) {
cx.deps += vec(full_path);
cx.deps += [full_path];
ret;
}

View file

@ -118,7 +118,7 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
fn make_path_expr(parser p, common::span sp, vec[ast::ident] idents)
-> @ast::expr {
let vec[@ast::ty] types = vec();
let vec[@ast::ty] types = [];
auto path = rec(idents=idents, types=types);
auto sp_path = rec(node=path, span=sp);
auto pathexpr = ast::expr_path(sp_path, p.get_ann());
@ -143,14 +143,14 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
fn make_rec_expr(parser p, common::span sp,
vec[tup(ast::ident, @ast::expr)] fields) -> @ast::expr {
let vec[ast::field] astfields = vec();
let vec[ast::field] astfields = [];
for (tup(ast::ident, @ast::expr) field in fields) {
auto ident = field._0;
auto val = field._1;
auto astfield = rec(mut = ast::imm,
ident = ident,
expr = val);
astfields += vec(astfield);
astfields += [astfield];
}
auto recexpr = ast::expr_rec(astfields,
@ -163,7 +163,7 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
fn make_path_vec(str ident) -> vec[str] {
// FIXME: #fmt can't currently be used from within std
// because we're explicitly referencing the 'std' crate here
ret vec("std", "extfmt", "rt", ident);
ret ["std", "extfmt", "rt", ident];
}
fn make_rt_path_expr(parser p, common::span sp, str ident) -> @ast::expr {
@ -177,7 +177,7 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
fn make_flags(parser p, common::span sp, vec[flag] flags)
-> @ast::expr {
let vec[@ast::expr] flagexprs = vec();
let vec[@ast::expr] flagexprs = [];
for (flag f in flags) {
auto fstr;
alt (f) {
@ -197,14 +197,14 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
fstr = "flag_alternate";
}
}
flagexprs += vec(make_rt_path_expr(p, sp, fstr));
flagexprs += [make_rt_path_expr(p, sp, fstr)];
}
// FIXME: 0-length vectors can't have their type inferred
// through the rec that these flags are a member of, so
// this is a hack placeholder flag
if (_vec::len[@ast::expr](flagexprs) == 0u) {
flagexprs += vec(make_rt_path_expr(p, sp, "flag_none"));
flagexprs += [make_rt_path_expr(p, sp, "flag_none")];
}
ret make_vec_expr(p, sp, flagexprs);
@ -218,7 +218,7 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
case (count_is(?c)) {
auto count_lit = make_new_int(p, sp, c);
auto count_is_path = make_path_vec("count_is");
auto count_is_args = vec(count_lit);
auto count_is_args = [count_lit];
ret make_call(p, sp, count_is_path, count_is_args);
}
case (_) {
@ -261,10 +261,10 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
@ast::expr width_expr,
@ast::expr precision_expr,
@ast::expr ty_expr) -> @ast::expr {
ret make_rec_expr(p, sp, vec(tup("flags", flags_expr),
ret make_rec_expr(p, sp, [tup("flags", flags_expr),
tup("width", width_expr),
tup("precision", precision_expr),
tup("ty", ty_expr)));
tup("ty", ty_expr)]);
}
auto rt_conv_flags = make_flags(p, sp, cnv.flags);
@ -284,7 +284,7 @@ fn pieces_to_expr(parser p, vec[piece] pieces, vec[@ast::expr] args)
auto fname = "conv_" + conv_type;
auto path = make_path_vec(fname);
auto cnv_expr = make_rt_conv_expr(p, sp, cnv);
auto args = vec(cnv_expr, arg);
auto args = [cnv_expr, arg];
ret make_call(p, arg.span, path, args);
}

View file

@ -91,7 +91,7 @@ fn new_reader(session sess, io::reader rdr,
}
}
auto file = _str::unsafe_from_bytes(rdr.read_whole_stream());
let vec[str] strs = vec();
let vec[str] strs = [];
auto rd = reader(sess, file, _str::byte_len(file), 0u, -1 as char,
filemap.start_pos, filemap.start_pos,
strs, filemap, itr);
@ -228,11 +228,11 @@ fn scan_exponent(reader rdr) -> option::t[str] {
auto res = "";
if (c == 'e' || c == 'E') {
res += _str::from_bytes(vec(c as u8));
res += _str::from_bytes([c as u8]);
rdr.bump();
c = rdr.curr();
if (c == '-' || c == '+') {
res += _str::from_bytes(vec(c as u8));
res += _str::from_bytes([c as u8]);
rdr.bump();
}
auto exponent = scan_dec_digits(rdr);
@ -256,7 +256,7 @@ fn scan_dec_digits(reader rdr) -> str {
while (is_dec_digit (c) || c == '_') {
if (c != '_') {
res += _str::from_bytes(vec(c as u8));
res += _str::from_bytes([c as u8]);
}
rdr.bump();
c = rdr.curr();
@ -766,7 +766,7 @@ fn read_block_comment(reader rdr) -> cmnt {
auto p = rdr.get_chpos();
rdr.bump(); rdr.bump();
while (rdr.curr() == ' ') {rdr.bump();}
let vec[str] lines = vec();
let vec[str] lines = [];
auto val = "";
auto level = 1;
while (true) {
@ -802,7 +802,7 @@ fn gather_comments(session sess, str path) -> vec[cmnt] {
auto srdr = io::file_reader(path);
auto itr = @interner::mk_interner[str](_str::hash, _str::eq);
auto rdr = new_reader(sess, srdr, codemap::new_filemap(path, 0u), itr);
let vec[cmnt] comments = vec();
let vec[cmnt] comments = [];
while (!rdr.is_eof()) {
while (true) {
consume_whitespace(rdr);

View file

@ -422,7 +422,7 @@ fn parse_ty_constr(parser p) -> @ast::constr {
fn parse_constrs(parser p) -> common::spanned[vec[@ast::constr]] {
auto lo = p.get_lo_pos();
auto hi = p.get_hi_pos();
let vec[@ast::constr] constrs = vec();
let vec[@ast::constr] constrs = [];
if (p.peek() == token::COLON) {
p.bump();
while (true) {
@ -580,7 +580,7 @@ fn parse_seq_to_end[T](token::token ket,
uint hi,
parser p) -> vec[T] {
let bool first = true;
let vec[T] v = vec();
let vec[T] v = [];
while (p.peek() != ket) {
alt(sep) {
case (some[token::token](?t)) {
@ -595,7 +595,7 @@ fn parse_seq_to_end[T](token::token ket,
}
// FIXME: v += f(p) doesn't work at the moment.
let T t = f(p);
v += vec(t);
v += [t];
}
hi = p.get_hi_pos();
expect(p, ket);
@ -677,7 +677,7 @@ fn parse_ty_args(parser p, uint hi) ->
some(token::COMMA),
pf, p);
}
let vec[@ast::ty] v = vec();
let vec[@ast::ty] v = [];
auto pos = p.get_lo_pos();
ret spanned(hi, hi, v);
}
@ -687,12 +687,12 @@ fn parse_path(parser p) -> ast::path {
auto lo = p.get_lo_pos();
auto hi = lo;
let vec[ast::ident] ids = vec();
let vec[ast::ident] ids = [];
while (true) {
alt (p.peek()) {
case (token::IDENT(?i, _)) {
hi = p.get_hi_pos();
ids += vec(p.get_str(i));
ids += [p.get_str(i)];
p.bump();
if (p.peek() == token::MOD_SEP) {
p.bump();
@ -797,7 +797,7 @@ fn parse_bottom_expr(parser p) -> @ast::expr {
pf, hi, p));
}
let vec[@ast::method] meths = vec();
let vec[@ast::method] meths = [];
let option::t[ast::ident] with_obj = none[ast::ident];
expect(p, token::LBRACE);
@ -830,7 +830,7 @@ fn parse_bottom_expr(parser p) -> @ast::expr {
} else if (eat_word(p, "rec")) {
expect(p, token::LPAREN);
auto fields = vec(parse_field(p));
auto fields = [parse_field(p)];
auto more = true;
auto base = none[@ast::expr];
@ -846,7 +846,7 @@ fn parse_bottom_expr(parser p) -> @ast::expr {
more = false;
} else if (p.peek() == token::COMMA) {
p.bump();
fields += vec(parse_field(p));
fields += [parse_field(p)];
} else {
unexpected(p, p.peek());
}
@ -1151,7 +1151,7 @@ type op_spec = rec(token::token tok, ast::binop op, int prec);
// FIXME make this a const, don't store it in parser state
fn prec_table() -> vec[op_spec] {
ret vec(rec(tok=token::BINOP(token::STAR), op=ast::mul, prec=11),
ret [rec(tok=token::BINOP(token::STAR), op=ast::mul, prec=11),
rec(tok=token::BINOP(token::SLASH), op=ast::div, prec=11),
rec(tok=token::BINOP(token::PERCENT), op=ast::rem, prec=11),
rec(tok=token::BINOP(token::PLUS), op=ast::add, prec=10),
@ -1170,7 +1170,7 @@ fn prec_table() -> vec[op_spec] {
rec(tok=token::EQEQ, op=ast::eq, prec=3),
rec(tok=token::NE, op=ast::ne, prec=3),
rec(tok=token::ANDAND, op=ast::and, prec=2),
rec(tok=token::OROR, op=ast::or, prec=1));
rec(tok=token::OROR, op=ast::or, prec=1)];
}
fn parse_binops(parser p) -> @ast::expr {
@ -1342,14 +1342,14 @@ fn parse_alt_expr(parser p) -> @ast::expr {
expect(p, token::RPAREN);
expect(p, token::LBRACE);
let vec[ast::arm] arms = vec();
let vec[ast::arm] arms = [];
while (p.peek() != token::RBRACE) {
if (eat_word(p, "case")) {
expect(p, token::LPAREN);
auto pat = parse_pat(p);
expect(p, token::RPAREN);
auto block = parse_block(p);
arms += vec(rec(pat=pat, block=block));
arms += [rec(pat=pat, block=block)];
} else if (p.peek() == token::RBRACE) {
/* empty */
} else {
@ -1480,7 +1480,7 @@ fn parse_pat(parser p) -> @ast::pat {
args = a.node;
hi = a.span.hi;
}
case (_) { args = vec(); }
case (_) { args = []; }
}
pat = ast::pat_tag(tag_path, args, p.get_ann());
@ -1630,7 +1630,7 @@ fn stmt_ends_with_semi(@ast::stmt stmt) -> bool {
fn parse_block(parser p) -> ast::block {
auto lo = p.get_lo_pos();
let vec[@ast::stmt] stmts = vec();
let vec[@ast::stmt] stmts = [];
let option::t[@ast::expr] expr = none[@ast::expr];
expect(p, token::LBRACE);
@ -1650,7 +1650,7 @@ fn parse_block(parser p) -> ast::block {
alt (p.peek()) {
case (token::SEMI) {
p.bump();
stmts += vec(stmt);
stmts += [stmt];
}
case (token::RBRACE) { expr = some(e); }
case (?t) {
@ -1660,13 +1660,13 @@ fn parse_block(parser p) -> ast::block {
token::to_str(p.get_reader(), t));
fail;
}
stmts += vec(stmt);
stmts += [stmt];
}
}
}
case (none[@ast::expr]) {
// Not an expression statement.
stmts += vec(stmt);
stmts += [stmt];
// FIXME: crazy differentiation between conditions
// used in branches and binary expressions in rustboot
// means we cannot use && here. I know, right?
@ -1693,7 +1693,7 @@ fn parse_ty_param(parser p) -> ast::ty_param {
}
fn parse_ty_params(parser p) -> vec[ast::ty_param] {
let vec[ast::ty_param] ty_params = vec();
let vec[ast::ty_param] ty_params = [];
if (p.peek() == token::LBRACKET) {
auto f = parse_ty_param; // FIXME: pass as lval directly
ty_params = parse_seq[ast::ty_param](token::LBRACKET, token::RBRACKET,
@ -1775,7 +1775,7 @@ fn parse_method(parser p) -> @ast::method {
fn parse_dtor(parser p) -> @ast::method {
auto lo = p.get_last_lo_pos();
let ast::block b = parse_block(p);
let vec[ast::arg] inputs = vec();
let vec[ast::arg] inputs = [];
let @ast::ty output = @spanned(lo, lo, ast::ty_nil);
let ast::fn_decl d = rec(inputs=inputs,
output=output,
@ -1802,7 +1802,7 @@ fn parse_item_obj(parser p, ast::layer lyr) -> @ast::item {
some(token::COMMA),
pf, p);
let vec[@ast::method] meths = vec();
let vec[@ast::method] meths = [];
let option::t[@ast::method] dtor = none[@ast::method];
expect(p, token::LBRACE);
@ -1829,9 +1829,9 @@ fn parse_item_obj(parser p, ast::layer lyr) -> @ast::item {
fn parse_mod_items(parser p, token::token term) -> ast::_mod {
auto view_items = parse_view(p);
let vec[@ast::item] items = vec();
let vec[@ast::item] items = [];
while (p.peek() != term) {
items += vec(parse_item(p));
items += [parse_item(p)];
}
ret rec(view_items=view_items, items=items);
}
@ -1899,12 +1899,12 @@ fn parse_native_item(parser p) -> @ast::native_item {
fn parse_native_mod_items(parser p,
str native_name,
ast::native_abi abi) -> ast::native_mod {
let vec[@ast::native_item] items = vec();
let vec[@ast::native_item] items = [];
auto view_items = parse_native_view(p);
while (p.peek() != token::RBRACE) {
items += vec(parse_native_item(p));
items += [parse_native_item(p)];
}
ret rec(native_name=native_name, abi=abi,
view_items=view_items,
@ -1982,7 +1982,7 @@ fn parse_item_tag(parser p) -> @ast::item {
auto id = parse_ident(p);
auto ty_params = parse_ty_params(p);
let vec[ast::variant] variants = vec();
let vec[ast::variant] variants = [];
expect(p, token::LBRACE);
while (p.peek() != token::RBRACE) {
auto tok = p.peek();
@ -1992,7 +1992,7 @@ fn parse_item_tag(parser p) -> @ast::item {
auto vlo = p.get_lo_pos();
p.bump();
let vec[ast::variant_arg] args = vec();
let vec[ast::variant_arg] args = [];
alt (p.peek()) {
case (token::LPAREN) {
auto f = parse_ty;
@ -2001,7 +2001,7 @@ fn parse_item_tag(parser p) -> @ast::item {
some(token::COMMA),
f, p);
for (@ast::ty ty in arg_tys.node) {
args += vec(rec(ty=ty, id=p.next_def_id()));
args += [rec(ty=ty, id=p.next_def_id())];
}
}
case (_) { /* empty */ }
@ -2013,7 +2013,7 @@ fn parse_item_tag(parser p) -> @ast::item {
auto id = p.next_def_id();
auto vr = rec(name=p.get_str(name), args=args,
id=id, ann=p.get_ann());
variants += vec(spanned[ast::variant_](vlo, vhi, vr));
variants += [spanned[ast::variant_](vlo, vhi, vr)];
}
case (token::RBRACE) { /* empty */ }
case (_) {
@ -2135,7 +2135,7 @@ fn parse_optional_meta(parser p) -> vec[@ast::meta_item] {
ret parse_meta(p);
}
case (_) {
let vec[@ast::meta_item] v = vec();
let vec[@ast::meta_item] v = [];
ret v;
}
}
@ -2156,11 +2156,11 @@ fn parse_rest_import_name(parser p, ast::ident first,
option::t[ast::ident] def_ident)
-> @ast::view_item {
auto lo = p.get_lo_pos();
let vec[ast::ident] identifiers = vec(first);
let vec[ast::ident] identifiers = [first];
while (p.peek() != token::SEMI) {
expect(p, token::MOD_SEP);
auto i = parse_ident(p);
identifiers += vec(i);
identifiers += [i];
}
auto hi = p.get_hi_pos();
p.bump();
@ -2248,17 +2248,17 @@ fn is_view_item(&parser p) -> bool {
}
fn parse_view(parser p) -> vec[@ast::view_item] {
let vec[@ast::view_item] items = vec();
let vec[@ast::view_item] items = [];
while (is_view_item(p)) {
items += vec(parse_view_item(p));
items += [parse_view_item(p)];
}
ret items;
}
fn parse_native_view(parser p) -> vec[@ast::view_item] {
let vec[@ast::view_item] items = vec();
let vec[@ast::view_item] items = [];
while (is_view_item(p)) {
items += vec(parse_view_item(p));
items += [parse_view_item(p)];
}
ret items;
}
@ -2267,7 +2267,7 @@ fn parse_native_view(parser p) -> vec[@ast::view_item] {
fn parse_crate_from_source_file(parser p) -> @ast::crate {
auto lo = p.get_lo_pos();
auto m = parse_mod_items(p, token::EOF);
let vec[@ast::crate_directive] cdirs = vec();
let vec[@ast::crate_directive] cdirs = [];
ret @spanned(lo, p.get_lo_pos(), rec(directives=cdirs,
module=m));
}
@ -2362,7 +2362,7 @@ fn parse_crate_directive(parser p) -> ast::crate_directive
fn parse_crate_directives(parser p, token::token term)
-> vec[@ast::crate_directive] {
let vec[@ast::crate_directive] cdirs = vec();
let vec[@ast::crate_directive] cdirs = [];
while (p.peek() != term) {
auto cdir = @parse_crate_directive(p);
@ -2376,7 +2376,7 @@ fn parse_crate_from_crate_file(parser p) -> @ast::crate {
auto lo = p.get_lo_pos();
auto prefix = std::fs::dirname(p.get_filemap().name);
auto cdirs = parse_crate_directives(p, token::EOF);
let vec[str] deps = vec();
let vec[str] deps = [];
auto cx = @rec(p=p,
mode=eval::mode_parse,
mutable deps = deps,

View file

@ -1395,7 +1395,7 @@ obj builder(BuilderRef B, @mutable bool terminated) {
let ValueRef T = llvm::LLVMGetNamedFunction(M,
_str::buf("llvm.trap"));
assert (T as int != 0);
let vec[ValueRef] Args = vec();
let vec[ValueRef] Args = [];
ret llvm::LLVMBuildCall(B, T,
_vec::buf[ValueRef](Args),
_vec::len[ValueRef](Args),
@ -1467,7 +1467,7 @@ fn mk_type_names() -> type_names {
}
fn type_to_str(type_names names, TypeRef ty) -> str {
let vec[TypeRef] v = vec();
let vec[TypeRef] v = [];
ret type_to_str_inner(names, v, ty);
}
@ -1478,7 +1478,7 @@ fn type_to_str_inner(type_names names,
ret names.get_name(ty);
}
auto outer = outer0 + vec(ty);
auto outer = outer0 + [ty];
let int kind = llvm::LLVMGetTypeKind(ty);

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);

View file

@ -31,9 +31,9 @@ type ps = @rec(mutable vec[context] context,
mutable bool potential_brk);
fn mkstate(io::writer out, uint width) -> ps {
let vec[context] stack = vec(rec(tp=cx_v, indent=0u));
let vec[token] buff = vec();
let vec[boxtype] sd = vec();
let vec[context] stack = [rec(tp=cx_v, indent=0u)];
let vec[token] buff = [];
let vec[boxtype] sd = [];
ret @rec(mutable context=stack,
width=width,
out=out,
@ -81,7 +81,7 @@ fn direct_token(ps p, token tok) {
}
fn buffer_token(ps p, token tok) {
p.buffered += vec(tok);
p.buffered += [tok];
auto col = p.scancol;
p.scancol = col + token_size(tok);
if (p.scancol > p.width) {
@ -140,13 +140,13 @@ fn finish_scan(ps p, bool fits) {
push_context(p, cx_h, base_indent(p) + ind);
}
}
p.scandepth = vec();
p.scandepth = [];
p.scanning = scan_none;
for (token t in buf) { add_token(p, t); }
}
fn start_scan(ps p, token tok, scantype tp) {
p.buffered = vec();
p.buffered = [];
p.scancol = p.col;
p.scanning = tp;
buffer_token(p, tok);

View file

@ -307,7 +307,7 @@ fn print_item(ps s, @ast::item item) {
bopen(s);
for (@ast::method meth in _obj.methods) {
hbox(s);
let vec[ast::ty_param] typarams = vec();
let vec[ast::ty_param] typarams = [];
maybe_print_comment(s, meth.span.lo);
print_fn(s, meth.node.meth.decl, meth.node.ident, typarams);
space(s.s);
@ -360,7 +360,7 @@ fn print_literal(ps s, @ast::lit lit) {
alt (lit.node) {
case (ast::lit_str(?st)) {print_string(s, st);}
case (ast::lit_char(?ch)) {
wrd(s.s, "'" + escape_str(_str::from_bytes(vec(ch as u8)), '\'')
wrd(s.s, "'" + escape_str(_str::from_bytes([ch as u8]), '\'')
+ "'");
}
case (ast::lit_int(?val)) {

View file

@ -20,7 +20,7 @@ type interner[T] = rec(
fn mk_interner[T](hashfn[T] hasher, eqfn[T] eqer) -> interner[T] {
auto m = map::mk_hashmap[T,uint](hasher, eqer);
let vec[T] vect = vec();
let vec[T] vect = [];
ret rec(map=m, mutable vect=vect, hasher=hasher, eqer=eqer);
}
@ -30,7 +30,7 @@ fn intern[T](&interner[T] itr, &T val) -> uint {
case (none[uint]) {
auto new_idx = _vec::len[T](itr.vect);
itr.map.insert(val, new_idx);
itr.vect += vec(val);
itr.vect += [val];
ret new_idx;
}
}

View file

@ -141,7 +141,7 @@ fn unsafe_from_bytes(vec[mutable? u8] v) -> str {
}
fn unsafe_from_byte(u8 u) -> str {
ret rustrt::str_from_vec(vec(u));
ret rustrt::str_from_vec([u]);
}
fn str_from_cstr(sbuf cstr) -> str {
@ -248,7 +248,7 @@ fn char_len(str s) -> uint {
}
fn to_chars(str s) -> vec[char] {
let vec[char] buf = vec();
let vec[char] buf = [];
auto i = 0u;
auto len = byte_len(s);
while (i < len) {
@ -419,12 +419,12 @@ fn unshift_byte(&mutable str s, u8 b) {
}
fn split(str s, u8 sep) -> vec[str] {
let vec[str] v = vec();
let vec[str] v = [];
let str accum = "";
let bool ends_with_sep = false;
for (u8 c in s) {
if (c == sep) {
v += vec(accum);
v += [accum];
accum = "";
ends_with_sep = true;
} else {
@ -434,7 +434,7 @@ fn split(str s, u8 sep) -> vec[str] {
}
if (_str::byte_len(accum) != 0u ||
ends_with_sep) {
v += vec(accum);
v += [accum];
}
ret v;
}
@ -486,5 +486,5 @@ fn to_upper(str s) -> str {
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:

View file

@ -75,7 +75,7 @@ fn init_fn[T](&init_op[T] op, uint n_elts) -> vec[T] {
let vec[T] v = alloc[T](n_elts);
let uint i = 0u;
while (i < n_elts) {
v += vec(op(i));
v += [op(i)];
i += 1u;
}
ret v;
@ -85,7 +85,7 @@ fn init_fn_mut[T](&init_op[T] op, uint n_elts) -> vec[mutable T] {
let vec[mutable T] v = alloc_mut[T](n_elts);
let uint i = 0u;
while (i < n_elts) {
v += vec(mutable op(i));
v += [mutable op(i)];
i += 1u;
}
ret v;
@ -103,7 +103,7 @@ fn init_elt[T](&T t, uint n_elts) -> vec[T] {
let uint i = n_elts;
while (i > 0u) {
i -= 1u;
v += vec(t);
v += [t];
}
ret v;
}
@ -113,7 +113,7 @@ fn init_elt_mut[T](&T t, uint n_elts) -> vec[mutable T] {
let uint i = n_elts;
while (i > 0u) {
i -= 1u;
v += vec(mutable t);
v += [mutable t];
}
ret v;
}
@ -156,7 +156,7 @@ fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
auto result = alloc[T](end - start);
let uint i = start;
while (i < end) {
result += vec(v.(i));
result += [v.(i)];
i += 1u;
}
ret result;
@ -180,12 +180,12 @@ fn pop[T](&mutable array[T] v) -> T {
}
fn push[T](&mutable array[T] v, &T t) {
v += vec(t);
v += [t];
}
fn unshift[T](&mutable array[T] v, &T t) {
auto res = alloc[T](len[T](v) + 1u);
res += vec(t);
res += [t];
res += v;
v = res;
}
@ -194,7 +194,7 @@ fn grow[T](&array[T] v, uint n, &T initval) {
let uint i = n;
while (i > 0u) {
i -= 1u;
v += vec(initval);
v += [initval];
}
}
@ -209,7 +209,7 @@ fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) {
fn map[T, U](&option::operator[T,U] f, &array[T] v) -> vec[U] {
let vec[U] u = alloc[U](len[T](v));
for (T ve in v) {
u += vec(f(ve));
u += [f(ve)];
}
ret u;
}
@ -223,7 +223,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &array[T] v0, &array[U] v1) -> vec[V] {
let vec[V] u = alloc[V](v0_len);
auto i = 0u;
while (i < v0_len) {
u += vec(f(v0.(i), v1.(i)));
u += [f(v0.(i), v1.(i))];
i += 1u;
}
@ -262,8 +262,8 @@ fn unzip[T, U](&vec[tup(T, U)] v) -> tup(vec[T], vec[U]) {
else {
auto rest = slice[tup(T, U)](v, 1u, sz);
auto tl = unzip[T, U](rest);
auto a = vec(v.(0)._0);
auto b = vec(v.(0)._1);
auto a = [v.(0)._0];
auto b = [v.(0)._1];
ret tup(a + tl._0, b + tl._1);
}
}
@ -280,18 +280,18 @@ fn clone[T](&vec[T] v) -> vec[T] {
fn plus_option[T](&vec[T] v, &option::t[T] o) -> () {
alt (o) {
case (none[T]) {}
case (some[T](?x)) { v += vec(x); }
case (some[T](?x)) { v += [x]; }
}
}
fn cat_options[T](&vec[option::t[T]] v) -> vec[T] {
let vec[T] res = vec();
let vec[T] res = [];
for (option::t[T] o in v) {
alt (o) {
case (none[T]) { }
case (some[T](?t)) {
res += vec(t);
res += [t];
}
}
}
@ -301,9 +301,9 @@ fn cat_options[T](&vec[option::t[T]] v) -> vec[T] {
// TODO: Remove in favor of built-in "freeze" operation when it's implemented.
fn freeze[T](vec[mutable T] v) -> vec[T] {
let vec[T] result = vec();
let vec[T] result = [];
for (T elem in v) {
result += vec(elem);
result += [elem];
}
ret result;
}

View file

@ -217,6 +217,6 @@ fn eq_vec(&t v0, &vec[uint] v1) -> bool {
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
//

View file

@ -122,22 +122,22 @@ fn write_sized_vint(&io::buf_writer w, uint n, uint size) {
let vec[u8] buf;
alt (size) {
case (1u) {
buf = vec(0x80u8 | (n as u8));
buf = [0x80u8 | (n as u8)];
}
case (2u) {
buf = vec(0x40u8 | ((n >> 8u) as u8),
(n & 0xffu) as u8);
buf = [0x40u8 | ((n >> 8u) as u8),
(n & 0xffu) as u8];
}
case (3u) {
buf = vec(0x20u8 | ((n >> 16u) as u8),
buf = [0x20u8 | ((n >> 16u) as u8),
((n >> 8u) & 0xffu) as u8,
(n & 0xffu) as u8);
(n & 0xffu) as u8];
}
case (4u) {
buf = vec(0x10u8 | ((n >> 24u) as u8),
buf = [0x10u8 | ((n >> 24u) as u8),
((n >> 16u) & 0xffu) as u8,
((n >> 8u) & 0xffu) as u8,
(n & 0xffu) as u8);
(n & 0xffu) as u8];
}
case (_) {
log_err "vint to write too big";
@ -158,7 +158,7 @@ fn write_vint(&io::buf_writer w, uint n) {
}
fn create_writer(&io::buf_writer w) -> writer {
let vec[uint] size_positions = vec();
let vec[uint] size_positions = [];
ret rec(writer=w, mutable size_positions=size_positions);
}
@ -169,8 +169,8 @@ fn start_tag(&writer w, uint tag_id) {
write_vint(w.writer, tag_id);
// Write a placeholder four-byte size.
w.size_positions += vec(w.writer.tell());
let vec[u8] zeroes = vec(0u8, 0u8, 0u8, 0u8);
w.size_positions += [w.writer.tell()];
let vec[u8] zeroes = [0u8, 0u8, 0u8, 0u8];
w.writer.write(zeroes);
}

View file

@ -79,14 +79,14 @@ mod ct {
}
fn parse_fmt_string(str s) -> vec[piece] {
let vec[piece] pieces = vec();
let vec[piece] pieces = [];
auto lim = _str::byte_len(s);
auto buf = "";
fn flush_buf(str buf, &vec[piece] pieces) -> str {
if (_str::byte_len(buf) > 0u) {
auto piece = piece_string(buf);
pieces += vec(piece);
pieces += [piece];
}
ret "";
}
@ -106,7 +106,7 @@ mod ct {
} else {
buf = flush_buf(buf, pieces);
auto res = parse_conversion(s, i, lim);
pieces += vec(res._0);
pieces += [res._0];
i = res._1;
}
} else {
@ -180,7 +180,7 @@ mod ct {
}
fn parse_flags(str s, uint i, uint lim) -> tup(vec[flag], uint) {
let vec[flag] noflags = vec();
let vec[flag] noflags = [];
if (i >= lim) {
ret tup(noflags, i);
@ -190,7 +190,7 @@ mod ct {
auto next = parse_flags(s, i + 1u, lim);
auto rest = next._0;
auto j = next._1;
let vec[flag] curr = vec(f);
let vec[flag] curr = [f];
ret tup(curr + rest, j);
}
@ -539,7 +539,7 @@ mod rt {
|| head == '-' as u8
|| head == ' ' as u8) {
auto headstr = _str::unsafe_from_bytes(vec(head));
auto headstr = _str::unsafe_from_bytes([head]);
auto bytelen = _str::byte_len(s);
auto numpart = _str::substr(s, 1u, bytelen - 1u);
ret headstr + padstr + numpart;
@ -793,7 +793,7 @@ mod RT {
|| head == '-' as u8
|| head == ' ' as u8) {
auto headstr = _str::unsafe_from_bytes(vec(head));
auto headstr = _str::unsafe_from_bytes([head]);
auto bytelen = _str::byte_len(s);
auto numpart = _str::substr(s, 1u, bytelen - 1u);
ret headstr + padstr + numpart;

View file

@ -36,7 +36,7 @@ fn list_dir(path p) -> vec[str] {
if (pl == 0u || p.(pl - 1u) as char != os_fs::path_sep) {
p += path_sep();
}
let vec[str] full_paths = vec();
let vec[str] full_paths = [];
for (str filename in os_fs::list_dir(p)) {
if (!_str::eq(filename, ".")) {if (!_str::eq(filename, "..")) {
_vec::push[str](full_paths, p + filename);

View file

@ -106,7 +106,7 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
fn empty_(uint x) -> vec[optval]{ret _vec::empty[optval]();}
auto f = empty_;
auto vals = _vec::init_fn_mut[vec[optval]](f, n_opts);
let vec[str] free = vec();
let vec[str] free = [];
auto l = _vec::len[str](args);
auto i = 0u;
@ -125,15 +125,15 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
auto tail = _str::slice(cur, 2u, curlen);
auto eq = _str::index(tail, '=' as u8);
if (eq == -1) {
names = vec(long(tail));
names = [long(tail)];
} else {
names = vec(long(_str::slice(tail, 0u, eq as uint)));
names = [long(_str::slice(tail, 0u, eq as uint))];
i_arg = option::some[str]
(_str::slice(tail, (eq as uint) + 1u, curlen - 2u));
}
} else {
auto j = 1u;
names = vec();
names = [];
while (j < curlen) {
auto range = _str::char_range_at(cur, j);
_vec::push[name](names, short(range._0));
@ -221,7 +221,7 @@ fn opt_str(match m, str nm) -> str {
}
}
fn opt_strs(match m, str nm) -> vec[str] {
let vec[str] acc = vec();
let vec[str] acc = [];
for (optval v in opt_vals(m, nm)) {
alt (v) {
case (val(?s)) { _vec::push[str](acc, s); }

View file

@ -120,7 +120,7 @@ state obj new_reader(buf_reader rdr) {
ret rdr.eof();
}
fn read_line() -> str {
let vec[u8] buf = vec();
let vec[u8] buf = [];
// No break yet in rustc
auto go_on = true;
while (go_on) {
@ -131,7 +131,7 @@ state obj new_reader(buf_reader rdr) {
ret _str::unsafe_from_bytes(buf);
}
fn read_c_str() -> str {
let vec[u8] buf = vec();
let vec[u8] buf = [];
auto go_on = true;
while (go_on) {
auto ch = rdr.read_byte();
@ -172,7 +172,7 @@ state obj new_reader(buf_reader rdr) {
ret val;
}
fn read_whole_stream() -> vec[u8] {
let vec[u8] buf = vec();
let vec[u8] buf = [];
while (!rdr.eof()) {
buf += rdr.read(2048u);
}
@ -366,9 +366,9 @@ type writer =
};
fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
let vec[u8] bytes = vec();
let vec[u8] bytes = [];
while (size > 0u) {
bytes += vec((n & 255u) as u8);
bytes += [(n & 255u) as u8];
n >>= 8u;
size -= 1u;
}
@ -376,10 +376,10 @@ fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
}
fn uint_to_be_bytes(uint n, uint size) -> vec[u8] {
let vec[u8] bytes = vec();
let vec[u8] bytes = [];
auto i = (size - 1u) as int;
while (i >= 0) {
bytes += vec(((n >> ((i * 8) as uint)) & 255u) as u8);
bytes += [((n >> ((i * 8) as uint)) & 255u) as u8];
i -= 1;
}
ret bytes;
@ -466,7 +466,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
while (vpos < vlen) {
auto b = v.(vpos);
if (buf.pos == _vec::len(buf.buf)) {
buf.buf += vec(mutable b);
buf.buf += [mutable b];
} else {
buf.buf.(buf.pos) = b;
}
@ -486,7 +486,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
fn string_writer() -> str_writer {
// FIXME: yikes, this is bad. Needs fixing of mutable syntax.
let vec[mutable u8] b = vec(mutable 0u8);
let vec[mutable u8] b = [mutable 0u8];
_vec::pop(b);
let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u);

View file

@ -65,7 +65,7 @@ fn dylib_filename(str base) -> str {
}
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
let vec[mutable int] fds = [mutable 0, 0];
assert (os::libc::pipe(_vec::buf(fds)) == 0);
ret tup(fds.(0), fds.(1));
}
@ -75,7 +75,7 @@ fn fd_FILE(int fd) -> libc::FILE {
}
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
let vec[mutable int] status = [mutable 0];
assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
ret status.(0);
}

View file

@ -62,7 +62,7 @@ fn dylib_filename(str base) -> str {
}
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
let vec[mutable int] fds = [mutable 0, 0];
assert (os::libc::pipe(_vec::buf(fds)) == 0);
ret tup(fds.(0), fds.(1));
}
@ -72,7 +72,7 @@ fn fd_FILE(int fd) -> libc::FILE {
}
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
let vec[mutable int] status = [mutable 0];
assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
ret status.(0);
}

View file

@ -6,7 +6,7 @@ fn list_dir(str path) -> vec[str] {
// TODO ensure this is always closed
auto dir = os::libc::opendir(_str::buf(path));
assert (dir as uint != 0u);
let vec[str] result = vec();
let vec[str] result = [];
while (true) {
auto ent = os::libc::readdir(dir);
if (ent as int == 0) {

View file

@ -5,8 +5,8 @@ native "rust" mod rustrt {
fn rust_run_program(vbuf argv, int in_fd, int out_fd, int err_fd) -> int;
}
fn argvec(str prog, vec[str] args) -> vec[sbuf] {
auto argptrs = vec(_str::buf(prog));
fn arg_vec(str prog, vec[str] args) -> vec[sbuf] {
auto argptrs = [_str::buf(prog)];
for (str arg in args) {
_vec::push[sbuf](argptrs, _str::buf(arg));
}
@ -15,7 +15,7 @@ fn argvec(str prog, vec[str] args) -> vec[sbuf] {
}
fn run_program(str prog, vec[str] args) -> int {
auto pid = rustrt::rust_run_program(_vec::buf[sbuf](argvec(prog, args)),
auto pid = rustrt::rust_run_program(_vec::buf[sbuf](arg_vec(prog, args)),
0, 0, 0);
ret os::waitpid(pid);
}
@ -33,7 +33,7 @@ fn start_program(str prog, vec[str] args) -> @program {
auto pipe_input = os::pipe();
auto pipe_output = os::pipe();
auto pid = rustrt::rust_run_program
(_vec::buf[sbuf](argvec(prog, args)),
(_vec::buf[sbuf](arg_vec(prog, args)),
pipe_input._0, pipe_output._1, 0);
if (pid == -1) {fail;}
os::libc::close(pipe_input._0);
@ -92,5 +92,5 @@ fn program_output(str prog, vec[str] args)
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:

View file

@ -174,13 +174,13 @@ fn mk_sha1() -> sha1 {
st.computed = true;
}
let vec[u8] res = vec();
let vec[u8] res = [];
for (u32 hpart in st.h) {
auto a = (hpart >> 24u32) & 0xFFu32 as u8;
auto b = (hpart >> 16u32) & 0xFFu32 as u8;
auto c = (hpart >> 8u32) & 0xFFu32 as u8;
auto d = (hpart & 0xFFu32 as u8);
res += vec(a,b,c,d);
res += [a,b,c,d];
}
ret res;
}

View file

@ -6,17 +6,17 @@ type lteq[T] = fn(&T a, &T b) -> bool;
fn merge_sort[T](lteq[T] le, vec[T] v) -> vec[T] {
fn merge[T](lteq[T] le, vec[T] a, vec[T] b) -> vec[T] {
let vec[T] res = vec();
let vec[T] res = [];
let uint a_len = len[T](a);
let uint a_ix = 0u;
let uint b_len = len[T](b);
let uint b_ix = 0u;
while (a_ix < a_len && b_ix < b_len) {
if (le(a.(a_ix), b.(b_ix))) {
res += vec(a.(a_ix));
res += [a.(a_ix)];
a_ix += 1u;
} else {
res += vec(b.(b_ix));
res += [b.(b_ix)];
b_ix += 1u;
}
}

View file

@ -22,12 +22,12 @@ const u8 color_bright_cyan = 14u8;
const u8 color_bright_white = 15u8;
fn esc(io::buf_writer writer) {
writer.write(vec(0x1bu8, '[' as u8));
writer.write([0x1bu8, '[' as u8]);
}
fn reset(io::buf_writer writer) {
esc(writer);
writer.write(vec('0' as u8, 'm' as u8));
writer.write(['0' as u8, 'm' as u8]);
}
fn color_supported() -> bool {
@ -39,10 +39,10 @@ fn set_color(io::buf_writer writer, u8 first_char, u8 color) {
esc(writer);
if (color >= 8u8) {
writer.write(vec('1' as u8, ';' as u8));
writer.write(['1' as u8, ';' as u8]);
color -= 8u8;
}
writer.write(vec(first_char, ('0' as u8) + color, 'm' as u8));
writer.write([first_char, ('0' as u8) + color, 'm' as u8]);
}
fn fg(io::buf_writer writer, u8 color) {

View file

@ -7,14 +7,14 @@ type node = option::t[uint];
type ufind = rec(mutable vec[mutable node] nodes);
fn make() -> ufind {
let vec[mutable node] v = vec(mutable none[uint]);
let vec[mutable node] v = [mutable none[uint]];
_vec::pop(v); // FIXME: botch
ret rec(mutable nodes=v);
}
fn make_set(&ufind ufnd) -> uint {
auto idx = _vec::len(ufnd.nodes);
ufnd.nodes += vec(mutable none[uint]);
ufnd.nodes += [mutable none[uint]];
ret idx;
}

View file

@ -52,7 +52,7 @@ fn dylib_filename(str base) -> str {
}
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
let vec[mutable int] fds = [mutable 0, 0];
assert (os::libc::_pipe(_vec::buf(fds), 1024u,
libc_constants::O_BINARY()) == 0);
ret tup(fds.(0), fds.(1));

View file

@ -1,4 +1,7 @@
T
T 2011-05-16 ae030c5
linux-i386 83a6f52df4029b61ebd628795b0a400265c98179
macos-i386 1167e8b782165be738cbd08eeab104ede0d61df6
winnt-i386 456bc38c2bc7ebb27fd008e3ccd05f16f6a31fe6
S 2011-05-12 b1d3364
linux-i386 7671ac0de19d9ea981616b3c58c1d48f1b43820a

View file

@ -28,10 +28,10 @@ type aminoacids = tup(char, u32);
fn make_cumulative(vec[aminoacids] aa) -> vec[aminoacids] {
let u32 cp = 0u32;
let vec[aminoacids] ans = vec();
let vec[aminoacids] ans = [];
for (aminoacids a in aa) {
cp += a._1;
ans += vec(tup(a._0, cp));
ans += [tup(a._0, cp)];
}
ret ans;
}
@ -91,7 +91,7 @@ fn make_repeat_fasta(str id, str desc, str s, int n) {
}
fn main(vec[str] args) {
let vec[aminoacids] iub = make_cumulative(vec(tup( 'a', 27u32 ),
let vec[aminoacids] iub = make_cumulative([tup( 'a', 27u32 ),
tup( 'c', 12u32 ),
tup( 'g', 12u32 ),
tup( 't', 27u32 ),
@ -106,12 +106,12 @@ fn main(vec[str] args) {
tup( 'S', 2u32 ),
tup( 'V', 2u32 ),
tup( 'W', 2u32 ),
tup( 'Y', 2u32 )));
tup( 'Y', 2u32 )]);
let vec[aminoacids] homosapiens = make_cumulative(vec(tup( 'a', 30u32 ),
let vec[aminoacids] homosapiens = make_cumulative([tup( 'a', 30u32 ),
tup( 'c', 20u32 ),
tup( 'g', 20u32 ),
tup( 't', 30u32 )));
tup( 't', 30u32 )]);
let str alu =
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +

View file

@ -7,7 +7,7 @@ native "llvm" mod llvm {
fn main() {
let vec[int] inputs = vec(
let vec[int] inputs = [
50000,
500000
//
@ -16,7 +16,7 @@ fn main() {
// during 'make check' under valgrind
// 5000000
// 50000000
);
];
let vec[Body::props] bodies = NBodySystem::MakeNBodySystem();
@ -38,13 +38,13 @@ fn main() {
mod NBodySystem {
fn MakeNBodySystem() -> vec[Body::props] {
let vec[Body::props] bodies = vec(
let vec[Body::props] bodies = [
// these each return a Body::props
Body::sun(),
Body::jupiter(),
Body::saturn(),
Body::uranus(),
Body::neptune());
Body::neptune()];
let float px = 0.0;
let float py = 0.0;

View file

@ -8,5 +8,5 @@
type x = vec[x];
fn main() {
let x b = vec();
let x b = [];
}

View file

@ -3,6 +3,6 @@
// xfail-stage2
// error-pattern: writing to immutable type
fn main() {
let vec[int] v = vec(1, 2, 3);
let vec[int] v = [1, 2, 3];
v.(1) = 4;
}

View file

@ -6,7 +6,7 @@
// error-pattern:bounds check
fn main() {
let vec[int] v = vec(10);
let vec[int] v = [10];
let int x = 0;
assert (v.(x) == 10);
// Bounds-check failure.

View file

@ -6,7 +6,7 @@
// error-pattern:bounds check
fn main() {
let vec[int] v = vec(10, 20);
let vec[int] v = [10, 20];
let int x = 0;
assert (v.(x) == 10);
// Bounds-check failure.

View file

@ -7,7 +7,7 @@ import std::option::some;
fn foo[T](&option::t[T] y) {
let int x;
let vec[int] res = vec();
let vec[int] res = [];
/* tests that x doesn't get put in the precondition for the
entire if expression */
@ -22,7 +22,7 @@ fn foo[T](&option::t[T] y) {
x = 42;
}
}
res += vec(x);
res += [x];
}
ret;

View file

@ -1,6 +1,6 @@
fn main(vec[str] args) {
let vec[str] vs = vec("hi", "there", "this", "is", "a", "vec");
let vec[vec[str]] vvs = vec(args, vs);
let vec[str] vs = ["hi", "there", "this", "is", "a", "vec"];
let vec[vec[str]] vvs = [args, vs];
for (vec[str] vs in vvs) {
for (str s in vs) {
log s;

View file

@ -13,7 +13,7 @@ fn main() {
} while (i < 30);
assert (i == 20);
for (int x in vec(1, 2, 3, 4, 5, 6)) {
for (int x in [1, 2, 3, 4, 5, 6]) {
if (x == 3) { break; }
assert (x <= 3);
}
@ -32,7 +32,7 @@ fn main() {
assert (i % 2 != 0);
} while (i < 10);
for (int x in vec(1, 2, 3, 4, 5, 6)) {
for (int x in [1, 2, 3, 4, 5, 6]) {
if (x % 2 == 0) { cont; }
assert (x % 2 != 0);
}

View file

@ -1,4 +1,4 @@
fn main() {
let vec[mutable int] v = vec(mutable);
let vec[mutable int] v = [mutable];
}

View file

@ -16,7 +16,7 @@ fn test_vec() {
ret v1 == v2;
}
auto eq = bind compare_vec(_, _);
test_generic[vec[int]](vec(1, 2, 3), eq);
test_generic[vec[int]]([1, 2, 3], eq);
}
fn main() {

View file

@ -12,7 +12,7 @@ fn test_vec() {
ret v1 == v2;
}
auto eq = bind compare_vec(_, _);
test_generic[vec[int]](vec(1, 2), eq);
test_generic[vec[int]]([1, 2], eq);
}
fn main() {

View file

@ -12,7 +12,7 @@ fn test_vec() {
ret v1 == v2;
}
auto eq = bind compare_vec(_, _);
test_generic[vec[int]](vec(1, 2), vec(2, 3), eq);
test_generic[vec[int]]([1, 2], [2, 3], eq);
}
fn main() {

View file

@ -15,7 +15,7 @@ iter range(int start, int stop) -> int {
fn main() {
let vec[mutable int] a =
vec(mutable -1, -1, -1, -1, -1, -1, -1, -1);
[mutable -1, -1, -1, -1, -1, -1, -1, -1];
let int p = 0;
for each (int i in two()) {

View file

@ -6,7 +6,7 @@ iter two() -> int {
}
fn main() {
let vec[mutable int] a = vec(mutable -1, -1, -1, -1);
let vec[mutable int] a = [mutable -1, -1, -1, -1];
let int p = 0;
for each (int i in two()) {

View file

@ -2,7 +2,7 @@
fn main() {
let vec[int] v = vec(0, 1, 2, 3, 4, 5);
let vec[int] v = [0, 1, 2, 3, 4, 5];
let str s = "abcdef";
assert (v.(3u) == 3);
assert (v.(3u8) == 3);

View file

@ -16,10 +16,10 @@ fn test_1_element() {
auto act;
act = bitv::create(1u, false);
assert (bitv::eq_vec(act, vec(0u)));
assert (bitv::eq_vec(act, [0u]));
act = bitv::create(1u, true);
assert (bitv::eq_vec(act, vec(1u)));
assert (bitv::eq_vec(act, [1u]));
}
fn test_10_elements() {
@ -27,11 +27,11 @@ fn test_10_elements() {
// all 0
act = bitv::create(10u, false);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// all 1
act = bitv::create(10u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]));
// mixed
act = bitv::create(10u, false);
@ -40,7 +40,7 @@ fn test_10_elements() {
bitv::set(act, 2u, true);
bitv::set(act, 3u, true);
bitv::set(act, 4u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u)));
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u]));
// mixed
act = bitv::create(10u, false);
@ -49,7 +49,7 @@ fn test_10_elements() {
bitv::set(act, 7u, true);
bitv::set(act, 8u, true);
bitv::set(act, 9u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u)));
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u]));
// mixed
act = bitv::create(10u, false);
@ -57,7 +57,7 @@ fn test_10_elements() {
bitv::set(act, 3u, true);
bitv::set(act, 6u, true);
bitv::set(act, 9u, true);
assert (bitv::eq_vec(act, vec(1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u)));
assert (bitv::eq_vec(act, [1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u]));
}
fn test_31_elements() {
@ -65,17 +65,17 @@ fn test_31_elements() {
// all 0
act = bitv::create(31u, false);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// all 1
act = bitv::create(31u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u)));
1u, 1u, 1u, 1u, 1u, 1u, 1u]));
// mixed
act = bitv::create(31u, false);
@ -87,10 +87,10 @@ fn test_31_elements() {
bitv::set(act, 5u, true);
bitv::set(act, 6u, true);
bitv::set(act, 7u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// mixed
act = bitv::create(31u, false);
@ -102,10 +102,10 @@ fn test_31_elements() {
bitv::set(act, 21u, true);
bitv::set(act, 22u, true);
bitv::set(act, 23u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// mixed
act = bitv::create(31u, false);
@ -116,20 +116,20 @@ fn test_31_elements() {
bitv::set(act, 28u, true);
bitv::set(act, 29u, true);
bitv::set(act, 30u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u)));
1u, 1u, 1u, 1u, 1u, 1u, 1u]));
// mixed
act = bitv::create(31u, false);
bitv::set(act, 3u, true);
bitv::set(act, 17u, true);
bitv::set(act, 30u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 1u)));
0u, 0u, 0u, 0u, 0u, 0u, 1u]));
}
fn test_32_elements() {
@ -137,17 +137,17 @@ fn test_32_elements() {
// all 0
act = bitv::create(32u, false);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// all 1
act = bitv::create(32u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]));
// mixed
act = bitv::create(32u, false);
@ -159,10 +159,10 @@ fn test_32_elements() {
bitv::set(act, 5u, true);
bitv::set(act, 6u, true);
bitv::set(act, 7u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// mixed
act = bitv::create(32u, false);
@ -174,10 +174,10 @@ fn test_32_elements() {
bitv::set(act, 21u, true);
bitv::set(act, 22u, true);
bitv::set(act, 23u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
// mixed
act = bitv::create(32u, false);
@ -189,10 +189,10 @@ fn test_32_elements() {
bitv::set(act, 29u, true);
bitv::set(act, 30u, true);
bitv::set(act, 31u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]));
// mixed
act = bitv::create(32u, false);
@ -200,10 +200,10 @@ fn test_32_elements() {
bitv::set(act, 17u, true);
bitv::set(act, 30u, true);
bitv::set(act, 31u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u)));
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u]));
}
fn test_33_elements() {
@ -211,19 +211,19 @@ fn test_33_elements() {
// all 0
act = bitv::create(33u, false);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u)));
0u]));
// all 1
act = bitv::create(33u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u)));
1u]));
// mixed
act = bitv::create(33u, false);
@ -235,11 +235,11 @@ fn test_33_elements() {
bitv::set(act, 5u, true);
bitv::set(act, 6u, true);
bitv::set(act, 7u, true);
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u)));
0u]));
// mixed
act = bitv::create(33u, false);
@ -251,11 +251,11 @@ fn test_33_elements() {
bitv::set(act, 21u, true);
bitv::set(act, 22u, true);
bitv::set(act, 23u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u)));
0u]));
// mixed
act = bitv::create(33u, false);
@ -267,11 +267,11 @@ fn test_33_elements() {
bitv::set(act, 29u, true);
bitv::set(act, 30u, true);
bitv::set(act, 31u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u)));
0u]));
// mixed
act = bitv::create(33u, false);
@ -280,11 +280,11 @@ fn test_33_elements() {
bitv::set(act, 30u, true);
bitv::set(act, 31u, true);
bitv::set(act, 32u, true);
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
assert (bitv::eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u,
1u)));
1u]));
}
fn main() {

View file

@ -14,7 +14,7 @@ fn test_simple(str tmpfilebase) {
log frood;
{
let io::writer out = io::file_writer(tmpfile, vec(io::create));
let io::writer out = io::file_writer(tmpfile, [io::create]);
out.write_str(frood);
}

View file

@ -19,32 +19,32 @@ fn check_sort(vec[mutable int] v1, vec[mutable int] v2) {
fn main() {
{
auto v1 = vec(mutable 3,7,4,5,2,9,5,8);
auto v2 = vec(mutable 2,3,4,5,5,7,8,9);
auto v1 = [mutable 3,7,4,5,2,9,5,8];
auto v2 = [mutable 2,3,4,5,5,7,8,9];
check_sort(v1, v2);
}
{
auto v1 = vec(mutable 1,1,1);
auto v2 = vec(mutable 1,1,1);
auto v1 = [mutable 1,1,1];
auto v2 = [mutable 1,1,1];
check_sort(v1, v2);
}
{
let vec[mutable int] v1 = vec(mutable);
let vec[mutable int] v2 = vec(mutable);
let vec[mutable int] v1 = [mutable];
let vec[mutable int] v2 = [mutable];
check_sort(v1, v2);
}
{
auto v1 = vec(mutable 9);
auto v2 = vec(mutable 9);
auto v1 = [mutable 9];
auto v2 = [mutable 9];
check_sort(v1, v2);
}
{
auto v1 = vec(mutable 9,3,3,3,9);
auto v2 = vec(mutable 3,3,3,9,9);
auto v1 = [mutable 9,3,3,3,9];
auto v2 = [mutable 3,3,3,9,9];
check_sort(v1, v2);
}

View file

@ -24,44 +24,44 @@ fn main() {
// Test messages from FIPS 180-1
let vec[test] fips_180_1_tests =
vec(
[
rec(input = "abc",
output = vec(0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8,
output = [0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8,
0x06u8, 0x81u8, 0x6Au8, 0xBAu8, 0x3Eu8,
0x25u8, 0x71u8, 0x78u8, 0x50u8, 0xC2u8,
0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8)
0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]
),
rec(input = "abcdbcdecdefdefgefghfghighij"
+ "hijkijkljklmklmnlmnomnopnopq",
output = vec(0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8,
output = [0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8,
0x3Bu8, 0xD2u8, 0x6Eu8, 0xBAu8, 0xAEu8,
0x4Au8, 0xA1u8, 0xF9u8, 0x51u8, 0x29u8,
0xE5u8, 0xE5u8, 0x46u8, 0x70u8, 0xF1u8)
0xE5u8, 0xE5u8, 0x46u8, 0x70u8, 0xF1u8]
),
rec(input = a_million_letter_a(),
output = vec(0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, 0xD4u8,
output = [0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, 0xD4u8,
0xC4u8, 0xDAu8, 0xA4u8, 0xF6u8, 0x1Eu8,
0xEBu8, 0x2Bu8, 0xDBu8, 0xADu8, 0x27u8,
0x31u8, 0x65u8, 0x34u8, 0x01u8, 0x6Fu8)
0x31u8, 0x65u8, 0x34u8, 0x01u8, 0x6Fu8]
)
);
];
// Examples from wikipedia
let vec[test] wikipedia_tests =
vec(
[
rec(input = "The quick brown fox jumps over the lazy dog",
output = vec(0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8,
output = [0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8,
0x2du8, 0x28u8, 0xfcu8, 0xedu8, 0x84u8,
0x9eu8, 0xe1u8, 0xbbu8, 0x76u8, 0xe7u8,
0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8)
0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8]
),
rec(input = "The quick brown fox jumps over the lazy cog",
output = vec(0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8,
output = [0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8,
0x5eu8, 0x1bu8, 0x3au8, 0xfau8, 0xd3u8,
0xe8u8, 0x5au8, 0x0bu8, 0xd1u8, 0x7du8,
0x9bu8, 0x10u8, 0x0du8, 0xb4u8, 0xb3u8)
0x9bu8, 0x10u8, 0x0du8, 0xb4u8, 0xb3u8]
)
);
];
auto tests = fips_180_1_tests + wikipedia_tests;

View file

@ -17,32 +17,32 @@ fn check_sort(vec[int] v1, vec[int] v2) {
fn main() {
{
auto v1 = vec(3,7,4,5,2,9,5,8);
auto v2 = vec(2,3,4,5,5,7,8,9);
auto v1 = [3,7,4,5,2,9,5,8];
auto v2 = [2,3,4,5,5,7,8,9];
check_sort(v1, v2);
}
{
auto v1 = vec(1,1,1);
auto v2 = vec(1,1,1);
auto v1 = [1,1,1];
auto v2 = [1,1,1];
check_sort(v1, v2);
}
{
let vec[int] v1 = vec();
let vec[int] v2 = vec();
let vec[int] v1 = [];
let vec[int] v2 = [];
check_sort(v1, v2);
}
{
auto v1 = vec(9);
auto v2 = vec(9);
auto v1 = [9];
auto v2 = [9];
check_sort(v1, v2);
}
{
auto v1 = vec(9,3,3,3,9);
auto v2 = vec(3,3,3,9,9);
auto v1 = [9,3,3,3,9];
auto v2 = [3,3,3,9,9];
check_sort(v1, v2);
}

View file

@ -73,10 +73,10 @@ fn test_concat() {
assert (_str::eq(_str::concat(v), s));
}
t(vec("you", "know", "I'm", "no", "good"), "youknowI'mnogood");
let vec[str] v = vec();
t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
let vec[str] v = [];
t(v, "");
t(vec("hi"), "hi");
t(["hi"], "hi");
}
fn test_connect() {
@ -84,10 +84,10 @@ fn test_connect() {
assert (_str::eq(_str::connect(v, sep), s));
}
t(vec("you", "know", "I'm", "no", "good"), " ", "you know I'm no good");
let vec[str] v = vec();
t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good");
let vec[str] v = [];
t(v, " ", "");
t(vec("hi"), " ", "hi");
t(["hi"], " ", "hi");
}
fn test_to_upper() {

View file

@ -23,7 +23,7 @@ fn test_init_fn() {
}
fn test_slice() {
let vec[int] v = vec(1,2,3,4,5);
let vec[int] v = [1,2,3,4,5];
auto v2 = std::_vec::slice[int](v, 2u, 4u);
assert (std::_vec::len[int](v2) == 2u);
assert (v2.(0) == 3);
@ -33,7 +33,7 @@ fn test_slice() {
fn test_map() {
fn square(&int x) -> int { ret x * x; }
let std::option::operator[int, int] op = square;
let vec[int] v = vec(1, 2, 3, 4, 5);
let vec[int] v = [1, 2, 3, 4, 5];
let vec[int] s = std::_vec::map[int, int](op, v);
let int i = 0;
while (i < 5) {
@ -45,8 +45,8 @@ fn test_map() {
fn test_map2() {
fn times(&int x, &int y) -> int { ret x * y; }
auto f = times;
auto v0 = vec(1, 2, 3, 4, 5);
auto v1 = vec(5, 4, 3, 2, 1);
auto v0 = [1, 2, 3, 4, 5];
auto v1 = [5, 4, 3, 2, 1];
auto u = std::_vec::map2[int,int,int](f, v0, v1);
auto i = 0;

View file

@ -1,5 +1,5 @@
fn main() {
auto x = vec(1,2,3);
auto x = [1,2,3];
auto y = 0;
for (int i in x) {
log i;

View file

@ -9,9 +9,9 @@ fn len(vec[mutable? int] v) -> uint {
}
fn main() {
auto v0 = vec(1, 2, 3, 4, 5);
auto v0 = [1, 2, 3, 4, 5];
log len(v0);
auto v1 = vec(mutable 1, 2, 3, 4, 5);
auto v1 = [mutable 1, 2, 3, 4, 5];
log len(v1);
}

View file

@ -3,11 +3,11 @@
use std;
fn grow(&mutable vec[int] v) {
v += vec(1);
v += [1];
}
fn main() {
let vec[int] v = vec();
let vec[int] v = [];
grow(v);
grow(v);
grow(v);

View file

@ -2,5 +2,5 @@ fn main() {
// This just tests whether the vec leaks its members.
let vec[mutable @tup(int,int)] pvec =
vec(mutable @tup(1,2), @tup(3,4), @tup(5,6));
[mutable @tup(1,2), @tup(3,4), @tup(5,6)];
}

View file

@ -5,7 +5,7 @@ fn main() {
ret data.(i);
}
}
auto b = buf(vec(1 as u8, 2 as u8, 3 as u8));
auto b = buf([1 as u8, 2 as u8, 3 as u8]);
log b.get(1);
assert (b.get(1) == (2 as u8));
}

View file

@ -3,13 +3,13 @@ fn main() {
assert ("hello " > "hello");
assert ("hello" != "there");
assert (vec(1,2,3,4) > vec(1,2,3));
assert (vec(1,2,3) < vec(1,2,3,4));
assert (vec(1,2,4,4) > vec(1,2,3,4));
assert (vec(1,2,3,4) < vec(1,2,4,4));
assert (vec(1,2,3) <= vec(1,2,3));
assert (vec(1,2,3) <= vec(1,2,3,3));
assert (vec(1,2,3,4) > vec(1,2,3));
assert (vec(1,2,3) == vec(1,2,3));
assert (vec(1,2,3) != vec(1,1,3));
assert ([1,2,3,4] > [1,2,3]);
assert ([1,2,3] < [1,2,3,4]);
assert ([1,2,4,4] > [1,2,3,4]);
assert ([1,2,3,4] < [1,2,4,4]);
assert ([1,2,3] <= [1,2,3]);
assert ([1,2,3] <= [1,2,3,3]);
assert ([1,2,3,4] > [1,2,3]);
assert ([1,2,3] == [1,2,3]);
assert ([1,2,3] != [1,1,3]);
}

View file

@ -13,6 +13,6 @@ fn uhoh[T](vec[clam[T]] v) {
}
fn main() {
let vec[clam[int]] v = vec(b[int], b[int], a[int](42, 17));
let vec[clam[int]] v = [b[int], b[int], a[int](42, 17)];
uhoh[int](v);
}

View file

@ -22,7 +22,7 @@ fn test_rec() {
fn test_vec() {
let port[vec[int]] po = port();
let chan[vec[int]] ch = chan(po);
let vec[int] v0 = vec(0, 1, 2);
let vec[int] v0 = [0, 1, 2];
ch <| v0;

View file

@ -21,13 +21,13 @@ fn test00(bool create_threads) {
let int number_of_tasks = 8;
let int i = 0;
let vec[task] tasks = vec();
let vec[task] tasks = [];
while (i < number_of_tasks) {
i = i + 1;
if (create_threads) {
tasks += vec(spawn thread start(i));
tasks += [spawn thread start(i)];
} else {
tasks += vec(spawn start(i));
tasks += [spawn start(i)];
}
}

View file

@ -31,13 +31,13 @@ fn test00(bool is_multithreaded) {
let int i = 0;
// Create and spawn tasks...
let vec[task] tasks = vec();
let vec[task] tasks = [];
while (i < number_of_tasks) {
if (is_multithreaded) {
tasks += vec(
spawn thread test00_start(ch, i, number_of_messages));
tasks += [
spawn thread test00_start(ch, i, number_of_messages)];
} else {
tasks += vec(spawn test00_start(ch, i, number_of_messages));
tasks += [spawn test00_start(ch, i, number_of_messages)];
}
i = i + 1;
}

View file

@ -33,14 +33,14 @@ fn test00(bool is_multithreaded) {
let int i = 0;
let vec[task] tasks = vec();
let vec[task] tasks = [];
while (i < number_of_tasks) {
i = i + 1;
if (is_multithreaded) {
tasks += vec(
spawn thread test00_start(ch, i, number_of_messages));
tasks += [
spawn thread test00_start(ch, i, number_of_messages)];
} else {
tasks += vec(spawn test00_start(ch, i, number_of_messages));
tasks += [spawn test00_start(ch, i, number_of_messages)];
}
}
@ -147,11 +147,11 @@ fn test06() {
let int i = 0;
let vec[task] tasks = vec();
let vec[task] tasks = [];
while (i < number_of_tasks) {
i = i + 1;
tasks += vec(spawn thread test06_start(i));
// tasks += vec(spawn test06_start(i));
tasks += [spawn thread test06_start(i)];
// tasks += [spawn test06_start(i)];
}
for (task t in tasks) {

View file

@ -9,7 +9,7 @@ iter range(uint lo, uint hi) -> uint {
fn create_index[T](vec[tup(T, uint)] index, fn(&T) -> uint hash_fn) {
for each (uint i in range(0u, 256u)) {
let vec[T] bucket = vec();
let vec[T] bucket = [];
}
}

View file

@ -8,7 +8,7 @@ import std::io;
fn main() {
// Chars of 1, 2, 3, and 4 bytes
let vec[char] chs = vec('e', 'é', '€', 0x10000 as char);
let vec[char] chs = ['e', 'é', '€', 0x10000 as char];
let str s = _str::from_chars(chs);
assert (_str::byte_len(s) == 10u);
@ -19,9 +19,9 @@ fn main() {
assert (_str::char_at(s, 1u) == 'é');
assert (_str::is_utf8(_str::bytes(s)));
assert (!_str::is_utf8(vec(0x80_u8)));
assert (!_str::is_utf8(vec(0xc0_u8)));
assert (!_str::is_utf8(vec(0xc0_u8, 0x10_u8)));
assert (!_str::is_utf8([0x80_u8]));
assert (!_str::is_utf8([0xc0_u8]));
assert (!_str::is_utf8([0xc0_u8, 0x10_u8]));
auto stack = "a×c€";
assert (_str::pop_char(stack) == '€');

View file

@ -13,5 +13,5 @@ fn slice[T](vec[T] e) {
}
fn main() {
slice[str](vec("a"));
slice[str](["a"]);
}

View file

@ -13,8 +13,8 @@ import std::_vec;
const uint const_refcount = 0x7bad_face_u;
fn fast_growth() {
let vec[int] v = vec(1,2,3,4,5);
v += vec(6,7,8,9,0);
let vec[int] v = [1,2,3,4,5];
v += [6,7,8,9,0];
log v.(9);
assert (v.(0) == 1);
@ -23,9 +23,9 @@ fn fast_growth() {
}
fn slow_growth() {
let vec[int] v = vec();
let vec[int] v = [];
let vec[int] u = v;
v += vec(17);
v += [17];
log v.(0);
assert (v.(0) == 17);
@ -34,7 +34,7 @@ fn slow_growth() {
fn slow_growth2_helper(str s) { // ref up: s
obj acc(vec[str] v) {
fn add(&str s) { v += vec(s); }
fn add(&str s) { v += [s]; }
}
let str ss = s; // ref up: s
@ -50,7 +50,7 @@ fn slow_growth2_helper(str s) { // ref up: s
* copy of existing elements should increment the ref count of
* mumble, the existing str in the originally- shared vec.
*/
let vec[str] v = vec(mumble); // ref up: v, mumble
let vec[str] v = [mumble]; // ref up: v, mumble
let acc a = acc(v); // ref up: a, v
log _vec::refcount[str](v);

View file

@ -1,8 +1,8 @@
// -*- rust -*-
fn main() {
let vec[int] a = vec(1,2,3,4,5);
let vec[int] b = vec(6,7,8,9,0);
let vec[int] a = [1,2,3,4,5];
let vec[int] b = [6,7,8,9,0];
let vec[int] v = a + b;
log v.(9);
assert (v.(0) == 1);

View file

@ -1,4 +1,4 @@
fn main() {
// This just tests whether the vec leaks its members.
let vec[@tup(int,int)] pvec = vec(@tup(1,2),@tup(3,4),@tup(5,6));
let vec[@tup(int,int)] pvec = [@tup(1,2),@tup(3,4),@tup(5,6)];
}

View file

@ -1,9 +1,9 @@
fn main() {
auto v = vec(1);
v += vec(2);
v += vec(3);
v += vec(4);
v += vec(5);
auto v = [1];
v += [2];
v += [3];
v += [4];
v += [5];
assert (v.(0) == 1);
assert (v.(1) == 2);
assert (v.(2) == 3);

View file

@ -1,4 +1,4 @@
fn main() {
let tup(mutable vec[int]) i = tup(mutable vec(1,2,3));
i._0 = vec(4,5,6);
let tup(mutable vec[int]) i = tup(mutable [1,2,3]);
i._0 = [4,5,6];
}

View file

@ -1,9 +1,9 @@
fn main() {
let vec[int] later;
if (true) {
later = vec(1);
later = [1];
} else {
later = vec(2);
later = [2];
}
log later.(0);
}

View file

@ -1,9 +1,9 @@
fn push[T](&mutable vec[mutable? T] v, &T t) {
v += vec(t);
v += [t];
}
fn main() {
auto v = @vec(1, 2, 3);
auto v = @[1, 2, 3];
push[int](*v, 1);
}

View file

@ -2,7 +2,7 @@ use std;
import std::_vec;
fn main() {
auto v = vec(1, 2, 3);
auto v = [1, 2, 3];
log_err _vec::refcount[int](v);
log_err _vec::refcount[int](v);
log_err _vec::refcount[int](v);

View file

@ -2,7 +2,7 @@
// xfail-stage1
// xfail-stage2
fn main() {
let vec[int] v = vec(1,2,3,4,5);
let vec[int] v = [1,2,3,4,5];
auto v2 = v.(1,2);
assert (v2.(0) == 2);
assert (v2.(1) == 3);

View file

@ -1,7 +1,7 @@
// -*- rust -*-
fn main() {
let vec[int] v = vec(10, 20);
let vec[int] v = [10, 20];
assert (v.(0) == 10);
assert (v.(1) == 20);
let int x = 0;

View file

@ -6,7 +6,7 @@ fn main() {
log i;
i = i + 1;
if (i == 95) {
let vec[int] v = vec(1,2,3,4,5); // we check that it is freed by break
let vec[int] v = [1,2,3,4,5]; // we check that it is freed by break
log "breaking";
break;
}