diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 98f540de7e816..1fb3bfd039f0a 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -272,13 +272,13 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, type provided_metas = {name: option::t[str], vers: option::t[str], - cmh_items: (@ast::meta_item)[]}; + cmh_items: [@ast::meta_item]}; fn provided_link_metas(sess: &session::session, c: &ast::crate) -> provided_metas { let name: option::t[str] = none; let vers: option::t[str] = none; - let cmh_items: (@ast::meta_item)[] = ~[]; + let cmh_items: [@ast::meta_item] = ~[]; let linkage_metas = attr::find_linkage_metas(c.node.attrs); attr::require_unique_names(sess, linkage_metas); for meta: @ast::meta_item in linkage_metas { @@ -412,7 +412,7 @@ fn get_symbol_hash(ccx: &@crate_ctxt, t: &ty::t) -> str { ret hash; } -fn mangle(ss: &str[]) -> str { +fn mangle(ss: &[str]) -> str { // Follow C++ namespace-mangling style let n = "_ZN"; // Begin name-sequence. @@ -423,14 +423,14 @@ fn mangle(ss: &str[]) -> str { ret n; } -fn exported_name(path: &str[], hash: &str, vers: &str) -> str { +fn exported_name(path: &[str], hash: &str, vers: &str) -> str { // FIXME: versioning isn't working yet ret mangle(path + ~[hash]); // + "@" + vers; } -fn mangle_exported_name(ccx: &@crate_ctxt, path: &str[], t: &ty::t) -> str { +fn mangle_exported_name(ccx: &@crate_ctxt, path: &[str], t: &ty::t) -> str { let hash = get_symbol_hash(ccx, t); ret exported_name(path, hash, ccx.link_meta.vers); } @@ -442,12 +442,12 @@ fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: &ty::t, name: &str) ret mangle(~[name, s, hash]); } -fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &str[], +fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[str], flav: &str) -> str { ret mangle(path + ~[ccx.names.next(flav)]); } -fn mangle_internal_name_by_path(ccx: &@crate_ctxt, path: &str[]) -> str { +fn mangle_internal_name_by_path(ccx: &@crate_ctxt, path: &[str]) -> str { ret mangle(path); } diff --git a/src/comp/back/upcall.rs b/src/comp/back/upcall.rs index 1f7dab3a3d6a6..44d5cb9bb34ac 100644 --- a/src/comp/back/upcall.rs +++ b/src/comp/back/upcall.rs @@ -70,9 +70,9 @@ type upcalls = fn declare_upcalls(tn: type_names, tydesc_type: TypeRef, taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls { fn decl(tn: type_names, tydesc_type: TypeRef, taskptr_type: TypeRef, - llmod: ModuleRef, name: str, tys: TypeRef[], rv: TypeRef) -> + llmod: ModuleRef, name: str, tys: [TypeRef], rv: TypeRef) -> ValueRef { - let arg_tys: TypeRef[] = ~[taskptr_type]; + let arg_tys: [TypeRef] = ~[taskptr_type]; for t: TypeRef in tys { arg_tys += ~[t]; } let fn_ty = T_fn(arg_tys, rv); ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty); @@ -82,7 +82,7 @@ fn declare_upcalls(tn: type_names, tydesc_type: TypeRef, // FIXME: Sigh:.. remove this when I fix the typechecker pushdown. // --pcwalton - let empty_vec: TypeRef[] = ~[]; + let empty_vec: [TypeRef] = ~[]; ret @{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()]), diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs index 2ded0723845ab..ebb9672374cbf 100644 --- a/src/comp/driver/session.rs +++ b/src/comp/driver/session.rs @@ -37,7 +37,7 @@ type options = time_passes: bool, time_llvm_passes: bool, output_type: back::link::output_type, - library_search_paths: str[], + library_search_paths: [str], sysroot: str, cfg: ast::crate_cfg, test: bool, @@ -46,7 +46,7 @@ type options = no_trans: bool }; -type crate_metadata = {name: str, data: u8[]}; +type crate_metadata = {name: str, data: [u8]}; obj session(targ_cfg: @config, opts: @options, diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index a8361ba64eedb..061193022cbdc 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -29,8 +29,8 @@ export mk_attr; // From a list of crate attributes get only the meta_items that impact crate // linkage -fn find_linkage_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] { - let metas: (@ast::meta_item)[] = ~[]; +fn find_linkage_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] { + let metas: [@ast::meta_item] = ~[]; for attr: ast::attribute in find_attrs_by_name(attrs, "link") { alt attr.node.value.node { ast::meta_list(_, items) { metas += items; } @@ -41,8 +41,8 @@ fn find_linkage_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] { } // Search a list of attributes and return only those with a specific name -fn find_attrs_by_name(attrs: &ast::attribute[], name: ast::ident) -> - ast::attribute[] { +fn find_attrs_by_name(attrs: &[ast::attribute], name: ast::ident) -> + [ast::attribute] { let filter = bind fn (a: &ast::attribute, name: ast::ident) -> option::t[ast::attribute] { @@ -57,8 +57,8 @@ fn get_attr_name(attr: &ast::attribute) -> ast::ident { get_meta_item_name(@attr.node.value) } -fn find_meta_items_by_name(metas: &(@ast::meta_item)[], name: ast::ident) -> - (@ast::meta_item)[] { +fn find_meta_items_by_name(metas: &[@ast::meta_item], name: ast::ident) -> + [@ast::meta_item] { let filter = bind fn (m: &@ast::meta_item, name: ast::ident) -> option::t[@ast::meta_item] { @@ -94,7 +94,7 @@ fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t[str] { fn attr_meta(attr: &ast::attribute) -> @ast::meta_item { @attr.node.value } // Get the meta_items from inside a vector of attributes -fn attr_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] { +fn attr_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] { let mitems = ~[]; for a: ast::attribute in attrs { mitems += ~[attr_meta(a)]; } ret mitems; @@ -121,7 +121,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { } } -fn contains(haystack: &(@ast::meta_item)[], needle: @ast::meta_item) -> bool { +fn contains(haystack: &[@ast::meta_item], needle: @ast::meta_item) -> bool { log #fmt("looking for %s", syntax::print::pprust::meta_item_to_str(*needle)); for item: @ast::meta_item in haystack { @@ -133,13 +133,13 @@ fn contains(haystack: &(@ast::meta_item)[], needle: @ast::meta_item) -> bool { ret false; } -fn contains_name(metas: &(@ast::meta_item)[], name: ast::ident) -> bool { +fn contains_name(metas: &[@ast::meta_item], name: ast::ident) -> bool { let matches = find_meta_items_by_name(metas, name); ret ivec::len(matches) > 0u; } // FIXME: This needs to sort by meta_item variant in addition to the item name -fn sort_meta_items(items: &(@ast::meta_item)[]) -> (@ast::meta_item)[] { +fn sort_meta_items(items: &[@ast::meta_item]) -> [@ast::meta_item] { fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool { fn key(m: &@ast::meta_item) -> ast::ident { alt m.node { @@ -152,18 +152,18 @@ fn sort_meta_items(items: &(@ast::meta_item)[]) -> (@ast::meta_item)[] { } // This is sort of stupid here, converting to a vec of mutables and back - let v: (@ast::meta_item)[mutable ] = ~[mutable ]; + let v: [mutable @ast::meta_item] = ~[mutable]; for mi: @ast::meta_item in items { v += ~[mutable mi]; } std::sort::ivector::quick_sort(lteq, v); - let v2: (@ast::meta_item)[] = ~[]; + let v2: [@ast::meta_item] = ~[]; for mi: @ast::meta_item in v { v2 += ~[mi]; } ret v2; } -fn remove_meta_items_by_name(items: &(@ast::meta_item)[], name: str) -> - (@ast::meta_item)[] { +fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) -> + [@ast::meta_item] { let filter = bind fn (item: &@ast::meta_item, name: str) -> @@ -177,7 +177,7 @@ fn remove_meta_items_by_name(items: &(@ast::meta_item)[], name: str) -> } fn require_unique_names(sess: &session::session, - metas: &(@ast::meta_item)[]) { + metas: &[@ast::meta_item]) { let map = map::mk_hashmap[str, ()](str::hash, str::eq); for meta: @ast::meta_item in metas { let name = get_meta_item_name(meta); @@ -202,7 +202,7 @@ fn mk_name_value_item(name: ast::ident, value: ast::lit) -> @ast::meta_item { ret @span(ast::meta_name_value(name, value)); } -fn mk_list_item(name: ast::ident, items: &(@ast::meta_item)[]) -> +fn mk_list_item(name: ast::ident, items: &[@ast::meta_item]) -> @ast::meta_item { ret @span(ast::meta_list(name, items)); } diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs index e1e580f191eca..fb5222b0c5750 100644 --- a/src/comp/front/config.rs +++ b/src/comp/front/config.rs @@ -91,7 +91,7 @@ fn native_item_in_cfg(cfg: &ast::crate_cfg, item: &@ast::native_item) -> // Determine if an item should be translated in the current crate // configuration based on the item's attributes -fn in_cfg(cfg: &ast::crate_cfg, attrs: &ast::attribute[]) -> bool { +fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool { // The "cfg" attributes on the item let item_cfg_attrs = attr::find_attrs_by_name(attrs, "cfg"); @@ -103,9 +103,9 @@ fn in_cfg(cfg: &ast::crate_cfg, attrs: &ast::attribute[]) -> bool { // which the item is valid let item_cfg_metas = { - fn extract_metas(inner_items: &(@ast::meta_item)[], + fn extract_metas(inner_items: &[@ast::meta_item], cfg_item: &@ast::meta_item) -> - (@ast::meta_item)[] { + [@ast::meta_item] { alt cfg_item.node { ast::meta_list(name, items) { assert (name == "cfg"); diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs index 23dadca206e5f..8604b64880876 100644 --- a/src/comp/front/test.rs +++ b/src/comp/front/test.rs @@ -11,12 +11,12 @@ export modify_for_testing; type node_id_gen = @fn() -> ast::node_id ; -type test = {path: ast::ident[], ignore: bool}; +type test = {path: [ast::ident], ignore: bool}; type test_ctxt = @{next_node_id: node_id_gen, - mutable path: ast::ident[], - mutable testfns: test[]}; + mutable path: [ast::ident], + mutable testfns: [test]}; // Traverse the crate, collecting all the test functions, eliding any // existing main functions, and synthesizing a main test harness @@ -139,7 +139,7 @@ mod __test { std::test::test_main(args, tests()) } - fn tests() -> std::test::test_desc[] { + fn tests() -> [std::test::test_desc] { ... the list of tests in the crate ... } } @@ -211,7 +211,7 @@ fn empty_fn_ty() -> ast::ty { ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs)); } -// The ast::ty of std::test::test_desc[] +// The ast::ty of [std::test::test_desc] fn mk_test_desc_ivec_ty(cx: &test_ctxt) -> @ast::ty { let test_desc_ty_path: ast::path = nospan({global: false, diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 9f08bbb9476ff..62ad92ac380f7 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -909,7 +909,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool, ret llvm::LLVMBuildRet(B, V); } - fn AggregateRet(RetVals: &ValueRef[]) -> ValueRef { + fn AggregateRet(RetVals: &[ValueRef]) -> ValueRef { assert (!*terminated); *terminated = true; ret llvm::LLVMBuildAggregateRet(B, ivec::to_ptr(RetVals), @@ -941,7 +941,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool, ret llvm::LLVMBuildIndirectBr(B, Addr, NumDests); } - fn Invoke(Fn: ValueRef, Args: &ValueRef[], Then: BasicBlockRef, + fn Invoke(Fn: ValueRef, Args: &[ValueRef], Then: BasicBlockRef, Catch: BasicBlockRef) -> ValueRef { assert (!*terminated); *terminated = true; @@ -1151,13 +1151,13 @@ obj builder(B: BuilderRef, terminated: @mutable bool, ret llvm::LLVMBuildStore(B, Val, Ptr); } - fn GEP(Pointer: ValueRef, Indices: &ValueRef[]) -> ValueRef { + fn GEP(Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef { assert (!*terminated); ret llvm::LLVMBuildGEP(B, Pointer, ivec::to_ptr(Indices), ivec::len(Indices), str::buf("")); } - fn InBoundsGEP(Pointer: ValueRef, Indices: &ValueRef[]) -> ValueRef { + fn InBoundsGEP(Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef { assert (!*terminated); ret llvm::LLVMBuildInBoundsGEP(B, Pointer, ivec::to_ptr(Indices), ivec::len(Indices), str::buf("")); @@ -1289,7 +1289,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool, /* Miscellaneous instructions */ - fn Phi(Ty: TypeRef, vals: &ValueRef[], bbs: &BasicBlockRef[]) -> + fn Phi(Ty: TypeRef, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef { assert (!*terminated); let phi = llvm::LLVMBuildPhi(B, Ty, str::buf("")); @@ -1299,20 +1299,20 @@ obj builder(B: BuilderRef, terminated: @mutable bool, ret phi; } - fn AddIncomingToPhi(phi: ValueRef, vals: &ValueRef[], - bbs: &BasicBlockRef[]) { + fn AddIncomingToPhi(phi: ValueRef, vals: &[ValueRef], + bbs: &[BasicBlockRef]) { assert (ivec::len[ValueRef](vals) == ivec::len[BasicBlockRef](bbs)); llvm::LLVMAddIncoming(phi, ivec::to_ptr(vals), ivec::to_ptr(bbs), ivec::len(vals)); } - fn Call(Fn: ValueRef, Args: &ValueRef[]) -> ValueRef { + fn Call(Fn: ValueRef, Args: &[ValueRef]) -> ValueRef { assert (!*terminated); ret llvm::LLVMBuildCall(B, Fn, ivec::to_ptr(Args), ivec::len(Args), str::buf("")); } - fn FastCall(Fn: ValueRef, Args: &ValueRef[]) -> ValueRef { + fn FastCall(Fn: ValueRef, Args: &[ValueRef]) -> ValueRef { assert (!*terminated); let v = llvm::LLVMBuildCall(B, Fn, ivec::to_ptr(Args), ivec::len(Args), @@ -1321,7 +1321,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool, ret v; } - fn CallWithConv(Fn: ValueRef, Args: &ValueRef[], Conv: uint) -> ValueRef { + fn CallWithConv(Fn: ValueRef, Args: &[ValueRef], Conv: uint) -> ValueRef { assert (!*terminated); let v = llvm::LLVMBuildCall(B, Fn, ivec::to_ptr(Args), ivec::len(Args), @@ -1392,7 +1392,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool, let T: ValueRef = llvm::LLVMGetNamedFunction(M, str::buf("llvm.trap")); assert (T as int != 0); - let Args: ValueRef[] = ~[]; + let Args: [ValueRef] = ~[]; ret llvm::LLVMBuildCall(B, T, ivec::to_ptr(Args), ivec::len(Args), str::buf("")); } @@ -1447,7 +1447,7 @@ fn type_to_str(names: type_names, ty: TypeRef) -> str { ret type_to_str_inner(names, ~[], ty); } -fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) -> +fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) -> str { if names.type_has_name(ty) { ret names.get_name(ty); } @@ -1456,7 +1456,7 @@ fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) -> let kind: int = llvm::LLVMGetTypeKind(ty); - fn tys_str(names: type_names, outer: &TypeRef[], tys: &TypeRef[]) -> str { + fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str { let s: str = ""; let first: bool = true; for t: TypeRef in tys { @@ -1493,7 +1493,7 @@ fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) -> let s = "fn("; let out_ty: TypeRef = llvm::LLVMGetReturnType(ty); let n_args: uint = llvm::LLVMCountParamTypes(ty); - let args: TypeRef[] = ivec::init_elt[TypeRef](0 as TypeRef, n_args); + let args: [TypeRef] = ivec::init_elt[TypeRef](0 as TypeRef, n_args); llvm::LLVMGetParamTypes(ty, ivec::to_ptr(args)); s += tys_str(names, outer, args); s += ") -> "; @@ -1505,7 +1505,7 @@ fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) -> 9 { let s: str = "{"; let n_elts: uint = llvm::LLVMCountStructElementTypes(ty); - let elts: TypeRef[] = ivec::init_elt[TypeRef](0 as TypeRef, n_elts); + let elts: [TypeRef] = ivec::init_elt[TypeRef](0 as TypeRef, n_elts); llvm::LLVMGetStructElementTypes(ty, ivec::to_ptr(elts)); s += tys_str(names, outer, elts); s += "}"; @@ -1552,7 +1552,7 @@ fn float_width(llt: TypeRef) -> uint { }; } -fn fn_ty_param_tys(fn_ty: TypeRef) -> TypeRef[] { +fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] { let args = ivec::init_elt(0 as TypeRef, llvm::LLVMCountParamTypes(fn_ty)); llvm::LLVMGetParamTypes(fn_ty, ivec::to_ptr(args)); ret args; diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs index b0fa97f7ea9ee..0bca7e600e325 100644 --- a/src/comp/metadata/creader.rs +++ b/src/comp/metadata/creader.rs @@ -46,7 +46,7 @@ fn read_crates(sess: session::session, crate: &ast::crate) { type env = @{sess: session::session, crate_cache: @hashmap[str, int], - library_search_paths: str[], + library_search_paths: [str], mutable next_crate_num: ast::crate_num}; fn visit_view_item(e: env, i: &@ast::view_item) { @@ -89,7 +89,7 @@ fn list_file_metadata(path: str, out: ioivec::writer) { } } -fn metadata_matches(crate_data: &@u8[], metas: &(@ast::meta_item)[]) -> bool { +fn metadata_matches(crate_data: &@[u8], metas: &[@ast::meta_item]) -> bool { let attrs = decoder::get_crate_attributes(crate_data); let linkage_metas = attr::find_linkage_metas(attrs); @@ -116,9 +116,9 @@ fn default_native_lib_naming(sess: session::session, static: bool) -> } fn find_library_crate(sess: &session::session, ident: &ast::ident, - metas: &(@ast::meta_item)[], - library_search_paths: &str[]) -> - option::t[{ident: str, data: @u8[]}] { + metas: &[@ast::meta_item], + library_search_paths: &[str]) -> + option::t[{ident: str, data: @[u8]}] { attr::require_unique_names(sess, metas); @@ -146,9 +146,9 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident, } fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str, - metas: &(@ast::meta_item)[], - library_search_paths: &str[]) -> - option::t[{ident: str, data: @u8[]}] { + metas: &[@ast::meta_item], + library_search_paths: &[str]) -> + option::t[{ident: str, data: @[u8]}] { let prefix: str = nn.prefix + crate_name; // FIXME: we could probably use a 'glob' function in std::fs but it will // be much easier to write once the unsafe module knows more about FFI @@ -183,10 +183,10 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str, ret none; } -fn get_metadata_section(filename: str) -> option::t[@u8[]] { +fn get_metadata_section(filename: str) -> option::t[@[u8]] { let b = str::buf(filename); let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(b); - if mb as int == 0 { ret option::none[@u8[]]; } + if mb as int == 0 { ret option::none[@[u8]]; } let of = mk_object_file(mb); let si = mk_section_iter(of.llof); while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False { @@ -196,17 +196,17 @@ fn get_metadata_section(filename: str) -> option::t[@u8[]] { let cbuf = llvm::LLVMGetSectionContents(si.llsi); let csz = llvm::LLVMGetSectionSize(si.llsi); let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf); - ret option::some[@u8[]](@ivec::unsafe::from_buf(cvbuf, csz)); + ret option::some[@[u8]](@ivec::unsafe::from_buf(cvbuf, csz)); } llvm::LLVMMoveToNextSection(si.llsi); } - ret option::none[@u8[]]; + ret option::none[@[u8]]; } fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident, - metas: &(@ast::meta_item)[], - library_search_paths: &str[]) -> - {ident: str, data: @u8[]} { + metas: &[@ast::meta_item], + library_search_paths: &[str]) -> + {ident: str, data: @[u8]} { alt find_library_crate(sess, ident, metas, library_search_paths) { @@ -217,7 +217,7 @@ fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident, } } -fn resolve_crate(e: env, ident: ast::ident, metas: (@ast::meta_item)[], +fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item], span: span) -> ast::crate_num { if !e.crate_cache.contains_key(ident) { let cinfo = @@ -245,7 +245,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: (@ast::meta_item)[], } // Go through the crate metadata and load any crates that it references -fn resolve_crate_deps(e: env, cdata: &@u8[]) -> cstore::cnum_map { +fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map { log "resolving deps of external crate"; // The map from crate numbers in the crate we're resolving to local crate // numbers diff --git a/src/comp/metadata/csearch.rs b/src/comp/metadata/csearch.rs index 7a397fff317c8..d526ee05247b2 100644 --- a/src/comp/metadata/csearch.rs +++ b/src/comp/metadata/csearch.rs @@ -22,12 +22,12 @@ fn get_type_param_count(cstore: &cstore::cstore, def: &ast::def_id) -> uint { } fn lookup_defs(cstore: &cstore::cstore, cnum: ast::crate_num, - path: &ast::ident[]) -> ast::def[] { + path: &[ast::ident]) -> [ast::def] { let cdata = cstore::get_crate_data(cstore, cnum).data; ret decoder::lookup_defs(cdata, cnum, path); } -fn get_tag_variants(tcx: ty::ctxt, def: ast::def_id) -> ty::variant_info[] { +fn get_tag_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] { let cstore = tcx.sess.get_cstore(); let cnum = def.crate; let cdata = cstore::get_crate_data(cstore, cnum).data; diff --git a/src/comp/metadata/cstore.rs b/src/comp/metadata/cstore.rs index 1b1249b8f9bd4..bebd695fda15e 100644 --- a/src/comp/metadata/cstore.rs +++ b/src/comp/metadata/cstore.rs @@ -29,7 +29,7 @@ export get_use_stmt_cnum; // own crate numbers. type cnum_map = map::hashmap[ast::crate_num, ast::crate_num]; -type crate_metadata = {name: str, data: @u8[], cnum_map: cnum_map}; +type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map}; // This is a bit of an experiment at encapsulating the data in cstore. By // keeping all the data in a non-exported tag variant, it's impossible for @@ -41,9 +41,9 @@ tag cstore { private(cstore_private); } type cstore_private = @{metas: map::hashmap[ast::crate_num, crate_metadata], use_crate_map: use_crate_map, - mutable used_crate_files: str[], - mutable used_libraries: str[], - mutable used_link_args: str[]}; + mutable used_crate_files: [str], + mutable used_libraries: [str], + mutable used_link_args: [str]}; // Map from node_id's of local use statements to crate numbers type use_crate_map = map::hashmap[ast::node_id, ast::crate_num]; @@ -88,7 +88,7 @@ fn add_used_crate_file(cstore: &cstore, lib: &str) { } } -fn get_used_crate_files(cstore: &cstore) -> str[] { +fn get_used_crate_files(cstore: &cstore) -> [str] { ret p(cstore).used_crate_files; } @@ -101,7 +101,7 @@ fn add_used_library(cstore: &cstore, lib: &str) -> bool { ret true; } -fn get_used_libraries(cstore: &cstore) -> str[] { +fn get_used_libraries(cstore: &cstore) -> [str] { ret p(cstore).used_libraries; } @@ -114,7 +114,7 @@ fn add_used_link_args(cstore: &cstore, args: &str) { } } -fn get_used_link_args(cstore: &cstore) -> str[] { +fn get_used_link_args(cstore: &cstore) -> [str] { ret p(cstore).used_link_args; } diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs index 45c9dcf3b37aa..56bd7754290a6 100644 --- a/src/comp/metadata/decoder.rs +++ b/src/comp/metadata/decoder.rs @@ -35,8 +35,8 @@ export external_resolver; // build. type external_resolver = fn(&ast::def_id) -> ast::def_id ; -fn lookup_hash(d: &ebmlivec::doc, eq_fn: fn(&u8[]) -> bool , hash: uint) -> - ebmlivec::doc[] { +fn lookup_hash(d: &ebmlivec::doc, eq_fn: fn(&[u8]) -> bool , hash: uint) -> + [ebmlivec::doc] { let index = ebmlivec::get_doc(d, tag_index); let table = ebmlivec::get_doc(index, tag_index_table); let hash_pos = table.start + hash % 256u * 4u; @@ -44,7 +44,7 @@ fn lookup_hash(d: &ebmlivec::doc, eq_fn: fn(&u8[]) -> bool , hash: uint) -> let bucket = ebmlivec::doc_at(d.data, pos); // Awkward logic because we can't ret from foreach yet - let result: ebmlivec::doc[] = ~[]; + let result: [ebmlivec::doc] = ~[]; let belt = tag_index_buckets_bucket_elt; for each elt: ebmlivec::doc in ebmlivec::tagged_docs(bucket, belt) { let pos = ebmlivec::be_uint_from_bytes(elt.data, elt.start, 4u); @@ -57,7 +57,7 @@ fn lookup_hash(d: &ebmlivec::doc, eq_fn: fn(&u8[]) -> bool , hash: uint) -> fn maybe_find_item(item_id: int, items: &ebmlivec::doc) -> option::t[ebmlivec::doc] { - fn eq_item(bytes: &u8[], item_id: int) -> bool { + fn eq_item(bytes: &[u8], item_id: int) -> bool { ret ebmlivec::be_uint_from_bytes(@bytes, 0u, 4u) as int == item_id; } let eqer = bind eq_item(_, item_id); @@ -73,7 +73,7 @@ fn find_item(item_id: int, items: &ebmlivec::doc) -> ebmlivec::doc { // Looks up an item in the given metadata and returns an ebmlivec doc pointing // to the item data. -fn lookup_item(item_id: int, data: &@u8[]) -> ebmlivec::doc { +fn lookup_item(item_id: int, data: &@[u8]) -> ebmlivec::doc { let items = ebmlivec::get_doc(ebmlivec::new_doc(data), tag_items); ret find_item(item_id, items); } @@ -114,11 +114,11 @@ fn item_type(item: &ebmlivec::doc, this_cnum: ast::crate_num, tcx: ty::ctxt, def_parser, tcx); } -fn item_ty_param_kinds(item: &ebmlivec::doc) -> ast::kind[] { - let ks: ast::kind[] = ~[]; +fn item_ty_param_kinds(item: &ebmlivec::doc) -> [ast::kind] { + let ks: [ast::kind] = ~[]; let tp = tag_items_data_item_ty_param_kinds; for each p: ebmlivec::doc in ebmlivec::tagged_docs(item, tp) { - let dat : u8[] = ebmlivec::doc_data(p); + let dat : [u8] = ebmlivec::doc_data(p); let vi = ebmlivec::vint_at(dat, 0u); let i = 0u; while i < vi.val { @@ -135,8 +135,8 @@ fn item_ty_param_kinds(item: &ebmlivec::doc) -> ast::kind[] { } fn tag_variant_ids(item: &ebmlivec::doc, this_cnum: ast::crate_num) -> - ast::def_id[] { - let ids: ast::def_id[] = ~[]; + [ast::def_id] { + let ids: [ast::def_id] = ~[]; let v = tag_items_data_item_variant; for each p: ebmlivec::doc in ebmlivec::tagged_docs(item, v) { let ext = parse_def_id(ebmlivec::doc_data(p)); @@ -147,15 +147,15 @@ fn tag_variant_ids(item: &ebmlivec::doc, this_cnum: ast::crate_num) -> // Given a path and serialized crate metadata, returns the ID of the // definition the path refers to. -fn resolve_path(path: &ast::ident[], data: @u8[]) -> ast::def_id[] { - fn eq_item(data: &u8[], s: str) -> bool { +fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] { + fn eq_item(data: &[u8], s: str) -> bool { ret str::eq(str::unsafe_from_bytes_ivec(data), s); } let s = str::connect_ivec(path, "::"); let md = ebmlivec::new_doc(data); let paths = ebmlivec::get_doc(md, tag_paths); let eqer = bind eq_item(_, s); - let result: ast::def_id[] = ~[]; + let result: [ast::def_id] = ~[]; for doc: ebmlivec::doc in lookup_hash(paths, eqer, hash_path(s)) { let did_doc = ebmlivec::get_doc(doc, tag_def_id); result += ~[parse_def_id(ebmlivec::doc_data(did_doc))]; @@ -164,14 +164,14 @@ fn resolve_path(path: &ast::ident[], data: @u8[]) -> ast::def_id[] { } // Crate metadata queries -fn lookup_defs(data: &@u8[], cnum: ast::crate_num, path: &ast::ident[]) -> - ast::def[] { +fn lookup_defs(data: &@[u8], cnum: ast::crate_num, path: &[ast::ident]) -> + [ast::def] { ret ivec::map(bind lookup_def(cnum, data, _), resolve_path(path, data)); } // FIXME doesn't yet handle re-exported externals -fn lookup_def(cnum: ast::crate_num, data: @u8[], did_: &ast::def_id) -> +fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: &ast::def_id) -> ast::def { let item = lookup_item(did_.node, data); let fam_ch = item_family(item); @@ -197,13 +197,13 @@ fn lookup_def(cnum: ast::crate_num, data: @u8[], did_: &ast::def_id) -> ret def; } -fn get_type(data: @u8[], def: ast::def_id, tcx: &ty::ctxt, +fn get_type(data: @[u8], def: ast::def_id, tcx: &ty::ctxt, extres: &external_resolver) -> ty::ty_param_kinds_and_ty { let this_cnum = def.crate; let node_id = def.node; let item = lookup_item(node_id, data); let t = item_type(item, this_cnum, tcx, extres); - let tp_kinds : ast::kind[]; + let tp_kinds : [ast::kind]; let fam_ch = item_family(item); let has_ty_params = family_has_type_params(fam_ch); if has_ty_params { @@ -212,31 +212,31 @@ fn get_type(data: @u8[], def: ast::def_id, tcx: &ty::ctxt, ret {kinds: tp_kinds, ty: t}; } -fn get_type_param_count(data: @u8[], id: ast::node_id) -> uint { +fn get_type_param_count(data: @[u8], id: ast::node_id) -> uint { ret ivec::len(get_type_param_kinds(data, id)); } -fn get_type_param_kinds(data: @u8[], id: ast::node_id) -> ast::kind[] { +fn get_type_param_kinds(data: @[u8], id: ast::node_id) -> [ast::kind] { ret item_ty_param_kinds(lookup_item(id, data)); } -fn get_symbol(data: @u8[], id: ast::node_id) -> str { +fn get_symbol(data: @[u8], id: ast::node_id) -> str { ret item_symbol(lookup_item(id, data)); } -fn get_tag_variants(data: &@u8[], def: ast::def_id, tcx: &ty::ctxt, - extres: &external_resolver) -> ty::variant_info[] { +fn get_tag_variants(data: &@[u8], def: ast::def_id, tcx: &ty::ctxt, + extres: &external_resolver) -> [ty::variant_info] { let external_crate_id = def.crate; let data = cstore::get_crate_data(tcx.sess.get_cstore(), external_crate_id).data; let items = ebmlivec::get_doc(ebmlivec::new_doc(data), tag_items); let item = find_item(def.node, items); - let infos: ty::variant_info[] = ~[]; + let infos: [ty::variant_info] = ~[]; let variant_ids = tag_variant_ids(item, external_crate_id); for did: ast::def_id in variant_ids { let item = find_item(did.node, items); let ctor_ty = item_type(item, external_crate_id, tcx, extres); - let arg_tys: ty::t[] = ~[]; + let arg_tys: [ty::t] = ~[]; alt ty::struct(tcx, ctor_ty) { ty::ty_fn(_, args, _, _, _) { for a: ty::arg in args { arg_tys += ~[a.ty]; } @@ -294,8 +294,8 @@ fn item_family_to_str(fam: u8) -> str { } } -fn get_meta_items(md: &ebmlivec::doc) -> (@ast::meta_item)[] { - let items: (@ast::meta_item)[] = ~[]; +fn get_meta_items(md: &ebmlivec::doc) -> [@ast::meta_item] { + let items: [@ast::meta_item] = ~[]; for each meta_item_doc: ebmlivec::doc in ebmlivec::tagged_docs(md, tag_meta_item_word) { let nd = ebmlivec::get_doc(meta_item_doc, tag_meta_item_name); @@ -322,8 +322,8 @@ fn get_meta_items(md: &ebmlivec::doc) -> (@ast::meta_item)[] { ret items; } -fn get_attributes(md: &ebmlivec::doc) -> ast::attribute[] { - let attrs: ast::attribute[] = ~[]; +fn get_attributes(md: &ebmlivec::doc) -> [ast::attribute] { + let attrs: [ast::attribute] = ~[]; alt ebmlivec::maybe_get_doc(md, tag_attributes) { option::some(attrs_d) { for each attr_doc: ebmlivec::doc in @@ -359,14 +359,14 @@ fn list_crate_attributes(md: &ebmlivec::doc, out: ioivec::writer) { out.write_str("\n\n"); } -fn get_crate_attributes(data: @u8[]) -> ast::attribute[] { +fn get_crate_attributes(data: @[u8]) -> [ast::attribute] { ret get_attributes(ebmlivec::new_doc(data)); } type crate_dep = {cnum: ast::crate_num, ident: str}; -fn get_crate_deps(data: @u8[]) -> crate_dep[] { - let deps: crate_dep[] = ~[]; +fn get_crate_deps(data: @[u8]) -> [crate_dep] { + let deps: [crate_dep] = ~[]; let cratedoc = ebmlivec::new_doc(data); let depsdoc = ebmlivec::get_doc(cratedoc, tag_crate_deps); let crate_num = 1; @@ -379,7 +379,7 @@ fn get_crate_deps(data: @u8[]) -> crate_dep[] { ret deps; } -fn list_crate_deps(data: @u8[], out: ioivec::writer) { +fn list_crate_deps(data: @[u8], out: ioivec::writer) { out.write_str("=External Dependencies=\n"); for dep: crate_dep in get_crate_deps(data) { @@ -389,7 +389,7 @@ fn list_crate_deps(data: @u8[], out: ioivec::writer) { out.write_str("\n"); } -fn list_crate_items(bytes: &@u8[], md: &ebmlivec::doc, out: ioivec::writer) { +fn list_crate_items(bytes: &@[u8], md: &ebmlivec::doc, out: ioivec::writer) { out.write_str("=Items=\n"); let paths = ebmlivec::get_doc(md, tag_paths); let items = ebmlivec::get_doc(md, tag_items); @@ -410,7 +410,7 @@ fn list_crate_items(bytes: &@u8[], md: &ebmlivec::doc, out: ioivec::writer) { out.write_str("\n"); } -fn list_crate_metadata(bytes: &@u8[], out: ioivec::writer) { +fn list_crate_metadata(bytes: &@[u8], out: ioivec::writer) { let md = ebmlivec::new_doc(bytes); list_crate_attributes(md, out); list_crate_deps(bytes, out); diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index 6649cca29a385..c0af681745323 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -38,8 +38,8 @@ fn encode_def_id(ebml_w: &ebmlivec::writer, id: &def_id) { type entry[T] = {val: T, pos: uint}; -fn encode_tag_variant_paths(ebml_w: &ebmlivec::writer, variants: &variant[], - path: &str[], index: &mutable (entry[str])[]) { +fn encode_tag_variant_paths(ebml_w: &ebmlivec::writer, variants: &[variant], + path: &[str], index: &mutable [entry[str]]) { for variant: variant in variants { add_to_index(ebml_w, path, index, variant.node.name); ebmlivec::start_tag(ebml_w, tag_paths_data_item); @@ -49,8 +49,8 @@ fn encode_tag_variant_paths(ebml_w: &ebmlivec::writer, variants: &variant[], } } -fn add_to_index(ebml_w: &ebmlivec::writer, path: &str[], - index: &mutable (entry[str])[], name: &str) { +fn add_to_index(ebml_w: &ebmlivec::writer, path: &[str], + index: &mutable [entry[str]], name: &str) { let full_path = path + ~[name]; index += ~[{val: str::connect_ivec(full_path, "::"), @@ -58,8 +58,8 @@ fn add_to_index(ebml_w: &ebmlivec::writer, path: &str[], } fn encode_native_module_item_paths(ebml_w: &ebmlivec::writer, - nmod: &native_mod, path: &str[], - index: &mutable (entry[str])[]) { + nmod: &native_mod, path: &[str], + index: &mutable [entry[str]]) { for nitem: @native_item in nmod.items { add_to_index(ebml_w, path, index, nitem.ident); ebmlivec::start_tag(ebml_w, tag_paths_data_item); @@ -70,7 +70,7 @@ fn encode_native_module_item_paths(ebml_w: &ebmlivec::writer, } fn encode_module_item_paths(ebml_w: &ebmlivec::writer, module: &_mod, - path: &str[], index: &mutable (entry[str])[]) { + path: &[str], index: &mutable [entry[str]]) { for it: @item in module.items { if !is_exported(it.ident, module) { cont; } alt it.node { @@ -149,9 +149,9 @@ fn encode_module_item_paths(ebml_w: &ebmlivec::writer, module: &_mod, } fn encode_item_paths(ebml_w: &ebmlivec::writer, crate: &@crate) -> - (entry[str])[] { - let index: (entry[str])[] = ~[]; - let path: str[] = ~[]; + [entry[str]] { + let index: [entry[str]] = ~[]; + let path: [str] = ~[]; ebmlivec::start_tag(ebml_w, tag_paths); encode_module_item_paths(ebml_w, crate.node.module, path, index); ebmlivec::end_tag(ebml_w); @@ -174,7 +174,7 @@ fn encode_inlineness(ebml_w: &ebmlivec::writer, c: u8) { fn def_to_str(did: &def_id) -> str { ret #fmt("%d:%d", did.crate, did.node); } -fn encode_type_param_kinds(ebml_w: &ebmlivec::writer, tps: &ty_param[]) { +fn encode_type_param_kinds(ebml_w: &ebmlivec::writer, tps: &[ty_param]) { ebmlivec::start_tag(ebml_w, tag_items_data_item_ty_param_kinds); ebmlivec::write_vint(ebml_w.writer, ivec::len[ty_param](tps)); for tp: ty_param in tps { @@ -225,9 +225,9 @@ fn encode_tag_id(ebml_w: &ebmlivec::writer, id: &def_id) { } fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer, - id: node_id, variants: &variant[], - index: &mutable (entry[int])[], - ty_params: &ty_param[]) { + id: node_id, variants: &[variant], + index: &mutable [entry[int]], + ty_params: &[ty_param]) { for variant: variant in variants { index += ~[{val: variant.node.id, pos: ebml_w.writer.tell()}]; ebmlivec::start_tag(ebml_w, tag_items_data_item); @@ -246,7 +246,7 @@ fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer, } fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: &ebmlivec::writer, - item: @item, index: &mutable (entry[int])[]) { + item: @item, index: &mutable [entry[int]]) { alt item.node { item_const(_, _) { ebmlivec::start_tag(ebml_w, tag_items_data_item); @@ -368,8 +368,8 @@ fn encode_info_for_native_item(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer, } fn encode_info_for_items(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer) -> - (entry[int])[] { - let index: (entry[int])[] = ~[]; + [entry[int]] { + let index: [entry[int]] = ~[]; ebmlivec::start_tag(ebml_w, tag_items_data); for each kvp: @{key: node_id, val: middle::ast_map::ast_node} in ecx.ccx.ast_map.items() { @@ -392,9 +392,9 @@ fn encode_info_for_items(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer) -> // Path and definition ID indexing -fn create_index[T](index: &(entry[T])[], hash_fn: fn(&T) -> uint ) -> - (@(entry[T])[])[] { - let buckets: (@mutable (entry[T])[])[] = ~[]; +fn create_index[T](index: &[entry[T]], hash_fn: fn(&T) -> uint ) -> + [@[entry[T]]] { + let buckets: [@mutable [entry[T]]] = ~[]; for each i: uint in uint::range(0u, 256u) { buckets += ~[@mutable ~[]]; } for elt: entry[T] in index { let h = hash_fn(elt.val); @@ -402,19 +402,19 @@ fn create_index[T](index: &(entry[T])[], hash_fn: fn(&T) -> uint ) -> } let buckets_frozen = ~[]; - for bucket: @mutable (entry[T])[] in buckets { + for bucket: @mutable [entry[T]] in buckets { buckets_frozen += ~[@*bucket]; } ret buckets_frozen; } -fn encode_index[T](ebml_w: &ebmlivec::writer, buckets: &(@(entry[T])[])[], +fn encode_index[T](ebml_w: &ebmlivec::writer, buckets: &[@[entry[T]]], write_fn: fn(&ioivec::writer, &T) ) { let writer = ioivec::new_writer_(ebml_w.writer); ebmlivec::start_tag(ebml_w, tag_index); - let bucket_locs: uint[] = ~[]; + let bucket_locs: [uint] = ~[]; ebmlivec::start_tag(ebml_w, tag_index_buckets); - for bucket: @(entry[T])[] in buckets { + for bucket: @[entry[T]] in buckets { bucket_locs += ~[ebml_w.writer.tell()]; ebmlivec::start_tag(ebml_w, tag_index_buckets_bucket); for elt: entry[T] in *bucket { @@ -475,7 +475,7 @@ fn encode_meta_item(ebml_w: &ebmlivec::writer, mi: &meta_item) { } } -fn encode_attributes(ebml_w: &ebmlivec::writer, attrs: &attribute[]) { +fn encode_attributes(ebml_w: &ebmlivec::writer, attrs: &[attribute]) { ebmlivec::start_tag(ebml_w, tag_attributes); for attr: attribute in attrs { ebmlivec::start_tag(ebml_w, tag_attribute); @@ -489,9 +489,9 @@ fn encode_attributes(ebml_w: &ebmlivec::writer, attrs: &attribute[]) { // metadata that Rust cares about for linking crates. This attribute requires // 'name' and 'vers' items, so if the user didn't provide them we will throw // them in anyway with default values. -fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> attribute[] { +fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] { - fn synthesize_link_attr(ecx: &@encode_ctxt, items: &(@meta_item)[]) -> + fn synthesize_link_attr(ecx: &@encode_ctxt, items: &[@meta_item]) -> attribute { assert (ecx.ccx.link_meta.name != ""); @@ -514,7 +514,7 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> attribute[] { ret attr::mk_attr(link_item); } - let attrs: attribute[] = ~[]; + let attrs: [attribute] = ~[]; let found_link_attr = false; for attr: attribute in crate.node.attrs { attrs += @@ -538,12 +538,12 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> attribute[] { fn encode_crate_deps(ebml_w: &ebmlivec::writer, cstore: &cstore::cstore) { - fn get_ordered_names(cstore: &cstore::cstore) -> str[] { + fn get_ordered_names(cstore: &cstore::cstore) -> [str] { type hashkv = @{key: crate_num, val: cstore::crate_metadata}; type numname = {crate: crate_num, ident: str}; // Pull the cnums and names out of cstore - let pairs: numname[mutable ] = ~[mutable ]; + let pairs: [mutable numname] = ~[mutable]; for each hashkv: hashkv in cstore::iter_crate_data(cstore) { pairs += ~[mutable {crate: hashkv.key, ident: hashkv.val.name}]; } diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index a54b8622bb0b3..286d59e401a86 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -22,7 +22,7 @@ export parse_ty_data; type str_def = fn(str) -> ast::def_id ; type pstate = - {data: @u8[], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt}; + {data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt}; tag ty_or_bang { a_ty(ty::t); a_bang; } @@ -49,7 +49,7 @@ fn parse_ident_(st: @pstate, sd: str_def, is_last: fn(char) -> bool ) -> } -fn parse_ty_data(data: @u8[], crate_num: int, pos: uint, len: uint, +fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, len: uint, sd: str_def, tcx: ty::ctxt) -> ty::t { let st = @{data: data, crate: crate_num, mutable pos: pos, len: len, tcx: tcx}; @@ -64,8 +64,8 @@ fn parse_ty_or_bang(st: @pstate, sd: str_def) -> ty_or_bang { } } -fn parse_constrs(st: @pstate, sd: str_def) -> (@ty::constr)[] { - let rslt: (@ty::constr)[] = ~[]; +fn parse_constrs(st: @pstate, sd: str_def) -> [@ty::constr] { + let rslt: [@ty::constr] = ~[]; alt peek(st) as char { ':' { do { @@ -81,8 +81,8 @@ fn parse_constrs(st: @pstate, sd: str_def) -> (@ty::constr)[] { } // FIXME less copy-and-paste -fn parse_ty_constrs(st: @pstate, sd: str_def) -> (@ty::type_constr)[] { - let rslt: (@ty::type_constr)[] = ~[]; +fn parse_ty_constrs(st: @pstate, sd: str_def) -> [@ty::type_constr] { + let rslt: [@ty::type_constr] = ~[]; alt peek(st) as char { ':' { do { @@ -98,7 +98,7 @@ fn parse_ty_constrs(st: @pstate, sd: str_def) -> (@ty::type_constr)[] { } fn parse_path(st: @pstate, sd: str_def) -> ast::path { - let idents: ast::ident[] = ~[]; + let idents: [ast::ident] = ~[]; fn is_last(c: char) -> bool { ret c == '(' || c == ':'; } idents += ~[parse_ident_(st, sd, is_last)]; while true { @@ -153,7 +153,7 @@ fn parse_ty_constr_arg(st: @pstate, sd: str_def) -> fn parse_constr[@T](st: @pstate, sd: str_def, pser: arg_parser[T]) -> @ty::constr_general[T] { let sp = {lo: 0u, hi: 0u}; // FIXME: use a real span - let args: (@sp_constr_arg[T])[] = ~[]; + let args: [@sp_constr_arg[T]] = ~[]; let pth: path = parse_path(st, sd); let ignore: char = next(st) as char; assert (ignore as char == '('); @@ -197,7 +197,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { 't' { assert (next(st) as char == '['); let def = parse_def(st, sd); - let params: ty::t[] = ~[]; + let params: [ty::t] = ~[]; while peek(st) as char != ']' { params += ~[parse_ty(st, sd)]; } st.pos = st.pos + 1u; ret ty::mk_tag(st.tcx, def, params); @@ -223,7 +223,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { 'C' { ret ty::mk_chan(st.tcx, parse_ty(st, sd)); } 'R' { assert (next(st) as char == '['); - let fields: ty::field[] = ~[]; + let fields: [ty::field] = ~[]; while peek(st) as char != ']' { let name = ""; while peek(st) as char != '=' { @@ -264,7 +264,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { } 'O' { assert (next(st) as char == '['); - let methods: ty::method[] = ~[]; + let methods: [ty::method] = ~[]; while peek(st) as char != ']' { let proto; alt next(st) as char { @@ -291,7 +291,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { assert (next(st) as char == '['); let def = parse_def(st, sd); let inner = parse_ty(st, sd); - let params: ty::t[] = ~[]; + let params: [ty::t] = ~[]; while peek(st) as char != ']' { params += ~[parse_ty(st, sd)]; } st.pos = st.pos + 1u; ret ty::mk_res(st.tcx, def, inner, params); @@ -369,9 +369,9 @@ fn parse_hex(st: @pstate) -> uint { } fn parse_ty_fn(st: @pstate, sd: str_def) -> - {args: ty::arg[], ty: ty::t, cf: ast::controlflow, cs: (@ty::constr)[]} { + {args: [ty::arg], ty: ty::t, cf: ast::controlflow, cs: [@ty::constr]} { assert (next(st) as char == '['); - let inputs: ty::arg[] = ~[]; + let inputs: [ty::arg] = ~[]; while peek(st) as char != ']' { let mode = ty::mo_val; if peek(st) as char == '&' { @@ -396,7 +396,7 @@ fn parse_ty_fn(st: @pstate, sd: str_def) -> // Rust metadata parsing -fn parse_def_id(buf: &u8[]) -> ast::def_id { +fn parse_def_id(buf: &[u8]) -> ast::def_id { let colon_idx = 0u; let len = ivec::len[u8](buf); while colon_idx < len && buf.(colon_idx) != ':' as u8 { colon_idx += 1u; } diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index 6227876a7b307..b41da9f8cfa9b 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -199,8 +199,8 @@ fn enc_proto(w: &ioivec::writer, proto: proto) { } } -fn enc_ty_fn(w: &ioivec::writer, cx: &@ctxt, args: &ty::arg[], out: &ty::t, - cf: &controlflow, constrs: &(@ty::constr)[]) { +fn enc_ty_fn(w: &ioivec::writer, cx: &@ctxt, args: &[ty::arg], out: &ty::t, + cf: &controlflow, constrs: &[@ty::constr]) { w.write_char('['); for arg: ty::arg in args { alt arg.mode { diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index d6aca1cf36c04..2eefe1c9f5d21 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -25,14 +25,14 @@ import std::option::is_none; tag valid { valid; overwritten(span, ast::path); val_taken(span, ast::path); } type restrict = - @{root_vars: node_id[], + @{root_vars: [node_id], block_defnum: node_id, - bindings: node_id[], - tys: ty::t[], - depends_on: uint[], + bindings: [node_id], + tys: [ty::t], + depends_on: [uint], mutable ok: valid}; -type scope = @restrict[]; +type scope = @[restrict]; tag local_info { arg(ast::mode); objfield(ast::mutability); } @@ -51,7 +51,7 @@ fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) { tcx.sess.abort_if_errors(); } -fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &ast::ty_param[], sp: &span, +fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &[ast::ty_param], sp: &span, name: &fn_ident, id: ast::node_id, sc: &scope, v: &vt[scope]) { visit::visit_fn_decl(f.decl, sc, v); for arg_: ast::arg in f.decl.inputs { @@ -164,14 +164,14 @@ fn visit_decl(cx: &@ctx, d: &@ast::decl, sc: &scope, v: &vt[scope]) { } } -fn check_call(cx: &ctx, f: &@ast::expr, args: &(@ast::expr)[], sc: &scope) -> - {root_vars: node_id[], unsafe_ts: ty::t[]} { +fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope) -> + {root_vars: [node_id], unsafe_ts: [ty::t]} { let fty = ty::expr_ty(cx.tcx, f); let arg_ts = fty_args(cx, fty); - let roots: node_id[] = ~[]; - let mut_roots: {arg: uint, node: node_id}[] = ~[]; - let unsafe_ts: ty::t[] = ~[]; - let unsafe_t_offsets: uint[] = ~[]; + let roots: [node_id] = ~[]; + let mut_roots: [{arg: uint, node: node_id}] = ~[]; + let unsafe_ts: [ty::t] = ~[]; + let unsafe_t_offsets: [uint] = ~[]; let i = 0u; for arg_t: ty::arg in arg_ts { if arg_t.mode != ty::mo_val { @@ -308,13 +308,13 @@ fn check_tail_call(cx: &ctx, call: &@ast::expr) { } } -fn check_alt(cx: &ctx, input: &@ast::expr, arms: &ast::arm[], sc: &scope, +fn check_alt(cx: &ctx, input: &@ast::expr, arms: &[ast::arm], sc: &scope, v: &vt[scope]) { visit::visit_expr(input, sc, v); let root = expr_root(cx, input, true); let roots = alt path_def_id(cx, root.ex) { some(did) { ~[did.node] } _ { ~[] } }; - let forbidden_tp: ty::t[] = + let forbidden_tp: [ty::t] = alt inner_mut(root.ds) { some(t) { ~[t] } _ { ~[] } }; for a: ast::arm in arms { let dnums = arm_defnums(a); @@ -331,7 +331,7 @@ fn check_alt(cx: &ctx, input: &@ast::expr, arms: &ast::arm[], sc: &scope, } } -fn arm_defnums(arm: &ast::arm) -> node_id[] { +fn arm_defnums(arm: &ast::arm) -> [node_id] { ret ast::pat_binding_ids(arm.pats.(0)); } @@ -506,7 +506,7 @@ fn test_scope(cx: &ctx, sc: &scope, r: &restrict, p: &ast::path) { } } -fn deps(sc: &scope, roots: &node_id[]) -> uint[] { +fn deps(sc: &scope, roots: &[node_id]) -> [uint] { let i = 0u; let result = ~[]; for r: restrict in *sc { @@ -528,8 +528,8 @@ type deref = @{mut: bool, kind: deref_t, outer_t: ty::t}; // the inner derefs come in front, so foo.bar.baz becomes rec(ex=foo, // ds=[field(baz),field(bar)]) fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) -> - {ex: @ast::expr, ds: @deref[]} { - fn maybe_auto_unbox(cx: &ctx, t: ty::t) -> {t: ty::t, ds: deref[]} { + {ex: @ast::expr, ds: @[deref]} { + fn maybe_auto_unbox(cx: &ctx, t: ty::t) -> {t: ty::t, ds: [deref]} { let ds = ~[]; while true { alt ty::struct(cx.tcx, t) { @@ -557,7 +557,7 @@ fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) -> } ret {t: t, ds: ds}; } - let ds: deref[] = ~[]; + let ds: [deref] = ~[]; while true { alt { ex.node } { ast::expr_field(base, ident) { @@ -621,12 +621,12 @@ fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) -> ret {ex: ex, ds: @ds}; } -fn mut_field(ds: &@deref[]) -> bool { +fn mut_field(ds: &@[deref]) -> bool { for d: deref in *ds { if d.mut { ret true; } } ret false; } -fn inner_mut(ds: &@deref[]) -> option::t[ty::t] { +fn inner_mut(ds: &@[deref]) -> option::t[ty::t] { for d: deref in *ds { if d.mut { ret some(d.outer_t); } } ret none; } @@ -701,7 +701,7 @@ fn def_is_local(d: &ast::def, objfields_count: bool) -> bool { }; } -fn fty_args(cx: &ctx, fty: ty::t) -> ty::arg[] { +fn fty_args(cx: &ctx, fty: ty::t) -> [ty::arg] { ret alt ty::struct(cx.tcx, ty::type_autoderef(cx.tcx, fty)) { ty::ty_fn(_, args, _, _, _) | ty::ty_native_fn(_, args, _) { args } }; diff --git a/src/comp/middle/check_alt.rs b/src/comp/middle/check_alt.rs index c0053ecc56d88..b3feeeb3fecd8 100644 --- a/src/comp/middle/check_alt.rs +++ b/src/comp/middle/check_alt.rs @@ -15,7 +15,7 @@ fn check_expr(tcx: &ty::ctxt, ex: &@expr, s: &(), v: &visit::vt[()]) { alt ex.node { expr_alt(_, arms) { check_arms(tcx, arms); } _ { } } } -fn check_arms(tcx: &ty::ctxt, arms: &arm[]) { +fn check_arms(tcx: &ty::ctxt, arms: &[arm]) { let i = 0; for arm: arm in arms { for arm_pat: @pat in arm.pats { @@ -38,7 +38,7 @@ fn check_arms(tcx: &ty::ctxt, arms: &arm[]) { } fn pattern_supersedes(tcx: &ty::ctxt, a: &@pat, b: &@pat) -> bool { - fn patterns_supersede(tcx: &ty::ctxt, as: &(@pat)[], bs: &(@pat)[]) -> + fn patterns_supersede(tcx: &ty::ctxt, as: &[@pat], bs: &[@pat]) -> bool { let i = 0; for a: @pat in as { @@ -47,8 +47,8 @@ fn pattern_supersedes(tcx: &ty::ctxt, a: &@pat, b: &@pat) -> bool { } ret true; } - fn field_patterns_supersede(tcx: &ty::ctxt, fas: &field_pat[], - fbs: &field_pat[]) -> bool { + fn field_patterns_supersede(tcx: &ty::ctxt, fas: &[field_pat], + fbs: &[field_pat]) -> bool { let wild = @{id: 0, node: pat_wild, span: {lo: 0u, hi: 0u}}; for fa: field_pat in fas { let pb = wild; diff --git a/src/comp/middle/freevars.rs b/src/comp/middle/freevars.rs index 4b3ac5739dd3c..fa1cc2aa09346 100644 --- a/src/comp/middle/freevars.rs +++ b/src/comp/middle/freevars.rs @@ -30,7 +30,7 @@ export def_lookup; // testing membership, the list of referencing sites is what you want for most // other things. type freevar_set = hashset[ast::node_id]; -type freevar_info = {defs: freevar_set, refs: @ast::node_id[]}; +type freevar_info = {defs: freevar_set, refs: @[ast::node_id]}; type freevar_map = hashmap[ast::node_id, freevar_info]; // Searches through part of the AST for all references to locals or @@ -40,12 +40,12 @@ type freevar_map = hashmap[ast::node_id, freevar_info]; // in order to start the search. fn collect_freevars(def_map: &resolve::def_map, sess: &session::session, walker: &fn(&visit::vt[()]) , - initial_decls: ast::node_id[]) -> freevar_info { + initial_decls: [ast::node_id]) -> freevar_info { let decls = new_int_hash(); for decl: ast::node_id in initial_decls { set_add(decls, decl); } let refs = @mutable ~[]; - let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], sp: &span, + let walk_fn = lambda(f: &ast::_fn, tps: &[ast::ty_param], sp: &span, i: &ast::fn_ident, nid: ast::node_id) { for a: ast::arg in f.decl.inputs { set_add(decls, a.id); } }; @@ -107,7 +107,7 @@ fn annotate_freevars(sess: &session::session, def_map: &resolve::def_map, crate: &@ast::crate) -> freevar_map { let freevars = new_int_hash(); - let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], sp: &span, + let walk_fn = lambda(f: &ast::_fn, tps: &[ast::ty_param], sp: &span, i: &ast::fn_ident, nid: ast::node_id) { let start_walk = lambda(v: &visit::vt[()]) { v.visit_fn(f, tps, sp, i, nid, (), v); @@ -148,7 +148,7 @@ fn get_freevar_info(tcx: &ty::ctxt, fid: ast::node_id) -> freevar_info { fn get_freevar_defs(tcx: &ty::ctxt, fid: ast::node_id) -> freevar_set { ret get_freevar_info(tcx, fid).defs; } -fn get_freevars(tcx: &ty::ctxt, fid: ast::node_id) -> @ast::node_id[] { +fn get_freevars(tcx: &ty::ctxt, fid: ast::node_id) -> @[ast::node_id] { ret get_freevar_info(tcx, fid).refs; } fn has_freevars(tcx: &ty::ctxt, fid: ast::node_id) -> bool { diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 5aa955e7c44f0..d1e9236d035bf 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -49,7 +49,7 @@ export def_map; tag scope { scope_crate; scope_item(@ast::item); - scope_fn(ast::fn_decl, ast::proto, ast::ty_param[]); + scope_fn(ast::fn_decl, ast::proto, [ast::ty_param]); scope_native_item(@ast::native_item); scope_loop(@ast::local); // there's only 1 decl per loop. @@ -104,7 +104,7 @@ type glob_imp_def = {def: def, item: @ast::view_item}; type indexed_mod = {m: option::t[ast::_mod], index: mod_index, - mutable glob_imports: glob_imp_def[], + mutable glob_imports: [glob_imp_def], glob_imported_names: hashmap[str, import_state]}; @@ -119,9 +119,9 @@ type env = ast_map: ast_map::map, imports: hashmap[ast::node_id, import_state], mod_map: hashmap[ast::node_id, @indexed_mod], - ext_map: hashmap[def_id, ident[]], + ext_map: hashmap[def_id, [ident]], ext_cache: ext_hash, - mutable reported: {ident: str, sc: scope}[], + mutable reported: [{ident: str, sc: scope}], sess: session}; @@ -139,7 +139,7 @@ fn resolve_crate(sess: session, amap: &ast_map::map, crate: @ast::crate) -> ast_map: amap, imports: new_int_hash[import_state](), mod_map: new_int_hash[@indexed_mod](), - ext_map: new_def_hash[ident[]](), + ext_map: new_def_hash[[ident]](), ext_cache: new_ext_hash(), mutable reported: ~[], sess: sess}; @@ -327,7 +327,7 @@ fn visit_native_item_with_scope(ni: &@ast::native_item, sc: &scopes, visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v); } -fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &ast::ty_param[], +fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &[ast::ty_param], sp: &span, name: &fn_ident, id: node_id, sc: &scopes, v: &vt[scopes]) { // is this a main fn declaration? @@ -375,7 +375,7 @@ fn visit_expr_with_scope(x: &@ast::expr, sc: &scopes, v: &vt[scopes]) { } } -fn follow_import(e: &env, sc: &scopes, path: &ident[], sp: &span) -> +fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) -> option::t[def] { let path_len = ivec::len(path); let dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module); @@ -701,7 +701,7 @@ fn lookup_in_scope(e: &env, sc: scopes, sp: &span, name: &ident, } -fn lookup_in_ty_params(name: &ident, ty_params: &ast::ty_param[]) -> +fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) -> option::t[def] { let i = 0u; for tp: ast::ty_param in ty_params { @@ -738,7 +738,7 @@ fn lookup_in_pat(name: &ident, pat: &ast::pat) -> option::t[def_id] { } fn lookup_in_fn(name: &ident, decl: &ast::fn_decl, - ty_params: &ast::ty_param[], ns: namespace) -> + ty_params: &[ast::ty_param], ns: namespace) -> option::t[def] { alt ns { ns_value. { @@ -754,7 +754,7 @@ fn lookup_in_fn(name: &ident, decl: &ast::fn_decl, } } -fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &ast::ty_param[], +fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param], ns: namespace) -> option::t[def] { alt ns { ns_value. { @@ -1138,7 +1138,7 @@ fn ns_for_def(d: def) -> namespace { }; } -fn lookup_external(e: &env, cnum: int, ids: &ident[], ns: namespace) -> +fn lookup_external(e: &env, cnum: int, ids: &[ident], ns: namespace) -> option::t[def] { for d: def in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids) { e.ext_map.insert(ast::def_id_of_def(d), ids); @@ -1211,8 +1211,8 @@ fn mie_span(mie: &mod_index_entry) -> span { } fn check_item(e: &@env, i: &@ast::item, x: &(), v: &vt[()]) { - fn typaram_names(tps: &ast::ty_param[]) -> ident[] { - let x: ast::ident[] = ~[]; + fn typaram_names(tps: &[ast::ty_param]) -> [ident] { + let x: [ast::ident] = ~[]; for tp: ast::ty_param in tps { x += ~[tp.ident] } ret x; } @@ -1347,10 +1347,10 @@ fn check_ty(e: &@env, ty: &@ast::ty, x: &(), v: &vt[()]) { visit::visit_ty(ty, x, v); } -type checker = @{mutable seen: ident[], kind: str, sess: session}; +type checker = @{mutable seen: [ident], kind: str, sess: session}; fn checker(e: &env, kind: str) -> checker { - let seen: ident[] = ~[]; + let seen: [ident] = ~[]; ret @{mutable seen: seen, kind: kind, sess: e.sess}; } @@ -1365,7 +1365,7 @@ fn add_name(ch: &checker, sp: &span, name: &ident) { fn ident_id(i: &ident) -> ident { ret i; } -fn ensure_unique[T](e: &env, sp: &span, elts: &T[], id: fn(&T) -> ident , +fn ensure_unique[T](e: &env, sp: &span, elts: &[T], id: fn(&T) -> ident , kind: &str) { let ch = checker(e, kind); for elt: T in elts { add_name(ch, sp, id(elt)); } diff --git a/src/comp/middle/shape.rs b/src/comp/middle/shape.rs index c9abfac24487f..2477b4473220f 100644 --- a/src/comp/middle/shape.rs +++ b/src/comp/middle/shape.rs @@ -39,7 +39,7 @@ type ctxt = { mutable next_tag_id: u16, pad: u16, tag_id_to_index: hashmap[ast::def_id,u16], - mutable tag_order: ast::def_id[], + mutable tag_order: [ast::def_id], resources: interner::interner[res_info], llshapetablesty: TypeRef, llshapetables: ValueRef @@ -102,7 +102,7 @@ fn mk_global(ccx : &@crate_ctxt, name : &str, llval : ValueRef) -> ValueRef { // // TODO: Use this in dynamic_size_of() as well. -fn largest_variants(ccx : &@crate_ctxt, tag_id : &ast::def_id) -> uint[] { +fn largest_variants(ccx : &@crate_ctxt, tag_id : &ast::def_id) -> [uint] { // Compute the minimum and maximum size and alignment for each variant. // // TODO: We could do better here; e.g. we know that any variant that @@ -186,7 +186,7 @@ fn round_up(size : u16, align : u8) -> u16 { type size_align = { size: u16, align: u8 }; -fn compute_static_tag_size(ccx : &@crate_ctxt, largest_variants : &uint[], +fn compute_static_tag_size(ccx : &@crate_ctxt, largest_variants : &[uint], did : &ast::def_id) -> size_align { let max_size = 0u16; let max_align = 1u8; let variants = ty::tag_variants(ccx.tcx, did); @@ -263,20 +263,20 @@ fn mk_ctxt(llmod : ModuleRef) -> ctxt { }; } -fn add_bool(dest : &mutable u8[], val : bool) { +fn add_bool(dest : &mutable [u8], val : bool) { dest += ~[if val { 1u8 } else { 0u8 }]; } -fn add_u16(dest : &mutable u8[], val : u16) { +fn add_u16(dest : &mutable [u8], val : u16) { dest += ~[(val & 0xffu16) as u8, (val >> 8u16) as u8]; } -fn add_substr(dest : &mutable u8[], src : &u8[]) { +fn add_substr(dest : &mutable [u8], src : &[u8]) { add_u16(dest, ivec::len(src) as u16); dest += src; } -fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> u8[] { +fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> [u8] { let s = ~[]; alt ty::struct(ccx.tcx, t) { @@ -395,7 +395,7 @@ fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> u8[] { ret s; } -fn add_size_hint(ccx : &@crate_ctxt, s : &mutable u8[], typ : ty::t) { +fn add_size_hint(ccx : &@crate_ctxt, s : &mutable [u8], typ : ty::t) { if (ty::type_has_dynamic_size(ccx.tcx, typ)) { s += ~[ 0u8, 0u8, 0u8 ]; ret; @@ -407,7 +407,7 @@ fn add_size_hint(ccx : &@crate_ctxt, s : &mutable u8[], typ : ty::t) { } // FIXME: We might discover other variants as we traverse these. Handle this. -fn shape_of_variant(ccx : &@crate_ctxt, v : &ty::variant_info) -> u8[] { +fn shape_of_variant(ccx : &@crate_ctxt, v : &ty::variant_info) -> [u8] { let s = ~[]; for t : ty::t in v.args { s += shape_of(ccx, t); } ret s; diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 15e6f8862fcaa..90c059136c9ac 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -88,9 +88,9 @@ fn type_of(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef { ret type_of_inner(cx, sp, t); } -fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &ty::arg[]) -> - TypeRef[] { - let atys: TypeRef[] = ~[]; +fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &[ty::arg]) -> + [TypeRef] { + let atys: [TypeRef] = ~[]; for arg: ty::arg in inputs { let t: TypeRef = type_of_inner(cx, sp, arg.ty); t = alt arg.mode { @@ -110,9 +110,9 @@ fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &ty::arg[]) -> // - new_fn_ctxt // - trans_args fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto, - is_method: bool, inputs: &ty::arg[], output: &ty::t, + is_method: bool, inputs: &[ty::arg], output: &ty::t, ty_param_count: uint) -> TypeRef { - let atys: TypeRef[] = ~[]; + let atys: [TypeRef] = ~[]; // Arg 0: Output pointer. atys += ~[T_ptr(type_of_inner(cx, sp, output))]; @@ -147,7 +147,7 @@ fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto, } fn type_of_fn(cx: &@crate_ctxt, sp: &span, proto: ast::proto, - inputs: &ty::arg[], output: &ty::t, ty_param_count: uint) -> + inputs: &[ty::arg], output: &ty::t, ty_param_count: uint) -> TypeRef { ret type_of_fn_full(cx, sp, proto, false, inputs, output, ty_param_count); } @@ -163,9 +163,9 @@ fn type_of_fn_from_ty(cx: &@crate_ctxt, sp: &span, } fn type_of_native_fn(cx: &@crate_ctxt, sp: &span, abi: ast::native_abi, - inputs: &ty::arg[], output: &ty::t, ty_param_count: uint) + inputs: &[ty::arg], output: &ty::t, ty_param_count: uint) -> TypeRef { - let atys: TypeRef[] = ~[]; + let atys: [TypeRef] = ~[]; if abi == ast::native_abi_rust { atys += ~[T_taskptr(*cx)]; let i = 0u; @@ -224,7 +224,7 @@ fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef { ty::ty_chan(t) { llty = T_ptr(T_chan(type_of_inner(cx, sp, t))); } ty::ty_task. { llty = T_taskptr(*cx); } ty::ty_rec(fields) { - let tys: TypeRef[] = ~[]; + let tys: [TypeRef] = ~[]; for f: ty::field in fields { tys += ~[type_of_inner(cx, sp, f.mt.ty)]; } @@ -382,10 +382,10 @@ fn get_simple_extern_fn(externs: &hashmap[str, ValueRef], llmod: ModuleRef, fn trans_native_call(b: &builder, glues: @glue_fns, lltaskptr: ValueRef, externs: &hashmap[str, ValueRef], tn: &type_names, llmod: ModuleRef, name: &str, pass_task: bool, - args: &ValueRef[]) -> ValueRef { + args: &[ValueRef]) -> ValueRef { let n: int = std::ivec::len[ValueRef](args) as int; let llnative: ValueRef = get_simple_extern_fn(externs, llmod, name, n); - let call_args: ValueRef[] = ~[]; + let call_args: [ValueRef] = ~[]; for a: ValueRef in args { call_args += ~[b.ZExtOrBitCast(a, T_int())]; } ret b.Call(llnative, call_args); } @@ -533,7 +533,7 @@ fn static_size_of_tag(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> uint { } fn dynamic_size_of(cx: &@block_ctxt, t: ty::t) -> result { - fn align_elements(cx: &@block_ctxt, elts: &ty::t[]) -> result { + fn align_elements(cx: &@block_ctxt, elts: &[ty::t]) -> result { // // C padding rules: // @@ -564,7 +564,7 @@ fn dynamic_size_of(cx: &@block_ctxt, t: ty::t) -> result { ret rslt(szptr.bcx, szptr.bcx.build.Load(szptr.val)); } ty::ty_rec(flds) { - let tys: ty::t[] = ~[]; + let tys: [ty::t] = ~[]; for f: ty::field in flds { tys += ~[f.mt.ty]; } ret align_elements(cx, tys); } @@ -578,8 +578,8 @@ fn dynamic_size_of(cx: &@block_ctxt, t: ty::t) -> result { for variant: ty::variant_info in variants { // Perform type substitution on the raw argument types. - let raw_tys: ty::t[] = variant.args; - let tys: ty::t[] = ~[]; + let raw_tys: [ty::t] = variant.args; + let tys: [ty::t] = ~[]; for raw_ty: ty::t in raw_tys { let t = ty::substitute_type_params(bcx_tcx(cx), tps, raw_ty); tys += ~[t]; @@ -641,8 +641,8 @@ fn dynamic_align_of(cx: &@block_ctxt, t: &ty::t) -> result { // Simple wrapper around GEP that takes an array of ints and wraps them // in C_int() -fn GEPi(cx: &@block_ctxt, base: ValueRef, ixs: &int[]) -> ValueRef { - let v: ValueRef[] = ~[]; +fn GEPi(cx: &@block_ctxt, base: ValueRef, ixs: &[int]) -> ValueRef { + let v: [ValueRef] = ~[]; for i: int in ixs { v += ~[C_int(i)]; } ret cx.build.GEP(base, v); } @@ -665,7 +665,7 @@ fn bump_ptr(bcx: &@block_ctxt, t: &ty::t, base: ValueRef, sz: ValueRef) // ty::struct and knows what to do when it runs into a ty_param stuck in the // middle of the thing it's GEP'ing into. Much like size_of and align_of, // above. -fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &int[]) -> +fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &[int]) -> result { assert (ty::type_is_tup_like(bcx_tcx(cx), t)); // It might be a static-known type. Handle this. @@ -688,8 +688,8 @@ fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &int[]) -> // elements of the type and splitting the Xth off. Return the prefix as // well as the innermost Xth type. - fn split_type(ccx: &@crate_ctxt, t: &ty::t, ixs: &int[], n: uint) -> - {prefix: ty::t[], target: ty::t} { + fn split_type(ccx: &@crate_ctxt, t: &ty::t, ixs: &[int], n: uint) -> + {prefix: [ty::t], target: ty::t} { let len: uint = std::ivec::len[int](ixs); // We don't support 0-index or 1-index GEPs: The former is nonsense // and the latter would only be meaningful if we supported non-0 @@ -706,7 +706,7 @@ fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &int[]) -> } assert (n < len); let ix: int = ixs.(n); - let prefix: ty::t[] = ~[]; + let prefix: [ty::t] = ~[]; let i: int = 0; while i < ix { prefix += ~[ty::get_element_type(ccx.tcx, t, i as uint)]; @@ -748,7 +748,7 @@ fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &int[]) -> // appropriate. @llblobptr is the data part of a tag value; its actual type is // meaningless, as it will be cast away. fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id, - variant_id: &ast::def_id, ty_substs: &ty::t[], ix: int) -> result { + variant_id: &ast::def_id, ty_substs: &[ty::t], ix: int) -> result { let variant = ty::tag_variant_with_id(bcx_tcx(cx), tag_id, variant_id); // Synthesize a tuple type so that GEP_tup_like() can work its magic. // Separately, store the type of the element we're interested in. @@ -757,7 +757,7 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id, let elem_ty = ty::mk_nil(bcx_tcx(cx)); // typestate infelicity let i = 0; - let true_arg_tys: ty::t[] = ~[]; + let true_arg_tys: [ty::t] = ~[]; for aty: ty::t in arg_tys { let arg_ty = ty::substitute_type_params(bcx_tcx(cx), ty_substs, aty); true_arg_tys += ~[arg_ty]; @@ -868,11 +868,11 @@ fn field_of_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool, field: int) -> // indices of the ty params present in the type. This is used solely for // constructing derived tydescs. fn linearize_ty_params(cx: &@block_ctxt, t: &ty::t) -> - {params: uint[], descs: ValueRef[]} { - let param_vals: ValueRef[] = ~[]; - let param_defs: uint[] = ~[]; + {params: [uint], descs: [ValueRef]} { + let param_vals: [ValueRef] = ~[]; + let param_defs: [uint] = ~[]; type rr = - {cx: @block_ctxt, mutable vals: ValueRef[], mutable defs: uint[]}; + {cx: @block_ctxt, mutable vals: [ValueRef], mutable defs: [uint]}; fn linearizer(r: @rr, t: ty::t) { alt ty::struct(bcx_tcx(r.cx), t) { @@ -1006,7 +1006,7 @@ fn get_tydesc(cx: &@block_ctxt, orig_t: &ty::t, escapes: bool, ret rslt(cx, info.tydesc); } -fn get_static_tydesc(cx: &@block_ctxt, orig_t: &ty::t, ty_params: &uint[]) -> +fn get_static_tydesc(cx: &@block_ctxt, orig_t: &ty::t, ty_params: &[uint]) -> @tydesc_info { let t = ty::strip_cname(bcx_tcx(cx), orig_t); @@ -1050,7 +1050,7 @@ fn set_glue_inlining(cx: &@local_ctxt, f: ValueRef, t: &ty::t) { // Generates the declaration for (but doesn't emit) a type descriptor. -fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &uint[]) +fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &[uint]) -> @tydesc_info { log "+++ declare_tydesc " + ty_to_str(cx.ccx.tcx, t); let ccx = cx.ccx; @@ -1108,7 +1108,7 @@ fn declare_generic_glue(cx: &@local_ctxt, t: &ty::t, llfnty: TypeRef, fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t, llfn: ValueRef, helper: &make_generic_glue_helper_fn, - ty_params: &uint[]) -> ValueRef { + ty_params: &[uint]) -> ValueRef { let fcx = new_fn_ctxt(cx, sp, llfn); llvm::LLVMSetLinkage(llfn, lib::llvm::LLVMInternalLinkage as llvm::Linkage); @@ -1125,7 +1125,7 @@ fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t, let ty_param_count = std::ivec::len[uint](ty_params); let lltyparams = llvm::LLVMGetParam(llfn, 3u); let copy_args_bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs); - let lltydescs = ~[mutable ]; + let lltydescs = ~[mutable]; let p = 0u; while p < ty_param_count { let llparam = copy_args_bcx.build.GEP(lltyparams, ~[C_int(p as int)]); @@ -1157,7 +1157,7 @@ fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t, } fn make_generic_glue(cx: &@local_ctxt, sp: &span, t: &ty::t, llfn: ValueRef, - helper: &make_generic_glue_helper_fn, ty_params: &uint[], + helper: &make_generic_glue_helper_fn, ty_params: &[uint], name: &str) -> ValueRef { if !cx.ccx.sess.get_opts().stats { ret make_generic_glue_inner(cx, sp, t, llfn, helper, ty_params); @@ -1438,7 +1438,7 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) { } fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id, - inner_t: ty::t, tps: &ty::t[]) -> result { + inner_t: ty::t, tps: &[ty::t]) -> result { let ccx = bcx_ccx(cx); let inner_t_s = ty::substitute_type_params(ccx.tcx, tps, inner_t); let tup_ty = ty::mk_imm_tup(ccx.tcx, ~[ty::mk_int(ccx.tcx), inner_t_s]); @@ -1618,7 +1618,7 @@ fn make_cmp_glue(cx: &@block_ctxt, lhs0: ValueRef, rhs0: ValueRef, t: &ty::t, if load_inner { // If `load_inner` is true, then the pointer type will always // be i8, because the data part of a vector always has type - // i8[]. So we need to cast it to the proper type. + // [i8]. So we need to cast it to the proper type. if !ty::type_has_dynamic_size(bcx_tcx(last_cx), t) { let llelemty = @@ -1819,13 +1819,13 @@ fn iter_structural_ty(cx: &@block_ctxt, v: ValueRef, t: &ty::t, ret iter_structural_ty_full(cx, v, v, t, bind adaptor_fn(f, _, _, _, _)); } -fn load_inbounds(cx: &@block_ctxt, p: ValueRef, idxs: &ValueRef[]) -> +fn load_inbounds(cx: &@block_ctxt, p: ValueRef, idxs: &[ValueRef]) -> ValueRef { ret cx.build.Load(cx.build.InBoundsGEP(p, idxs)); } fn store_inbounds(cx: &@block_ctxt, v: ValueRef, p: ValueRef, - idxs: &ValueRef[]) { + idxs: &[ValueRef]) { cx.build.Store(v, cx.build.InBoundsGEP(p, idxs)); } @@ -1919,7 +1919,7 @@ fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, bv: ValueRef, } fn iter_variant(cx: @block_ctxt, a_tup: ValueRef, b_tup: ValueRef, - variant: &ty::variant_info, tps: &ty::t[], + variant: &ty::variant_info, tps: &[ty::t], tid: &ast::def_id, f: &val_pair_and_ty_fn) -> result { if std::ivec::len[ty::t](variant.args) == 0u { ret rslt(cx, C_nil()); @@ -2331,7 +2331,7 @@ fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t, } let llcmpresultptr = alloca(r.bcx, T_i1()); - let llargs: ValueRef[] = + let llargs: [ValueRef] = ~[llcmpresultptr, r.bcx.fcx.lltaskptr, lltydesc, lltydescs, llrawlhsptr, llrawrhsptr, llop]; r.bcx.build.Call(llfn, llargs); @@ -3543,11 +3543,11 @@ fn trans_binary(cx: &@block_ctxt, op: ast::binop, a: &@ast::expr, } } -fn join_results(parent_cx: &@block_ctxt, t: TypeRef, ins: &result[]) -> +fn join_results(parent_cx: &@block_ctxt, t: TypeRef, ins: &[result]) -> result { - let live: result[] = ~[]; - let vals: ValueRef[] = ~[]; - let bbs: BasicBlockRef[] = ~[]; + let live: [result] = ~[]; + let vals: [ValueRef] = ~[]; + let bbs: [BasicBlockRef] = ~[]; for r: result in ins { if !is_terminated(r.bcx) { live += ~[r]; @@ -3574,7 +3574,7 @@ fn join_results(parent_cx: &@block_ctxt, t: TypeRef, ins: &result[]) -> ret rslt(join_cx, phi); } -fn join_branches(parent_cx: &@block_ctxt, ins: &result[]) -> @block_ctxt { +fn join_branches(parent_cx: &@block_ctxt, ins: &[result]) -> @block_ctxt { let out = new_sub_block_ctxt(parent_cx, "join"); for r: result in ins { if !is_terminated(r.bcx) { r.bcx.build.Br(out.llbb); } @@ -3668,8 +3668,8 @@ fn trans_for(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr, // construct a closure out of them. If copying is true, it is a // heap allocated closure that copies the upvars into environment. // Otherwise, it is stack allocated and copies pointers to the upvars. -fn build_environment(bcx: @block_ctxt, lltydescs: ValueRef[], - bound_tys: ty::t[], bound_vals: lval_result[], +fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef], + bound_tys: [ty::t], bound_vals: [lval_result], copying: bool) -> {ptr: ValueRef, ptrty: ty::t, bcx: @block_ctxt} { // Synthesize a closure type. @@ -3687,7 +3687,7 @@ fn build_environment(bcx: @block_ctxt, lltydescs: ValueRef[], // (We'll need room for that many tydescs in the closure.) let ty_param_count = std::ivec::len(lltydescs); let tydesc_ty: ty::t = ty::mk_type(bcx_tcx(bcx)); - let captured_tys: ty::t[] = + let captured_tys: [ty::t] = std::ivec::init_elt(tydesc_ty, ty_param_count); // Get all the types we've got (some of which we synthesized @@ -3696,7 +3696,7 @@ fn build_environment(bcx: @block_ctxt, lltydescs: ValueRef[], // closure_tys = [tydesc_ty, [bound_ty1, bound_ty2, ...], [tydesc_ty, // tydesc_ty, ...]] - let closure_tys: ty::t[] = + let closure_tys: [ty::t] = ~[tydesc_ty, bindings_ty, ty::mk_imm_tup(bcx_tcx(bcx), captured_tys)]; // Finally, synthesize a type for that whole vector. @@ -3764,10 +3764,10 @@ fn build_environment(bcx: @block_ctxt, lltydescs: ValueRef[], // Given a context and a list of upvars, build a closure. This just // collects the upvars and packages them up for build_environment. -fn build_closure(cx: &@block_ctxt, upvars: &@ast::node_id[], copying: bool) +fn build_closure(cx: &@block_ctxt, upvars: &@[ast::node_id], copying: bool) -> {ptr: ValueRef, ptrty: ty::t, bcx: @block_ctxt} { - let closure_vals: lval_result[] = ~[]; - let closure_tys: ty::t[] = ~[]; + let closure_vals: [lval_result] = ~[]; + let closure_tys: [ty::t] = ~[]; // If we need to, package up the iterator body to call if !copying && !option::is_none(cx.fcx.lliterbody) { closure_vals += ~[lval_mem(cx, option::get(cx.fcx.lliterbody))]; @@ -3819,7 +3819,7 @@ fn find_environment_tydescs(bcx: &@block_ctxt, envty: &ty::t, // and a list of upvars, generate code to load and populate the environment // with the upvars and type descriptors. fn load_environment(enclosing_cx: &@block_ctxt, fcx: &@fn_ctxt, - envty: &ty::t, upvars: &@ast::node_id[], + envty: &ty::t, upvars: &@[ast::node_id], copying: bool) { let bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs); @@ -3975,8 +3975,8 @@ fn trans_do_while(cx: &@block_ctxt, body: &ast::blk, cond: &@ast::expr) -> type generic_info = {item_type: ty::t, - static_tis: (option::t[@tydesc_info])[], - tydescs: ValueRef[]}; + static_tis: [option::t[@tydesc_info]], + tydescs: [ValueRef]}; type lval_result = {res: result, @@ -4023,8 +4023,8 @@ fn lval_generic_fn(cx: &@block_ctxt, tpt: &ty::ty_param_kinds_and_ty, let tys = ty::node_id_to_type_params(bcx_tcx(cx), id); if std::ivec::len[ty::t](tys) != 0u { let bcx = lv.res.bcx; - let tydescs: ValueRef[] = ~[]; - let tis: (option::t[@tydesc_info])[] = ~[]; + let tydescs: [ValueRef] = ~[]; + let tis: [option::t[@tydesc_info]] = ~[]; for t: ty::t in tys { // TODO: Doesn't always escape. @@ -4119,7 +4119,7 @@ fn trans_var(cx: &@block_ctxt, sp: &span, id: ast::node_id) -> ret lval_mem(cx, ccx.consts.get(did.node)); } else { let tp = ty::node_id_to_monotype(ccx.tcx, id); - let k: ast::kind[] = ~[]; + let k: [ast::kind] = ~[]; ret lval_val(cx, load_if_immediate(cx, trans_external_path(cx, did, @@ -4408,8 +4408,8 @@ fn trans_cast(cx: &@block_ctxt, e: &@ast::expr, id: ast::node_id) -> result { } fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t, - outgoing_fty: &ty::t, args: &(option::t[@ast::expr])[], - env_ty: &ty::t, bound_tys: &ty::t[], + outgoing_fty: &ty::t, args: &[option::t[@ast::expr]], + env_ty: &ty::t, bound_tys: &[ty::t], ty_param_count: uint) -> {val: ValueRef, ty: TypeRef} { // Here we're not necessarily constructing a thunk in the sense of @@ -4496,7 +4496,7 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t, } // Set up the three implicit arguments to the thunk. - let llargs: ValueRef[] = ~[llretptr, fcx.lltaskptr, lltargetclosure]; + let llargs: [ValueRef] = ~[llretptr, fcx.lltaskptr, lltargetclosure]; // Copy in the type parameters. let i: uint = 0u; @@ -4515,7 +4515,7 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t, let a: uint = 3u; // retptr, task ptr, env come first let b: int = 1; let outgoing_arg_index: uint = 0u; - let llout_arg_tys: TypeRef[] = + let llout_arg_tys: [TypeRef] = type_of_explicit_args(cx.ccx, sp, outgoing_args); for arg: option::t[@ast::expr] in args { let out_arg = outgoing_args.(outgoing_arg_index); @@ -4592,15 +4592,15 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t, } fn trans_bind(cx: &@block_ctxt, f: &@ast::expr, - args: &(option::t[@ast::expr])[], id: ast::node_id) -> result { + args: &[option::t[@ast::expr]], id: ast::node_id) -> result { let f_res = trans_lval_gen(cx, f); ret trans_bind_1(cx, f, f_res, args, id); } fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result, - args: &(option::t[@ast::expr])[], id: ast::node_id) -> + args: &[option::t[@ast::expr]], id: ast::node_id) -> result { - let bound: (@ast::expr)[] = ~[]; + let bound: [@ast::expr] = ~[]; for argopt: option::t[@ast::expr] in args { alt argopt { none. { } some(e) { bound += ~[e]; } } } @@ -4608,7 +4608,7 @@ fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result, // Figure out which tydescs we need to pass, if any. let outgoing_fty: ty::t = ty::expr_ty(bcx_tcx(cx), f); let outgoing_fty_real; // the type with typarams still in it - let lltydescs: ValueRef[]; + let lltydescs: [ValueRef]; alt f_res.generic { none. { outgoing_fty_real = outgoing_fty; lltydescs = ~[]; } some(ginfo) { @@ -4633,8 +4633,8 @@ fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result, let bound_f = {res: {bcx: bcx, val: src_loc} with f_res}; // Arrange for the bound function to live in the first binding spot. - let bound_tys: ty::t[] = ~[outgoing_fty]; - let bound_vals: lval_result[] = ~[bound_f]; + let bound_tys: [ty::t] = ~[outgoing_fty]; + let bound_vals: [lval_result] = ~[bound_f]; // Translate the bound expressions. for e: @ast::expr in bound { let lv = trans_lval(bcx, e); @@ -4729,11 +4729,11 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef, // - trans_args fn trans_args(cx: &@block_ctxt, llenv: ValueRef, gen: &option::t[generic_info], lliterbody: &option::t[ValueRef], - es: &(@ast::expr)[], fn_ty: &ty::t) -> - {bcx: @block_ctxt, args: ValueRef[], retslot: ValueRef} { - let args: ty::arg[] = ty::ty_fn_args(bcx_tcx(cx), fn_ty); - let llargs: ValueRef[] = ~[]; - let lltydescs: ValueRef[] = ~[]; + es: &[@ast::expr], fn_ty: &ty::t) -> + {bcx: @block_ctxt, args: [ValueRef], retslot: ValueRef} { + let args: [ty::arg] = ty::ty_fn_args(bcx_tcx(cx), fn_ty); + let llargs: [ValueRef] = ~[]; + let lltydescs: [ValueRef] = ~[]; let bcx: @block_ctxt = cx; // Arg 0: Output pointer. @@ -4802,7 +4802,7 @@ fn trans_args(cx: &@block_ctxt, llenv: ValueRef, } fn trans_call(cx: &@block_ctxt, f: &@ast::expr, - lliterbody: &option::t[ValueRef], args: &(@ast::expr)[], + lliterbody: &option::t[ValueRef], args: &[@ast::expr], id: ast::node_id) -> result { // NB: 'f' isn't necessarily a function; it might be an entire self-call // expression because of the hack that allows us to process self-calls @@ -4885,7 +4885,7 @@ fn trans_call(cx: &@block_ctxt, f: &@ast::expr, ret rslt(bcx, retval); } -fn trans_vec(cx: &@block_ctxt, args: &(@ast::expr)[], id: ast::node_id) -> +fn trans_vec(cx: &@block_ctxt, args: &[@ast::expr], id: ast::node_id) -> result { let t = node_id_type(bcx_ccx(cx), id); let unit_ty = t; @@ -4945,7 +4945,7 @@ fn trans_vec(cx: &@block_ctxt, args: &(@ast::expr)[], id: ast::node_id) -> // TODO: Move me to ivec:: -fn trans_ivec(bcx: @block_ctxt, args: &(@ast::expr)[], id: ast::node_id) -> +fn trans_ivec(bcx: @block_ctxt, args: &[@ast::expr], id: ast::node_id) -> result { let typ = node_id_type(bcx_ccx(bcx), id); let unit_ty; @@ -5038,7 +5038,7 @@ fn trans_ivec(bcx: @block_ctxt, args: &(@ast::expr)[], id: ast::node_id) -> ret rslt(bcx, llvecptr); } -fn trans_rec(cx: &@block_ctxt, fields: &ast::field[], +fn trans_rec(cx: &@block_ctxt, fields: &[ast::field], base: &option::t[@ast::expr], id: ast::node_id) -> result { let bcx = cx; let t = node_id_type(bcx_ccx(bcx), id); @@ -5056,7 +5056,7 @@ fn trans_rec(cx: &@block_ctxt, fields: &ast::field[], base_val = base_res.val; } } - let ty_fields: ty::field[] = ~[]; + let ty_fields: [ty::field] = ~[]; alt ty::struct(bcx_tcx(cx), t) { ty::ty_rec(flds) { ty_fields = flds; } } for tf: ty::field in ty_fields { let e_ty = tf.mt.ty; @@ -5492,7 +5492,7 @@ fn trans_put(cx: &@block_ctxt, e: &option::t[@ast::expr]) -> result { } let bcx = cx; let dummy_retslot = alloca(bcx, T_nil()); - let llargs: ValueRef[] = ~[dummy_retslot, cx.fcx.lltaskptr, llenv]; + let llargs: [ValueRef] = ~[dummy_retslot, cx.fcx.lltaskptr, llenv]; alt e { none. { } some(x) { @@ -5640,9 +5640,9 @@ fn trans_anon_obj(bcx: @block_ctxt, sp: &span, anon_obj: &ast::anon_obj, // Fields. // FIXME (part of issue #538): Where do we fill in the field *values* from // the outer object? - let additional_fields: ast::anon_obj_field[] = ~[]; - let additional_field_vals: result[] = ~[]; - let additional_field_tys: ty::t[] = ~[]; + let additional_fields: [ast::anon_obj_field] = ~[]; + let additional_field_vals: [result] = ~[]; + let additional_field_tys: [ty::t] = ~[]; alt anon_obj.fields { none. { } some(fields) { @@ -5897,7 +5897,7 @@ fn trans_stmt(cx: &@block_ctxt, s: &ast::stmt) -> result { // next three functions instead. fn new_block_ctxt(cx: &@fn_ctxt, parent: &block_parent, kind: block_kind, name: &str) -> @block_ctxt { - let cleanups: cleanup[] = ~[]; + let cleanups: [cleanup] = ~[]; let s = str::buf(""); let held_name; //HACK for str::buf, which doesn't keep its value alive if cx.lcx.ccx.sess.get_opts().save_temps || @@ -5941,7 +5941,7 @@ fn new_sub_block_ctxt(bcx: &@block_ctxt, n: &str) -> @block_ctxt { } fn new_raw_block_ctxt(fcx: &@fn_ctxt, llbb: BasicBlockRef) -> @block_ctxt { - let cleanups: cleanup[] = ~[]; + let cleanups: [cleanup] = ~[]; ret @{llbb: llbb, build: new_builder(llbb), parent: parent_none, @@ -5996,7 +5996,7 @@ iter block_locals(b: &ast::blk) -> @ast::local { } fn llstaticallocas_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt { - let cleanups: cleanup[] = ~[]; + let cleanups: [cleanup] = ~[]; ret @{llbb: fcx.llstaticallocas, build: new_builder(fcx.llstaticallocas), parent: parent_none, @@ -6007,7 +6007,7 @@ fn llstaticallocas_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt { } fn llderivedtydescs_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt { - let cleanups: cleanup[] = ~[]; + let cleanups: [cleanup] = ~[]; ret @{llbb: fcx.llderivedtydescs, build: new_builder(fcx.llderivedtydescs), parent: parent_none, @@ -6018,7 +6018,7 @@ fn llderivedtydescs_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt { } fn lldynamicallocas_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt { - let cleanups: cleanup[] = ~[]; + let cleanups: [cleanup] = ~[]; ret @{llbb: fcx.lldynamicallocas, build: new_builder(fcx.lldynamicallocas), parent: parent_none, @@ -6125,7 +6125,7 @@ fn trans_block(cx: &@block_ctxt, b: &ast::blk, output: &out_method) -> } fn new_local_ctxt(ccx: &@crate_ctxt) -> @local_ctxt { - let pth: str[] = ~[]; + let pth: [str] = ~[]; ret @{path: pth, module_path: ~[ccx.link_meta.name], obj_typarams: ~[], @@ -6210,7 +6210,7 @@ fn new_fn_ctxt(cx: @local_ctxt, sp: &span, llfndecl: ValueRef) -> @fn_ctxt { // field of the fn_ctxt with fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto, ty_self: option::t[ty::t], ret_ty: ty::t, - args: &ast::arg[], ty_params: &ast::ty_param[]) { + args: &[ast::arg], ty_params: &[ast::ty_param]) { // Skip the implicit arguments 0, 1, and 2. TODO: Pull out 3u and define // it as a constant, since we're using it in several places in trans this // way. @@ -6250,8 +6250,8 @@ fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto, } } -fn copy_args_to_allocas(fcx: @fn_ctxt, args: &ast::arg[], - arg_tys: &ty::arg[]) { +fn copy_args_to_allocas(fcx: @fn_ctxt, args: &[ast::arg], + arg_tys: &[ty::arg]) { let bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs); let arg_n: uint = 0u; for aarg: ast::arg in args { @@ -6273,8 +6273,8 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, args: &ast::arg[], } } -fn add_cleanups_for_args(bcx: &@block_ctxt, args: &ast::arg[], - arg_tys: &ty::arg[]) { +fn add_cleanups_for_args(bcx: &@block_ctxt, args: &[ast::arg], + arg_tys: &[ty::arg]) { let arg_n: uint = 0u; for aarg: ast::arg in args { if aarg.mode == ast::val { @@ -6297,7 +6297,7 @@ fn is_terminated(cx: &@block_ctxt) -> bool { ret llvm::LLVMIsATerminatorInst(inst) as int != 0; } -fn arg_tys_of_fn(ccx: &@crate_ctxt, id: ast::node_id) -> ty::arg[] { +fn arg_tys_of_fn(ccx: &@crate_ctxt, id: ast::node_id) -> [ty::arg] { alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id)) { ty::ty_fn(_, arg_tys, _, _, _) { ret arg_tys; } } @@ -6305,7 +6305,7 @@ fn arg_tys_of_fn(ccx: &@crate_ctxt, id: ast::node_id) -> ty::arg[] { fn populate_fn_ctxt_from_llself(fcx: @fn_ctxt, llself: val_self_pair) { let bcx = llstaticallocas_block_ctxt(fcx); - let field_tys: ty::t[] = ~[]; + let field_tys: [ty::t] = ~[]; for f: ast::obj_field in bcx.fcx.lcx.obj_fields { field_tys += ~[node_id_type(bcx_ccx(bcx), f.id)]; } @@ -6371,7 +6371,7 @@ fn finish_fn(fcx: &@fn_ctxt, lltop: BasicBlockRef) { fn trans_closure(bcx_maybe: &option::t[@block_ctxt], llfnty: &option::t[TypeRef], cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef, ty_self: option::t[ty::t], - ty_params: &ast::ty_param[], id: ast::node_id) + ty_params: &[ast::ty_param], id: ast::node_id) -> option::t[{fn_pair: ValueRef, bcx: @block_ctxt}] { set_uwtable(llfndecl); @@ -6446,7 +6446,7 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt], fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef, ty_self: option::t[ty::t], - ty_params: &ast::ty_param[], id: ast::node_id) { + ty_params: &[ast::ty_param], id: ast::node_id) { trans_closure(none, none, cx, sp, f, llfndecl, ty_self, ty_params, id); } @@ -6454,7 +6454,7 @@ fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn, // trans_fn: creates an LLVM function corresponding to a source language // function. fn trans_fn(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef, - ty_self: option::t[ty::t], ty_params: &ast::ty_param[], + ty_self: option::t[ty::t], ty_params: &[ast::ty_param], id: ast::node_id) { if !cx.ccx.sess.get_opts().stats { trans_fn_inner(cx, sp, f, llfndecl, ty_self, ty_params, id); @@ -6482,8 +6482,8 @@ fn trans_fn(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef, // the corresponding method on inner does, calls that method on outer, and // returns the value returned from that call. fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, - ty_params: &ast::ty_param[], outer_obj_ty: ty::t, - additional_field_tys: &ty::t[]) -> ValueRef { + ty_params: &[ast::ty_param], outer_obj_ty: ty::t, + additional_field_tys: &[ty::t]) -> ValueRef { // Create a local context that's aware of the name of the method we're // creating. @@ -6561,7 +6561,7 @@ fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, // Set up the three implicit arguments to the outer method we'll need // to call. let self_arg = llself_obj_ptr; - let llouter_mthd_args: ValueRef[] = ~[llretptr, fcx.lltaskptr, self_arg]; + let llouter_mthd_args: [ValueRef] = ~[llretptr, fcx.lltaskptr, self_arg]; // Copy the explicit arguments that are being passed into the forwarding // function (they're in fcx.llargs) to llouter_mthd_args. @@ -6600,9 +6600,9 @@ fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, // from that call. (The inner object won't exist until run-time, but we know // its type statically.) fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, - ty_params: &ast::ty_param[], inner_obj_ty: ty::t, + ty_params: &[ast::ty_param], inner_obj_ty: ty::t, backwarding_vtbl: ValueRef, - additional_field_tys: &ty::t[]) -> ValueRef { + additional_field_tys: &[ty::t]) -> ValueRef { // Create a local context that's aware of the name of the method we're // creating. @@ -6747,7 +6747,7 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, // Set up the three implicit arguments to the original method we'll need // to call. let self_arg = llself_obj_ptr; - let llorig_mthd_args: ValueRef[] = ~[llretptr, fcx.lltaskptr, self_arg]; + let llorig_mthd_args: [ValueRef] = ~[llretptr, fcx.lltaskptr, self_arg]; // Copy the explicit arguments that are being passed into the forwarding // function (they're in fcx.llargs) to llorig_mthd_args. @@ -6774,7 +6774,7 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, // process_normal_mthd: Create the contents of a normal vtable slot. A helper // function for create_vtbl. fn process_normal_mthd(cx: @local_ctxt, m: @ast::method, self_ty: ty::t, - ty_params: &ast::ty_param[]) -> ValueRef { + ty_params: &[ast::ty_param]) -> ValueRef { let llfnty = T_nil(); alt ty::struct(cx.ccx.tcx, node_id_type(cx.ccx, m.node.id)) { @@ -6835,7 +6835,7 @@ fn vtbl_mthd_lteq(a: &vtbl_mthd, b: &vtbl_mthd) -> bool { // Used by create_vtbl to filter a list of methods to remove the ones that we // don't need forwarding slots for. fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd, - addtl_meths: (@ast::method)[]) -> + addtl_meths: [@ast::method]) -> option::t[vtbl_mthd] { // Since m is a fwding_mthd, and we're checking to see if it's in @@ -6860,11 +6860,11 @@ fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd, // Create a vtable for an object being translated. Returns a pointer into // read-only memory. fn create_vtbl(cx: @local_ctxt, sp: &span, outer_obj_ty: ty::t, - ob: &ast::_obj, ty_params: &ast::ty_param[], + ob: &ast::_obj, ty_params: &[ast::ty_param], inner_obj_ty: option::t[ty::t], - additional_field_tys: &ty::t[]) -> ValueRef { + additional_field_tys: &[ty::t]) -> ValueRef { - let llmethods: ValueRef[] = ~[]; + let llmethods: [ValueRef] = ~[]; alt inner_obj_ty { none. { @@ -6894,7 +6894,7 @@ fn create_vtbl(cx: @local_ctxt, sp: &span, outer_obj_ty: ty::t, // original methods onto the list of methods we need forwarding // methods for. - let meths: vtbl_mthd[] = ~[]; + let meths: [vtbl_mthd] = ~[]; // Gather up methods on the original object in 'meths'. alt ty::struct(cx.ccx.tcx, inner_obj_ty) { @@ -6961,8 +6961,8 @@ fn create_backwarding_vtbl(cx: @local_ctxt, sp: &span, inner_obj_ty: ty::t, // object, and it needs to forward them to the corresponding slots on the // outer object. All we know about either one are their types. - let llmethods: ValueRef[] = ~[]; - let meths: ty::method[]= ~[]; + let llmethods: [ValueRef] = ~[]; + let meths: [ty::method]= ~[]; // Gather up methods on the inner object. alt ty::struct(cx.ccx.tcx, inner_obj_ty) { @@ -7004,7 +7004,7 @@ fn create_backwarding_vtbl(cx: @local_ctxt, sp: &span, inner_obj_ty: ty::t, // trans_obj: creates an LLVM function that is the object constructor for the // object being translated. fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj, - ctor_id: ast::node_id, ty_params: &ast::ty_param[]) { + ctor_id: ast::node_id, ty_params: &[ast::ty_param]) { // To make a function, we have to create a function context and, inside // that, a number of block contexts for which code is generated. @@ -7021,7 +7021,7 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj, // The fields of our object will become the arguments to the function // we're creating. - let fn_args: ast::arg[] = ~[]; + let fn_args: [ast::arg] = ~[]; for f: ast::obj_field in ob.fields { fn_args += ~[{mode: ast::alias(false), ty: f.ty, ident: f.ident, id: f.id}]; @@ -7032,7 +7032,7 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj, create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty::t], ty::ret_ty_of_fn(ccx.tcx, ctor_id), fn_args, ty_params); - let arg_tys: ty::arg[] = arg_tys_of_fn(ccx, ctor_id); + let arg_tys: [ty::arg] = arg_tys_of_fn(ccx, ctor_id); copy_args_to_allocas(fcx, fn_args, arg_tys); // Create the first block context in the function and keep a handle on it @@ -7087,14 +7087,14 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj, } else { // Otherwise, we have to synthesize a big structural type for the // object body. - let obj_fields: ty::t[] = ~[]; + let obj_fields: [ty::t] = ~[]; for a: ty::arg in arg_tys { obj_fields += ~[a.ty]; } // Tuple type for fields: [field, ...] let fields_ty: ty::t = ty::mk_imm_tup(ccx.tcx, obj_fields); let tydesc_ty = ty::mk_type(ccx.tcx); - let tps: ty::t[] = ~[]; + let tps: [ty::t] = ~[]; for tp: ast::ty_param in ty_params { tps += ~[tydesc_ty]; } // Tuple type for typarams: [typaram, ...] @@ -7186,7 +7186,7 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj, } fn trans_res_ctor(cx: @local_ctxt, sp: &span, dtor: &ast::_fn, - ctor_id: ast::node_id, ty_params: &ast::ty_param[]) { + ctor_id: ast::node_id, ty_params: &[ast::ty_param]) { // Create a function for the constructor let llctor_decl; alt cx.ccx.item_ids.find(ctor_id) { @@ -7226,14 +7226,14 @@ fn trans_res_ctor(cx: @local_ctxt, sp: &span, dtor: &ast::_fn, fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id, variant: &ast::variant, index: int, is_degen: bool, - ty_params: &ast::ty_param[]) { + ty_params: &[ast::ty_param]) { if std::ivec::len[ast::variant_arg](variant.node.args) == 0u { ret; // nullary constructors are just constants } // Translate variant arguments to function arguments. - let fn_args: ast::arg[] = ~[]; + let fn_args: [ast::arg] = ~[]; let i = 0u; for varg: ast::variant_arg in variant.node.args { fn_args += @@ -7255,7 +7255,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id, create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty::t], ty::ret_ty_of_fn(cx.ccx.tcx, variant.node.id), fn_args, ty_params); - let ty_param_substs: ty::t[] = ~[]; + let ty_param_substs: [ty::t] = ~[]; i = 0u; for tp: ast::ty_param in ty_params { ty_param_substs += ~[ty::mk_param(cx.ccx.tcx, i, tp.kind)]; @@ -7408,14 +7408,14 @@ fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef { ret struct_elt(llpairty, 0u); } -fn decl_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], flav: str, - ty_params: &ast::ty_param[], node_id: ast::node_id) { +fn decl_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str], flav: str, + ty_params: &[ast::ty_param], node_id: ast::node_id) { decl_fn_and_pair_full(ccx, sp, path, flav, ty_params, node_id, node_id_type(ccx, node_id)); } -fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &str[], - flav: str, ty_params: &ast::ty_param[], +fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &[str], + flav: str, ty_params: &[ast::ty_param], node_id: ast::node_id, node_type: ty::t) { let llfty = type_of_fn_from_ty(ccx, sp, node_type, std::ivec::len(ty_params)); @@ -7522,7 +7522,7 @@ fn native_fn_wrapper_type(cx: &@crate_ctxt, sp: &span, ty_param_count: uint, } } -fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], +fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str], name: str, id: ast::node_id) { let num_ty_param = native_fn_ty_param_count(ccx, id); // Declare the wrapper. @@ -7589,7 +7589,7 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], lltaskptr = vp2i(bcx, fcx.lltaskptr); } else { lltaskptr = fcx.lltaskptr; } - let call_args: ValueRef[] = ~[]; + let call_args: [ValueRef] = ~[]; if pass_task { call_args += ~[lltaskptr]; } if uses_retptr { call_args += ~[bcx.fcx.llretptr]; } @@ -7623,10 +7623,10 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], } fn trans_simple_native_abi(bcx: &@block_ctxt, name: str, - call_args: &mutable ValueRef[], fn_type: ty::t, + call_args: &mutable [ValueRef], fn_type: ty::t, first_arg_n: uint, uses_retptr: bool, cc: uint) -> {val: ValueRef, rptr: ValueRef} { - let call_arg_tys: TypeRef[] = ~[]; + let call_arg_tys: [TypeRef] = ~[]; for arg: ValueRef in call_args { call_arg_tys += ~[val_ty(arg)]; } let llnativefnty; @@ -7653,7 +7653,7 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], let args = ty::ty_fn_args(ccx.tcx, fn_type); // Build up the list of arguments. - let drop_args: {val: ValueRef, ty: ty::t}[] = ~[]; + let drop_args: [{val: ValueRef, ty: ty::t}] = ~[]; let i = arg_n; for arg: ty::arg in args { let llarg = llvm::LLVMGetParam(fcx.llfn, i); @@ -7714,10 +7714,10 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], finish_fn(fcx, lltop); } -fn item_path(item: &@ast::item) -> str[] { ret ~[item.ident]; } +fn item_path(item: &@ast::item) -> [str] { ret ~[item.ident]; } -fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &str[], - v: &vt[str[]]) { +fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &[str], + v: &vt[[str]]) { alt i.node { ast::native_item_fn(_, _, _) { if !ccx.obj_methods.contains_key(i.id) { @@ -7728,8 +7728,8 @@ fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &str[], } } -fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &str[], - v: &vt[str[]]) { +fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], + v: &vt[[str]]) { visit::visit_item(i, pt + item_path(i), v); alt i.node { ast::item_const(_, _) { @@ -7747,8 +7747,8 @@ fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &str[], } } -fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &str[], - v: &vt[str[]]) { +fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &[str], + v: &vt[[str]]) { let new_pt = pt + item_path(i); visit::visit_item(i, new_pt, v); alt i.node { @@ -7787,8 +7787,8 @@ fn collect_items(ccx: &@crate_ctxt, crate: @ast::crate) { visit::visit_crate(*crate, ~[], visit::mk_vt(visitor2)); } -fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &str[], - v: &vt[str[]]) { +fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], + v: &vt[[str]]) { let new_pt = pt + item_path(i); visit::visit_item(i, new_pt, v); alt i.node { @@ -7813,8 +7813,8 @@ fn collect_tag_ctors(ccx: &@crate_ctxt, crate: @ast::crate) { // The constant translation pass. -fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &str[], - v: &vt[str[]]) { +fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[str], + v: &vt[[str]]) { let new_pt = pt + item_path(it); visit::visit_item(it, new_pt, v); alt it.node { @@ -7862,15 +7862,15 @@ fn i2p(v: ValueRef, t: TypeRef) -> ValueRef { } fn declare_intrinsics(llmod: ModuleRef) -> hashmap[str, ValueRef] { - let T_memmove32_args: TypeRef[] = + let T_memmove32_args: [TypeRef] = ~[T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()]; - let T_memmove64_args: TypeRef[] = + let T_memmove64_args: [TypeRef] = ~[T_ptr(T_i8()), T_ptr(T_i8()), T_i64(), T_i32(), T_i1()]; - let T_memset32_args: TypeRef[] = + let T_memset32_args: [TypeRef] = ~[T_ptr(T_i8()), T_i8(), T_i32(), T_i32(), T_i1()]; - let T_memset64_args: TypeRef[] = + let T_memset64_args: [TypeRef] = ~[T_ptr(T_i8()), T_i8(), T_i64(), T_i32(), T_i1()]; - let T_trap_args: TypeRef[] = ~[]; + let T_trap_args: [TypeRef] = ~[]; let memmove32 = decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i32", T_fn(T_memmove32_args, T_void())); @@ -7907,7 +7907,7 @@ fn trace_ptr(cx: &@block_ctxt, v: ValueRef) { } fn trap(bcx: &@block_ctxt) { - let v: ValueRef[] = ~[]; + let v: [ValueRef] = ~[]; alt bcx_ccx(bcx).intrinsics.find("llvm.trap") { some(x) { bcx.build.Call(x, v); } _ { bcx_ccx(bcx).sess.bug("unbound llvm.trap in trap"); } @@ -7968,7 +7968,7 @@ fn create_module_map(ccx: &@crate_ctxt) -> ValueRef { llvm::LLVMAddGlobal(ccx.llmod, maptype, str::buf("_rust_mod_map")); llvm::LLVMSetLinkage(map, lib::llvm::LLVMInternalLinkage as llvm::Linkage); - let elts: ValueRef[] = ~[]; + let elts: [ValueRef] = ~[]; for each item: @{key: str, val: ValueRef} in ccx.module_data.items() { let elt = C_struct(~[p2i(C_cstr(ccx, item.key)), p2i(item.val)]); elts += ~[elt]; @@ -7982,7 +7982,7 @@ fn create_module_map(ccx: &@crate_ctxt) -> ValueRef { // FIXME use hashed metadata instead of crate names once we have that fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef { - let subcrates: ValueRef[] = ~[]; + let subcrates: [ValueRef] = ~[]; let i = 1; let cstore = ccx.sess.get_cstore(); while cstore::have_crate_data(cstore, i) { diff --git a/src/comp/middle/trans_alt.rs b/src/comp/middle/trans_alt.rs index cdfff0ffe9a90..f15922a20fe2a 100644 --- a/src/comp/middle/trans_alt.rs +++ b/src/comp/middle/trans_alt.rs @@ -53,10 +53,10 @@ fn variant_opt(ccx: &@crate_ctxt, pat_id: ast::node_id) -> opt { fail; } -type bind_map = {ident: ast::ident, val: ValueRef}[]; +type bind_map = [{ident: ast::ident, val: ValueRef}]; type match_branch = - @{pats: (@ast::pat)[], body: BasicBlockRef, mutable bound: bind_map}; -type match = match_branch[]; + @{pats: [@ast::pat], body: BasicBlockRef, mutable bound: bind_map}; +type match = [match_branch]; fn matches_always(p: &@ast::pat) -> bool { ret alt p.node { @@ -75,7 +75,7 @@ fn bind_for_pat(p: &@ast::pat, br: &match_branch, val: ValueRef) { } } -type enter_pat = fn(&@ast::pat) -> option::t[(@ast::pat)[]] ; +type enter_pat = fn(&@ast::pat) -> option::t[[@ast::pat]] ; fn enter_match(m: &match, col: uint, val: ValueRef, e: &enter_pat) -> match { let result = ~[]; @@ -96,7 +96,7 @@ fn enter_match(m: &match, col: uint, val: ValueRef, e: &enter_pat) -> match { } fn enter_default(m: &match, col: uint, val: ValueRef) -> match { - fn e(p: &@ast::pat) -> option::t[(@ast::pat)[]] { + fn e(p: &@ast::pat) -> option::t[[@ast::pat]] { ret if matches_always(p) { some(~[]) } else { none }; } ret enter_match(m, col, val, e); @@ -106,7 +106,7 @@ fn enter_opt(ccx: &@crate_ctxt, m: &match, opt: &opt, col: uint, tag_size: uint, val: ValueRef) -> match { let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}}; fn e(ccx: &@crate_ctxt, dummy: &@ast::pat, opt: &opt, size: uint, - p: &@ast::pat) -> option::t[(@ast::pat)[]] { + p: &@ast::pat) -> option::t[[@ast::pat]] { alt p.node { ast::pat_tag(ctor, subpats) { ret if opt_eq(variant_opt(ccx, p.id), opt) { @@ -122,11 +122,11 @@ fn enter_opt(ccx: &@crate_ctxt, m: &match, opt: &opt, col: uint, ret enter_match(m, col, val, bind e(ccx, dummy, opt, tag_size, _)); } -fn enter_rec(m: &match, col: uint, fields: &ast::ident[], val: ValueRef) -> +fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) -> match { let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}}; - fn e(dummy: &@ast::pat, fields: &ast::ident[], p: &@ast::pat) -> - option::t[(@ast::pat)[]] { + fn e(dummy: &@ast::pat, fields: &[ast::ident], p: &@ast::pat) -> + option::t[[@ast::pat]] { alt p.node { ast::pat_rec(fpats, _) { let pats = ~[]; @@ -147,7 +147,7 @@ fn enter_rec(m: &match, col: uint, fields: &ast::ident[], val: ValueRef) -> fn enter_box(m: &match, col: uint, val: ValueRef) -> match { let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}}; - fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t[(@ast::pat)[]] { + fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t[[@ast::pat]] { alt p.node { ast::pat_box(sub) { ret some(~[sub]); } _ { ret some(~[dummy]); } @@ -156,8 +156,8 @@ fn enter_box(m: &match, col: uint, val: ValueRef) -> match { ret enter_match(m, col, val, bind e(dummy, _)); } -fn get_options(ccx: &@crate_ctxt, m: &match, col: uint) -> opt[] { - fn add_to_set(set: &mutable opt[], val: &opt) { +fn get_options(ccx: &@crate_ctxt, m: &match, col: uint) -> [opt] { + fn add_to_set(set: &mutable [opt], val: &opt) { for l: opt in set { if opt_eq(l, val) { ret; } } set += ~[val]; } @@ -177,7 +177,7 @@ fn get_options(ccx: &@crate_ctxt, m: &match, col: uint) -> opt[] { fn extract_variant_args(bcx: @block_ctxt, pat_id: ast::node_id, vdefs: &{tg: def_id, var: def_id}, val: ValueRef) - -> {vals: ValueRef[], bcx: @block_ctxt} { + -> {vals: [ValueRef], bcx: @block_ctxt} { let ccx = bcx.fcx.lcx.ccx; let ty_param_substs = ty::node_id_to_type_params(ccx.tcx, pat_id); let blobptr = val; @@ -203,7 +203,7 @@ fn extract_variant_args(bcx: @block_ctxt, pat_id: ast::node_id, ret {vals: args, bcx: bcx}; } -fn collect_record_fields(m: &match, col: uint) -> ast::ident[] { +fn collect_record_fields(m: &match, col: uint) -> [ast::ident] { let fields = ~[]; for br: match_branch in m { alt br.pats.(col).node { @@ -260,8 +260,8 @@ fn pick_col(m: &match) -> uint { ret best_col; } -fn compile_submatch(bcx: @block_ctxt, m: &match, vals: ValueRef[], - f: &mk_fail, exits: &mutable exit_node[]) { +fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef], + f: &mk_fail, exits: &mutable [exit_node]) { if ivec::len(m) == 0u { bcx.build.Br(f()); ret; } if ivec::len(m.(0).pats) == 0u { exits += ~[{bound: m.(0).bound, from: bcx.llbb, to: m.(0).body}]; @@ -391,7 +391,7 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: ValueRef[], } // Returns false for unreachable blocks -fn make_phi_bindings(bcx: &@block_ctxt, map: &exit_node[], +fn make_phi_bindings(bcx: &@block_ctxt, map: &[exit_node], ids: &ast::pat_id_map) -> bool { fn assoc(key: str, list: &bind_map) -> option::t[ValueRef] { for elt: {ident: ast::ident, val: ValueRef} in list { @@ -421,7 +421,7 @@ fn make_phi_bindings(bcx: &@block_ctxt, map: &exit_node[], ret success; } -fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &ast::arm[], +fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &[ast::arm], id: ast::node_id, output: &trans::out_method) -> result { let bodies = ~[]; let match: match = ~[]; diff --git a/src/comp/middle/trans_comm.rs b/src/comp/middle/trans_comm.rs index 2fc24f8cb528f..6891b28f01003 100644 --- a/src/comp/middle/trans_comm.rs +++ b/src/comp/middle/trans_comm.rs @@ -63,7 +63,7 @@ fn trans_chan(cx: &@block_ctxt, e: &@ast::expr, id: ast::node_id) -> result { } fn trans_spawn(cx: &@block_ctxt, dom: &ast::spawn_dom, name: &option::t[str], - func: &@ast::expr, args: &(@ast::expr)[], id: ast::node_id) -> + func: &@ast::expr, args: &[@ast::expr], id: ast::node_id) -> result { let bcx = cx; // Make the task name @@ -107,8 +107,8 @@ fn trans_spawn(cx: &@block_ctxt, dom: &ast::spawn_dom, name: &option::t[str], // Translate the arguments, remembering their types and where the values // ended up. - let arg_tys: ty::t[] = ~[]; - let arg_vals: ValueRef[] = ~[]; + let arg_tys: [ty::t] = ~[]; + let arg_vals: [ValueRef] = ~[]; for e: @ast::expr in args { let e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e); let arg = trans_expr(bcx, e); @@ -168,7 +168,7 @@ fn mk_spawn_wrapper(cx: &@block_ctxt, func: &@ast::expr, args_ty: &ty::t) -> // 3u to skip the three implicit args let arg: ValueRef = llvm::LLVMGetParam(fcx.llfn, 3u); - let child_args: ValueRef[] = + let child_args: [ValueRef] = ~[llvm::LLVMGetParam(fcx.llfn, 0u), llvm::LLVMGetParam(fcx.llfn, 1u), llvm::LLVMGetParam(fcx.llfn, 2u)]; // unpack the arguments diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index e0b26a97c9fcb..bb61b9f794ba9 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -79,7 +79,7 @@ type tydesc_info = mutable drop_glue: option::t[ValueRef], mutable free_glue: option::t[ValueRef], mutable cmp_glue: option::t[ValueRef], - ty_params: uint[]}; + ty_params: [uint]}; /* * A note on nomenclature of linking: "upcall", "extern" and "native". @@ -102,7 +102,7 @@ type stats = mutable n_glues_created: uint, mutable n_null_glues: uint, mutable n_real_glues: uint, - fn_times: @mutable {ident: str, time: int}[]}; + fn_times: @mutable [{ident: str, time: int}]}; // Crate context. Every crate we compile has one of these. type crate_ctxt = { @@ -146,10 +146,10 @@ type crate_ctxt = { }; type local_ctxt = - {path: str[], - module_path: str[], - obj_typarams: ast::ty_param[], - obj_fields: ast::obj_field[], + {path: [str], + module_path: [str], + obj_typarams: [ast::ty_param], + obj_fields: [ast::obj_field], ccx: @crate_ctxt}; // Types used for llself. @@ -252,7 +252,7 @@ type fn_ctxt = { // this functions type parameters, fetched via llvm::LLVMGetParam. // For example, for a function foo[A, B, C](), lltydescs contains // the ValueRefs for the tydescs for A, B, and C. - mutable lltydescs: ValueRef[], + mutable lltydescs: [ValueRef], // Derived tydescs are tydescs created at runtime, for types that // involve type parameters inside type constructors. For example, @@ -386,7 +386,7 @@ type block_ctxt = { // A list of functions that run at the end of translating this // block, cleaning up any variables that were introduced in the // block and need to go out of scope at the end of it. - mutable cleanups: cleanup[], + mutable cleanups: [cleanup], // The source span where this block comes from, for error // reporting. @@ -508,7 +508,7 @@ fn T_size_t() -> TypeRef { ret T_i32(); } -fn T_fn(inputs: &TypeRef[], output: TypeRef) -> TypeRef { +fn T_fn(inputs: &[TypeRef], output: TypeRef) -> TypeRef { ret llvm::LLVMFunctionType(output, std::ivec::to_ptr(inputs), std::ivec::len[TypeRef](inputs), False); } @@ -519,7 +519,7 @@ fn T_fn_pair(cx: &crate_ctxt, tfn: TypeRef) -> TypeRef { fn T_ptr(t: TypeRef) -> TypeRef { ret llvm::LLVMPointerType(t, 0u); } -fn T_struct(elts: &TypeRef[]) -> TypeRef { +fn T_struct(elts: &[TypeRef]) -> TypeRef { ret llvm::LLVMStructType(std::ivec::to_ptr(elts), std::ivec::len(elts), False); } @@ -529,7 +529,7 @@ fn T_named_struct(name: &str) -> TypeRef { ret llvm::LLVMStructCreateNamed(c, str::buf(name)); } -fn set_struct_body(t: TypeRef, elts: &TypeRef[]) { +fn set_struct_body(t: TypeRef, elts: &[TypeRef]) { llvm::LLVMStructSetBody(t, std::ivec::to_ptr(elts), std::ivec::len(elts), False); } @@ -565,7 +565,7 @@ fn T_task() -> TypeRef { fn T_tydesc_field(cx: &crate_ctxt, field: int) -> TypeRef { // Bit of a kludge: pick the fn typeref out of the tydesc.. - let tydesc_elts: TypeRef[] = + let tydesc_elts: [TypeRef] = std::ivec::init_elt[TypeRef](T_nil(), abi::n_tydesc_fields as uint); llvm::LLVMGetStructElementTypes(cx.tydesc_type, std::ivec::to_ptr[TypeRef](tydesc_elts)); @@ -839,33 +839,33 @@ fn C_postr(s: &str) -> ValueRef { fn C_zero_byte_arr(size: uint) -> ValueRef { let i = 0u; - let elts: ValueRef[] = ~[]; + let elts: [ValueRef] = ~[]; while i < size { elts += ~[C_u8(0u)]; i += 1u; } ret llvm::LLVMConstArray(T_i8(), std::ivec::to_ptr(elts), std::ivec::len(elts)); } -fn C_struct(elts: &ValueRef[]) -> ValueRef { +fn C_struct(elts: &[ValueRef]) -> ValueRef { ret llvm::LLVMConstStruct(std::ivec::to_ptr(elts), std::ivec::len(elts), False); } -fn C_named_struct(T: TypeRef, elts: &ValueRef[]) -> ValueRef { +fn C_named_struct(T: TypeRef, elts: &[ValueRef]) -> ValueRef { ret llvm::LLVMConstNamedStruct(T, std::ivec::to_ptr(elts), std::ivec::len(elts)); } -fn C_array(ty: TypeRef, elts: &ValueRef[]) -> ValueRef { +fn C_array(ty: TypeRef, elts: &[ValueRef]) -> ValueRef { ret llvm::LLVMConstArray(ty, std::ivec::to_ptr(elts), std::ivec::len(elts)); } -fn C_bytes(bytes : &u8[]) -> ValueRef { +fn C_bytes(bytes : &[u8]) -> ValueRef { ret llvm::LLVMConstString(unsafe::reinterpret_cast(ivec::to_ptr(bytes)), ivec::len(bytes), False); } -fn C_shape(ccx : &@crate_ctxt, bytes : &u8[]) -> ValueRef { +fn C_shape(ccx : &@crate_ctxt, bytes : &[u8]) -> ValueRef { let llshape = C_bytes(bytes); let llglobal = llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), str::buf(ccx.names.next("shape"))); diff --git a/src/comp/middle/tstate/annotate.rs b/src/comp/middle/tstate/annotate.rs index 705a2dc534c67..4c50f5780c0fe 100644 --- a/src/comp/middle/tstate/annotate.rs +++ b/src/comp/middle/tstate/annotate.rs @@ -23,11 +23,11 @@ import aux::crate_ctxt; import aux::add_node; import middle::tstate::ann::empty_ann; -fn collect_ids_expr(e: &@expr, rs: @mutable node_id[]) { *rs += ~[e.id]; } +fn collect_ids_expr(e: &@expr, rs: @mutable [node_id]) { *rs += ~[e.id]; } -fn collect_ids_block(b: &blk, rs: @mutable node_id[]) { *rs += ~[b.node.id]; } +fn collect_ids_block(b: &blk, rs: @mutable [node_id]) { *rs += ~[b.node.id]; } -fn collect_ids_stmt(s: &@stmt, rs: @mutable node_id[]) { +fn collect_ids_stmt(s: &@stmt, rs: @mutable [node_id]) { alt s.node { stmt_decl(_, id) { log "node_id " + int::str(id); @@ -43,12 +43,12 @@ fn collect_ids_stmt(s: &@stmt, rs: @mutable node_id[]) { } } -fn collect_ids_local(l: &@local, rs: @mutable node_id[]) { +fn collect_ids_local(l: &@local, rs: @mutable [node_id]) { *rs += pat_binding_ids(l.node.pat); } -fn node_ids_in_fn(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident, - id: node_id, rs: @mutable node_id[]) { +fn node_ids_in_fn(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident, + id: node_id, rs: @mutable [node_id]) { let collect_ids = visit::mk_simple_visitor(@{visit_expr: bind collect_ids_expr(_, rs), visit_block: bind collect_ids_block(_, rs), @@ -58,7 +58,7 @@ fn node_ids_in_fn(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident, visit::visit_fn(f, tps, sp, i, id, (), collect_ids); } -fn init_vecs(ccx: &crate_ctxt, node_ids: &node_id[], len: uint) { +fn init_vecs(ccx: &crate_ctxt, node_ids: &[node_id], len: uint) { for i: node_id in node_ids { log int::str(i) + " |-> " + uint::str(len); add_node(ccx, i, empty_ann(len)); @@ -66,14 +66,14 @@ fn init_vecs(ccx: &crate_ctxt, node_ids: &node_id[], len: uint) { } fn visit_fn(ccx: &crate_ctxt, num_constraints: uint, f: &_fn, - tps: &ty_param[], sp: &span, i: &fn_ident, id: node_id) { - let node_ids: @mutable node_id[] = @mutable ~[]; + tps: &[ty_param], sp: &span, i: &fn_ident, id: node_id) { + let node_ids: @mutable [node_id] = @mutable ~[]; node_ids_in_fn(f, tps, sp, i, id, node_ids); let node_id_vec = *node_ids; init_vecs(ccx, node_id_vec, num_constraints); } -fn annotate_in_fn(ccx: &crate_ctxt, f: &_fn, tps: &ty_param[], sp: &span, +fn annotate_in_fn(ccx: &crate_ctxt, f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident, id: node_id) { let f_info = get_fn_info(ccx, id); visit_fn(ccx, num_constraints(f_info), f, tps, sp, i, id); diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index 2b08dde75c6dc..3e53d51b0c4dc 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -58,7 +58,7 @@ fn def_id_to_str(d: def_id) -> str { ret int::str(d.crate) + "," + int::str(d.node); } -fn comma_str(args: &(@constr_arg_use)[]) -> str { +fn comma_str(args: &[@constr_arg_use]) -> str { let rslt = ""; let comma = false; for a: @constr_arg_use in args { @@ -117,7 +117,7 @@ fn first_difference_string(fcx: &fn_ctxt, expected: &tritv::t, fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { log_err tritv_to_str(fcx, v); } -fn tos(v: &uint[]) -> str { +fn tos(v: &[uint]) -> str { let rslt = ""; for i: uint in v { if i == 0u { @@ -127,9 +127,9 @@ fn tos(v: &uint[]) -> str { ret rslt; } -fn log_cond(v: &uint[]) { log tos(v); } +fn log_cond(v: &[uint]) { log tos(v); } -fn log_cond_err(v: &uint[]) { log_err tos(v); } +fn log_cond_err(v: &[uint]) { log_err tos(v); } fn log_pp(pp: &pre_and_post) { let p1 = tritv::to_vec(pp.precondition); @@ -169,7 +169,7 @@ fn log_states_err(pp: &pre_and_post_state) { fn print_ident(i: &ident) { log " " + i + " "; } -fn print_idents(idents: &mutable ident[]) { +fn print_idents(idents: &mutable [ident]) { if ivec::len[ident](idents) == 0u { ret; } log "an ident: " + ivec::pop[ident](idents); print_idents(idents); @@ -206,7 +206,7 @@ to represent predicate *arguments* however. This type Both types store an ident and span, for error-logging purposes. */ -type pred_args_ = {args: (@constr_arg_use)[], bit_num: uint}; +type pred_args_ = {args: [@constr_arg_use], bit_num: uint}; type pred_args = spanned[pred_args_]; @@ -219,7 +219,7 @@ tag constraint { // FIXME: really only want it to be mutable during collect_locals. // freeze it after that. - cpred(path, @mutable pred_args[]); + cpred(path, @mutable [pred_args]); } // An ninit variant has a node_id because it refers to a local var. @@ -229,7 +229,7 @@ tag constraint { // and give ninit a constraint saying it's local. tag tsconstr { ninit(node_id, ident); - npred(path, def_id, (@constr_arg_use)[]); + npred(path, def_id, [@constr_arg_use]); } type sp_constr = spanned[tsconstr]; @@ -278,7 +278,7 @@ type fn_info = computation, of all local variables that may be used */ // Doesn't seem to work without the @ -- bug - used_vars: @mutable node_id[]}; + used_vars: @mutable [node_id]}; fn tsconstr_to_def_id(t: &tsconstr) -> def_id { alt t { ninit(id, _) { local_def(id) } npred(_, id, _) { id } } @@ -291,7 +291,7 @@ fn tsconstr_to_node_id(t: &tsconstr) -> node_id { } /* mapping from node ID to typestate annotation */ -type node_ann_table = @mutable ts_ann[mutable ]; +type node_ann_table = @mutable [mutable ts_ann]; /* mapping from function name to fn_info map */ @@ -507,7 +507,7 @@ fn pure_exp(ccx: &crate_ctxt, id: node_id, p: &prestate) -> bool { fn num_constraints(m: fn_info) -> uint { ret m.num_constraints; } fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt { - let na: ts_ann[mutable ] = ~[mutable ]; + let na: [mutable ts_ann] = ~[mutable]; ret {tcx: cx, node_anns: @mutable na, fm: @new_int_hash[fn_info]()}; } @@ -521,7 +521,7 @@ fn controlflow_expr(ccx: &crate_ctxt, e: @expr) -> controlflow { } } -fn constraints_expr(cx: &ty::ctxt, e: @expr) -> (@ty::constr)[] { +fn constraints_expr(cx: &ty::ctxt, e: @expr) -> [@ty::constr] { alt ty::struct(cx, ty::node_id_to_type(cx, e.id)) { ty::ty_fn(_, _, _, _, cs) { ret cs; } _ { ret ~[]; } @@ -554,13 +554,13 @@ fn node_id_to_def_upvar(cx: &fn_ctxt, id: node_id) -> option::t[def] { ret freevars::def_lookup(cx.ccx.tcx, cx.id, id); } -fn norm_a_constraint(id: def_id, c: &constraint) -> norm_constraint[] { +fn norm_a_constraint(id: def_id, c: &constraint) -> [norm_constraint] { alt c { cinit(n, sp, i) { ret ~[{bit_num: n, c: respan(sp, ninit(id.node, i))}]; } cpred(p, descs) { - let rslt: norm_constraint[] = ~[]; + let rslt: [norm_constraint] = ~[]; for pd: pred_args in *descs { rslt += ~[{bit_num: pd.node.bit_num, @@ -574,8 +574,8 @@ fn norm_a_constraint(id: def_id, c: &constraint) -> norm_constraint[] { // Tried to write this as an iterator, but I got a // non-exhaustive match in trans. -fn constraints(fcx: &fn_ctxt) -> norm_constraint[] { - let rslt: norm_constraint[] = ~[]; +fn constraints(fcx: &fn_ctxt) -> [norm_constraint] { + let rslt: [norm_constraint] = ~[]; for each p: @{key: def_id, val: constraint} in fcx.enclosing.constrs.items() { rslt += norm_a_constraint(p.key, p.val); @@ -586,8 +586,8 @@ fn constraints(fcx: &fn_ctxt) -> norm_constraint[] { // FIXME // Would rather take an immutable vec as an argument, // should freeze it at some earlier point. -fn match_args(fcx: &fn_ctxt, occs: &@mutable pred_args[], - occ: &(@constr_arg_use)[]) -> uint { +fn match_args(fcx: &fn_ctxt, occs: &@mutable [pred_args], + occ: &[@constr_arg_use]) -> uint { log "match_args: looking at " + constr_args_to_str(fn (i: &inst) -> str { ret i.ident; }, occ); for pd: pred_args in *occs { @@ -638,10 +638,10 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: &@expr) -> @constr_arg_use { } } -fn exprs_to_constr_args(tcx: ty::ctxt, args: &(@expr)[]) -> - (@constr_arg_use)[] { +fn exprs_to_constr_args(tcx: ty::ctxt, args: &[@expr]) -> + [@constr_arg_use] { let f = bind expr_to_constr_arg(tcx, _); - let rslt: (@constr_arg_use)[] = ~[]; + let rslt: [@constr_arg_use] = ~[]; for e: @expr in args { rslt += ~[f(e)]; } rslt } @@ -679,16 +679,16 @@ fn pred_args_to_str(p: &pred_args) -> str { + ">" } -fn substitute_constr_args(cx: &ty::ctxt, actuals: &(@expr)[], c: &@ty::constr) +fn substitute_constr_args(cx: &ty::ctxt, actuals: &[@expr], c: &@ty::constr) -> tsconstr { - let rslt: (@constr_arg_use)[] = ~[]; + let rslt: [@constr_arg_use] = ~[]; for a: @constr_arg in c.node.args { rslt += ~[substitute_arg(cx, actuals, a)]; } ret npred(c.node.path, c.node.id, rslt); } -fn substitute_arg(cx: &ty::ctxt, actuals: &(@expr)[], a: @constr_arg) -> +fn substitute_arg(cx: &ty::ctxt, actuals: &[@expr], a: @constr_arg) -> @constr_arg_use { let num_actuals = ivec::len(actuals); alt a.node { @@ -704,7 +704,7 @@ fn substitute_arg(cx: &ty::ctxt, actuals: &(@expr)[], a: @constr_arg) -> } } -fn pred_args_matches(pattern: &(constr_arg_general_[inst])[], +fn pred_args_matches(pattern: &[constr_arg_general_[inst]], desc: &pred_args) -> bool { let i = 0u; for c: @constr_arg_use in desc.node.args { @@ -729,8 +729,8 @@ fn pred_args_matches(pattern: &(constr_arg_general_[inst])[], ret true; } -fn find_instance_(pattern: &(constr_arg_general_[inst])[], - descs: &pred_args[]) -> option::t[uint] { +fn find_instance_(pattern: &[constr_arg_general_[inst]], + descs: &[pred_args]) -> option::t[uint] { for d: pred_args in descs { if pred_args_matches(pattern, d) { ret some(d.node.bit_num); } } @@ -738,10 +738,10 @@ fn find_instance_(pattern: &(constr_arg_general_[inst])[], } type inst = {ident: ident, node: node_id}; -type subst = {from: inst, to: inst}[]; +type subst = [{from: inst, to: inst}]; fn find_instances(fcx: &fn_ctxt, subst: &subst, c: &constraint) -> - {from: uint, to: uint}[] { + [{from: uint, to: uint}] { let rslt = ~[]; if ivec::len(subst) == 0u { ret rslt; } @@ -775,7 +775,7 @@ fn find_in_subst_bool(s: &subst, id: node_id) -> bool { is_some(find_in_subst(id, s)) } -fn insts_to_str(stuff: &(constr_arg_general_[inst])[]) -> str { +fn insts_to_str(stuff: &[constr_arg_general_[inst]]) -> str { let rslt = "<"; for i: constr_arg_general_[inst] in stuff { rslt += @@ -790,8 +790,8 @@ fn insts_to_str(stuff: &(constr_arg_general_[inst])[]) -> str { rslt } -fn replace(subst: subst, d: pred_args) -> (constr_arg_general_[inst])[] { - let rslt: (constr_arg_general_[inst])[] = ~[]; +fn replace(subst: subst, d: pred_args) -> [constr_arg_general_[inst]] { + let rslt: [constr_arg_general_[inst]] = ~[]; for c: @constr_arg_use in d.node.args { alt c.node { carg_ident(p) { @@ -991,7 +991,7 @@ fn forget_in_poststate_still_init(fcx: &fn_ctxt, p: &poststate, ret changed; } -fn any_eq(v: &node_id[], d: node_id) -> bool { +fn any_eq(v: &[node_id], d: node_id) -> bool { for i: node_id in v { if i == d { ret true; } } false } @@ -1012,13 +1012,13 @@ fn non_init_constraint_mentions(fcx: &fn_ctxt, c: &norm_constraint, }; } -fn args_mention[T](args: &(@constr_arg_use)[], q: fn(&T[], node_id) -> bool , - s: &T[]) -> bool { +fn args_mention[T](args: &[@constr_arg_use], q: fn(&[T], node_id) -> bool , + s: &[T]) -> bool { /* FIXME The following version causes an assertion in trans to fail (something about type_is_tup_like) - fn mentions[T](&(T)[] s, &fn(&(T)[], def_id) -> bool q, + fn mentions[T](&[T] s, &fn(&[T], def_id) -> bool q, &@constr_arg_use a) -> bool { alt (a.node) { case (carg_ident(?p1)) { @@ -1041,7 +1041,7 @@ fn args_mention[T](args: &(@constr_arg_use)[], q: fn(&T[], node_id) -> bool , fn use_var(fcx: &fn_ctxt, v: &node_id) { *fcx.enclosing.used_vars += ~[v]; } // FIXME: This should be a function in std::ivec::. -fn vec_contains(v: &@mutable node_id[], i: &node_id) -> bool { +fn vec_contains(v: &@mutable [node_id], i: &node_id) -> bool { for d: node_id in *v { if d == i { ret true; } } ret false; } @@ -1051,33 +1051,33 @@ fn op_to_oper_ty(io: init_op) -> oper_type { } // default function visitor -fn do_nothing[T](f: &_fn, tp: &ty_param[], sp: &span, i: &fn_ident, +fn do_nothing[T](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, iid: node_id, cx: &T, v: &visit::vt[T]) { } -fn args_to_constr_args(sp: &span, args: &arg[]) -> (@constr_arg_use)[] { - let actuals: (@constr_arg_use)[] = ~[]; +fn args_to_constr_args(sp: &span, args: &[arg]) -> [@constr_arg_use] { + let actuals: [@constr_arg_use] = ~[]; for a: arg in args { actuals += ~[@respan(sp, carg_ident({ident: a.ident, node: a.id}))]; } ret actuals; } -fn ast_constr_to_ts_constr(tcx: &ty::ctxt, args: &arg[], c: &@constr) -> +fn ast_constr_to_ts_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) -> tsconstr { let tconstr = ty::ast_constr_to_constr(tcx, c); ret npred(tconstr.node.path, tconstr.node.id, args_to_constr_args(tconstr.span, args)); } -fn ast_constr_to_sp_constr(tcx: &ty::ctxt, args: &arg[], c: &@constr) -> +fn ast_constr_to_sp_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) -> sp_constr { let tconstr = ast_constr_to_ts_constr(tcx, args, c); ret respan(c.span, tconstr); } -type binding = {lhs: inst[], rhs: option::t[initializer]}; +type binding = {lhs: [inst], rhs: option::t[initializer]}; fn local_to_bindings(loc : &@local) -> binding { let lhs = ~[]; @@ -1089,11 +1089,11 @@ fn local_to_bindings(loc : &@local) -> binding { rhs: loc.node.init} } -fn locals_to_bindings(locals : &(@local)[]) -> binding[] { +fn locals_to_bindings(locals : &[@local]) -> [binding] { ivec::map(local_to_bindings, locals) } -fn anon_bindings(es : &(@expr)[]) -> binding[] { +fn anon_bindings(es : &[@expr]) -> [binding] { fn expr_to_initializer(e : &@expr) -> initializer { {op: init_assign, expr: e} } diff --git a/src/comp/middle/tstate/bitvectors.rs b/src/comp/middle/tstate/bitvectors.rs index a055187e28676..3f4a80c01c39e 100644 --- a/src/comp/middle/tstate/bitvectors.rs +++ b/src/comp/middle/tstate/bitvectors.rs @@ -76,7 +76,7 @@ fn seq_tritv(p: &postcond, q: &postcond) { } } -fn seq_postconds(fcx: &fn_ctxt, ps: &postcond[]) -> postcond { +fn seq_postconds(fcx: &fn_ctxt, ps: &[postcond]) -> postcond { let sz = ivec::len(ps); if sz >= 1u { let prev = tritv_clone(ps.(0)); @@ -89,11 +89,11 @@ fn seq_postconds(fcx: &fn_ctxt, ps: &postcond[]) -> postcond { // return the precondition for evaluating each expr in order. // So, if e0's post is {x} and e1's pre is {x, y, z}, the entire // precondition shouldn't include x. -fn seq_preconds(fcx: &fn_ctxt, pps: &pre_and_post[]) -> precond { +fn seq_preconds(fcx: &fn_ctxt, pps: &[pre_and_post]) -> precond { let sz: uint = ivec::len(pps); let num_vars: uint = num_constraints(fcx.enclosing); - fn seq_preconds_go(fcx: &fn_ctxt, pps: &pre_and_post[], + fn seq_preconds_go(fcx: &fn_ctxt, pps: &[pre_and_post], first: &pre_and_post) -> precond { let sz: uint = ivec::len(pps); if sz >= 1u { diff --git a/src/comp/middle/tstate/ck.rs b/src/comp/middle/tstate/ck.rs index 73b845ac3bfb1..94c2d5c625f9c 100644 --- a/src/comp/middle/tstate/ck.rs +++ b/src/comp/middle/tstate/ck.rs @@ -125,7 +125,7 @@ fn check_states_stmt(s: &@stmt, fcx: &fn_ctxt, v: &visit::vt[fn_ctxt]) { } fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn, - tps: &ast::ty_param[], id: node_id, + tps: &[ast::ty_param], id: node_id, sp: &span, i: &fn_ident) { /* Postorder traversal instead of pre is important because we want the smallest possible erroneous statement @@ -170,7 +170,7 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn, check_unused_vars(fcx); } -fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &ast::ty_param[], id: node_id, +fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &[ast::ty_param], id: node_id, sp: &span, i: &fn_ident) { /* Compute the pre- and post-states for this function */ @@ -183,7 +183,7 @@ fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &ast::ty_param[], id: node_id, check_states_against_conditions(fcx, f, tps, id, sp, i); } -fn fn_states(f: &_fn, tps: &ast::ty_param[], sp: &span, i: &fn_ident, +fn fn_states(f: &_fn, tps: &[ast::ty_param], sp: &span, i: &fn_ident, id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) { visit::visit_fn(f, tps, sp, i, id, ccx, v); /* Look up the var-to-bit-num map for this function */ diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs index c420bc0151cfd..f60745d596a22 100644 --- a/src/comp/middle/tstate/collect_locals.rs +++ b/src/comp/middle/tstate/collect_locals.rs @@ -11,7 +11,7 @@ import util::common::new_def_hash; import syntax::codemap::span; import syntax::ast::respan; -type ctxt = {cs: @mutable sp_constr[], tcx: ty::ctxt}; +type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt}; fn collect_local(loc: &@local, cx: &ctxt, v: &visit::vt[ctxt]) { for each p: @pat in pat_bindings(loc.node.pat) { @@ -43,7 +43,7 @@ fn collect_pred(e: &@expr, cx: &ctxt, v: &visit::vt[ctxt]) { visit::visit_expr(e, cx, v); } -fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &ty_param[], sp: &span, +fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident, id: node_id) -> ctxt { let cx: ctxt = {cs: @mutable ~[], tcx: tcx}; let visitor = visit::default_visitor[ctxt](); @@ -75,7 +75,7 @@ fn add_constraint(tcx: &ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) } } none. { - let rslt: @mutable pred_args[] = + let rslt: @mutable [pred_args] = @mutable ~[respan(c.span, {args: args, bit_num: next})]; tbl.insert(d_id, cpred(p, rslt)); } @@ -88,7 +88,7 @@ fn add_constraint(tcx: &ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) /* builds a table mapping each local var defined in f to a bit number in the precondition/postcondition vectors */ -fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &ty_param[], f_sp: &span, +fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &[ty_param], f_sp: &span, f_name: &fn_ident, id: node_id) { let name = fn_ident_to_string(id, f_name); let res_map = @new_def_hash[constraint](); @@ -122,7 +122,7 @@ fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &ty_param[], f_sp: &span, add_constraint(cx.tcx, respan(f_sp, ninit(diverges_id, diverges_name)), next, res_map); - let v: @mutable node_id[] = @mutable ~[]; + let v: @mutable [node_id] = @mutable ~[]; let rslt = {constrs: res_map, num_constraints: diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index 473e1cfbf2bdd..fcdd4e9ab7eb5 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -73,7 +73,7 @@ fn find_pre_post_item(ccx: &crate_ctxt, i: &item) { alt i.node { item_const(_, e) { // make a fake fcx - let v: @mutable node_id[] = @mutable ~[]; + let v: @mutable [node_id] = @mutable ~[]; let fake_fcx = {enclosing: {constrs: @new_def_hash[constraint](), @@ -115,7 +115,7 @@ fn find_pre_post_item(ccx: &crate_ctxt, i: &item) { sets the precondition in a to be the result of combining the preconditions for , and the postcondition in a to be the union of all postconditions for */ -fn find_pre_post_exprs(fcx: &fn_ctxt, args: &(@expr)[], id: node_id) { +fn find_pre_post_exprs(fcx: &fn_ctxt, args: &[@expr], id: node_id) { if ivec::len[@expr](args) > 0u { log "find_pre_post_exprs: oper ="; log_expr(*args.(0)); @@ -669,7 +669,7 @@ fn find_pre_post_block(fcx: &fn_ctxt, b: blk) { let do_inner = bind do_inner_(fcx, _); option::map[@expr, ()](do_inner, b.node.expr); - let pps: pre_and_post[] = ~[]; + let pps: [pre_and_post] = ~[]; for s: @stmt in b.node.stmts { pps += ~[stmt_pp(fcx.ccx, *s)]; } alt b.node.expr { none. {/* no-op */ } @@ -709,7 +709,7 @@ fn find_pre_post_fn(fcx: &fn_ctxt, f: &_fn) { } } -fn fn_pre_post(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident, +fn fn_pre_post(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident, id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) { visit::visit_fn(f, tps, sp, i, id, ccx, v); assert (ccx.fm.contains_key(id)); diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index 0f7d920e6ce90..681db897d59f6 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -50,7 +50,7 @@ fn handle_move_or_copy(fcx: &fn_ctxt, post: &poststate, rhs_path: &path, } } -fn seq_states(fcx: &fn_ctxt, pres: &prestate, bindings: &binding[]) +fn seq_states(fcx: &fn_ctxt, pres: &prestate, bindings: &[binding]) -> {changed: bool, post: poststate} { let changed = false; let post = tritv_clone(pres); @@ -162,7 +162,7 @@ fn find_pre_post_state_two(fcx: &fn_ctxt, pres: &prestate, lhs: &@expr, } fn find_pre_post_state_call(fcx: &fn_ctxt, pres: &prestate, a: &@expr, - id: node_id, bs: &(@expr)[], cf: controlflow) -> + id: node_id, bs: &[@expr], cf: controlflow) -> bool { let changed = find_pre_post_state_expr(fcx, pres, a); ret find_pre_post_state_exprs(fcx, expr_poststate(fcx.ccx, a), id, bs, cf) @@ -170,7 +170,7 @@ fn find_pre_post_state_call(fcx: &fn_ctxt, pres: &prestate, a: &@expr, } fn find_pre_post_state_exprs(fcx: &fn_ctxt, pres: &prestate, id: node_id, - es: &(@expr)[], cf: controlflow) -> bool { + es: &[@expr], cf: controlflow) -> bool { let rs = seq_states(fcx, pres, anon_bindings(es)); let changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres); /* if this is a failing call, it sets everything as initialized */ diff --git a/src/comp/middle/tstate/tritv.rs b/src/comp/middle/tstate/tritv.rs index 1d33292c9a9f9..998e20e19a3c9 100644 --- a/src/comp/middle/tstate/tritv.rs +++ b/src/comp/middle/tstate/tritv.rs @@ -239,9 +239,9 @@ fn tritv_doesntcare(v: &t) -> bool { ret true; } -fn to_vec(v: &t) -> uint[] { +fn to_vec(v: &t) -> [uint] { let i: uint = 0u; - let rslt: uint[] = ~[]; + let rslt: [uint] = ~[]; while i < v.nbits { rslt += ~[alt tritv_get(v, i) { diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 00f2e6a1b86b2..2c1527ce24fcb 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -196,12 +196,12 @@ type field = {ident: ast::ident, mt: mt}; type method = {proto: ast::proto, ident: ast::ident, - inputs: arg[], + inputs: [arg], output: t, cf: controlflow, - constrs: (@constr)[]}; + constrs: [@constr]}; -type constr_table = hashmap[ast::node_id, constr[]]; +type constr_table = hashmap[ast::node_id, [constr]]; type mt = {ty: t, mut: ast::mutability}; @@ -262,7 +262,7 @@ tag sty { ty_char; ty_str; ty_istr; - ty_tag(def_id, t[]); + ty_tag(def_id, [t]); ty_box(mt); ty_vec(mt); ty_ivec(mt); @@ -270,18 +270,18 @@ tag sty { ty_port(t); ty_chan(t); ty_task; - ty_rec(field[]); - ty_fn(ast::proto, arg[], t, controlflow, (@constr)[]); - ty_native_fn(ast::native_abi, arg[], t); - ty_obj(method[]); - ty_res(def_id, t, t[]); + ty_rec([field]); + ty_fn(ast::proto, [arg], t, controlflow, [@constr]); + ty_native_fn(ast::native_abi, [arg], t); + ty_obj([method]); + ty_res(def_id, t, [t]); ty_var(int); // type variable ty_param(uint, ast::kind); // fn/tag type param ty_type; ty_native(def_id); - ty_constr(t, (@type_constr)[]); + ty_constr(t, [@type_constr]); // TODO: ty_fn_arg(t), for a possibly-aliased function argument } @@ -308,7 +308,7 @@ tag type_err { terr_constr_mismatch(@type_constr, @type_constr); } -type ty_param_kinds_and_ty = {kinds: ast::kind[], ty: t}; +type ty_param_kinds_and_ty = {kinds: [ast::kind], ty: t}; type type_cache = hashmap[ast::def_id, ty_param_kinds_and_ty]; @@ -358,7 +358,7 @@ const idx_first_others: uint = 21u; type type_store = interner::interner[@raw_t]; -type ty_param_substs_opt_and_ty = {substs: option::t[ty::t[]], ty: ty::t}; +type ty_param_substs_opt_and_ty = {substs: option::t[[ty::t]], ty: ty::t}; type node_type_table = @smallintmap::smallintmap[ty::ty_param_substs_opt_and_ty]; @@ -446,7 +446,7 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, in_cname: &option::t[str]) -> @raw_t { derive_flags_t(cx, has_params, has_vars, a.ty); } fn derive_flags_sig(cx: &ctxt, has_params: &mutable bool, - has_vars: &mutable bool, args: &arg[], tt: &t) { + has_vars: &mutable bool, args: &[arg], tt: &t) { for a: arg in args { derive_flags_arg(cx, has_params, has_vars, a); } derive_flags_t(cx, has_params, has_vars, tt); } @@ -551,7 +551,7 @@ fn mk_str(cx: &ctxt) -> t { ret idx_str; } fn mk_istr(cx: &ctxt) -> t { ret idx_istr; } -fn mk_tag(cx: &ctxt, did: &ast::def_id, tys: &t[]) -> t { +fn mk_tag(cx: &ctxt, did: &ast::def_id, tys: &[t]) -> t { ret gen_ty(cx, ty_tag(did, tys)); } @@ -581,9 +581,9 @@ fn mk_chan(cx: &ctxt, ty: &t) -> t { ret gen_ty(cx, ty_chan(ty)); } fn mk_task(cx: &ctxt) -> t { ret gen_ty(cx, ty_task); } -fn mk_rec(cx: &ctxt, fs: &field[]) -> t { ret gen_ty(cx, ty_rec(fs)); } +fn mk_rec(cx: &ctxt, fs: &[field]) -> t { ret gen_ty(cx, ty_rec(fs)); } -fn mk_imm_tup(cx: &ctxt, tys: &t[]) -> t { +fn mk_imm_tup(cx: &ctxt, tys: &[t]) -> t { let fields = ~[]; let i = 0u; for typ: t in tys { @@ -593,22 +593,22 @@ fn mk_imm_tup(cx: &ctxt, tys: &t[]) -> t { ret gen_ty(cx, ty_rec(fields)); } -fn mk_constr(cx: &ctxt, t: &t, cs: &(@type_constr)[]) -> t { +fn mk_constr(cx: &ctxt, t: &t, cs: &[@type_constr]) -> t { ret gen_ty(cx, ty_constr(t, cs)); } -fn mk_fn(cx: &ctxt, proto: &ast::proto, args: &arg[], ty: &t, - cf: &controlflow, constrs: &(@constr)[]) -> t { +fn mk_fn(cx: &ctxt, proto: &ast::proto, args: &[arg], ty: &t, + cf: &controlflow, constrs: &[@constr]) -> t { ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs)); } -fn mk_native_fn(cx: &ctxt, abi: &ast::native_abi, args: &arg[], ty: &t) -> t { +fn mk_native_fn(cx: &ctxt, abi: &ast::native_abi, args: &[arg], ty: &t) -> t { ret gen_ty(cx, ty_native_fn(abi, args, ty)); } -fn mk_obj(cx: &ctxt, meths: &method[]) -> t { ret gen_ty(cx, ty_obj(meths)); } +fn mk_obj(cx: &ctxt, meths: &[method]) -> t { ret gen_ty(cx, ty_obj(meths)); } -fn mk_res(cx: &ctxt, did: &ast::def_id, inner: &t, tps: &t[]) -> t { +fn mk_res(cx: &ctxt, did: &ast::def_id, inner: &t, tps: &[t]) -> t { ret gen_ty(cx, ty_res(did, inner, tps)); } @@ -758,12 +758,12 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t { ty = copy_cname(cx, mk_chan(cx, fold_ty(cx, fld, subty)), ty); } ty_tag(tid, subtys) { - let new_subtys: t[] = ~[]; + let new_subtys: [t] = ~[]; for subty: t in subtys { new_subtys += ~[fold_ty(cx, fld, subty)]; } ty = copy_cname(cx, mk_tag(cx, tid, new_subtys), ty); } ty_rec(fields) { - let new_fields: field[] = ~[]; + let new_fields: [field] = ~[]; for fl: field in fields { let new_ty = fold_ty(cx, fld, fl.mt.ty); let new_mt = {ty: new_ty, mut: fl.mt.mut}; @@ -772,7 +772,7 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t { ty = copy_cname(cx, mk_rec(cx, new_fields), ty); } ty_fn(proto, args, ret_ty, cf, constrs) { - let new_args: arg[] = ~[]; + let new_args: [arg] = ~[]; for a: arg in args { let new_ty = fold_ty(cx, fld, a.ty); new_args += ~[{mode: a.mode, ty: new_ty}]; @@ -783,7 +783,7 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t { cf, constrs), ty); } ty_native_fn(abi, args, ret_ty) { - let new_args: arg[] = ~[]; + let new_args: [arg] = ~[]; for a: arg in args { let new_ty = fold_ty(cx, fld, a.ty); new_args += ~[{mode: a.mode, ty: new_ty}]; @@ -794,9 +794,9 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t { fold_ty(cx, fld, ret_ty)), ty); } ty_obj(methods) { - let new_methods: method[] = ~[]; + let new_methods: [method] = ~[]; for m: method in methods { - let new_args: arg[] = ~[]; + let new_args: [arg] = ~[]; for a: arg in m.inputs { new_args += ~[{mode: a.mode, ty: fold_ty(cx, fld, a.ty)}]; } @@ -1400,8 +1400,8 @@ fn type_param(cx: &ctxt, ty: &t) -> option::t[uint] { // Returns an ivec of all the type variables // occurring in t. It may contain duplicates. -fn vars_in_type(cx:&ctxt, ty: &t) -> int[] { - fn collect_var(cx:&ctxt, vars: &@mutable int[], ty: t) { +fn vars_in_type(cx:&ctxt, ty: &t) -> [int] { + fn collect_var(cx:&ctxt, vars: &@mutable [int], ty: t) { alt struct(cx, ty) { ty_var(v) { *vars += ~[v]; @@ -1409,7 +1409,7 @@ fn vars_in_type(cx:&ctxt, ty: &t) -> int[] { _ {} } } - let rslt: @mutable int[] = @mutable (~[]); + let rslt: @mutable [int] = @mutable (~[]); walk_ty(cx, bind collect_var(cx, rslt, _), ty); // Works because of a "convenient" bug that lets us // return a mutable ivec as if it's immutable @@ -1462,7 +1462,7 @@ fn hash_type_structure(st: &sty) -> uint { h += h << 5u + hash_def(h, c.node.id); ret hash_type_constr_args(h, c.node.args); } - fn hash_type_constr_args(id: uint, args: (@ty_constr_arg)[]) -> uint { + fn hash_type_constr_args(id: uint, args: [@ty_constr_arg]) -> uint { let h = id; for a: @ty_constr_arg in args { alt a.node { @@ -1481,7 +1481,7 @@ fn hash_type_structure(st: &sty) -> uint { } - fn hash_fn(id: uint, args: &arg[], rty: &t) -> uint { + fn hash_fn(id: uint, args: &[arg], rty: &t) -> uint { let h = id; for a: arg in args { h += h << 5u + hash_ty(a.ty); } h += h << 5u + hash_ty(rty); @@ -1589,8 +1589,8 @@ fn arg_eq[T](eq: &fn(&T, &T) -> bool , a: @sp_constr_arg[T], } } -fn args_eq[T](eq: fn(&T, &T) -> bool , a: &(@sp_constr_arg[T])[], - b: &(@sp_constr_arg[T])[]) -> bool { +fn args_eq[T](eq: fn(&T, &T) -> bool , a: &[@sp_constr_arg[T]], + b: &[@sp_constr_arg[T]]) -> bool { let i: uint = 0u; for arg: @sp_constr_arg[T] in a { if !arg_eq(eq, arg, b.(i)) { ret false; } @@ -1605,7 +1605,7 @@ fn constr_eq(c: &@constr, d: &@constr) -> bool { args_eq(eq_int, c.node.args, d.node.args); } -fn constrs_eq(cs: &(@constr)[], ds: &(@constr)[]) -> bool { +fn constrs_eq(cs: &[@constr], ds: &[@constr]) -> bool { if ivec::len(cs) != ivec::len(ds) { ret false; } let i = 0u; for c: @constr in cs { if !constr_eq(c, ds.(i)) { ret false; } i += 1u; } @@ -1616,7 +1616,7 @@ fn equal_type_structures(a: &sty, b: &sty) -> bool { fn equal_mt(a: &mt, b: &mt) -> bool { ret a.mut == b.mut && eq_ty(a.ty, b.ty); } - fn equal_fn(args_a: &arg[], rty_a: &t, args_b: &arg[], rty_b: &t) -> + fn equal_fn(args_a: &[arg], rty_a: &t, args_b: &[arg], rty_b: &t) -> bool { if !eq_ty(rty_a, rty_b) { ret false; } let len = ivec::len[arg](args_a); @@ -1831,7 +1831,7 @@ fn node_id_to_type(cx: &ctxt, id: &ast::node_id) -> t { ret node_id_to_ty_param_substs_opt_and_ty(cx, id).ty; } -fn node_id_to_type_params(cx: &ctxt, id: &ast::node_id) -> t[] { +fn node_id_to_type_params(cx: &ctxt, id: &ast::node_id) -> [t] { alt node_id_to_ty_param_substs_opt_and_ty(cx, id).substs { none. { ret ~[]; } some(tps) { ret tps; } @@ -1864,7 +1864,7 @@ fn node_id_to_monotype(cx: &ctxt, id: ast::node_id) -> t { // Returns the number of distinct type parameters in the given type. fn count_ty_params(cx: &ctxt, ty: t) -> uint { - fn counter(cx: &ctxt, param_indices: @mutable uint[], ty: t) { + fn counter(cx: &ctxt, param_indices: @mutable [uint], ty: t) { alt struct(cx, ty) { ty_param(param_idx,_) { let seen = false; @@ -1876,7 +1876,7 @@ fn count_ty_params(cx: &ctxt, ty: t) -> uint { _ {/* fall through */ } } } - let param_indices: @mutable uint[] = @mutable ~[]; + let param_indices: @mutable [uint] = @mutable ~[]; let f = bind counter(cx, param_indices, _); walk_ty(cx, f, ty); ret ivec::len[uint](*param_indices); @@ -1892,7 +1892,7 @@ fn type_contains_params(cx: &ctxt, typ: &t) -> bool { // Type accessors for substructures of types -fn ty_fn_args(cx: &ctxt, fty: &t) -> arg[] { +fn ty_fn_args(cx: &ctxt, fty: &t) -> [arg] { alt struct(cx, fty) { ty::ty_fn(_, a, _, _, _) { ret a; } ty::ty_native_fn(_, a, _) { ret a; } @@ -1962,7 +1962,7 @@ fn expr_ty(cx: &ctxt, expr: &@ast::expr) -> t { } fn expr_ty_params_and_ty(cx: &ctxt, expr: &@ast::expr) -> - {params: t[], ty: t} { + {params: [t], ty: t} { ret {params: node_id_to_type_params(cx, expr.id), ty: node_id_to_type(cx, expr.id)}; } @@ -1983,20 +1983,20 @@ fn stmt_node_id(s: &@ast::stmt) -> ast::node_id { } fn field_idx(sess: &session::session, sp: &span, id: &ast::ident, - fields: &field[]) -> uint { + fields: &[field]) -> uint { let i: uint = 0u; for f: field in fields { if str::eq(f.ident, id) { ret i; } i += 1u; } sess.span_fatal(sp, "unknown field '" + id + "' of record"); } fn method_idx(sess: &session::session, sp: &span, id: &ast::ident, - meths: &method[]) -> uint { + meths: &[method]) -> uint { let i: uint = 0u; for m: method in meths { if str::eq(m.ident, id) { ret i; } i += 1u; } sess.span_fatal(sp, "unknown method '" + id + "' of obj"); } -fn sort_methods(meths: &method[]) -> method[] { +fn sort_methods(meths: &[method]) -> [method] { fn method_lteq(a: &method, b: &method) -> bool { ret str::lteq(a.ident, b.ident); } @@ -2150,8 +2150,8 @@ mod unify { // Right now this just checks that the lists of constraints are // pairwise equal. - fn unify_constrs(base_t: &t, expected: (@type_constr)[], - actual: &(@type_constr)[]) -> result { + fn unify_constrs(base_t: &t, expected: [@type_constr], + actual: &[@type_constr]) -> result { let expected_len = ivec::len(expected); let actual_len = ivec::len(actual); @@ -2211,11 +2211,11 @@ mod unify { } tag fn_common_res { fn_common_res_err(result); - fn_common_res_ok(arg[], t); + fn_common_res_ok([arg], t); } fn unify_fn_common(cx: &@ctxt, expected: &t, actual: &t, - expected_inputs: &arg[], expected_output: &t, - actual_inputs: &arg[], actual_output: &t) -> + expected_inputs: &[arg], expected_output: &t, + actual_inputs: &[arg], actual_output: &t) -> fn_common_res { let expected_len = ivec::len[arg](expected_inputs); let actual_len = ivec::len[arg](actual_inputs); @@ -2224,7 +2224,7 @@ mod unify { } // TODO: as above, we should have an iter2 iterator. - let result_ins: arg[] = ~[]; + let result_ins: [arg] = ~[]; let i = 0u; while i < expected_len { let expected_input = expected_inputs.(i); @@ -2253,10 +2253,10 @@ mod unify { } } fn unify_fn(cx: &@ctxt, e_proto: &ast::proto, a_proto: &ast::proto, - expected: &t, actual: &t, expected_inputs: &arg[], - expected_output: &t, actual_inputs: &arg[], actual_output: &t, + expected: &t, actual: &t, expected_inputs: &[arg], + expected_output: &t, actual_inputs: &[arg], actual_output: &t, expected_cf: &controlflow, actual_cf: &controlflow, - expected_constrs: &(@constr)[], actual_constrs: &(@constr)[]) + expected_constrs: &[@constr], actual_constrs: &[@constr]) -> result { if e_proto != a_proto { ret ures_err(terr_mismatch); } alt expected_cf { @@ -2295,8 +2295,8 @@ mod unify { } fn unify_native_fn(cx: &@ctxt, e_abi: &ast::native_abi, a_abi: &ast::native_abi, expected: &t, actual: &t, - expected_inputs: &arg[], expected_output: &t, - actual_inputs: &arg[], actual_output: &t) -> result { + expected_inputs: &[arg], expected_output: &t, + actual_inputs: &[arg], actual_output: &t) -> result { if e_abi != a_abi { ret ures_err(terr_mismatch); } let t = unify_fn_common(cx, expected, actual, expected_inputs, @@ -2310,9 +2310,9 @@ mod unify { } } fn unify_obj(cx: &@ctxt, expected: &t, actual: &t, - expected_meths: &method[], actual_meths: &method[]) -> + expected_meths: &[method], actual_meths: &[method]) -> result { - let result_meths: method[] = ~[]; + let result_meths: [method] = ~[]; let i: uint = 0u; let expected_len: uint = ivec::len[method](expected_meths); let actual_len: uint = ivec::len[method](actual_meths); @@ -2454,7 +2454,7 @@ mod unify { ret ures_err(terr_mismatch); } // TODO: factor this cruft out - let result_tps: t[] = ~[]; + let result_tps: [t] = ~[]; let i = 0u; let expected_len = ivec::len[t](expected_tps); while i < expected_len { @@ -2620,7 +2620,7 @@ mod unify { // TODO: implement an iterator that can iterate over // two arrays simultaneously. - let result_fields: field[] = ~[]; + let result_fields: [field] = ~[]; let i = 0u; while i < expected_len { let expected_field = expected_fields.(i); @@ -2835,11 +2835,11 @@ fn type_err_to_str(err: &ty::type_err) -> str { // Converts type parameters in a type to type variables and returns the // resulting type along with a list of type variable IDs. fn bind_params_in_type(sp: &span, cx: &ctxt, next_ty_var: fn() -> int , - typ: t, ty_param_count: uint) -> {ids: int[], ty: t} { - let param_var_ids: @mutable int[] = @mutable ~[]; + typ: t, ty_param_count: uint) -> {ids: [int], ty: t} { + let param_var_ids: @mutable [int] = @mutable ~[]; let i = 0u; while i < ty_param_count { *param_var_ids += ~[next_ty_var()]; i += 1u; } - fn binder(sp: span, cx: ctxt, param_var_ids: @mutable int[], + fn binder(sp: span, cx: ctxt, param_var_ids: @mutable [int], next_ty_var: fn() -> int , index: uint, kind: ast::kind) -> t { if index < ivec::len(*param_var_ids) { ret mk_var(cx, param_var_ids.(index)); @@ -2858,9 +2858,9 @@ fn bind_params_in_type(sp: &span, cx: &ctxt, next_ty_var: fn() -> int , // Replaces type parameters in the given type using the given list of // substitions. -fn substitute_type_params(cx: &ctxt, substs: &ty::t[], typ: t) -> t { +fn substitute_type_params(cx: &ctxt, substs: &[ty::t], typ: t) -> t { if !type_contains_params(cx, typ) { ret typ; } - fn substituter(cx: ctxt, substs: @ty::t[], idx: uint, + fn substituter(cx: ctxt, substs: @[ty::t], idx: uint, kind: ast::kind) -> t { // FIXME: bounds check can fail ret substs.(idx); @@ -2888,9 +2888,9 @@ fn def_has_ty_params(def: &ast::def) -> bool { // Tag information -type variant_info = {args: ty::t[], ctor_ty: ty::t, id: ast::def_id}; +type variant_info = {args: [ty::t], ctor_ty: ty::t, id: ast::def_id}; -fn tag_variants(cx: &ctxt, id: &ast::def_id) -> variant_info[] { +fn tag_variants(cx: &ctxt, id: &ast::def_id) -> [variant_info] { if ast::local_crate != id.crate { ret csearch::get_tag_variants(cx, id); } let item = alt cx.items.find(id.node) { @@ -2901,10 +2901,10 @@ fn tag_variants(cx: &ctxt, id: &ast::def_id) -> variant_info[] { ast_map::node_item(item) { alt item.node { ast::item_tag(variants, _) { - let result: variant_info[] = ~[]; + let result: [variant_info] = ~[]; for variant: ast::variant in variants { let ctor_ty = node_id_to_monotype(cx, variant.node.id); - let arg_tys: t[] = ~[]; + let arg_tys: [t] = ~[]; if std::ivec::len(variant.node.args) > 0u { for a: arg in ty_fn_args(cx, ctor_ty) { arg_tys += ~[a.ty]; diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 99e10eafa3cf2..1d6adb47b56cc 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -53,13 +53,13 @@ type ty_table = hashmap[ast::def_id, ty::t]; // Used for typechecking the methods of an object. tag obj_info { // Regular objects have a node_id at compile time. - regular_obj(ast::obj_field[], ast::node_id); + regular_obj([ast::obj_field], ast::node_id); // Anonymous objects only have a type at compile time. It's optional // because not all anonymous objects have a inner_obj to attach to. - anon_obj(ast::obj_field[], option::t[ty::sty]); + anon_obj([ast::obj_field], option::t[ty::sty]); } -type crate_ctxt = {mutable obj_infos: obj_info[], tcx: ty::ctxt}; +type crate_ctxt = {mutable obj_infos: [obj_info], tcx: ty::ctxt}; type fn_ctxt = // var_bindings, locals, local_names, and next_var_id are shared @@ -72,7 +72,7 @@ type fn_ctxt = locals: hashmap[ast::node_id, int], local_names: hashmap[ast::node_id, ast::ident], next_var_id: @mutable int, - mutable fixups: ast::node_id[], + mutable fixups: [ast::node_id], ccx: @crate_ctxt}; @@ -109,7 +109,7 @@ fn ident_for_local(loc: &@ast::local) -> ast::ident { // Returns the type parameter count and the type for the given definition. fn ty_param_kinds_and_ty_for_def(fcx: &@fn_ctxt, sp: &span, defn: &ast::def) -> ty_param_kinds_and_ty { - let no_kinds: ast::kind[] = ~[]; + let no_kinds: [ast::kind] = ~[]; alt defn { ast::def_arg(id) { assert (fcx.locals.contains_key(id.node)); @@ -175,7 +175,7 @@ fn instantiate_path(fcx: &@fn_ctxt, pth: &ast::path, fcx.ccx.tcx.sess.span_fatal (sp, "not enough type parameters provided for this item"); } - let ty_substs: ty::t[] = ~[]; + let ty_substs: [ty::t] = ~[]; let i = 0u; while i < ty_substs_len { let ty_var = ty::mk_var(fcx.ccx.tcx, ty_param_vars.(i)); @@ -184,7 +184,7 @@ fn instantiate_path(fcx: &@fn_ctxt, pth: &ast::path, ty_substs += ~[res_ty]; i += 1u; } - ty_substs_opt = some[ty::t[]](ty_substs); + ty_substs_opt = some[[ty::t]](ty_substs); if ty_param_count == 0u { fcx.ccx.tcx.sess.span_fatal(sp, "this item does not take type \ @@ -192,13 +192,13 @@ fn instantiate_path(fcx: &@fn_ctxt, pth: &ast::path, } } else { // We will acquire the type parameters through unification. - let ty_substs: ty::t[] = ~[]; + let ty_substs: [ty::t] = ~[]; let i = 0u; while i < ty_param_count { ty_substs += ~[ty::mk_var(fcx.ccx.tcx, ty_param_vars.(i))]; i += 1u; } - ty_substs_opt = some[ty::t[]](ty_substs); + ty_substs_opt = some[[ty::t]](ty_substs); } ret {substs: ty_substs_opt, ty: tpt.ty}; } @@ -281,7 +281,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) -> ret {ty: ast_ty_to_ty(tcx, getter, mt.ty), mut: mt.mut}; } fn instantiate(tcx: &ty::ctxt, sp: &span, getter: &ty_getter, - id: &ast::def_id, args: &(@ast::ty)[]) -> ty::t { + id: &ast::def_id, args: &[@ast::ty]) -> ty::t { // TODO: maybe record cname chains so we can do // "foo = int" like OCaml? @@ -292,7 +292,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) -> // The typedef is type-parametric. Do the type substitution. // - let param_bindings: ty::t[] = ~[]; + let param_bindings: [ty::t] = ~[]; for ast_ty: @ast::ty in args { param_bindings += ~[ast_ty_to_ty(tcx, getter, ast_ty)]; } @@ -340,7 +340,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) -> typ = ty::mk_chan(tcx, ast_ty_to_ty(tcx, getter, t)); } ast::ty_rec(fields) { - let flds: field[] = ~[]; + let flds: [field] = ~[]; for f: ast::ty_field in fields { let tm = ast_mt_to_mt(tcx, getter, f.node.mt); flds += ~[{ident: f.node.ident, mt: tm}]; @@ -378,7 +378,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) -> cname = some(path_to_str(path)); } ast::ty_obj(meths) { - let tmeths: ty::method[] = ~[]; + let tmeths: [ty::method] = ~[]; for m: ast::ty_method in meths { let ins = ~[]; for ta: ast::ty_arg in m.node.inputs { @@ -457,23 +457,23 @@ mod write { // Writes a type with no type parameters into the node type table. fn ty_only(tcx: &ty::ctxt, node_id: ast::node_id, typ: ty::t) { - ty(tcx, node_id, {substs: none[ty::t[]], ty: typ}); + ty(tcx, node_id, {substs: none[[ty::t]], ty: typ}); } // Writes a type with no type parameters into the node type table. This // function allows for the possibility of type variables. fn ty_only_fixup(fcx: @fn_ctxt, node_id: ast::node_id, typ: ty::t) { - ret ty_fixup(fcx, node_id, {substs: none[ty::t[]], ty: typ}); + ret ty_fixup(fcx, node_id, {substs: none[[ty::t]], ty: typ}); } // Writes a nil type into the node type table. fn nil_ty(tcx: &ty::ctxt, node_id: ast::node_id) { - ret ty(tcx, node_id, {substs: none[ty::t[]], ty: ty::mk_nil(tcx)}); + ret ty(tcx, node_id, {substs: none[[ty::t]], ty: ty::mk_nil(tcx)}); } // Writes the bottom type into the node type table. fn bot_ty(tcx: &ty::ctxt, node_id: ast::node_id) { - ret ty(tcx, node_id, {substs: none[ty::t[]], ty: ty::mk_bot(tcx)}); + ret ty(tcx, node_id, {substs: none[[ty::t]], ty: ty::mk_bot(tcx)}); } } @@ -504,7 +504,7 @@ fn proto_to_ty_proto(proto: &ast::proto) -> ast::proto { mod collect { type ctxt = {tcx: ty::ctxt}; - fn mk_ty_params(cx: &@ctxt, atps: &ast::ty_param[]) -> ty::t[] { + fn mk_ty_params(cx: &@ctxt, atps: &[ast::ty_param]) -> [ty::t] { let tps = ~[]; let i = 0u; for atp: ast::ty_param in atps { @@ -514,8 +514,8 @@ mod collect { ret tps; } - fn ty_param_kinds(tps: &ast::ty_param[]) -> ast::kind[] { - let k: ast::kind[] = ~[]; + fn ty_param_kinds(tps: &[ast::ty_param]) -> [ast::kind] { + let k: [ast::kind] = ~[]; for p: ast::ty_param in tps { k += ~[p.kind] } @@ -524,7 +524,7 @@ mod collect { fn ty_of_fn_decl(cx: &@ctxt, convert: &fn(&@ast::ty) -> ty::t , ty_of_arg: &fn(&ast::arg) -> arg , decl: &ast::fn_decl, - proto: ast::proto, ty_params: &ast::ty_param[], + proto: ast::proto, ty_params: &[ast::ty_param], def_id: &option::t[ast::def_id]) -> ty::ty_param_kinds_and_ty { let input_tys = ~[]; @@ -545,7 +545,7 @@ mod collect { fn ty_of_native_fn_decl(cx: &@ctxt, convert: &fn(&@ast::ty) -> ty::t , ty_of_arg: &fn(&ast::arg) -> arg , decl: &ast::fn_decl, abi: ast::native_abi, - ty_params: &ast::ty_param[], def_id: &ast::def_id) + ty_params: &[ast::ty_param], def_id: &ast::def_id) -> ty::ty_param_kinds_and_ty { let input_tys = ~[]; for a: ast::arg in decl.inputs { input_tys += ~[ty_of_arg(a)]; } @@ -611,18 +611,18 @@ mod collect { constrs: out_constrs}; } fn ty_of_obj(cx: @ctxt, id: &ast::ident, ob: &ast::_obj, - ty_params: &ast::ty_param[]) -> ty::ty_param_kinds_and_ty { + ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty { let methods = get_obj_method_types(cx, ob); let t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods)); t_obj = ty::rename(cx.tcx, t_obj, id); ret {kinds: ty_param_kinds(ty_params), ty: t_obj}; } fn ty_of_obj_ctor(cx: @ctxt, id: &ast::ident, ob: &ast::_obj, - ctor_id: ast::node_id, ty_params: &ast::ty_param[]) -> + ctor_id: ast::node_id, ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty { let t_obj = ty_of_obj(cx, id, ob, ty_params); - let t_inputs: arg[] = ~[]; + let t_inputs: [arg] = ~[]; for f: ast::obj_field in ob.fields { let g = bind getter(cx, _); let t_field = ast_ty_to_ty(cx.tcx, g, f.ty); @@ -639,7 +639,7 @@ mod collect { fn ty_of_item(cx: &@ctxt, it: &@ast::item) -> ty::ty_param_kinds_and_ty { let get = bind getter(cx, _); let convert = bind ast_ty_to_ty(cx.tcx, get, _); - let no_kinds: ast::kind[] = ~[]; + let no_kinds: [ast::kind] = ~[]; alt it.node { ast::item_const(t, _) { let typ = convert(t); @@ -682,7 +682,7 @@ mod collect { } ast::item_tag(_, tps) { // Create a new generic polytype. - let subtys: ty::t[] = mk_ty_params(cx, tps); + let subtys: [ty::t] = mk_ty_params(cx, tps); let t = ty::mk_tag(cx.tcx, local_def(it.id), subtys); let tpt = {kinds: ty_param_kinds(tps), ty: t}; cx.tcx.tcache.insert(local_def(it.id), tpt); @@ -694,7 +694,7 @@ mod collect { } fn ty_of_native_item(cx: &@ctxt, it: &@ast::native_item, abi: ast::native_abi) -> ty::ty_param_kinds_and_ty { - let no_kinds: ast::kind[] = ~[]; + let no_kinds: [ast::kind] = ~[]; alt it.node { ast::native_item_fn(_, fn_decl, params) { let get = bind getter(cx, _); @@ -716,11 +716,11 @@ mod collect { } } fn get_tag_variant_types(cx: &@ctxt, tag_id: &ast::def_id, - variants: &ast::variant[], - ty_params: &ast::ty_param[]) { + variants: &[ast::variant], + ty_params: &[ast::ty_param]) { // Create a set of parameter types shared among all the variants. - let ty_param_tys: ty::t[] = mk_ty_params(cx, ty_params); + let ty_param_tys: [ty::t] = mk_ty_params(cx, ty_params); for variant: ast::variant in variants { // Nullary tag constructors get turned into constants; n-ary tag // constructors get turned into functions. @@ -733,7 +733,7 @@ mod collect { // should be called to resolve named types. let f = bind getter(cx, _); - let args: arg[] = ~[]; + let args: [arg] = ~[]; for va: ast::variant_arg in variant.node.args { let arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty); args += ~[{mode: ty::mo_alias(false), ty: arg_ty}]; @@ -749,7 +749,7 @@ mod collect { write::ty_only(cx.tcx, variant.node.id, result_ty); } } - fn get_obj_method_types(cx: &@ctxt, object: &ast::_obj) -> ty::method[] { + fn get_obj_method_types(cx: &@ctxt, object: &ast::_obj) -> [ty::method] { let meths = ~[]; for m: @ast::method in object.methods { meths += ~[ty_of_method(cx, m)]; @@ -962,7 +962,7 @@ fn resolve_type_vars_if_possible(fcx: &@fn_ctxt, typ: ty::t) -> ty::t { // Demands - procedures that require that two types unify and emit an error // message if they don't. -type ty_param_substs_and_ty = {substs: ty::t[], ty: ty::t}; +type ty_param_substs_and_ty = {substs: [ty::t], ty: ty::t}; mod demand { fn simple(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, actual: &ty::t) -> @@ -977,7 +977,7 @@ mod demand { // Requires that the two types unify, and prints an error message if they // don't. Returns the unified type and the type parameter substitutions. fn full(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, actual: &ty::t, - ty_param_substs_0: &ty::t[], adk: autoderef_kind) -> + ty_param_substs_0: &[ty::t], adk: autoderef_kind) -> ty_param_substs_and_ty { let expected_1 = expected; let actual_1 = actual; @@ -989,8 +989,8 @@ mod demand { } else if (adk == AUTODEREF_BLOCK_COERCE) { actual_1 = do_fn_block_coerce(fcx, sp, actual, expected); } - let ty_param_substs: ty::t[mutable ] = ~[mutable ]; - let ty_param_subst_var_ids: int[] = ~[]; + let ty_param_substs: [mutable ty::t] = ~[mutable]; + let ty_param_subst_var_ids: [int] = ~[]; for ty_param_subst: ty::t in ty_param_substs_0 { // Generate a type variable and unify it with the type parameter // substitution. We will then pull out these type variables. @@ -1002,9 +1002,9 @@ mod demand { } fn mk_result(fcx: &@fn_ctxt, result_ty: &ty::t, - ty_param_subst_var_ids: &int[], implicit_boxes: uint) -> + ty_param_subst_var_ids: &[int], implicit_boxes: uint) -> ty_param_substs_and_ty { - let result_ty_param_substs: ty::t[] = ~[]; + let result_ty_param_substs: [ty::t] = ~[]; for var_id: int in ty_param_subst_var_ids { let tp_subst = ty::mk_var(fcx.ccx.tcx, var_id); result_ty_param_substs += ~[tp_subst]; @@ -1046,8 +1046,8 @@ fn are_compatible(fcx: &@fn_ctxt, expected: &ty::t, actual: &ty::t) -> bool { // Returns the types of the arguments to a tag variant. fn variant_arg_types(ccx: &@crate_ctxt, sp: &span, vid: &ast::def_id, - tag_ty_params: &ty::t[]) -> ty::t[] { - let result: ty::t[] = ~[]; + tag_ty_params: &[ty::t]) -> [ty::t] { + let result: [ty::t] = ~[]; let tpt = ty::lookup_item_type(ccx.tcx, vid); alt ty::struct(ccx.tcx, tpt.ty) { ty::ty_fn(_, ins, _, _, _) { @@ -1107,16 +1107,16 @@ mod writeback { }; let new_substs_opt; alt tpot.substs { - none[ty::t[]]. { new_substs_opt = none[ty::t[]]; } - some[ty::t[]](substs) { - let new_substs: ty::t[] = ~[]; + none[[ty::t]]. { new_substs_opt = none[[ty::t]]; } + some[[ty::t]](substs) { + let new_substs: [ty::t] = ~[]; for subst: ty::t in substs { alt resolve_type_vars_in_type(fcx, sp, subst) { some(t) { new_substs += ~[t]; } none. { wbcx.success = false; ret; } } } - new_substs_opt = some[ty::t[]](new_substs); + new_substs_opt = some[[ty::t]](new_substs); } } write::ty(fcx.ccx.tcx, id, {substs: new_substs_opt, ty: new_ty}); @@ -1296,7 +1296,7 @@ fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id, }; // Don't descend into fns and items - fn visit_fn[E](f: &ast::_fn, tp: &ast::ty_param[], sp: &span, + fn visit_fn[E](f: &ast::_fn, tp: &[ast::ty_param], sp: &span, i: &ast::fn_ident, id: ast::node_id, e: &E, v: &visit::vt[E]) { } fn visit_item[E](i: &@ast::item, e: &E, v: &visit::vt[E]) { } @@ -1373,7 +1373,7 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast::pat_id_map, pat: &@ast::pat, demand::full(fcx, pat.span, expected, ctor_ty, expected_tps, NO_AUTODEREF); path_tpot = - {substs: some[ty::t[]](path_tpt.substs), ty: path_tpt.ty}; + {substs: some[[ty::t]](path_tpt.substs), ty: path_tpt.ty}; // Get the number of arguments in this tag variant. let arg_types = @@ -1517,7 +1517,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { // A generic function to factor out common logic from call and bind // expressions. fn check_call_or_bind(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr, - args: &(option::t[@ast::expr])[], + args: &[option::t[@ast::expr]], call_kind: call_kind) -> bool { // Check the function. let bot = check_expr(fcx, f); @@ -1612,8 +1612,8 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { // A generic function for checking call expressions fn check_call(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr, - args: &(@ast::expr)[], call_kind: call_kind) -> bool { - let args_opt_0: (option::t[@ast::expr])[] = ~[]; + args: &[@ast::expr], call_kind: call_kind) -> bool { + let args_opt_0: [option::t[@ast::expr]] = ~[]; for arg: @ast::expr in args { args_opt_0 += ~[some[@ast::expr](arg)]; } @@ -1624,7 +1624,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { // A generic function for doing all of the checking for call expressions fn check_call_full(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr, - args: &(@ast::expr)[], call_kind: call_kind, + args: &[@ast::expr], call_kind: call_kind, id: ast::node_id) -> bool { /* here we're kind of hosed, as f can be any expr need to restrict it to being an explicit expr_path if we're @@ -2083,7 +2083,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { // Pull the argument and return types out. let proto_1; - let arg_tys_1: ty::arg[] = ~[]; + let arg_tys_1: [ty::arg] = ~[]; let rt_1; let fty = expr_ty(tcx, f); let t_1; @@ -2229,7 +2229,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { } ast::expr_rec(fields, base) { alt base { none. {/* no-op */ } some(b_0) { check_expr(fcx, b_0); } } - let fields_t: (spanned[field])[] = ~[]; + let fields_t: [spanned[field]] = ~[]; for f: ast::field in fields { bot |= check_expr(fcx, f.node.expr); let expr_t = expr_ty(tcx, f.node.expr); @@ -2249,7 +2249,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { some(bexpr) { bot |= check_expr(fcx, bexpr); let bexpr_t = expr_ty(tcx, bexpr); - let base_fields: field[] = ~[]; + let base_fields: [field] = ~[]; alt structure_of(fcx, expr.span, bexpr_t) { ty::ty_rec(flds) { base_fields = flds; } _ { @@ -2366,7 +2366,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { } } ast::expr_anon_obj(ao) { - let fields: ast::anon_obj_field[] = ~[]; + let fields: [ast::anon_obj_field] = ~[]; alt ao.fields { none. { } some(v) { fields = v; } } // FIXME: These next three functions are largely ripped off from @@ -2399,7 +2399,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { constrs: out_constrs}; } - let method_types: ty::method[] = ~[]; + let method_types: [ty::method] = ~[]; { // Outer methods. for m: @ast::method in ao.methods { @@ -2410,7 +2410,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { // Typecheck 'inner_obj'. If it exists, it had better have object // type. - let inner_obj_methods: ty::method[] = ~[]; + let inner_obj_methods: [ty::method] = ~[]; let inner_obj_ty: ty::t = ty::mk_nil(tcx); let inner_obj_sty: option::t[ty::sty] = none; alt ao.inner_obj { @@ -2448,7 +2448,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { // any methods that share a name with an outer method. fn filtering_fn(ccx: @crate_ctxt, m: &ty::method, - outer_obj_methods: (@ast::method)[]) -> + outer_obj_methods: [@ast::method]) -> option::t[ty::method] { for om: @ast::method in outer_obj_methods { @@ -2623,7 +2623,7 @@ fn check_const(ccx: &@crate_ctxt, sp: &span, e: &@ast::expr, // FIXME: this is kinda a kludge; we manufacture a fake function context // and statement context for checking the initializer expression. let rty = node_id_to_type(ccx.tcx, id); - let fixups: ast::node_id[] = ~[]; + let fixups: [ast::node_id] = ~[]; let fcx: @fn_ctxt = @{ret_ty: rty, purity: ast::pure_fn, @@ -2642,7 +2642,7 @@ fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id, let decl = f.decl; let body = f.body; let gather_result = gather_locals(ccx, f, id, old_fcx); - let fixups: ast::node_id[] = ~[]; + let fixups: [ast::node_id] = ~[]; let fcx: @fn_ctxt = @{ret_ty: ast_ty_to_ty_crate(ccx, decl.output), purity: decl.purity, @@ -2765,7 +2765,7 @@ fn check_for_main_fn(tcx: &ty::ctxt, crate: &@ast::crate) { fn check_crate(tcx: &ty::ctxt, crate: &@ast::crate) { collect::collect_item_types(tcx, crate); - let obj_infos: obj_info[] = ~[]; + let obj_infos: [obj_info] = ~[]; let ccx = @{mutable obj_infos: obj_infos, tcx: tcx}; let visit = visit::mk_simple_visitor diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 5b0787a5fc49d..c33bab39e770d 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -16,13 +16,13 @@ type fn_ident = option::t[ident]; // FIXME: with typestate constraint, could say // idents and types are the same length, and are // non-empty -type path_ = {global: bool, idents: ident[], types: (@ty)[]}; +type path_ = {global: bool, idents: [ident], types: [@ty]}; type path = spanned[path_]; fn path_name(p: &path) -> str { path_name_i(p.node.idents) } -fn path_name_i(idents: &ident[]) -> str { str::connect_ivec(idents, "::") } +fn path_name_i(idents: &[ident]) -> str { str::connect_ivec(idents, "::") } type crate_num = int; type node_id = int; @@ -85,22 +85,22 @@ fn def_id_of_def(d: def) -> def_id { // The set of meta_items that define the compilation environment of the crate, // used to drive conditional compilation -type crate_cfg = (@meta_item)[]; +type crate_cfg = [@meta_item]; type crate = spanned[crate_]; type crate_ = - {directives: (@crate_directive)[], + {directives: [@crate_directive], module: _mod, - attrs: attribute[], + attrs: [attribute], config: crate_cfg}; tag crate_directive_ { - cdir_src_mod(ident, option::t[filename], attribute[]); + cdir_src_mod(ident, option::t[filename], [attribute]); cdir_dir_mod(ident, option::t[filename], - (@crate_directive)[], - attribute[]); + [@crate_directive], + [attribute]); cdir_view_item(@view_item); cdir_syntax(path); cdir_auth(path, _auth); @@ -112,13 +112,13 @@ type meta_item = spanned[meta_item_]; tag meta_item_ { meta_word(ident); - meta_list(ident, (@meta_item)[]); + meta_list(ident, [@meta_item]); meta_name_value(ident, lit); } type blk = spanned[blk_]; -type blk_ = {stmts: (@stmt)[], expr: option::t[@expr], id: node_id}; +type blk_ = {stmts: [@stmt], expr: option::t[@expr], id: node_id}; type pat = {id: node_id, node: pat_, span: span}; @@ -128,8 +128,8 @@ tag pat_ { pat_wild; pat_bind(ident); pat_lit(@lit); - pat_tag(path, (@pat)[]); - pat_rec(field_pat[], bool); + pat_tag(path, [@pat]); + pat_rec([field_pat], bool); pat_box(@pat); } @@ -174,7 +174,7 @@ iter pat_bindings(pat: &@pat) -> @pat { } } -fn pat_binding_ids(pat: &@pat) -> node_id[] { +fn pat_binding_ids(pat: &@pat) -> [node_id] { let found = ~[]; for each b in pat_bindings(pat) { found += ~[b.id]; } ret found; @@ -275,9 +275,9 @@ type local = spanned[local_]; type decl = spanned[decl_]; -tag decl_ { decl_local((@local)[]); decl_item(@item); } +tag decl_ { decl_local([@local]); decl_item(@item); } -type arm = {pats: (@pat)[], block: blk}; +type arm = {pats: [@pat], block: blk}; type elt = {mut: mutability, expr: @expr}; @@ -295,12 +295,12 @@ tag seq_kind { sk_unique; sk_rc; } type expr = {id: node_id, node: expr_, span: span}; tag expr_ { - expr_vec((@expr)[], mutability, seq_kind); - expr_rec(field[], option::t[@expr]); - expr_call(@expr, (@expr)[]); + expr_vec([@expr], mutability, seq_kind); + expr_rec([field], option::t[@expr]); + expr_call(@expr, [@expr]); expr_self_method(ident); - expr_bind(@expr, (option::t[@expr])[]); - expr_spawn(spawn_dom, option::t[str], @expr, (@expr)[]); + expr_bind(@expr, [option::t[@expr]]); + expr_spawn(spawn_dom, option::t[str], @expr, [@expr]); expr_binary(binop, @expr, @expr); expr_unary(unop, @expr); expr_lit(@lit); @@ -311,7 +311,7 @@ tag expr_ { expr_for(@local, @expr, blk); expr_for_each(@local, @expr, blk); expr_do_while(blk, @expr); - expr_alt(@expr, arm[]); + expr_alt(@expr, [arm]); expr_fn(_fn); expr_block(blk); @@ -392,10 +392,10 @@ type ty_arg_ = {mode: mode, ty: @ty}; type ty_method_ = {proto: proto, ident: ident, - inputs: ty_arg[], + inputs: [ty_arg], output: @ty, cf: controlflow, - constrs: (@constr)[]}; + constrs: [@constr]}; type ty_field = spanned[ty_field_]; @@ -465,12 +465,12 @@ tag ty_ { ty_task; ty_port(@ty); ty_chan(@ty); - ty_rec(ty_field[]); - ty_fn(proto, ty_arg[], @ty, controlflow, (@constr)[]); - ty_obj(ty_method[]); + ty_rec([ty_field]); + ty_fn(proto, [ty_arg], @ty, controlflow, [@constr]); + ty_obj([ty_method]); ty_path(path, node_id); ty_type; - ty_constr(@ty, (@ty_constr)[]); + ty_constr(@ty, [@ty_constr]); ty_mac(mac); } @@ -496,7 +496,7 @@ type constr_arg = spanned[fn_constr_arg]; // constrained type, is * (referring to the base record) type constr_general_[ARG, ID] = - {path: path, args: (@spanned[constr_arg_general_[ARG]])[], id: ID}; + {path: path, args: [@spanned[constr_arg_general_[ARG]]], id: ID}; // In the front end, constraints have a node ID attached. // Typeck turns this to a def_id, using the output of resolve. @@ -514,12 +514,12 @@ type arg = {mode: mode, ty: @ty, ident: ident, id: node_id}; tag inlineness { il_normal; il_inline; } type fn_decl = - {inputs: arg[], + {inputs: [arg], output: @ty, purity: purity, il: inlineness, cf: controlflow, - constraints: (@constr)[]}; + constraints: [@constr]}; tag purity { pure_fn; // declared with "pred" @@ -550,16 +550,16 @@ type obj_field = {mut: mutability, ty: @ty, ident: ident, id: node_id}; type anon_obj_field = {mut: mutability, ty: @ty, expr: @expr, ident: ident, id: node_id}; -type _obj = {fields: obj_field[], methods: (@method)[]}; +type _obj = {fields: [obj_field], methods: [@method]}; type anon_obj = // New fields and methods, if they exist. - {fields: option::t[anon_obj_field[]], - methods: (@method)[], + {fields: option::t[[anon_obj_field]], + methods: [@method], // inner_obj: the original object being extended, if it exists. inner_obj: option::t[@expr]}; -type _mod = {view_items: (@view_item)[], items: (@item)[]}; +type _mod = {view_items: [@view_item], items: [@item]}; tag native_abi { native_abi_rust; @@ -572,21 +572,21 @@ tag native_abi { type native_mod = {native_name: str, abi: native_abi, - view_items: (@view_item)[], - items: (@native_item)[]}; + view_items: [@view_item], + items: [@native_item]}; type variant_arg = {ty: @ty, id: node_id}; -type variant_ = {name: str, args: variant_arg[], id: node_id}; +type variant_ = {name: str, args: [variant_arg], id: node_id}; type variant = spanned[variant_]; type view_item = spanned[view_item_]; tag view_item_ { - view_item_use(ident, (@meta_item)[], node_id); - view_item_import(ident, ident[], node_id); - view_item_import_glob(ident[], node_id); + view_item_use(ident, [@meta_item], node_id); + view_item_import(ident, [ident], node_id); + view_item_import_glob([ident], node_id); view_item_export(ident, node_id); } @@ -605,32 +605,32 @@ tag attr_style { attr_outer; attr_inner; } type attribute_ = {style: attr_style, value: meta_item}; type item = // For objs and resources, this is the type def_id - {ident: ident, attrs: attribute[], id: node_id, node: item_, span: span}; + {ident: ident, attrs: [attribute], id: node_id, node: item_, span: span}; tag item_ { item_const(@ty, @expr); - item_fn(_fn, ty_param[]); + item_fn(_fn, [ty_param]); item_mod(_mod); item_native_mod(native_mod); - item_ty(@ty, ty_param[]); - item_tag(variant[], ty_param[]); - item_obj(_obj, ty_param[], /* constructor id */node_id); + item_ty(@ty, [ty_param]); + item_tag([variant], [ty_param]); + item_obj(_obj, [ty_param], /* constructor id */node_id); item_res(_fn, /* dtor */ node_id, /* dtor id */ - ty_param[], + [ty_param], node_id /* ctor id */); } type native_item = {ident: ident, - attrs: attribute[], + attrs: [attribute], node: native_item_, id: node_id, span: span}; tag native_item_ { native_item_ty; - native_item_fn(option::t[str], fn_decl, ty_param[]); + native_item_fn(option::t[str], fn_decl, [ty_param]); } fn is_exported(i: ident, m: _mod) -> bool { diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 958ebf705f584..468e94255f0b7 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -17,9 +17,9 @@ type file_pos = {ch: uint, byte: uint}; * compiler. */ type filemap = - @{name: filename, start_pos: file_pos, mutable lines: file_pos[]}; + @{name: filename, start_pos: file_pos, mutable lines: [file_pos]}; -type codemap = @{mutable files: filemap[]}; +type codemap = @{mutable files: [filemap]}; type loc = {filename: filename, line: uint, col: uint}; @@ -175,7 +175,7 @@ fn emit_note(sp: &option::t[span], msg: &str, cm: &codemap) { emit_diagnostic(sp, msg, "note", 10u8, cm); } -type file_lines = {name: str, lines: uint[]}; +type file_lines = {name: str, lines: [uint]}; fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { let lo = lookup_char_pos(cm, sp.lo); diff --git a/src/comp/syntax/ext/concat_idents.rs b/src/comp/syntax/ext/concat_idents.rs index d2e6511a99382..0106f76982bf1 100644 --- a/src/comp/syntax/ext/concat_idents.rs +++ b/src/comp/syntax/ext/concat_idents.rs @@ -5,7 +5,7 @@ import syntax::ast; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, body: option::t[str]) -> @ast::expr { - let args: (@ast::expr)[] = alt arg.node { + let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#concat_idents requires a vector argument .") } }; @@ -19,4 +19,4 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, node: {global: false, idents: ~[res], types: ~[]}, span: sp}), span: sp}; -} \ No newline at end of file +} diff --git a/src/comp/syntax/ext/env.rs b/src/comp/syntax/ext/env.rs index f2f4ae6a8fa99..2a897b570ddeb 100644 --- a/src/comp/syntax/ext/env.rs +++ b/src/comp/syntax/ext/env.rs @@ -12,7 +12,7 @@ export expand_syntax_ext; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, body: option::t[str]) -> @ast::expr { - let args: (@ast::expr)[] = alt arg.node { + let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#env requires arguments of the form `[...]`.") } }; diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs index 10281a9934d49..3df7024054a62 100644 --- a/src/comp/syntax/ext/fmt.rs +++ b/src/comp/syntax/ext/fmt.rs @@ -18,7 +18,7 @@ export expand_syntax_ext; fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr, body: option::t[str]) -> @ast::expr { - let args: (@ast::expr)[] = alt arg.node { + let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#fmt requires arguments of the form `[...]`.") } }; @@ -43,7 +43,7 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr, // be factored out in common with other code that builds expressions. // FIXME: Cleanup the naming of these functions fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece], - args: &(@ast::expr)[]) -> @ast::expr { + args: &[@ast::expr]) -> @ast::expr { fn make_new_lit(cx: &ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { let sp_lit = @{node: lit, span: sp}; ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp}; @@ -65,20 +65,20 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece], let binexpr = ast::expr_binary(ast::add, lhs, rhs); ret @{id: cx.next_id(), node: binexpr, span: sp}; } - fn make_path_expr(cx: &ext_ctxt, sp: span, idents: &ast::ident[]) -> + fn make_path_expr(cx: &ext_ctxt, sp: span, idents: &[ast::ident]) -> @ast::expr { let path = {global: false, idents: idents, types: ~[]}; let sp_path = {node: path, span: sp}; let pathexpr = ast::expr_path(sp_path); ret @{id: cx.next_id(), node: pathexpr, span: sp}; } - fn make_vec_expr(cx: &ext_ctxt, sp: span, exprs: &(@ast::expr)[]) -> + fn make_vec_expr(cx: &ext_ctxt, sp: span, exprs: &[@ast::expr]) -> @ast::expr { let vecexpr = ast::expr_vec(exprs, ast::imm, ast::sk_rc); ret @{id: cx.next_id(), node: vecexpr, span: sp}; } - fn make_call(cx: &ext_ctxt, sp: span, fn_path: &ast::ident[], - args: &(@ast::expr)[]) -> @ast::expr { + fn make_call(cx: &ext_ctxt, sp: span, fn_path: &[ast::ident], + args: &[@ast::expr]) -> @ast::expr { let pathexpr = make_path_expr(cx, sp, fn_path); let callexpr = ast::expr_call(pathexpr, args); ret @{id: cx.next_id(), node: callexpr, span: sp}; @@ -86,7 +86,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece], fn make_rec_expr(cx: &ext_ctxt, sp: span, fields: vec[{ident: ast::ident, ex: @ast::expr}]) -> @ast::expr { - let astfields: ast::field[] = ~[]; + let astfields: [ast::field] = ~[]; for field: {ident: ast::ident, ex: @ast::expr} in fields { let ident = field.ident; let val = field.ex; @@ -97,7 +97,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece], let recexpr = ast::expr_rec(astfields, option::none[@ast::expr]); ret @{id: cx.next_id(), node: recexpr, span: sp}; } - fn make_path_vec(cx: &ext_ctxt, ident: str) -> str[] { + fn make_path_vec(cx: &ext_ctxt, ident: str) -> [str] { fn compiling_std(cx: &ext_ctxt) -> bool { ret str::find(cx.crate_file_name_hack, "std.rc") >= 0; } @@ -115,7 +115,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece], fn make_rt_conv_expr(cx: &ext_ctxt, sp: span, cnv: &conv) -> @ast::expr { fn make_flags(cx: &ext_ctxt, sp: span, flags: vec[flag]) -> @ast::expr { - let flagexprs: (@ast::expr)[] = ~[]; + let flagexprs: [@ast::expr] = ~[]; for f: flag in flags { let fstr; alt f { diff --git a/src/comp/syntax/ext/ident_to_str.rs b/src/comp/syntax/ext/ident_to_str.rs index 68a4303ec7298..9399f2e8fd4dd 100644 --- a/src/comp/syntax/ext/ident_to_str.rs +++ b/src/comp/syntax/ext/ident_to_str.rs @@ -5,7 +5,7 @@ import syntax::ast; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, body: option::t[str]) -> @ast::expr { - let args: (@ast::expr)[] = alt arg.node { + let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#ident_to_str requires a vector argument .") } }; @@ -18,4 +18,4 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, "expected an ident"), ast::sk_rc)); -} \ No newline at end of file +} diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 4e5470945440e..e2285aafc0bf1 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -93,8 +93,8 @@ fn match_error(cx: &ext_ctxt, m: &matchable, expected: &str) -> ! { type match_result = option::t[arb_depth[matchable]]; type selector = fn(&matchable) -> match_result ; -fn elts_to_ell(cx: &ext_ctxt, elts: &(@expr)[]) - -> {fixed: (@expr)[], rep: option::t[@expr]} { +fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr]) + -> {fixed: [@expr], rep: option::t[@expr]} { let idx: uint = 0u; for elt: @expr in elts { alt elt.node { @@ -153,7 +153,7 @@ fn compose_sels(s1: selector, s2: selector) -> selector { type binders = {real_binders: hashmap[ident, selector], - mutable literal_ast_matchers: selector[]}; + mutable literal_ast_matchers: [selector]}; type bindings = hashmap[ident, arb_depth[matchable]]; fn acumm_bindings(cx: &ext_ctxt, b_dest: &bindings, b_src: &bindings) { } @@ -272,8 +272,8 @@ iter free_vars(b: &bindings, e: @expr) -> ident { /* handle sequences (anywhere in the AST) of exprs, either real or ...ed */ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint], - recur: fn(&@expr) -> @expr , exprs: (@expr)[]) - -> (@expr)[] { + recur: fn(&@expr) -> @expr , exprs: [@expr]) + -> [@expr] { alt elts_to_ell(cx, exprs) { {fixed: fixed, rep: repeat_me_maybe} { let res = ivec::map(recur, fixed); @@ -580,7 +580,7 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) { /* TODO: move this to vec.rs */ -fn ivec_to_vec[T](v: &T[]) -> vec[T] { +fn ivec_to_vec[T](v: &[T]) -> vec[T] { let rs: vec[T] = vec::alloc[T](ivec::len(v)); for ve: T in v { rs += [ve]; } ret rs; @@ -614,7 +614,7 @@ fn p_t_s_r_ellipses(cx: &ext_ctxt, repeat_me: @expr, offset: uint, compose_sels(s, bind select(cx, repeat_me, offset, _)), b); } -fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: (@expr)[], repeat_after: bool, +fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], repeat_after: bool, s: &selector, b: &binders) { fn len_select(cx: &ext_ctxt, m: &matchable, repeat_after: bool, len: uint) -> match_result { @@ -662,7 +662,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: (@expr)[], repeat_after: bool, fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, body: option::t[str]) -> base::macro_def { - let args: (@ast::expr)[] = alt arg.node { + let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#macro requires arguments of the form `[...]`.") @@ -670,7 +670,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, }; let macro_name: option::t[str] = none; - let clauses: clause[] = ~[]; + let clauses: [clause] = ~[]; for arg: @expr in args { alt arg.node { expr_vec(elts, mut, seq_kind) { @@ -727,7 +727,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, ext: normal(ext)}; fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr, - body: option::t[str], clauses: clause[]) -> @expr { + body: option::t[str], clauses: [clause]) -> @expr { for c: clause in clauses { alt use_selectors_to_bind(c.params, arg) { some(bindings) { diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index af0673da3587b..d5d9898653df2 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -43,7 +43,7 @@ type ast_fold_precursor = fold_ident: fn(&ident, ast_fold) -> ident , fold_path: fn(&path_, ast_fold) -> path_ , fold_local: fn(&local_, ast_fold) -> local_ , - map_exprs: fn(fn(&@expr) -> @expr , (@expr)[]) -> (@expr)[] }; + map_exprs: fn(fn(&@expr) -> @expr , [@expr]) -> [@expr] }; type a_f = {fold_crate: fn(&crate) -> crate , @@ -68,7 +68,7 @@ type a_f = fold_ident: fn(&ident) -> ident , fold_path: fn(&path) -> path , fold_local: fn(&@local) -> @local , - map_exprs: fn(fn(&@expr) -> @expr , (@expr)[]) -> (@expr)[] }; + map_exprs: fn(fn(&@expr) -> @expr , [@expr]) -> [@expr] }; //fn nf_dummy[T](&T node) -> T { fail; } fn nf_crate_dummy(c: &crate) -> crate { fail; } @@ -501,7 +501,7 @@ fn noop_fold_local(l: &local_, fld: ast_fold) -> local_ { /* temporarily eta-expand because of a compiler bug with using `fn[T]` as a value */ -fn noop_map_exprs(f: fn(&@expr) -> @expr , es: (@expr)[]) -> (@expr)[] { +fn noop_map_exprs(f: fn(&@expr) -> @expr , es: [@expr]) -> [@expr] { ret ivec::map(f, es); } diff --git a/src/comp/syntax/parse/eval.rs b/src/comp/syntax/parse/eval.rs index c5bf0f2586b97..6dd06a97901ae 100644 --- a/src/comp/syntax/parse/eval.rs +++ b/src/comp/syntax/parse/eval.rs @@ -19,32 +19,32 @@ tag eval_mode { mode_depend; mode_parse; } type ctx = @{p: parser, mode: eval_mode, - mutable deps: str[], + mutable deps: [str], sess: parser::parse_sess, mutable chpos: uint, mutable byte_pos: uint, cfg: ast::crate_cfg}; -fn eval_crate_directives(cx: ctx, cdirs: &(@ast::crate_directive)[], +fn eval_crate_directives(cx: ctx, cdirs: &[@ast::crate_directive], prefix: str, - view_items: &mutable (@ast::view_item)[], - items: &mutable (@ast::item)[]) { + view_items: &mutable [@ast::view_item], + items: &mutable [@ast::item]) { for sub_cdir: @ast::crate_directive in cdirs { eval_crate_directive(cx, sub_cdir, prefix, view_items, items); } } -fn eval_crate_directives_to_mod(cx: ctx, cdirs: &(@ast::crate_directive)[], +fn eval_crate_directives_to_mod(cx: ctx, cdirs: &[@ast::crate_directive], prefix: str) -> ast::_mod { - let view_items: (@ast::view_item)[] = ~[]; - let items: (@ast::item)[] = ~[]; + let view_items: [@ast::view_item] = ~[]; + let items: [@ast::item] = ~[]; eval_crate_directives(cx, cdirs, prefix, view_items, items); ret {view_items: view_items, items: items}; } fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str, - view_items: &mutable (@ast::view_item)[], - items: &mutable (@ast::item)[]) { + view_items: &mutable [@ast::view_item], + items: &mutable [@ast::item]) { alt cdir.node { ast::cdir_src_mod(id, file_opt, attrs) { let file_path = id + ".rs"; diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index bf91dfc8a9c81..40c0d8b493545 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -37,7 +37,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap, mutable pos: uint, mutable ch: char, mutable chpos: uint, - mutable strs: str[], + mutable strs: [str], fm: codemap::filemap, itr: @interner::interner[str]) { fn is_eof() -> bool { ret ch == -1 as char; } @@ -81,7 +81,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap, codemap::emit_error(some({lo: chpos, hi: chpos}), m, cm); } } - let strs: str[] = ~[]; + let strs: [str] = ~[]; let rd = reader(cm, src, str::byte_len(src), 0u, 0u, -1 as char, filemap.start_pos.ch, strs, filemap, itr); @@ -550,7 +550,7 @@ tag cmnt_style { blank_line; // Just a manual blank line "\n\n", for layout } -type cmnt = {style: cmnt_style, lines: str[], pos: uint}; +type cmnt = {style: cmnt_style, lines: [str], pos: uint}; fn read_to_eol(rdr: &reader) -> str { let val = ""; @@ -578,14 +578,14 @@ fn consume_non_eol_whitespace(rdr: &reader) { } } -fn push_blank_line_comment(rdr: &reader, comments: &mutable cmnt[]) { +fn push_blank_line_comment(rdr: &reader, comments: &mutable [cmnt]) { log ">>> blank-line comment"; - let v: str[] = ~[]; + let v: [str] = ~[]; comments += ~[{style: blank_line, lines: v, pos: rdr.get_chpos()}]; } fn consume_whitespace_counting_blank_lines(rdr: &reader, - comments: &mutable cmnt[]) { + comments: &mutable [cmnt]) { while is_whitespace(rdr.curr()) && !rdr.is_eof() { if rdr.get_col() == 0u && rdr.curr() == '\n' { push_blank_line_comment(rdr, comments); @@ -597,7 +597,7 @@ fn consume_whitespace_counting_blank_lines(rdr: &reader, fn read_line_comments(rdr: &reader, code_to_the_left: bool) -> cmnt { log ">>> line comments"; let p = rdr.get_chpos(); - let lines: str[] = ~[]; + let lines: [str] = ~[]; while rdr.curr() == '/' && rdr.next() == '/' { let line = read_one_line_comment(rdr); log line; @@ -619,7 +619,7 @@ fn all_whitespace(s: &str, begin: uint, end: uint) -> bool { ret true; } -fn trim_whitespace_prefix_and_push_line(lines: &mutable str[], s: &str, +fn trim_whitespace_prefix_and_push_line(lines: &mutable [str], s: &str, col: uint) { let s1; if all_whitespace(s, 0u, col) { @@ -634,7 +634,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mutable str[], s: &str, fn read_block_comment(rdr: &reader, code_to_the_left: bool) -> cmnt { log ">>> block comment"; let p = rdr.get_chpos(); - let lines: str[] = ~[]; + let lines: [str] = ~[]; let col: uint = rdr.get_col(); rdr.bump(); rdr.bump(); @@ -682,7 +682,7 @@ fn peeking_at_comment(rdr: &reader) -> bool { } fn consume_comment(rdr: &reader, code_to_the_left: bool, - comments: &mutable cmnt[]) { + comments: &mutable [cmnt]) { log ">>> consume comment"; if rdr.curr() == '/' && rdr.next() == '/' { comments += ~[read_line_comments(rdr, code_to_the_left)]; @@ -710,12 +710,12 @@ type lit = {lit: str, pos: uint}; fn gather_comments_and_literals(cm: &codemap::codemap, path: str, srdr: ioivec::reader) -> - {cmnts: cmnt[], lits: lit[]} { + {cmnts: [cmnt], lits: [lit]} { let src = str::unsafe_from_bytes_ivec(srdr.read_whole_stream()); let itr = @interner::mk[str](str::hash, str::eq); let rdr = new_reader(cm, src, codemap::new_filemap(path, 0u, 0u), itr); - let comments: cmnt[] = ~[]; - let literals: lit[] = ~[]; + let comments: [cmnt] = ~[]; + let literals: [lit] = ~[]; let first_read: bool = true; while !rdr.is_eof() { while true { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index f0b25eb9a53d3..67d46d9a9eac5 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -47,7 +47,7 @@ type parser = fn get_hi_pos() -> uint ; fn get_last_lo_pos() -> uint ; fn get_last_hi_pos() -> uint ; - fn get_prec_table() -> @op_spec[] ; + fn get_prec_table() -> @[op_spec] ; fn get_str(token::str_num) -> str ; fn get_reader() -> lexer::reader ; fn get_filemap() -> codemap::filemap ; @@ -79,10 +79,10 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader, mutable tok: token::token, mutable tok_span: span, mutable last_tok_span: span, - mutable buffer: {tok: token::token, span: span}[], + mutable buffer: [{tok: token::token, span: span}], mutable restr: restriction, rdr: lexer::reader, - precs: @op_spec[], + precs: @[op_spec], bad_words: hashmap[str, ()]) { fn peek() -> token::token { ret tok; } fn bump() { @@ -121,7 +121,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader, fn get_last_hi_pos() -> uint { ret last_tok_span.hi; } fn get_file_type() -> file_type { ret ftype; } fn get_cfg() -> ast::crate_cfg { ret cfg; } - fn get_prec_table() -> @op_spec[] { ret precs; } + fn get_prec_table() -> @[op_spec] { ret precs; } fn get_str(i: token::str_num) -> str { ret interner::get(*rdr.get_interner(), i); } @@ -283,7 +283,7 @@ fn parse_ty_fn(proto: ast::proto, p: &parser, lo: uint) -> ast::ty_ { parse_fn_input_ty, p); // FIXME: there's no syntax for this right now anyway // auto constrs = parse_constrs(~[], p); - let constrs: (@ast::constr)[] = ~[]; + let constrs: [@ast::constr] = ~[]; let output: @ast::ty; let cf = ast::return; if p.peek() == token::RARROW { @@ -354,7 +354,7 @@ fn parse_ty_field(p: &parser) -> ast::ty_field { // if i is the jth ident in args, return j // otherwise, fail -fn ident_index(p: &parser, args: &ast::arg[], i: &ast::ident) -> uint { +fn ident_index(p: &parser, args: &[ast::arg], i: &ast::ident) -> uint { let j = 0u; for a: ast::arg in args { if a.ident == i { ret j; } j += 1u; } p.fatal("Unbound variable " + i + " in constraint arg"); @@ -374,7 +374,7 @@ fn parse_type_constr_arg(p: &parser) -> @ast::ty_constr_arg { ret @{node: carg, span: sp}; } -fn parse_constr_arg(args: &ast::arg[], p: &parser) -> @ast::constr_arg { +fn parse_constr_arg(args: &[ast::arg], p: &parser) -> @ast::constr_arg { let sp = p.get_span(); let carg = ast::carg_base; if p.peek() == token::BINOP(token::STAR) { @@ -386,11 +386,11 @@ fn parse_constr_arg(args: &ast::arg[], p: &parser) -> @ast::constr_arg { ret @{node: carg, span: sp}; } -fn parse_ty_constr(fn_args: &ast::arg[], p: &parser) -> @ast::constr { +fn parse_ty_constr(fn_args: &[ast::arg], p: &parser) -> @ast::constr { let lo = p.get_lo_pos(); let path = parse_path(p); let pf = bind parse_constr_arg(fn_args, _); - let args: {node: (@ast::constr_arg)[], span: span} = + let args: {node: [@ast::constr_arg], span: span} = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), pf, p); ret @spanned(lo, args.span.hi, {path: path, args: args.node, id: p.get_id()}); @@ -399,7 +399,7 @@ fn parse_ty_constr(fn_args: &ast::arg[], p: &parser) -> @ast::constr { fn parse_constr_in_type(p: &parser) -> @ast::ty_constr { let lo = p.get_lo_pos(); let path = parse_path(p); - let args: (@ast::ty_constr_arg)[] = + let args: [@ast::ty_constr_arg] = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_type_constr_arg, p).node; let hi = p.get_lo_pos(); @@ -409,8 +409,8 @@ fn parse_constr_in_type(p: &parser) -> @ast::ty_constr { fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general[T] , p: &parser) - -> (@ast::constr_general[T])[] { - let constrs: (@ast::constr_general[T])[] = ~[]; + -> [@ast::constr_general[T]] { + let constrs: [@ast::constr_general[T]] = ~[]; while true { let constr = pser(p); constrs += ~[constr]; @@ -419,51 +419,33 @@ fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general[T] , p: &parser) constrs } -fn parse_type_constraints(p: &parser) -> (@ast::ty_constr)[] { +fn parse_type_constraints(p: &parser) -> [@ast::ty_constr] { ret parse_constrs(parse_constr_in_type, p); } fn parse_ty_postfix(orig_t: ast::ty_, p: &parser) -> @ast::ty { let lo = p.get_lo_pos(); if p.peek() == token::LBRACKET { + // This is explicit type parameter instantiation. p.bump(); - let mut; - if eat_word(p, "mutable") { - if p.peek() == token::QUES { - p.bump(); - mut = ast::maybe_mut; - } else { mut = ast::mut; } - } else { mut = ast::imm; } - - if mut == ast::imm && p.peek() != token::RBRACKET { - // This is explicit type parameter instantiation. - let seq = - parse_seq_to_end(token::RBRACKET, some(token::COMMA), - parse_ty, p); - + let seq = + parse_seq_to_end(token::RBRACKET, some(token::COMMA), + parse_ty, p); - alt orig_t { - ast::ty_path(pth, ann) { - let hi = p.get_hi_pos(); - ret @spanned(lo, hi, - ast::ty_path(spanned(lo, hi, - {global: pth.node.global, - idents: pth.node.idents, - types: seq}), ann)); - } - _ { - p.fatal("type parameter instantiation only allowed for " + - "paths"); - } - } + alt orig_t { + ast::ty_path(pth, ann) { + let hi = p.get_hi_pos(); + ret @spanned(lo, hi, + ast::ty_path(spanned(lo, hi, + {global: pth.node.global, + idents: pth.node.idents, + types: seq}), ann)); + } + _ { + p.fatal("type parameter instantiation only allowed for paths"); + } } - - expect(p, token::RBRACKET); - let hi = p.get_hi_pos(); - // FIXME: spans are probably wrong - let t = ast::ty_ivec({ty: @spanned(lo, hi, orig_t), mut: mut}); - ret parse_ty_postfix(t, p); } ret @spanned(lo, p.get_lo_pos(), orig_t); } @@ -554,6 +536,11 @@ fn parse_ty(p: &parser) -> @ast::ty { t = ast::ty_vec(parse_mt(p)); hi = p.get_hi_pos(); expect(p, token::RBRACKET); + } else if (p.peek() == token::LBRACKET) { + expect(p, token::LBRACKET); + t = ast::ty_ivec(parse_mt(p)); + hi = p.get_hi_pos(); + expect(p, token::RBRACKET); } else if (eat_word(p, "fn")) { let flo = p.get_last_lo_pos(); t = parse_ty_fn(ast::proto_fn, p, flo); @@ -603,16 +590,16 @@ fn parse_arg(p: &parser) -> ast::arg { } fn parse_seq_to_end[T](ket: token::token, sep: option::t[token::token], - f: fn(&parser) -> T , p: &parser) -> T[] { + f: fn(&parser) -> T , p: &parser) -> [T] { let val = parse_seq_to_before_end(ket, sep, f, p); p.bump(); ret val; } fn parse_seq_to_before_end[T](ket: token::token, sep: option::t[token::token], - f: fn(&parser) -> T , p: &parser) -> T[] { + f: fn(&parser) -> T , p: &parser) -> [T] { let first: bool = true; - let v: T[] = ~[]; + let v: [T] = ~[]; while p.peek() != ket { alt sep { some(t) { if first { first = false; } else { expect(p, t); } } @@ -626,7 +613,7 @@ fn parse_seq_to_before_end[T](ket: token::token, sep: option::t[token::token], fn parse_seq[T](bra: token::token, ket: token::token, sep: option::t[token::token], f: fn(&parser) -> T , - p: &parser) -> spanned[T[]] { + p: &parser) -> spanned[[T]] { let lo = p.get_lo_pos(); expect(p, bra); let result = parse_seq_to_before_end[T](ket, sep, f, p); @@ -694,7 +681,7 @@ fn parse_path(p: &parser) -> ast::path { p.bump(); } else { global = false; } - let ids: ast::ident[] = ~[]; + let ids: [ast::ident] = ~[]; while true { alt p.peek() { token::IDENT(i, _) { @@ -858,14 +845,14 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr { // Anonymous object // Only make people type () if they're actually adding new fields - let fields: option::t[ast::anon_obj_field[]] = none; + let fields: option::t[[ast::anon_obj_field]] = none; if p.peek() == token::LPAREN { p.bump(); fields = some(parse_seq_to_end(token::RPAREN, some(token::COMMA), parse_anon_obj_field, p)); } - let meths: (@ast::method)[] = ~[]; + let meths: [@ast::method] = ~[]; let inner_obj: option::t[@ast::expr] = none; expect(p, token::LBRACE); while p.peek() != token::RBRACE { @@ -1147,7 +1134,7 @@ type op_spec = {tok: token::token, op: ast::binop, prec: int}; // FIXME make this a const, don't store it in parser state -fn prec_table() -> @op_spec[] { +fn prec_table() -> @[op_spec] { ret @~[{tok: token::BINOP(token::STAR), op: ast::mul, prec: 11}, {tok: token::BINOP(token::SLASH), op: ast::div, prec: 11}, {tok: token::BINOP(token::PERCENT), op: ast::rem, prec: 11}, @@ -1334,7 +1321,7 @@ fn parse_alt_expr(p: &parser) -> @ast::expr { let lo = p.get_last_lo_pos(); let discriminant = parse_expr(p); expect(p, token::LBRACE); - let arms: ast::arm[] = ~[]; + let arms: [ast::arm] = ~[]; while p.peek() != token::RBRACE { let pats = parse_pats(p); let blk = parse_block(p); @@ -1396,7 +1383,7 @@ fn parse_initializer(p: &parser) -> option::t[ast::initializer] { } } -fn parse_pats(p: &parser) -> (@ast::pat)[] { +fn parse_pats(p: &parser) -> [@ast::pat] { let pats = ~[]; while true { pats += ~[parse_pat(p)]; @@ -1472,7 +1459,7 @@ fn parse_pat(p: &parser) -> @ast::pat { } else { let tag_path = parse_path_and_ty_param_substs(p); hi = tag_path.span.hi; - let args: (@ast::pat)[]; + let args: [@ast::pat]; alt p.peek() { token::LPAREN. { let a = @@ -1643,7 +1630,7 @@ fn parse_block(p: &parser) -> ast::blk { // some blocks start with "#{"... fn parse_block_tail(p: &parser, lo: uint) -> ast::blk { - let stmts: (@ast::stmt)[] = ~[]; + let stmts: [@ast::stmt] = ~[]; let expr: option::t[@ast::expr] = none; while p.peek() != token::RBRACE { alt p.peek() { @@ -1696,8 +1683,8 @@ fn parse_ty_param(p: &parser) -> ast::ty_param { ret {ident: parse_ident(p), kind: k}; } -fn parse_ty_params(p: &parser) -> ast::ty_param[] { - let ty_params: ast::ty_param[] = ~[]; +fn parse_ty_params(p: &parser) -> [ast::ty_param] { + let ty_params: [ast::ty_param] = ~[]; if p.peek() == token::LBRACKET { ty_params = parse_seq(token::LBRACKET, token::RBRACKET, some(token::COMMA), @@ -1708,7 +1695,7 @@ fn parse_ty_params(p: &parser) -> ast::ty_param[] { fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness) -> ast::fn_decl { - let inputs: ast::spanned[ast::arg[]] = + let inputs: ast::spanned[[ast::arg]] = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg, p); let rslt: ty_or_bang; @@ -1753,14 +1740,14 @@ fn parse_fn(p: &parser, proto: ast::proto, purity: ast::purity, ret {decl: decl, proto: proto, body: body}; } -fn parse_fn_header(p: &parser) -> {ident: ast::ident, tps: ast::ty_param[]} { +fn parse_fn_header(p: &parser) -> {ident: ast::ident, tps: [ast::ty_param]} { let id = parse_value_ident(p); let ty_params = parse_ty_params(p); ret {ident: id, tps: ty_params}; } fn mk_item(p: &parser, lo: uint, hi: uint, ident: &ast::ident, - node: &ast::item_, attrs: &ast::attribute[]) -> @ast::item { + node: &ast::item_, attrs: &[ast::attribute]) -> @ast::item { ret @{ident: ident, attrs: attrs, id: p.get_id(), @@ -1769,7 +1756,7 @@ fn mk_item(p: &parser, lo: uint, hi: uint, ident: &ast::ident, } fn parse_item_fn_or_iter(p: &parser, purity: ast::purity, proto: ast::proto, - attrs: &ast::attribute[], il: ast::inlineness) + attrs: &[ast::attribute], il: ast::inlineness) -> @ast::item { let lo = p.get_last_lo_pos(); let t = parse_fn_header(p); @@ -1805,15 +1792,15 @@ fn parse_method(p: &parser) -> @ast::method { ret @spanned(lo, f.body.span.hi, meth); } -fn parse_item_obj(p: &parser, attrs: &ast::attribute[]) -> +fn parse_item_obj(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); let ident = parse_value_ident(p); let ty_params = parse_ty_params(p); - let fields: ast::spanned[ast::obj_field[]] = + let fields: ast::spanned[[ast::obj_field]] = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_obj_field, p); - let meths: (@ast::method)[] = ~[]; + let meths: [@ast::method] = ~[]; expect(p, token::LBRACE); while p.peek() != token::RBRACE { meths += ~[parse_method(p)]; @@ -1825,7 +1812,7 @@ fn parse_item_obj(p: &parser, attrs: &ast::attribute[]) -> attrs); } -fn parse_item_res(p: &parser, attrs: &ast::attribute[]) -> +fn parse_item_res(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); let ident = parse_value_ident(p); @@ -1853,11 +1840,11 @@ fn parse_item_res(p: &parser, attrs: &ast::attribute[]) -> } fn parse_mod_items(p: &parser, term: token::token, - first_item_attrs: &ast::attribute[]) -> ast::_mod { + first_item_attrs: &[ast::attribute]) -> ast::_mod { // Shouldn't be any view items since we've already parsed an item attr let view_items = if ivec::len(first_item_attrs) == 0u { parse_view(p) } else { ~[] }; - let items: (@ast::item)[] = ~[]; + let items: [@ast::item] = ~[]; let initial_attrs = first_item_attrs; while p.peek() != term { let attrs = initial_attrs + parse_outer_attributes(p); @@ -1873,7 +1860,7 @@ fn parse_mod_items(p: &parser, term: token::token, ret {view_items: view_items, items: items}; } -fn parse_item_const(p: &parser, attrs: &ast::attribute[]) -> @ast::item { +fn parse_item_const(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); let id = parse_value_ident(p); expect(p, token::COLON); @@ -1885,7 +1872,7 @@ fn parse_item_const(p: &parser, attrs: &ast::attribute[]) -> @ast::item { ret mk_item(p, lo, hi, id, ast::item_const(ty, e), attrs); } -fn parse_item_mod(p: &parser, attrs: &ast::attribute[]) -> @ast::item { +fn parse_item_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); let id = parse_ident(p); expect(p, token::LBRACE); @@ -1897,7 +1884,7 @@ fn parse_item_mod(p: &parser, attrs: &ast::attribute[]) -> @ast::item { ret mk_item(p, lo, hi, id, ast::item_mod(m), attrs + inner_attrs.inner); } -fn parse_item_native_type(p: &parser, attrs: &ast::attribute[]) -> +fn parse_item_native_type(p: &parser, attrs: &[ast::attribute]) -> @ast::native_item { let t = parse_type_decl(p); let hi = p.get_hi_pos(); @@ -1909,7 +1896,7 @@ fn parse_item_native_type(p: &parser, attrs: &ast::attribute[]) -> span: {lo: t.lo, hi: hi}}; } -fn parse_item_native_fn(p: &parser, attrs: &ast::attribute[]) -> +fn parse_item_native_fn(p: &parser, attrs: &[ast::attribute]) -> @ast::native_item { let lo = p.get_last_lo_pos(); let t = parse_fn_header(p); @@ -1925,7 +1912,7 @@ fn parse_item_native_fn(p: &parser, attrs: &ast::attribute[]) -> span: {lo: lo, hi: hi}}; } -fn parse_native_item(p: &parser, attrs: &ast::attribute[]) -> +fn parse_native_item(p: &parser, attrs: &[ast::attribute]) -> @ast::native_item { if eat_word(p, "type") { ret parse_item_native_type(p, attrs); @@ -1935,14 +1922,14 @@ fn parse_native_item(p: &parser, attrs: &ast::attribute[]) -> } fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi, - first_item_attrs: &ast::attribute[]) + first_item_attrs: &[ast::attribute]) -> ast::native_mod { // Shouldn't be any view items since we've already parsed an item attr let view_items = if ivec::len(first_item_attrs) == 0u { parse_native_view(p) } else { ~[] }; - let items: (@ast::native_item)[] = ~[]; + let items: [@ast::native_item] = ~[]; let initial_attrs = first_item_attrs; while p.peek() != token::RBRACE { let attrs = initial_attrs + parse_outer_attributes(p); @@ -1955,7 +1942,7 @@ fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi, items: items}; } -fn parse_item_native_mod(p: &parser, attrs: &ast::attribute[]) -> @ast::item { +fn parse_item_native_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); let abi = ast::native_abi_cdecl; if !is_word(p, "mod") { @@ -1995,7 +1982,7 @@ fn parse_type_decl(p: &parser) -> {lo: uint, ident: ast::ident} { ret {lo: lo, ident: id}; } -fn parse_item_type(p: &parser, attrs: &ast::attribute[]) -> @ast::item { +fn parse_item_type(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let t = parse_type_decl(p); let tps = parse_ty_params(p); expect(p, token::EQ); @@ -2005,11 +1992,11 @@ fn parse_item_type(p: &parser, attrs: &ast::attribute[]) -> @ast::item { ret mk_item(p, t.lo, hi, t.ident, ast::item_ty(ty, tps), attrs); } -fn parse_item_tag(p: &parser, attrs: &ast::attribute[]) -> @ast::item { +fn parse_item_tag(p: &parser, attrs: &[ast::attribute]) -> @ast::item { let lo = p.get_last_lo_pos(); let id = parse_ident(p); let ty_params = parse_ty_params(p); - let variants: ast::variant[] = ~[]; + let variants: [ast::variant] = ~[]; // Newtype syntax if p.peek() == token::EQ { if p.get_bad_expr_words().contains_key(id) { @@ -2034,7 +2021,7 @@ fn parse_item_tag(p: &parser, attrs: &ast::attribute[]) -> @ast::item { check_bad_word(p); let vlo = p.get_lo_pos(); p.bump(); - let args: ast::variant_arg[] = ~[]; + let args: [ast::variant_arg] = ~[]; let vhi = p.get_hi_pos(); alt p.peek() { token::LPAREN. { @@ -2071,7 +2058,7 @@ fn parse_auth(p: &parser) -> ast::_auth { } else { unexpected(p, p.peek()); } } -fn parse_item(p: &parser, attrs: &ast::attribute[]) -> option::t[@ast::item] { +fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t[@ast::item] { if eat_word(p, "const") { ret some(parse_item_const(p, attrs)); } else if (eat_word(p, "inline")) { @@ -2107,7 +2094,7 @@ fn parse_item(p: &parser, attrs: &ast::attribute[]) -> option::t[@ast::item] { // A type to distingush between the parsing of item attributes or syntax // extensions, which both begin with token.POUND -type attr_or_ext = option::t[either::t[ast::attribute[], @ast::expr]]; +type attr_or_ext = option::t[either::t[[ast::attribute], @ast::expr]]; fn parse_outer_attrs_or_ext(p: &parser) -> attr_or_ext { if p.peek() == token::POUND { @@ -2123,8 +2110,8 @@ fn parse_outer_attrs_or_ext(p: &parser) -> attr_or_ext { } // Parse attributes that appear before an item -fn parse_outer_attributes(p: &parser) -> ast::attribute[] { - let attrs: ast::attribute[] = ~[]; +fn parse_outer_attributes(p: &parser) -> [ast::attribute] { + let attrs: [ast::attribute] = ~[]; while p.peek() == token::POUND { attrs += ~[parse_attribute(p, ast::attr_outer)]; } @@ -2153,9 +2140,9 @@ fn parse_attribute_naked(p: &parser, style: ast::attr_style, lo: uint) -> // of the containing item or an outer attribute of the first contained item // until we see the semi). fn parse_inner_attrs_and_next(p: &parser) -> - {inner: ast::attribute[], next: ast::attribute[]} { - let inner_attrs: ast::attribute[] = ~[]; - let next_outer_attrs: ast::attribute[] = ~[]; + {inner: [ast::attribute], next: [ast::attribute]} { + let inner_attrs: [ast::attribute] = ~[]; + let next_outer_attrs: [ast::attribute] = ~[]; while p.peek() == token::POUND { let attr = parse_attribute(p, ast::attr_inner); if p.peek() == token::SEMI { @@ -2195,12 +2182,12 @@ fn parse_meta_item(p: &parser) -> @ast::meta_item { } } -fn parse_meta_seq(p: &parser) -> (@ast::meta_item)[] { +fn parse_meta_seq(p: &parser) -> [@ast::meta_item] { ret parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_meta_item, p).node; } -fn parse_optional_meta(p: &parser) -> (@ast::meta_item)[] { +fn parse_optional_meta(p: &parser) -> [@ast::meta_item] { alt p.peek() { token::LPAREN. { ret parse_meta_seq(p); } _ { ret ~[]; } } } @@ -2213,7 +2200,7 @@ fn parse_use(p: &parser) -> ast::view_item_ { fn parse_rest_import_name(p: &parser, first: ast::ident, def_ident: option::t[ast::ident]) -> ast::view_item_ { - let identifiers: ast::ident[] = ~[first]; + let identifiers: [ast::ident] = ~[first]; let glob: bool = false; while true { alt p.peek() { @@ -2308,14 +2295,14 @@ fn is_view_item(p: &parser) -> bool { } } -fn parse_view(p: &parser) -> (@ast::view_item)[] { - let items: (@ast::view_item)[] = ~[]; +fn parse_view(p: &parser) -> [@ast::view_item] { + let items: [@ast::view_item] = ~[]; while is_view_item(p) { items += ~[parse_view_item(p)]; } ret items; } -fn parse_native_view(p: &parser) -> (@ast::view_item)[] { - let items: (@ast::view_item)[] = ~[]; +fn parse_native_view(p: &parser) -> [@ast::view_item] { + let items: [@ast::view_item] = ~[]; while is_view_item(p) { items += ~[parse_view_item(p)]; } ret items; } @@ -2363,7 +2350,7 @@ fn parse_str(p: &parser) -> ast::ident { // Each crate file is a sequence of directives. // // Each directive imperatively extends its environment with 0 or more items. -fn parse_crate_directive(p: &parser, first_outer_attr: &ast::attribute[]) -> +fn parse_crate_directive(p: &parser, first_outer_attr: &[ast::attribute]) -> ast::crate_directive { // Collect the next attributes @@ -2418,8 +2405,8 @@ fn parse_crate_directive(p: &parser, first_outer_attr: &ast::attribute[]) -> } fn parse_crate_directives(p: &parser, term: token::token, - first_outer_attr: &ast::attribute[]) -> - (@ast::crate_directive)[] { + first_outer_attr: &[ast::attribute]) -> + [@ast::crate_directive] { // This is pretty ugly. If we have an outer attribute then we can't accept // seeing the terminator next, so if we do see it then fail the same way @@ -2428,7 +2415,7 @@ fn parse_crate_directives(p: &parser, term: token::token, expect_word(p, "mod"); } - let cdirs: (@ast::crate_directive)[] = ~[]; + let cdirs: [@ast::crate_directive] = ~[]; while p.peek() != term { let cdir = @parse_crate_directive(p, first_outer_attr); cdirs += ~[cdir]; @@ -2445,7 +2432,7 @@ fn parse_crate_from_crate_file(input: &str, cfg: &ast::crate_cfg, let crate_attrs = leading_attrs.inner; let first_cdir_attr = leading_attrs.next; let cdirs = parse_crate_directives(p, token::EOF, first_cdir_attr); - let deps: str[] = ~[]; + let deps: [str] = ~[]; let cx = @{p: p, mode: eval::mode_parse, diff --git a/src/comp/syntax/print/pp.rs b/src/comp/syntax/print/pp.rs index b1f84782952ea..00b6c5f32bff4 100644 --- a/src/comp/syntax/print/pp.rs +++ b/src/comp/syntax/print/pp.rs @@ -74,7 +74,7 @@ fn tok_str(t: token) -> str { } } -fn buf_str(toks: &token[mutable ], szs: &int[mutable ], left: uint, +fn buf_str(toks: &[mutable token], szs: &[mutable int], left: uint, right: uint, lim: uint) -> str { let n = ivec::len(toks); assert (n == ivec::len(szs)); @@ -104,10 +104,10 @@ fn mk_printer(out: ioivec::writer, linewidth: uint) -> printer { let n: uint = 3u * linewidth; log #fmt("mk_printer %u", linewidth); - let token: token[mutable ] = ivec::init_elt_mut(EOF, n); - let size: int[mutable ] = ivec::init_elt_mut(0, n); - let scan_stack: uint[mutable ] = ivec::init_elt_mut(0u, n); - let print_stack: print_stack_elt[] = ~[]; + let token: [mutable token] = ivec::init_elt_mut(EOF, n); + let size: [mutable int] = ivec::init_elt_mut(0, n); + let scan_stack: [mutable uint] = ivec::init_elt_mut(0u, n); + let print_stack: [print_stack_elt] = ~[]; ret printer(out, n, linewidth as int, // margin linewidth as int, // space 0u, // left @@ -208,10 +208,10 @@ obj printer(out: ioivec::writer, mutable right: uint, // index of right side of input stream - mutable token: token[mutable ], + mutable token: [mutable token], // ring-buffr stream goes through - mutable size: int[mutable ], // ring-buffer of calculated sizes + mutable size: [mutable int], // ring-buffer of calculated sizes mutable left_total: int, // running size of stream "...left" @@ -223,7 +223,7 @@ obj printer(out: ioivec::writer, // BEGIN (if there is any) on top of it. Stuff is flushed off the // bottom as it becomes irrelevant due to the primary ring-buffer // advancing. - mutable scan_stack: uint[mutable ], + mutable scan_stack: [mutable uint], mutable scan_stack_empty: bool, // top==bottom disambiguator mutable top: uint, // index of top of scan_stack @@ -231,7 +231,7 @@ obj printer(out: ioivec::writer, mutable bottom: uint, // index of bottom of scan_stack // stack of blocks-in-progress being flushed by print - mutable print_stack: print_stack_elt[], + mutable print_stack: [print_stack_elt], // buffered indentation to avoid writing trailing whitespace diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index dab764c5baabf..25cbf3c268e55 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -41,11 +41,11 @@ fn no_ann() -> pp_ann { type ps = @{s: pp::printer, cm: option::t[codemap], - comments: option::t[lexer::cmnt[]], - literals: option::t[lexer::lit[]], + comments: option::t[[lexer::cmnt]], + literals: option::t[[lexer::lit]], mutable cur_cmnt: uint, mutable cur_lit: uint, - mutable boxes: pp::breaks[], + mutable boxes: [pp::breaks], ann: pp_ann}; fn ibox(s: &ps, u: uint) { s.boxes += ~[pp::inconsistent]; pp::ibox(s.s, u); } @@ -53,11 +53,11 @@ fn ibox(s: &ps, u: uint) { s.boxes += ~[pp::inconsistent]; pp::ibox(s.s, u); } fn end(s: &ps) { ivec::pop(s.boxes); pp::end(s.s); } fn rust_printer(writer: ioivec::writer) -> ps { - let boxes: pp::breaks[] = ~[]; + let boxes: [pp::breaks] = ~[]; ret @{s: pp::mk_printer(writer, default_columns), cm: none[codemap], - comments: none[lexer::cmnt[]], - literals: none[lexer::lit[]], + comments: none[[lexer::cmnt]], + literals: none[[lexer::lit]], mutable cur_cmnt: 0u, mutable cur_lit: 0u, mutable boxes: boxes, @@ -74,7 +74,7 @@ const default_columns: uint = 78u; // copy forward. fn print_crate(cm: &codemap, crate: @ast::crate, filename: str, in: ioivec::reader, out: ioivec::writer, ann: &pp_ann) { - let boxes: pp::breaks[] = ~[]; + let boxes: [pp::breaks] = ~[]; let r = lexer::gather_comments_and_literals(cm, filename, in); let s = @{s: pp::mk_printer(out, default_columns), @@ -102,7 +102,7 @@ fn item_to_str(i: &@ast::item) -> str { be to_str(i, print_item); } fn path_to_str(p: &ast::path) -> str { be to_str(p, print_path); } -fn fun_to_str(f: &ast::_fn, name: str, params: &ast::ty_param[]) -> str { +fn fun_to_str(f: &ast::_fn, name: str, params: &[ast::ty_param]) -> str { let writer = ioivec::string_writer(); let s = rust_printer(writer.get_writer()); print_fn(s, f.decl, f.proto, name, params, f.decl.constraints); @@ -216,7 +216,7 @@ fn synth_comment(s: &ps, text: str) { word(s.s, "*/"); } -fn commasep[IN](s: &ps, b: breaks, elts: &IN[], op: fn(&ps, &IN) ) { +fn commasep[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) { box(s, 0u, b); let first = true; for elt: IN in elts { @@ -227,7 +227,7 @@ fn commasep[IN](s: &ps, b: breaks, elts: &IN[], op: fn(&ps, &IN) ) { } -fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &IN[], op: fn(&ps, &IN) , +fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) , get_span: fn(&IN) -> codemap::span ) { box(s, 0u, b); let len = ivec::len[IN](elts); @@ -246,12 +246,12 @@ fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &IN[], op: fn(&ps, &IN) , end(s); } -fn commasep_exprs(s: &ps, b: breaks, exprs: &(@ast::expr)[]) { +fn commasep_exprs(s: &ps, b: breaks, exprs: &[@ast::expr]) { fn expr_span(expr: &@ast::expr) -> codemap::span { ret expr.span; } commasep_cmnt(s, b, exprs, print_expr, expr_span); } -fn print_mod(s: &ps, _mod: &ast::_mod, attrs: &ast::attribute[]) { +fn print_mod(s: &ps, _mod: &ast::_mod, attrs: &[ast::attribute]) { print_inner_attributes(s, attrs); for vitem: @ast::view_item in _mod.view_items { print_view_item(s, vitem); @@ -260,7 +260,7 @@ fn print_mod(s: &ps, _mod: &ast::_mod, attrs: &ast::attribute[]) { } fn print_native_mod(s: &ps, nmod: &ast::native_mod, - attrs: &ast::attribute[]) { + attrs: &[ast::attribute]) { print_inner_attributes(s, attrs); for vitem: @ast::view_item in nmod.view_items { print_view_item(s, vitem); @@ -287,24 +287,13 @@ fn print_type(s: &ps, ty: &ast::ty) { ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); } ast::ty_vec(mt) { word(s.s, "vec["); print_mt(s, mt); word(s.s, "]"); } ast::ty_ivec(mt) { - let parens = - alt mt.ty.node { - ast::ty_box(_) | ast::ty_vec(_) | ast::ty_ptr(_) | - ast::ty_port(_) | ast::ty_chan(_) { - true - } - ast::ty_path(pt, _) { ivec::len(pt.node.types) > 0u } - _ { false } - }; - if parens { popen(s); } - print_type(s, *mt.ty); - if parens { pclose(s); } word(s.s, "["); alt mt.mut { - ast::mut. { word(s.s, "mutable"); } - ast::maybe_mut. { word(s.s, "mutable?"); } + ast::mut. { word_space(s, "mutable"); } + ast::maybe_mut. { word_space(s, "mutable?"); } ast::imm. {} } + print_type(s, *mt.ty); word(s.s, "]"); } ast::ty_ptr(mt) { word(s.s, "*"); print_mt(s, mt); } @@ -516,7 +505,7 @@ fn print_item(s: &ps, item: &@ast::item) { space(s.s); bopen(s); for meth: @ast::method in _obj.methods { - let typarams: ast::ty_param[] = ~[]; + let typarams: [ast::ty_param] = ~[]; hardbreak_if_not_bol(s); maybe_print_comment(s, meth.span.lo); print_fn(s, meth.node.meth.decl, meth.node.meth.proto, @@ -541,7 +530,7 @@ fn print_item(s: &ps, item: &@ast::item) { s.ann.post(ann_node); } -fn print_outer_attributes(s: &ps, attrs: &ast::attribute[]) { +fn print_outer_attributes(s: &ps, attrs: &[ast::attribute]) { let count = 0; for attr: ast::attribute in attrs { alt attr.node.style { @@ -552,7 +541,7 @@ fn print_outer_attributes(s: &ps, attrs: &ast::attribute[]) { if count > 0 { hardbreak_if_not_bol(s); } } -fn print_inner_attributes(s: &ps, attrs: &ast::attribute[]) { +fn print_inner_attributes(s: &ps, attrs: &[ast::attribute]) { let count = 0; for attr: ast::attribute in attrs { alt attr.node.style { @@ -1022,7 +1011,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) { // Methods for meth: @ast::method in anon_obj.methods { - let typarams: ast::ty_param[] = ~[]; + let typarams: [ast::ty_param] = ~[]; hardbreak_if_not_bol(s); maybe_print_comment(s, meth.span.lo); print_fn(s, meth.node.meth.decl, meth.node.meth.proto, @@ -1156,7 +1145,7 @@ fn print_pat(s: &ps, pat: &@ast::pat) { } fn print_fn(s: &ps, decl: ast::fn_decl, proto: ast::proto, name: str, - typarams: &ast::ty_param[], constrs: (@ast::constr)[]) { + typarams: &[ast::ty_param], constrs: [@ast::constr]) { alt decl.purity { ast::impure_fn. { head(s, proto_to_str(proto)); } _ { head(s, "pred"); } @@ -1167,7 +1156,7 @@ fn print_fn(s: &ps, decl: ast::fn_decl, proto: ast::proto, name: str, } fn print_fn_args_and_ret(s: &ps, decl: &ast::fn_decl, - constrs: (@ast::constr)[]) { + constrs: [@ast::constr]) { popen(s); fn print_arg(s: &ps, x: &ast::arg) { ibox(s, indent_unit); @@ -1203,7 +1192,7 @@ fn print_kind(s: &ps, kind: ast::kind) { } } -fn print_type_params(s: &ps, params: &ast::ty_param[]) { +fn print_type_params(s: &ps, params: &[ast::ty_param]) { if ivec::len(params) > 0u { word(s.s, "["); fn printParam(s: &ps, param: &ast::ty_param) { @@ -1318,8 +1307,8 @@ fn print_mt(s: &ps, mt: &ast::mt) { } fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str], - inputs: &ast::ty_arg[], output: &@ast::ty, - cf: &ast::controlflow, constrs: &(@ast::constr)[]) { + inputs: &[ast::ty_arg], output: &@ast::ty, + cf: &ast::controlflow, constrs: &[@ast::constr]) { ibox(s, indent_unit); word(s.s, proto_to_str(proto)); alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } } @@ -1528,7 +1517,7 @@ fn next_comment(s: &ps) -> option::t[lexer::cmnt] { // Removing the aliases from the type of f in the next two functions // triggers memory corruption, but I haven't isolated the bug yet. FIXME fn constr_args_to_str[T](f: &fn(&T) -> str , - args: &(@ast::sp_constr_arg[T])[]) -> str { + args: &[@ast::sp_constr_arg[T]]) -> str { let comma = false; let s = "("; for a: @ast::sp_constr_arg[T] in args { @@ -1559,7 +1548,7 @@ fn ast_ty_fn_constr_to_str(c: &@ast::constr) -> str { } // FIXME: fix repeated code -fn ast_ty_fn_constrs_str(constrs: &(@ast::constr)[]) -> str { +fn ast_ty_fn_constrs_str(constrs: &[@ast::constr]) -> str { let s = ""; let colon = true; for c: @ast::constr in constrs { @@ -1581,7 +1570,7 @@ fn ast_fn_constr_to_str(decl: &ast::fn_decl, c: &@ast::constr) -> str { // FIXME: fix repeated code fn ast_fn_constrs_str(decl: &ast::fn_decl, - constrs: &(@ast::constr)[]) -> str { + constrs: &[@ast::constr]) -> str { let s = ""; let colon = true; for c: @ast::constr in constrs { @@ -1606,7 +1595,7 @@ fn ty_constr_to_str(c: &@ast::ty_constr) -> str { } -fn ast_ty_constrs_str(constrs: &(@ast::ty_constr)[]) -> str { +fn ast_ty_constrs_str(constrs: &[@ast::ty_constr]) -> str { let s = ""; let colon = true; for c: @ast::ty_constr in constrs { diff --git a/src/comp/syntax/util/interner.rs b/src/comp/syntax/util/interner.rs index 7e7a9ca710732..7f95d0ef0e717 100644 --- a/src/comp/syntax/util/interner.rs +++ b/src/comp/syntax/util/interner.rs @@ -12,7 +12,7 @@ import std::option::some; type interner[T] = {map: hashmap[T, uint], - mutable vect: T[], + mutable vect: [T], hasher: hashfn[T], eqer: eqfn[T]}; diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index 673fa46d466cd..9c639b8c5c008 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -33,7 +33,7 @@ type visitor[E] = visit_ty: fn(&@ty, &E, &vt[E]) , visit_constr: fn(&path, &span, node_id, &E, &vt[E]) , visit_fn: - fn(&_fn, &ty_param[], &span, &fn_ident, node_id, &E, &vt[E]) }; + fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt[E]) }; fn default_visitor[E]() -> visitor[E] { ret @{visit_mod: bind visit_mod[E](_, _, _, _), @@ -195,7 +195,7 @@ fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt[E]) { v.visit_ty(fd.output, e, v); } -fn visit_fn[E](f: &_fn, tp: &ty_param[], sp: &span, i: &fn_ident, id: node_id, +fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id, e: &E, v: &vt[E]) { visit_fn_decl(f.decl, e, v); v.visit_block(f.body, e, v); @@ -227,7 +227,7 @@ fn visit_expr_opt[E](eo: option::t[@expr], e: &E, v: &vt[E]) { alt eo { none. { } some(ex) { v.visit_expr(ex, e, v); } } } -fn visit_exprs[E](exprs: &(@expr)[], e: &E, v: &vt[E]) { +fn visit_exprs[E](exprs: &[@expr], e: &E, v: &vt[E]) { for ex: @expr in exprs { v.visit_expr(ex, e, v); } } @@ -362,7 +362,7 @@ type simple_visitor = visit_expr: fn(&@expr) , visit_ty: fn(&@ty) , visit_constr: fn(&path, &span, node_id) , - visit_fn: fn(&_fn, &ty_param[], &span, &fn_ident, node_id) }; + visit_fn: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) }; fn default_simple_visitor() -> simple_visitor { ret @{visit_mod: fn (m: &_mod, sp: &span) { }, @@ -379,7 +379,7 @@ fn default_simple_visitor() -> simple_visitor { visit_ty: fn (t: &@ty) { }, visit_constr: fn (p: &path, sp: &span, id: node_id) { }, visit_fn: - fn (f: &_fn, tps: &ty_param[], sp: &span, ident: &fn_ident, + fn (f: &_fn, tps: &[ty_param], sp: &span, ident: &fn_ident, id: node_id) { }}; } @@ -439,8 +439,8 @@ fn mk_simple_visitor(v: &simple_visitor) -> vt[()] { f(pt, sp, id); visit_constr(pt, sp, id, e, v); } - fn v_fn(f: fn(&_fn, &ty_param[], &span, &fn_ident, node_id) , ff: &_fn, - tps: &ty_param[], sp: &span, ident: &fn_ident, id: node_id, + fn v_fn(f: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) , ff: &_fn, + tps: &[ty_param], sp: &span, ident: &fn_ident, id: node_id, e: &(), v: &vt[()]) { f(ff, tps, sp, ident, id); visit_fn(ff, tps, sp, ident, id, e, v); diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index aed835aedec59..e0e9a5bfa52d4 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -49,7 +49,7 @@ fn new_def_hash[@V]() -> std::map::hashmap[ast::def_id, V] { fn elt_expr(e: &ast::elt) -> @ast::expr { ret e.expr; } -fn elt_exprs(elts: &ast::elt[]) -> (@ast::expr)[] { +fn elt_exprs(elts: &[ast::elt]) -> [@ast::expr] { let es = ~[]; for e: ast::elt in elts { es += ~[e.expr]; } ret es; @@ -57,7 +57,7 @@ fn elt_exprs(elts: &ast::elt[]) -> (@ast::expr)[] { fn field_expr(f: &ast::field) -> @ast::expr { ret f.node.expr; } -fn field_exprs(fields: &ast::field[]) -> (@ast::expr)[] { +fn field_exprs(fields: &[ast::field]) -> [@ast::expr] { let es = ~[]; for f: ast::field in fields { es += ~[f.node.expr]; } ret es; @@ -77,11 +77,11 @@ fn log_block_err(b: &ast::blk) { log_err print::pprust::block_to_str(b); } fn log_item_err(i: &@ast::item) { log_err print::pprust::item_to_str(i); } -fn log_fn(f: &ast::_fn, name: str, params: &ast::ty_param[]) { +fn log_fn(f: &ast::_fn, name: str, params: &[ast::ty_param]) { log print::pprust::fun_to_str(f, name, params); } -fn log_fn_err(f: &ast::_fn, name: str, params: &ast::ty_param[]) { +fn log_fn_err(f: &ast::_fn, name: str, params: &[ast::ty_param]) { log_err print::pprust::fun_to_str(f, name, params); } @@ -161,7 +161,7 @@ fn call_kind_str(c: call_kind) -> str { } } -fn is_main_name(path: &str[]) -> bool { +fn is_main_name(path: &[str]) -> bool { str::eq(option::get(std::ivec::last(path)), "main") } diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs index 93530b26f3535..63d84d363e4f2 100644 --- a/src/comp/util/ppaux.rs +++ b/src/comp/util/ppaux.rs @@ -42,8 +42,8 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str { ret s + ty_to_str(cx, input.ty); } fn fn_to_str(cx: &ctxt, proto: ast::proto, ident: option::t[ast::ident], - inputs: &arg[], output: t, cf: ast::controlflow, - constrs: &(@constr)[]) -> str { + inputs: &[arg], output: t, cf: ast::controlflow, + constrs: &[@constr]) -> str { let s = proto_to_str(proto); alt ident { some(i) { s += " "; s += i; } _ { } } s += "("; @@ -98,7 +98,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str { ty_type. { s += "type"; } ty_task. { s += "task"; } ty_rec(elems) { - let strs: str[] = ~[]; + let strs: [str] = ~[]; for fld: field in elems { strs += ~[field_to_str(cx, fld)]; } s += "{" + str::connect_ivec(strs, ",") + "}"; } @@ -107,7 +107,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str { s += ""; if ivec::len[t](tps) > 0u { - let strs: str[] = ~[]; + let strs: [str] = ~[]; for typ: t in tps { strs += ~[ty_to_str(cx, typ)]; } s += "[" + str::connect_ivec(strs, ",") + "]"; } @@ -149,7 +149,7 @@ fn constr_to_str(c: &@constr) -> str { pprust::constr_args_to_str(pprust::uint_to_str, c.node.args); } -fn constrs_str(constrs: &(@constr)[]) -> str { +fn constrs_str(constrs: &[@constr]) -> str { let s = ""; let colon = true; for c: @constr in constrs { diff --git a/src/fuzzer/ast_match.rs b/src/fuzzer/ast_match.rs index fd9a5535707be..0aede0667b851 100644 --- a/src/fuzzer/ast_match.rs +++ b/src/fuzzer/ast_match.rs @@ -1,7 +1,7 @@ use std; import std::ivec; -fn ivec_equal[T](v: &T[], u: &T[], element_equality_test: fn(&T, &T) -> bool ) +fn ivec_equal[T](v: &[T], u: &[T], element_equality_test: fn(&T, &T) -> bool ) -> bool { let Lv = ivec::len(v); if Lv != ivec::len(u) { ret false; } @@ -24,4 +24,4 @@ fn main() { assert (ivec_equal(~[5, 5], ~[5, 5], builtin_equal)); log_err "Pass"; -} \ No newline at end of file +} diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 312f0e77787af..1f7c2c45eccc8 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -38,7 +38,7 @@ fn contains(haystack: &str, needle: &str) -> bool { str::find(haystack, needle) != -1 } -fn find_rust_files(files: &mutable str[], path: str) { +fn find_rust_files(files: &mutable [str], path: str) { if str::ends_with(path, ".rs") { if file_contains(path, "xfail-stage1") { //log_err "Skipping " + path + " because it is marked as xfail-stage1"; @@ -89,10 +89,10 @@ fn safe_to_steal(e: ast::expr_) -> bool { } } -fn steal_exprs(crate: &ast::crate) -> ast::expr[] { - let exprs: @mutable ast::expr[] = @mutable ~[]; +fn steal_exprs(crate: &ast::crate) -> [ast::expr] { + let exprs: @mutable [ast::expr] = @mutable ~[]; // "Stash" is not type-parameterized because of the need for safe_to_steal - fn stash_expr(es: @mutable ast::expr[], e: &@ast::expr) { + fn stash_expr(es: @mutable [ast::expr], e: &@ast::expr) { if safe_to_steal(e.node) { *es += ~[*e]; } else {/* now my indices are wrong :( */ } @@ -316,7 +316,7 @@ fn check_roundtrip_convergence(code: &str, maxIters: uint) { } } -fn check_convergence(files: &str[]) { +fn check_convergence(files: &[str]) { log_err #fmt("pp convergence tests: %u files", ivec::len(files)); for file in files { if !file_is_confusing(file) { @@ -330,7 +330,7 @@ fn check_convergence(files: &str[]) { } } -fn check_variants(files: &str[]) { +fn check_variants(files: &[str]) { for file in files { if !file_is_confusing(file) { let s = ioivec::read_whole_file_str(file); diff --git a/src/fuzzer/ivec_fuzz.rs b/src/fuzzer/ivec_fuzz.rs index 3f959f649b125..8448ef1dadfba 100644 --- a/src/fuzzer/ivec_fuzz.rs +++ b/src/fuzzer/ivec_fuzz.rs @@ -7,8 +7,8 @@ Idea: provide functions for 'exhaustive' and 'random' modification of vecs. two functions, "return the number of possible edits" and "return edit #n" It would be nice if this could be data-driven, so the two functions could share information: - type vec_modifier = rec(fn (&T[] v, uint i) -> T[] fun, uint lo, uint di); - const vec_modifier[] vec_modifiers = ~[rec(fun=vec_omit, 0u, 1u), ...]; + type vec_modifier = rec(fn (&[T] v, uint i) -> [T] fun, uint lo, uint di); + const [vec_modifier] vec_modifiers = ~[rec(fun=vec_omit, 0u, 1u), ...]; But that gives me "error: internal compiler error unimplemented consts that's not a plain literal". https://github.com/graydon/rust/issues/570 @@ -26,24 +26,24 @@ import std::ivec::slice; import std::ivec::len; import std::int; -//fn vec_reverse(&T[] v) -> T[] { ... } +//fn vec_reverse(&[T] v) -> [T] { ... } -fn vec_omit[T](v: &T[], i: uint) -> T[] { +fn vec_omit[T](v: &[T], i: uint) -> [T] { slice(v, 0u, i) + slice(v, i + 1u, len(v)) } -fn vec_dup[T](v: &T[], i: uint) -> T[] { +fn vec_dup[T](v: &[T], i: uint) -> [T] { slice(v, 0u, i) + ~[v.(i)] + slice(v, i, len(v)) } -fn vec_swadj[T](v: &T[], i: uint) -> T[] { +fn vec_swadj[T](v: &[T], i: uint) -> [T] { slice(v, 0u, i) + ~[v.(i + 1u), v.(i)] + slice(v, i + 2u, len(v)) } -fn vec_prefix[T](v: &T[], i: uint) -> T[] { slice(v, 0u, i) } -fn vec_suffix[T](v: &T[], i: uint) -> T[] { slice(v, i, len(v)) } +fn vec_prefix[T](v: &[T], i: uint) -> [T] { slice(v, 0u, i) } +fn vec_suffix[T](v: &[T], i: uint) -> [T] { slice(v, i, len(v)) } -fn vec_poke[T](v: &T[], i: uint, x: &T) -> T[] { +fn vec_poke[T](v: &[T], i: uint, x: &T) -> [T] { slice(v, 0u, i) + ~[x] + slice(v, i + 1u, len(v)) } -fn vec_insert[T](v: &T[], i: uint, x: &T) -> T[] { +fn vec_insert[T](v: &[T], i: uint, x: &T) -> [T] { slice(v, 0u, i) + ~[x] + slice(v, i, len(v)) } @@ -54,8 +54,8 @@ iter ix(skip_low: uint, skip_high: uint, length: uint) -> uint { } // Returns a bunch of modified versions of v, some of which introduce new elements (borrowed from xs). -fn vec_edits[T](v: &T[], xs: &T[]) -> T[][] { - let edits: T[][] = ~[]; +fn vec_edits[T](v: &[T], xs: &[T]) -> [[T]] { + let edits: [[T]] = ~[]; let Lv: uint = len(v); if Lv != 1u { @@ -85,7 +85,7 @@ fn vec_edits[T](v: &T[], xs: &T[]) -> T[][] { } // Would be nice if this were built in: https://github.com/graydon/rust/issues/424 -fn vec_to_str(v: &int[]) -> str { +fn vec_to_str(v: &[int]) -> str { let i = 0u; let s = "["; while i < len(v) { @@ -96,7 +96,7 @@ fn vec_to_str(v: &int[]) -> str { ret s + "]"; } -fn show_edits(a: &int[], xs: &int[]) { +fn show_edits(a: &[int], xs: &[int]) { log_err "=== Edits of " + vec_to_str(a) + " ==="; let b = vec_edits(a, xs); for each i: uint in ix(0u, 1u, len(b)) { log_err vec_to_str(b.(i)); } @@ -111,4 +111,4 @@ fn demo_edits() { show_edits(~[1, 2, 3, 4], xs); } -fn main() { demo_edits(); } \ No newline at end of file +fn main() { demo_edits(); } diff --git a/src/lib/aio.rs b/src/lib/aio.rs index b6f5730d8505b..81c6ddf80fb73 100644 --- a/src/lib/aio.rs +++ b/src/lib/aio.rs @@ -10,7 +10,7 @@ native "rust" mod rustrt { fn aio_connect(host: sbuf, port: int, connected: chan[socket]); fn aio_serve(host: sbuf, port: int, acceptChan: chan[socket]) -> server; fn aio_writedata(s: socket, buf: *u8, size: uint, status: chan[bool]); - fn aio_read(s: socket, reader: chan[u8[]]); + fn aio_read(s: socket, reader: chan[[u8]]); fn aio_close_server(s: server, status: chan[bool]); fn aio_close_socket(s: socket); fn aio_is_null_client(s: socket) -> bool; @@ -26,7 +26,7 @@ tag pending_connection { tag socket_event { connected(client); closed; - received(u8[]); + received([u8]); } tag server_event { @@ -37,7 +37,7 @@ tag request { quit; connect(pending_connection,chan[socket_event]); serve(str,int,chan[server_event],chan[server]); - write(client,u8[],chan[bool]); + write(client,[u8],chan[bool]); close_server(server, chan[bool]); close_client(client); } @@ -56,14 +56,14 @@ fn new_client(client: client, evt: chan[socket_event]) { // Start the read before notifying about the connect. This avoids a race // condition where the receiver can close the socket before we start // reading. - let reader: port[u8[]] = port(); + let reader: port[[u8]] = port(); rustrt::aio_read(client, chan(reader)); evt <| connected(client); while (true) { log "waiting for bytes"; - let data: u8[]; + let data: [u8]; reader |> data; log "got some bytes"; log ivec::len[u8](data); diff --git a/src/lib/bitv.rs b/src/lib/bitv.rs index 8201264135d75..b5b376be5c189 100644 --- a/src/lib/bitv.rs +++ b/src/lib/bitv.rs @@ -24,7 +24,7 @@ export eq_vec; // an optimizing version of this module that produces a different obj // for the case where nbits <= 32. -type t = @{storage: uint[mutable ], nbits: uint}; +type t = @{storage: [mutable uint], nbits: uint}; // FIXME: this should be a constant once they work @@ -150,7 +150,7 @@ fn to_vec(v: &t) -> vec[uint] { ret vec::init_fn[uint](sub, v.nbits); } -fn to_ivec(v: &t) -> uint[] { +fn to_ivec(v: &t) -> [uint] { let sub = bind init_to_vec(v, _); ret ivec::init_fn[uint](sub, v.nbits); } @@ -178,7 +178,7 @@ fn eq_vec(v0: &t, v1: &vec[uint]) -> bool { ret true; } -fn eq_ivec(v0: &t, v1: &uint[]) -> bool { +fn eq_ivec(v0: &t, v1: &[uint]) -> bool { assert (v0.nbits == ivec::len[uint](v1)); let len = v0.nbits; let i = 0u; diff --git a/src/lib/deque.rs b/src/lib/deque.rs index a501cfaf8f1e4..a6c43572bb5dd 100644 --- a/src/lib/deque.rs +++ b/src/lib/deque.rs @@ -26,10 +26,10 @@ fn create[@T]() -> t[T] { */ - fn grow[@T](nelts: uint, lo: uint, elts: &(cell[T])[mutable ]) -> - (cell[T])[mutable ] { + fn grow[@T](nelts: uint, lo: uint, elts: &[mutable cell[T]]) -> + [mutable cell[T]] { assert (nelts == ivec::len(elts)); - let rv = ~[mutable ]; + let rv = ~[mutable]; let i = 0u; let nalloc = uint::next_power_of_two(nelts + 1u); @@ -42,13 +42,13 @@ fn create[@T]() -> t[T] { ret rv; } - fn get[@T](elts: &(cell[T])[mutable ], i: uint) -> T { + fn get[@T](elts: &[mutable cell[T]], i: uint) -> T { ret alt elts.(i) { option::some(t) { t } _ { fail } }; } obj deque[@T](mutable nelts: uint, mutable lo: uint, mutable hi: uint, - mutable elts: (cell[T])[mutable ]) { + mutable elts: [mutable cell[T]]) { fn size() -> uint { ret nelts; } fn add_front(t: &T) { let oldlo: uint = lo; @@ -101,7 +101,7 @@ fn create[@T]() -> t[T] { ret get[T](elts, idx); } } - let v: (cell[T])[mutable ] = + let v: [mutable cell[T]] = ivec::init_elt_mut(option::none, initial_capacity); ret deque[T](0u, 0u, 0u, v); } diff --git a/src/lib/ebmlivec.rs b/src/lib/ebmlivec.rs index 41e5bf03b1a32..1fb5860b4a0c2 100644 --- a/src/lib/ebmlivec.rs +++ b/src/lib/ebmlivec.rs @@ -15,9 +15,9 @@ type ebml_state = {ebml_tag: ebml_tag, tag_pos: uint, data_pos: uint}; // modules within this file. // ebml reading -type doc = {data: @u8[], start: uint, end: uint}; +type doc = {data: @[u8], start: uint, end: uint}; -fn vint_at(data: &u8[], start: uint) -> {val: uint, next: uint} { +fn vint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { let a = data.(start); if a & 0x80u8 != 0u8 { ret {val: a & 0x7fu8 as uint, next: start + 1u}; } if a & 0x40u8 != 0u8 { @@ -39,11 +39,11 @@ fn vint_at(data: &u8[], start: uint) -> {val: uint, next: uint} { } else { log_err "vint too big"; fail; } } -fn new_doc(data: &@u8[]) -> doc { +fn new_doc(data: &@[u8]) -> doc { ret {data: data, start: 0u, end: ivec::len[u8](*data)}; } -fn doc_at(data: &@u8[], start: uint) -> doc { +fn doc_at(data: &@[u8], start: uint) -> doc { let elt_tag = vint_at(*data, start); let elt_size = vint_at(*data, elt_tag.next); let end = elt_size.next + elt_size.val; @@ -96,9 +96,9 @@ iter tagged_docs(d: doc, tg: uint) -> doc { } } -fn doc_data(d: doc) -> u8[] { ret ivec::slice[u8](*d.data, d.start, d.end); } +fn doc_data(d: doc) -> [u8] { ret ivec::slice[u8](*d.data, d.start, d.end); } -fn be_uint_from_bytes(data: &@u8[], start: uint, size: uint) -> uint { +fn be_uint_from_bytes(data: &@[u8], start: uint, size: uint) -> uint { let sz = size; assert (sz <= 4u); let val = 0u; @@ -117,10 +117,10 @@ fn doc_as_uint(d: doc) -> uint { // ebml writing -type writer = {writer: ioivec::buf_writer, mutable size_positions: uint[]}; +type writer = {writer: ioivec::buf_writer, mutable size_positions: [uint]}; fn write_sized_vint(w: &ioivec::buf_writer, n: uint, size: uint) { - let buf: u8[]; + let buf: [u8]; alt size { 1u { buf = ~[0x80u8 | (n as u8)]; } 2u { buf = ~[0x40u8 | (n >> 8u as u8), n & 0xffu as u8]; } @@ -149,7 +149,7 @@ fn write_vint(w: &ioivec::buf_writer, n: uint) { } fn create_writer(w: &ioivec::buf_writer) -> writer { - let size_positions: uint[] = ~[]; + let size_positions: [uint] = ~[]; ret {writer: w, mutable size_positions: size_positions}; } @@ -162,7 +162,7 @@ fn start_tag(w: &writer, tag_id: uint) { // Write a placeholder four-byte size. w.size_positions += ~[w.writer.tell()]; - let zeroes: u8[] = ~[0u8, 0u8, 0u8, 0u8]; + let zeroes: [u8] = ~[0u8, 0u8, 0u8, 0u8]; w.writer.write(zeroes); } diff --git a/src/lib/either.rs b/src/lib/either.rs index a410acd83ad33..5ca232a617f17 100644 --- a/src/lib/either.rs +++ b/src/lib/either.rs @@ -13,25 +13,25 @@ fn either[T, U, alt value { left(l) { f_left(l) } right(r) { f_right(r) } } } -fn lefts[T, U](eithers: &(t[T, U])[]) -> T[] { - let result: T[] = ~[]; +fn lefts[T, U](eithers: &[t[T, U]]) -> [T] { + let result: [T] = ~[]; for elt: t[T, U] in eithers { alt elt { left(l) { result += ~[l] } _ {/* fallthrough */ } } } ret result; } -fn rights[T, U](eithers: &(t[T, U])[]) -> U[] { - let result: U[] = ~[]; +fn rights[T, U](eithers: &[t[T, U]]) -> [U] { + let result: [U] = ~[]; for elt: t[T, U] in eithers { alt elt { right(r) { result += ~[r] } _ {/* fallthrough */ } } } ret result; } -fn partition[T, U](eithers: &(t[T, U])[]) -> {lefts: T[], rights: U[]} { - let lefts: T[] = ~[]; - let rights: U[] = ~[]; +fn partition[T, U](eithers: &[t[T, U]]) -> {lefts: [T], rights: [U]} { + let lefts: [T] = ~[]; + let rights: [U] = ~[]; for elt: t[T, U] in eithers { alt elt { left(l) { lefts += ~[l] } right(r) { rights += ~[r] } } } diff --git a/src/lib/fs.rs b/src/lib/fs.rs index 7a4467fecd0c9..9f47b2d11f7f4 100644 --- a/src/lib/fs.rs +++ b/src/lib/fs.rs @@ -44,10 +44,10 @@ fn connect(pre: path, post: path) -> path { fn file_is_dir(p: path) -> bool { ret rustrt::rust_file_is_dir(p) != 0; } -fn list_dir(p: path) -> str[] { +fn list_dir(p: path) -> [str] { let pl = str::byte_len(p); if pl == 0u || p.(pl - 1u) as char != os_fs::path_sep { p += path_sep(); } - let full_paths: str[] = ~[]; + let full_paths: [str] = ~[]; for filename: str in os_fs::list_dir(p) { if !str::eq(filename, ".") { if !str::eq(filename, "..") { full_paths += ~[p + filename]; } diff --git a/src/lib/getopts.rs b/src/lib/getopts.rs index bb2a58c1cc041..3ae030e8717f0 100644 --- a/src/lib/getopts.rs +++ b/src/lib/getopts.rs @@ -66,7 +66,7 @@ fn optmulti(name: str) -> opt { tag optval { val(str); given; } -type match = {opts: opt[], vals: optval[][mutable ], free: vec[str]}; +type match = {opts: [opt], vals: [mutable [optval]], free: vec[str]}; fn is_arg(arg: str) -> bool { ret str::byte_len(arg) > 1u && arg.(0) == '-' as u8; @@ -76,7 +76,7 @@ fn name_str(nm: name) -> str { ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; } -fn find_opt(opts: &opt[], nm: name) -> option::t[uint] { +fn find_opt(opts: &[opt], nm: name) -> option::t[uint] { let i = 0u; let l = ivec::len[opt](opts); while i < l { if opts.(i).name == nm { ret some[uint](i); } i += 1u; } @@ -116,10 +116,10 @@ fn getopts(args: vec[str], opts: vec[opt]) -> result { ret getopts_ivec(args_ivec, opts_ivec); } -fn getopts_ivec(args: &str[], opts: &opt[]) -> result { +fn getopts_ivec(args: &[str], opts: &[opt]) -> result { let n_opts = ivec::len[opt](opts); - fn f(x: uint) -> optval[] { ret ~[]; } - let vals = ivec::init_fn_mut[optval[]](f, n_opts); + fn f(x: uint) -> [optval] { ret ~[]; } + let vals = ivec::init_fn_mut[[optval]](f, n_opts); let free: vec[str] = []; let l = ivec::len[str](args); let i = 0u; @@ -209,7 +209,7 @@ fn getopts_ivec(args: &str[], opts: &opt[]) -> result { ret success({opts: opts, vals: vals, free: free}); } -fn opt_vals(m: &match, nm: str) -> optval[] { +fn opt_vals(m: &match, nm: str) -> [optval] { ret alt find_opt(m.opts, mkname(nm)) { some(id) { m.vals.(id) } none. { log_err "No option '" + nm + "' defined."; fail } @@ -234,8 +234,8 @@ fn opt_strs(m: &match, nm: str) -> vec[str] { ret acc; } -fn opt_strs_ivec(m: &match, nm: str) -> str[] { - let acc: str[] = ~[]; +fn opt_strs_ivec(m: &match, nm: str) -> [str] { + let acc: [str] = ~[]; for v: optval in opt_vals(m, nm) { alt v { val(s) { acc += ~[s]; } _ { } } } diff --git a/src/lib/ioivec.rs b/src/lib/ioivec.rs index 728a1d0e3d272..95c0e42542507 100644 --- a/src/lib/ioivec.rs +++ b/src/lib/ioivec.rs @@ -19,7 +19,7 @@ type buf_reader = // FIXME: Seekable really should be orthogonal. We will need // inheritance. obj { - fn read(uint) -> u8[] ; + fn read(uint) -> [u8] ; fn read_byte() -> int ; fn unread_byte(int) ; fn eof() -> bool ; @@ -38,7 +38,7 @@ type reader = fn get_buf_reader() -> buf_reader ; fn read_byte() -> int ; fn unread_byte(int) ; - fn read_bytes(uint) -> u8[] ; + fn read_bytes(uint) -> [u8] ; fn read_char() -> char ; fn eof() -> bool ; fn read_line() -> str ; @@ -46,7 +46,7 @@ type reader = fn read_le_uint(uint) -> uint ; fn read_le_int(uint) -> int ; fn read_be_uint(uint) -> uint ; - fn read_whole_stream() -> u8[] ; + fn read_whole_stream() -> [u8] ; fn seek(int, seek_style) ; fn tell() -> uint ; }; @@ -60,7 +60,7 @@ resource FILE_res(f: os::libc::FILE) { } obj FILE_buf_reader(f: os::libc::FILE, res: option::t[@FILE_res]) { - fn read(len: uint) -> u8[] { + fn read(len: uint) -> [u8] { let buf = ~[]; ivec::reserve[u8](buf, len); let read = os::libc_ivec::fread(ivec::to_ptr[u8](buf), 1u, len, f); @@ -84,7 +84,7 @@ obj new_reader(rdr: buf_reader) { fn get_buf_reader() -> buf_reader { ret rdr; } fn read_byte() -> int { ret rdr.read_byte(); } fn unread_byte(byte: int) { ret rdr.unread_byte(byte); } - fn read_bytes(len: uint) -> u8[] { ret rdr.read(len); } + fn read_bytes(len: uint) -> [u8] { ret rdr.read(len); } fn read_char() -> char { let c0 = rdr.read_byte(); if c0 == -1 { @@ -111,7 +111,7 @@ obj new_reader(rdr: buf_reader) { } fn eof() -> bool { ret rdr.eof(); } fn read_line() -> str { - let buf: u8[] = ~[]; + let buf: [u8] = ~[]; // No break yet in rustc let go_on = true; @@ -124,7 +124,7 @@ obj new_reader(rdr: buf_reader) { ret str::unsafe_from_bytes_ivec(buf); } fn read_c_str() -> str { - let buf: u8[] = ~[]; + let buf: [u8] = ~[]; let go_on = true; while go_on { let ch = rdr.read_byte(); @@ -165,8 +165,8 @@ obj new_reader(rdr: buf_reader) { } ret val; } - fn read_whole_stream() -> u8[] { - let buf: u8[] = ~[]; + fn read_whole_stream() -> [u8] { + let buf: [u8] = ~[]; while !rdr.eof() { buf += rdr.read(2048u); } ret buf; } @@ -192,10 +192,10 @@ fn new_reader_(bufr: buf_reader) -> reader { ret new_reader(bufr); } // Byte buffer readers // TODO: mutable? u8, but this fails with rustboot. -type byte_buf = @{buf: u8[], mutable pos: uint}; +type byte_buf = @{buf: [u8], mutable pos: uint}; obj byte_buf_reader(bbuf: byte_buf) { - fn read(len: uint) -> u8[] { + fn read(len: uint) -> [u8] { let rest = ivec::len[u8](bbuf.buf) - bbuf.pos; let to_read = len; if rest < to_read { to_read = rest; } @@ -219,7 +219,7 @@ obj byte_buf_reader(bbuf: byte_buf) { fn tell() -> uint { ret bbuf.pos; } } -fn new_byte_buf_reader(buf: &u8[]) -> buf_reader { +fn new_byte_buf_reader(buf: &[u8]) -> buf_reader { ret byte_buf_reader(@{buf: buf, mutable pos: 0u}); } @@ -238,13 +238,13 @@ type buf_writer = // FIXME: eventually u64 obj { - fn write(&u8[]) ; + fn write(&[u8]) ; fn seek(int, seek_style) ; fn tell() -> uint ; }; obj FILE_writer(f: os::libc::FILE, res: option::t[@FILE_res]) { - fn write(v: &u8[]) { + fn write(v: &[u8]) { let len = ivec::len[u8](v); let vbuf = ivec::to_ptr[u8](v); let nout = os::libc_ivec::fwrite(vbuf, len, 1u, f); @@ -263,7 +263,7 @@ resource fd_res(fd: int) { } obj fd_buf_writer(fd: int, res: option::t[@fd_res]) { - fn write(v: &u8[]) { + fn write(v: &[u8]) { let len = ivec::len[u8](v); let count = 0u; let vbuf; @@ -288,7 +288,7 @@ obj fd_buf_writer(fd: int, res: option::t[@fd_res]) { } } -fn file_buf_writer(path: str, flags: &fileflag[]) -> buf_writer { +fn file_buf_writer(path: str, flags: &[fileflag]) -> buf_writer { let fflags: int = os::libc_constants::O_WRONLY() | os::libc_constants::O_BINARY(); for f: fileflag in flags { @@ -322,20 +322,20 @@ type writer = fn write_char(char) ; fn write_int(int) ; fn write_uint(uint) ; - fn write_bytes(&u8[]) ; + fn write_bytes(&[u8]) ; fn write_le_uint(uint, uint) ; fn write_le_int(int, uint) ; fn write_be_uint(uint, uint) ; }; -fn uint_to_le_bytes(n: uint, size: uint) -> u8[] { - let bytes: u8[] = ~[]; +fn uint_to_le_bytes(n: uint, size: uint) -> [u8] { + let bytes: [u8] = ~[]; while size > 0u { bytes += ~[n & 255u as u8]; n >>= 8u; size -= 1u; } ret bytes; } -fn uint_to_be_bytes(n: uint, size: uint) -> u8[] { - let bytes: u8[] = ~[]; +fn uint_to_be_bytes(n: uint, size: uint) -> [u8] { + let bytes: [u8] = ~[]; let i = size - 1u as int; while i >= 0 { bytes += ~[n >> (i * 8 as uint) & 255u as u8]; i -= 1; } ret bytes; @@ -357,7 +357,7 @@ obj new_writer(out: buf_writer) { fn write_uint(n: uint) { out.write(str::bytes_ivec(uint::to_str(n, 10u))); } - fn write_bytes(bytes: &u8[]) { out.write(bytes); } + fn write_bytes(bytes: &[u8]) { out.write(bytes); } fn write_le_uint(n: uint, size: uint) { out.write(uint_to_le_bytes(n, size)); } @@ -373,7 +373,7 @@ obj new_writer(out: buf_writer) { // FIXME: Remove me once objects are exported. fn new_writer_(out: buf_writer) -> writer { ret new_writer(out); } -fn file_writer(path: str, flags: &fileflag[]) -> writer { +fn file_writer(path: str, flags: &[fileflag]) -> writer { ret new_writer(file_buf_writer(path, flags)); } @@ -395,10 +395,10 @@ type str_writer = fn get_str() -> str ; }; -type mutable_byte_buf = @{mutable buf: u8[mutable ], mutable pos: uint}; +type mutable_byte_buf = @{mutable buf: [mutable u8], mutable pos: uint}; obj byte_buf_writer(buf: mutable_byte_buf) { - fn write(v: &u8[]) { + fn write(v: &[u8]) { // Fast path. if buf.pos == ivec::len(buf.buf) { @@ -430,7 +430,7 @@ obj byte_buf_writer(buf: mutable_byte_buf) { fn string_writer() -> str_writer { // FIXME: yikes, this is bad. Needs fixing of mutable syntax. - let b: u8[mutable ] = ~[mutable 0u8]; + let b: [mutable u8] = ~[mutable 0u8]; ivec::pop(b); let buf: mutable_byte_buf = @{mutable buf: b, mutable pos: 0u}; obj str_writer_wrap(wr: writer, buf: mutable_byte_buf) { @@ -459,7 +459,7 @@ fn read_whole_file_str(file: &str) -> str { str::unsafe_from_bytes_ivec(read_whole_file(file)) } -fn read_whole_file(file: &str) -> u8[] { +fn read_whole_file(file: &str) -> [u8] { // FIXME: There's a lot of copying here file_reader(file).read_whole_stream() } diff --git a/src/lib/ivec.rs b/src/lib/ivec.rs index fb9df536df35f..a60b8aa63de4f 100644 --- a/src/lib/ivec.rs +++ b/src/lib/ivec.rs @@ -8,26 +8,26 @@ import ptr::addr_of; type operator2[T, U, V] = fn(&T, &U) -> V ; native "rust-intrinsic" mod rusti { - fn ivec_len[T](v: &T[]) -> uint; + fn ivec_len[T](v: &[T]) -> uint; } native "rust" mod rustrt { - fn ivec_reserve_shared[T](v: &mutable T[mutable? ], n: uint); - fn ivec_on_heap[T](v: &T[]) -> uint; - fn ivec_to_ptr[T](v: &T[]) -> *T; - fn ivec_copy_from_buf_shared[T](v: &mutable T[mutable? ], ptr: *T, + fn ivec_reserve_shared[T](v: &mutable [mutable? T], n: uint); + fn ivec_on_heap[T](v: &[T]) -> uint; + fn ivec_to_ptr[T](v: &[T]) -> *T; + fn ivec_copy_from_buf_shared[T](v: &mutable [mutable? T], ptr: *T, count: uint); } -fn from_vec[@T](v: &vec[T]) -> T[] { - let iv: T[] = ~[]; +fn from_vec[@T](v: &vec[T]) -> [T] { + let iv = ~[]; for e in v { iv += ~[e]; } ret iv; } -fn to_vec[@T](iv: &T[]) -> vec[T] { +fn to_vec[@T](iv: &[T]) -> vec[T] { let v: vec[T] = []; for e in iv { v += [e]; @@ -36,19 +36,19 @@ fn to_vec[@T](iv: &T[]) -> vec[T] { } /// Reserves space for `n` elements in the given vector. -fn reserve[@T](v: &mutable T[mutable? ], n: uint) { +fn reserve[@T](v: &mutable [mutable? T], n: uint) { rustrt::ivec_reserve_shared(v, n); } -fn on_heap[T](v: &T[]) -> bool { ret rustrt::ivec_on_heap(v) != 0u; } +fn on_heap[T](v: &[T]) -> bool { ret rustrt::ivec_on_heap(v) != 0u; } -fn to_ptr[T](v: &T[]) -> *T { ret rustrt::ivec_to_ptr(v); } +fn to_ptr[T](v: &[T]) -> *T { ret rustrt::ivec_to_ptr(v); } -fn len[T](v: &T[mutable? ]) -> uint { ret rusti::ivec_len(v); } +fn len[T](v: &[mutable? T]) -> uint { ret rusti::ivec_len(v); } type init_op[T] = fn(uint) -> T ; -fn init_fn[@T](op: &init_op[T], n_elts: uint) -> T[] { +fn init_fn[@T](op: &init_op[T], n_elts: uint) -> [T] { let v = ~[]; reserve(v, n_elts); let i: uint = 0u; @@ -57,15 +57,15 @@ fn init_fn[@T](op: &init_op[T], n_elts: uint) -> T[] { } // TODO: Remove me once we have slots. -fn init_fn_mut[@T](op: &init_op[T], n_elts: uint) -> T[mutable ] { - let v = ~[mutable ]; +fn init_fn_mut[@T](op: &init_op[T], n_elts: uint) -> [mutable T] { + let v = ~[mutable]; reserve(v, n_elts); let i: uint = 0u; while i < n_elts { v += ~[mutable op(i)]; i += 1u; } ret v; } -fn init_elt[@T](t: &T, n_elts: uint) -> T[] { +fn init_elt[@T](t: &T, n_elts: uint) -> [T] { let v = ~[]; reserve(v, n_elts); let i: uint = 0u; @@ -74,53 +74,53 @@ fn init_elt[@T](t: &T, n_elts: uint) -> T[] { } // TODO: Remove me once we have slots. -fn init_elt_mut[@T](t: &T, n_elts: uint) -> T[mutable ] { - let v = ~[mutable ]; +fn init_elt_mut[@T](t: &T, n_elts: uint) -> [mutable T] { + let v = ~[mutable]; reserve(v, n_elts); let i: uint = 0u; while i < n_elts { v += ~[mutable t]; i += 1u; } ret v; } -fn to_mut[@T](v: &T[]) -> T[mutable ] { - let vres = ~[mutable ]; +fn to_mut[@T](v: &[T]) -> [mutable T] { + let vres = ~[mutable]; for t: T in v { vres += ~[mutable t]; } ret vres; } -fn from_mut[@T](v: &T[mutable ]) -> T[] { +fn from_mut[@T](v: &[mutable T]) -> [T] { let vres = ~[]; for t: T in v { vres += ~[t]; } ret vres; } // Predicates -pred is_empty[T](v: &T[mutable? ]) -> bool { +pred is_empty[T](v: &[mutable? T]) -> bool { // FIXME: This would be easier if we could just call len for t: T in v { ret false; } ret true; } -pred is_not_empty[T](v: &T[mutable? ]) -> bool { ret !is_empty(v); } +pred is_not_empty[T](v: &[mutable? T]) -> bool { ret !is_empty(v); } // Accessors /// Returns the first element of a vector -fn head[@T](v: &T[mutable?]) : is_not_empty(v) -> T { ret v.(0); } +fn head[@T](v: &[mutable? T]) : is_not_empty(v) -> T { ret v.(0); } /// Returns all but the first element of a vector -fn tail[@T](v: &T[mutable? ]) : is_not_empty(v) -> T[mutable?] { +fn tail[@T](v: &[mutable? T]) : is_not_empty(v) -> [mutable? T] { ret slice(v, 1u, len(v)); } /// Returns the last element of `v`. -fn last[@T](v: &T[mutable? ]) -> option::t[T] { +fn last[@T](v: &[mutable? T]) -> option::t[T] { if len(v) == 0u { ret none; } ret some(v.(len(v) - 1u)); } /// Returns a copy of the elements from [`start`..`end`) from `v`. -fn slice[@T](v: &T[mutable? ], start: uint, end: uint) -> T[] { +fn slice[@T](v: &[mutable? T], start: uint, end: uint) -> [T] { assert (start <= end); assert (end <= len(v)); let result = ~[]; @@ -131,10 +131,10 @@ fn slice[@T](v: &T[mutable? ], start: uint, end: uint) -> T[] { } // TODO: Remove me once we have slots. -fn slice_mut[@T](v: &T[mutable? ], start: uint, end: uint) -> T[mutable ] { +fn slice_mut[@T](v: &[mutable? T], start: uint, end: uint) -> [mutable T] { assert (start <= end); assert (end <= len(v)); - let result = ~[mutable ]; + let result = ~[mutable]; reserve(result, end - start); let i = start; while i < end { result += ~[mutable v.(i)]; i += 1u; } @@ -145,7 +145,7 @@ fn slice_mut[@T](v: &T[mutable? ], start: uint, end: uint) -> T[mutable ] { // Mutators // TODO: Write this, unsafely, in a way that's not O(n). -fn pop[@T](v: &mutable T[mutable? ]) -> T { +fn pop[@T](v: &mutable [mutable? T]) -> T { let ln = len(v); assert (ln > 0u); ln -= 1u; @@ -160,14 +160,14 @@ fn pop[@T](v: &mutable T[mutable? ]) -> T { // Appending /// Expands the given vector in-place by appending `n` copies of `initval`. -fn grow[@T](v: &mutable T[], n: uint, initval: &T) { +fn grow[@T](v: &mutable [T], n: uint, initval: &T) { reserve(v, next_power_of_two(len(v) + n)); let i: uint = 0u; while i < n { v += ~[initval]; i += 1u; } } // TODO: Remove me once we have slots. -fn grow_mut[@T](v: &mutable T[mutable ], n: uint, initval: &T) { +fn grow_mut[@T](v: &mutable [mutable T], n: uint, initval: &T) { reserve(v, next_power_of_two(len(v) + n)); let i: uint = 0u; while i < n { v += ~[mutable initval]; i += 1u; } @@ -175,7 +175,7 @@ fn grow_mut[@T](v: &mutable T[mutable ], n: uint, initval: &T) { /// Calls `f` `n` times and appends the results of these calls to the given /// vector. -fn grow_fn[@T](v: &mutable T[], n: uint, init_fn: fn(uint) -> T ) { +fn grow_fn[@T](v: &mutable [T], n: uint, init_fn: fn(uint) -> T ) { reserve(v, next_power_of_two(len(v) + n)); let i: uint = 0u; while i < n { v += ~[init_fn(i)]; i += 1u; } @@ -184,7 +184,7 @@ fn grow_fn[@T](v: &mutable T[], n: uint, init_fn: fn(uint) -> T ) { /// Sets the element at position `index` to `val`. If `index` is past the end /// of the vector, expands the vector by replicating `initval` to fill the /// intervening space. -fn grow_set[@T](v: &mutable T[mutable ], index: uint, initval: &T, val: &T) { +fn grow_set[@T](v: &mutable [mutable T], index: uint, initval: &T, val: &T) { if index >= len(v) { grow_mut(v, index - len(v) + 1u, initval); } v.(index) = val; } @@ -192,7 +192,7 @@ fn grow_set[@T](v: &mutable T[mutable ], index: uint, initval: &T, val: &T) { // Functional utilities -fn map[@T, @U](f: fn(&T) -> U , v: &T[mutable? ]) -> U[] { +fn map[@T, @U](f: fn(&T) -> U , v: &[mutable? T]) -> [U] { let result = ~[]; reserve(result, len(v)); for elem: T in v { @@ -202,7 +202,7 @@ fn map[@T, @U](f: fn(&T) -> U , v: &T[mutable? ]) -> U[] { ret result; } -fn filter_map[@T, @U](f: fn(&T) -> option::t[U] , v: &T[mutable? ]) -> U[] { +fn filter_map[@T, @U](f: fn(&T) -> option::t[U] , v: &[mutable? T]) -> [U] { let result = ~[]; for elem: T in v { let elem2 = elem; // satisfies alias checker @@ -214,7 +214,7 @@ fn filter_map[@T, @U](f: fn(&T) -> option::t[U] , v: &T[mutable? ]) -> U[] { ret result; } -fn foldl[@T, @U](p: fn(&U, &T) -> U , z: &U, v: &T[mutable? ]) -> U { +fn foldl[@T, @U](p: fn(&U, &T) -> U , z: &U, v: &[mutable? T]) -> U { let sz = len(v); if sz == 0u { ret z; } let first = v.(0); @@ -222,33 +222,33 @@ fn foldl[@T, @U](p: fn(&U, &T) -> U , z: &U, v: &T[mutable? ]) -> U { ret p(foldl[T, U](p, z, rest), first); } -fn any[T](f: fn(&T) -> bool , v: &T[]) -> bool { +fn any[T](f: fn(&T) -> bool , v: &[T]) -> bool { for elem: T in v { if f(elem) { ret true; } } ret false; } -fn all[T](f: fn(&T) -> bool , v: &T[]) -> bool { +fn all[T](f: fn(&T) -> bool , v: &[T]) -> bool { for elem: T in v { if !f(elem) { ret false; } } ret true; } -fn member[T](x: &T, v: &T[]) -> bool { +fn member[T](x: &T, v: &[T]) -> bool { for elt: T in v { if x == elt { ret true; } } ret false; } -fn count[T](x: &T, v: &T[mutable? ]) -> uint { +fn count[T](x: &T, v: &[mutable? T]) -> uint { let cnt = 0u; for elt: T in v { if x == elt { cnt += 1u; } } ret cnt; } -fn find[@T](f: fn(&T) -> bool , v: &T[]) -> option::t[T] { +fn find[@T](f: fn(&T) -> bool , v: &[T]) -> option::t[T] { for elt: T in v { if f(elt) { ret some[T](elt); } } ret none[T]; } -fn unzip[@T, @U](v: &{_0: T, _1: U}[]) -> {_0: T[], _1: U[]} { +fn unzip[@T, @U](v: &[{_0: T, _1: U}]) -> {_0: [T], _1: [U]} { let sz = len(v); if sz == 0u { ret {_0: ~[], _1: ~[]}; @@ -263,7 +263,7 @@ fn unzip[@T, @U](v: &{_0: T, _1: U}[]) -> {_0: T[], _1: U[]} { // FIXME make the lengths being equal a constraint -fn zip[@T, @U](v: &T[], u: &U[]) -> {_0: T, _1: U}[] { +fn zip[@T, @U](v: &[T], u: &[U]) -> [{_0: T, _1: U}] { let sz = len(v); assert (sz == len(u)); if sz == 0u { @@ -281,17 +281,17 @@ mod unsafe { heap_part: *mutable ivec_heap_part}; type ivec_heap_part = {mutable fill: uint}; - fn copy_from_buf[T](v: &mutable T[], ptr: *T, count: uint) { + fn copy_from_buf[T](v: &mutable [T], ptr: *T, count: uint) { ret rustrt::ivec_copy_from_buf_shared(v, ptr, count); } - fn from_buf[T](ptr: *T, bytes: uint) -> T[] { + fn from_buf[T](ptr: *T, bytes: uint) -> [T] { let v = ~[]; copy_from_buf(v, ptr, bytes); ret v; } - fn set_len[T](v: &mutable T[], new_len: uint) { + fn set_len[T](v: &mutable [T], new_len: uint) { let new_fill = new_len * sys::size_of[T](); let stack_part: *mutable ivec_repr = ::unsafe::reinterpret_cast(addr_of(v)); diff --git a/src/lib/map.rs b/src/lib/map.rs index 3883d0b94e85d..738adaf377f72 100644 --- a/src/lib/map.rs +++ b/src/lib/map.rs @@ -26,7 +26,7 @@ fn mk_hashmap[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K]) -> hashmap[K, V] { let load_factor: util::rational = {num: 3, den: 4}; tag bucket[@K, @V] { nil; deleted; some(K, V); } - fn make_buckets[@K, @V](nbkts: uint) -> (bucket[K, V])[mutable ] { + fn make_buckets[@K, @V](nbkts: uint) -> [mutable (bucket[K, V])] { ret ivec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts); } // Derive two hash functions from the one given by taking the upper @@ -55,7 +55,7 @@ fn mk_hashmap[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K]) -> hashmap[K, V] { fn insert_common[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K], - bkts: &(bucket[K, V])[mutable ], nbkts: uint, + bkts: &[mutable bucket[K, V]], nbkts: uint, key: &K, val: &V) -> bool { let i: uint = 0u; let h: uint = hasher(key); @@ -80,7 +80,7 @@ fn mk_hashmap[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K]) -> hashmap[K, V] { } fn find_common[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K], - bkts: &(bucket[K, V])[mutable ], nbkts: uint, key: &K) + bkts: &[mutable bucket[K, V]], nbkts: uint, key: &K) -> option::t[V] { let i: uint = 0u; let h: uint = hasher(key); @@ -103,8 +103,8 @@ fn mk_hashmap[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K]) -> hashmap[K, V] { } fn rehash[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K], - oldbkts: &(bucket[K, V])[mutable ], noldbkts: uint, - newbkts: &(bucket[K, V])[mutable ], nnewbkts: uint) { + oldbkts: &[mutable bucket[K, V]], noldbkts: uint, + newbkts: &[mutable bucket[K, V]], nnewbkts: uint) { for b: bucket[K, V] in oldbkts { alt b { some(k_, v_) { @@ -119,7 +119,7 @@ fn mk_hashmap[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K]) -> hashmap[K, V] { obj hashmap[@K, @V](hasher: hashfn[K], eqer: eqfn[K], - mutable bkts: (bucket[K, V])[mutable ], + mutable bkts: [mutable bucket[K, V]], mutable nbkts: uint, mutable nelts: uint, lf: util::rational) { diff --git a/src/lib/posix_fs.rs b/src/lib/posix_fs.rs index 8ae7e3618a800..381a0c71755bf 100644 --- a/src/lib/posix_fs.rs +++ b/src/lib/posix_fs.rs @@ -1,11 +1,11 @@ native "rust" mod rustrt { fn rust_list_files(path: str) -> vec[str]; - fn rust_list_files_ivec(path: str) -> @str[]; + fn rust_list_files_ivec(path: str) -> @[str]; fn rust_dirent_filename(ent: os::libc::dirent) -> str; } -fn list_dir(path: str) -> str[] { +fn list_dir(path: str) -> [str] { ret *rustrt::rust_list_files_ivec(path); // TODO ensure this is always closed diff --git a/src/lib/sha1.rs b/src/lib/sha1.rs index cd633b28cca55..ed38c757fc4f8 100644 --- a/src/lib/sha1.rs +++ b/src/lib/sha1.rs @@ -26,10 +26,10 @@ type sha1 = // automatically during construction obj { fn input(&vec[u8]) ; - fn input_ivec(&u8[]) ; + fn input_ivec(&[u8]) ; fn input_str(&str) ; fn result() -> vec[u8] ; - fn result_ivec() -> u8[] ; + fn result_ivec() -> [u8] ; fn result_str() -> str ; fn reset() ; }; @@ -54,15 +54,15 @@ const k3: u32 = 0xCA62C1D6u32; // Builds a sha1 object fn mk_sha1() -> sha1 { type sha1state = - {h: u32[mutable ], + {h: [mutable u32], mutable len_low: u32, mutable len_high: u32, - msg_block: u8[mutable ], + msg_block: [mutable u8], mutable msg_block_idx: uint, mutable computed: bool, - work_buf: u32[mutable ]}; + work_buf: [mutable u32]}; - fn add_input(st: &sha1state, msg: &u8[]) { + fn add_input(st: &sha1state, msg: &[u8]) { // FIXME: Should be typestate precondition assert (!st.computed); @@ -164,9 +164,9 @@ fn mk_sha1() -> sha1 { fn circular_shift(bits: u32, word: u32) -> u32 { ret word << bits | word >> 32u32 - bits; } - fn mk_result(st: &sha1state) -> u8[] { + fn mk_result(st: &sha1state) -> [u8] { if !st.computed { pad_msg(st); st.computed = true; } - let rs: u8[] = ~[]; + let rs: [u8] = ~[]; for hpart: u32 in st.h { let a = hpart >> 24u32 & 0xFFu32 as u8; let b = hpart >> 16u32 & 0xFFu32 as u8; @@ -244,7 +244,7 @@ fn mk_sha1() -> sha1 { for b: u8 in msg { m += ~[b]; } add_input(st, m); } - fn input_ivec(msg: &u8[]) { add_input(st, msg); } + fn input_ivec(msg: &[u8]) { add_input(st, msg); } fn input_str(msg: &str) { add_input(st, str::bytes_ivec(msg)); } fn result() -> vec[u8] { let rivec = mk_result(st); @@ -252,7 +252,7 @@ fn mk_sha1() -> sha1 { for b: u8 in rivec { rvec += [b]; } ret rvec; } - fn result_ivec() -> u8[] { ret mk_result(st); } + fn result_ivec() -> [u8] { ret mk_result(st); } fn result_str() -> str { let r = mk_result(st); let s = ""; diff --git a/src/lib/sio.rs b/src/lib/sio.rs index 1ba432c0e8f03..464c05a0340eb 100644 --- a/src/lib/sio.rs +++ b/src/lib/sio.rs @@ -28,7 +28,7 @@ fn connect_to(ctx: ctx, ip: str, portnum: int) -> client { ret make_socket(ctx, p); } -fn read(c: client) -> u8[] { +fn read(c: client) -> [u8] { let evt: aio::socket_event; c.evt |> evt; alt evt { @@ -62,7 +62,7 @@ fn accept_from(server: server) -> client { } } -fn write_data(c: client, data: u8[]) -> bool { +fn write_data(c: client, data: [u8]) -> bool { let p: port[bool] = port(); c.ctx <| aio::write(c.client, data, chan(p)); let success: bool; diff --git a/src/lib/smallintmap.rs b/src/lib/smallintmap.rs index fdee322d30ee0..abb1979b66f81 100644 --- a/src/lib/smallintmap.rs +++ b/src/lib/smallintmap.rs @@ -7,10 +7,10 @@ import option::some; // FIXME: Should not be @; there's a bug somewhere in rustc that requires this // to be. -type smallintmap[T] = @{mutable v: (option::t[T])[mutable ]}; +type smallintmap[T] = @{mutable v: [mutable option::t[T]]}; fn mk[@T]() -> smallintmap[T] { - let v: (option::t[T])[mutable ] = ~[mutable ]; + let v: [mutable option::t[T]] = ~[mutable]; ret @{mutable v: v}; } diff --git a/src/lib/sort.rs b/src/lib/sort.rs index 2a7348b354f10..28592b9ca6fec 100644 --- a/src/lib/sort.rs +++ b/src/lib/sort.rs @@ -144,9 +144,9 @@ mod ivector { type lteq[T] = fn(&T, &T) -> bool ; - fn merge_sort[@T](le: lteq[T], v: &T[]) -> T[] { - fn merge[@T](le: lteq[T], a: &T[], b: &T[]) -> T[] { - let rs: T[] = ~[]; + fn merge_sort[@T](le: lteq[T], v: &[T]) -> [T] { + fn merge[@T](le: lteq[T], a: &[T], b: &[T]) -> [T] { + let rs: [T] = ~[]; let a_len: uint = ilen[T](a); let a_ix: uint = 0u; let b_len: uint = ilen[T](b); @@ -164,18 +164,18 @@ mod ivector { let v_len: uint = ilen[T](v); if v_len <= 1u { ret v; } let mid: uint = v_len / 2u; - let a: T[] = islice[T](v, 0u, mid); - let b: T[] = islice[T](v, mid, v_len); + let a: [T] = islice[T](v, 0u, mid); + let b: [T] = islice[T](v, mid, v_len); ret merge[T](le, merge_sort[T](le, a), merge_sort[T](le, b)); } - fn swap[@T](arr: &T[mutable ], x: uint, y: uint) { + fn swap[@T](arr: &[mutable T], x: uint, y: uint) { let a = arr.(x); arr.(x) = arr.(y); arr.(y) = a; } - fn part[@T](compare_func: lteq[T], arr: &T[mutable ], left: uint, + fn part[@T](compare_func: lteq[T], arr: &[mutable T], left: uint, right: uint, pivot: uint) -> uint { let pivot_value = arr.(pivot); swap[T](arr, pivot, right); @@ -192,7 +192,7 @@ mod ivector { ret storage_index; } - fn qsort[@T](compare_func: lteq[T], arr: &T[mutable ], left: uint, + fn qsort[@T](compare_func: lteq[T], arr: &[mutable T], left: uint, right: uint) { if right > left { let pivot = (left + right) / 2u; @@ -205,7 +205,7 @@ mod ivector { } } - fn quick_sort[@T](compare_func: lteq[T], arr: &T[mutable ]) { + fn quick_sort[@T](compare_func: lteq[T], arr: &[mutable T]) { if ilen[T](arr) == 0u { ret; } qsort[T](compare_func, arr, 0u, ilen[T](arr) - 1u); } @@ -217,7 +217,7 @@ mod ivector { // 'randomly ordered keys, abstract compare' & 'small number of key // values' fn qsort3[@T](compare_func_lt: lteq[T], compare_func_eq: lteq[T], - arr: &T[mutable ], left: int, right: int) { + arr: &[mutable T], left: int, right: int) { if right <= left { ret; } let v: T = arr.(right); let i: int = left - 1; @@ -265,7 +265,7 @@ mod ivector { } fn quick_sort3[@T](compare_func_lt: lteq[T], compare_func_eq: lteq[T], - arr: &T[mutable ]) { + arr: &[mutable T]) { if ilen[T](arr) == 0u { ret; } qsort3[T](compare_func_lt, compare_func_eq, arr, 0, (ilen[T](arr) as int) - 1); diff --git a/src/lib/str.rs b/src/lib/str.rs index be76238c01ca4..8a5586c3455fd 100644 --- a/src/lib/str.rs +++ b/src/lib/str.rs @@ -65,7 +65,7 @@ native "rust" mod rustrt { fn str_vec(s: str) -> vec[u8]; fn str_byte_len(s: str) -> uint; fn str_alloc(n_bytes: uint) -> str; - fn str_from_ivec(b: &u8[mutable? ]) -> str; + fn str_from_ivec(b: &[mutable? u8]) -> str; fn str_from_vec(b: vec[mutable? u8]) -> str; fn str_from_cstr(cstr: sbuf) -> str; fn str_from_buf(buf: sbuf, len: uint) -> str; @@ -190,7 +190,7 @@ fn buf(s: &str) -> sbuf { ret rustrt::str_buf(s); } fn bytes(s: &str) -> vec[u8] { ret rustrt::str_vec(s); } -fn bytes_ivec(s: str) -> u8[] { +fn bytes_ivec(s: str) -> [u8] { let sbuffer = buf(s); let ptr = unsafe::reinterpret_cast(sbuffer); ret ivec::unsafe::from_buf(ptr, byte_len(s)); @@ -204,7 +204,7 @@ fn unsafe_from_bytes(v: vec[mutable? u8]) -> str { ret rustrt::str_from_vec(v); } -fn unsafe_from_bytes_ivec(v: &u8[mutable? ]) -> str { +fn unsafe_from_bytes_ivec(v: &[mutable? u8]) -> str { ret rustrt::str_from_ivec(v); } @@ -463,8 +463,8 @@ fn split(s: str, sep: u8) -> vec[str] { ret v; } -fn split_ivec(s: str, sep: u8) -> str[] { - let v: str[] = ~[]; +fn split_ivec(s: str, sep: u8) -> [str] { + let v: [str] = ~[]; let accum: str = ""; let ends_with_sep: bool = false; for c: u8 in s { @@ -494,7 +494,7 @@ fn connect(v: vec[str], sep: str) -> str { ret s; } -fn connect_ivec(v: &str[], sep: str) -> str { +fn connect_ivec(v: &[str], sep: str) -> str { let s: str = ""; let first: bool = true; for ss: str in v { diff --git a/src/lib/test.rs b/src/lib/test.rs index 753323c826446..70f9580bf732d 100644 --- a/src/lib/test.rs +++ b/src/lib/test.rs @@ -48,7 +48,7 @@ type test_desc = {name: test_name, fn: test_fn, ignore: bool}; // The default console test runner. It accepts the command line // arguments and a vector of test_descs (generated at compile time). -fn test_main(args: &vec[str], tests: &test_desc[]) { +fn test_main(args: &vec[str], tests: &[test_desc]) { let ivec_args = { let iargs = ~[]; for arg: str in args { iargs += ~[arg] } iargs }; check (ivec::is_not_empty(ivec_args)); @@ -65,7 +65,7 @@ type test_opts = {filter: option::t[str], run_ignored: bool}; type opt_res = either::t[test_opts, str]; // Parses command line arguments into test options -fn parse_opts(args: &str[]) : ivec::is_not_empty(args) -> opt_res { +fn parse_opts(args: &[str]) : ivec::is_not_empty(args) -> opt_res { // FIXME (#649): Shouldn't have to check here check (ivec::is_not_empty(args)); @@ -98,11 +98,11 @@ tag test_result { tr_ok; tr_failed; tr_ignored; } type test_to_task = fn(&fn()) -> task ; // A simple console test runner -fn run_tests_console(opts: &test_opts, tests: &test_desc[]) -> bool { +fn run_tests_console(opts: &test_opts, tests: &[test_desc]) -> bool { run_tests_console_(opts, tests, default_test_to_task) } -fn run_tests_console_(opts: &test_opts, tests: &test_desc[], +fn run_tests_console_(opts: &test_opts, tests: &[test_desc], to_task: &test_to_task) -> bool { type test_state = @{ @@ -112,7 +112,7 @@ fn run_tests_console_(opts: &test_opts, tests: &test_desc[], mutable passed: uint, mutable failed: uint, mutable ignored: uint, - mutable failures: test_desc[] + mutable failures: [test_desc] }; fn callback(event: testevent, st: test_state) { @@ -210,12 +210,12 @@ fn use_color() -> bool { } tag testevent { - te_filtered(test_desc[]); + te_filtered([test_desc]); te_wait(test_desc); te_result(test_desc, test_result); } -fn run_tests(opts: &test_opts, tests: &test_desc[], +fn run_tests(opts: &test_opts, tests: &[test_desc], to_task: &test_to_task, callback: fn(testevent)) { let filtered_tests = filter_tests(opts, tests); @@ -249,7 +249,7 @@ fn run_tests(opts: &test_opts, tests: &test_desc[], fn get_concurrency() -> uint { rustrt::sched_threads() } -fn filter_tests(opts: &test_opts, tests: &test_desc[]) -> test_desc[] { +fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] { let filtered = tests; // Remove tests that don't match the test filter diff --git a/src/lib/ufind.rs b/src/lib/ufind.rs index dd2da2562366f..ab456d23b88f6 100644 --- a/src/lib/ufind.rs +++ b/src/lib/ufind.rs @@ -10,7 +10,7 @@ type node = option::t[uint]; type ufind = {mutable nodes: vec[mutable node]}; -fn make() -> ufind { ret {mutable nodes: [mutable ]}; } +fn make() -> ufind { ret {mutable nodes: [mutable]}; } fn make_set(ufnd: &ufind) -> uint { let idx = vec::len(ufnd.nodes); @@ -49,4 +49,4 @@ fn prune(ufnd: &ufind, n: uint) { let len = vec::len[node](ufnd.nodes); while len != n { vec::pop[node](ufnd.nodes); len -= 1u; } -} \ No newline at end of file +} diff --git a/src/lib/ufindivec.rs b/src/lib/ufindivec.rs index 37e44b8a15a7d..79a2811653acb 100644 --- a/src/lib/ufindivec.rs +++ b/src/lib/ufindivec.rs @@ -8,9 +8,9 @@ import option::some; // than the node itself. type node = option::t[uint]; -type ufind = {mutable nodes: node[mutable ]}; +type ufind = {mutable nodes: [mutable node]}; -fn make() -> ufind { ret {mutable nodes: ~[mutable ]}; } +fn make() -> ufind { ret {mutable nodes: ~[mutable]}; } fn make_set(ufnd: &ufind) -> uint { let idx = ivec::len(ufnd.nodes); @@ -49,4 +49,4 @@ fn prune(ufnd: &ufind, n: uint) { let len = ivec::len[node](ufnd.nodes); while len != n { ivec::pop[node](ufnd.nodes); len -= 1u; } -} \ No newline at end of file +} diff --git a/src/lib/win32_fs.rs b/src/lib/win32_fs.rs index ae3d683bf68bf..cd300941df091 100644 --- a/src/lib/win32_fs.rs +++ b/src/lib/win32_fs.rs @@ -2,11 +2,11 @@ native "rust" mod rustrt { fn rust_list_files(path: str) -> vec[str]; - fn rust_list_files_ivec(path: str) -> @str[]; + fn rust_list_files_ivec(path: str) -> @[str]; fn rust_file_is_dir(path: str) -> int; } -fn list_dir(path: str) -> str[] { +fn list_dir(path: str) -> [str] { ret *rustrt::rust_list_files_ivec(path + "*"); } diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index 0a6b94c7f2ed2..8b71014f8509a 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -73,13 +73,13 @@ mod map_reduce { type reducer = fn(str, getter) ; tag ctrl_proto { - find_reducer(u8[], chan[chan[reduce_proto]]); + find_reducer([u8], chan[chan[reduce_proto]]); mapper_done; } tag reduce_proto { emit_val(int); done; ref; release; } - fn start_mappers(ctrl: chan[ctrl_proto], inputs: vec[str]) -> task[] { + fn start_mappers(ctrl: chan[ctrl_proto], inputs: vec[str]) -> [task] { let tasks = ~[]; // log_err "starting mappers"; for i: str in inputs { diff --git a/src/test/compiletest/compiletest.rs b/src/test/compiletest/compiletest.rs index 2b4776148dff3..40898556b9c8b 100644 --- a/src/test/compiletest/compiletest.rs +++ b/src/test/compiletest/compiletest.rs @@ -25,7 +25,7 @@ fn main(args: vec[str]) { run_tests(config); } -fn parse_config(args: &str[]) -> config { +fn parse_config(args: &[str]) -> config { let opts = ~[getopts::reqopt("compile-lib-path"), getopts::reqopt("run-lib-path"), getopts::reqopt("rustc-path"), @@ -117,7 +117,7 @@ fn test_opts(config: &config) -> test::test_opts { } type tests_and_conv_fn = - {tests: test::test_desc[], to_task: fn(&fn() ) -> task }; + {tests: [test::test_desc], to_task: fn(&fn() ) -> task }; fn make_tests(cx: &cx) -> tests_and_conv_fn { log #fmt("making tests from %s", cx.config.src_base); diff --git a/src/test/compiletest/header.rs b/src/test/compiletest/header.rs index 41619ad9de5c6..46fc29e18fcd2 100644 --- a/src/test/compiletest/header.rs +++ b/src/test/compiletest/header.rs @@ -11,7 +11,7 @@ export is_test_ignored; type test_props = { // Lines that should be expected, in order, on standard out - error_patterns: str[], + error_patterns: [str], // Extra flags to pass to the compiler compile_flags: option::t[str], // If present, the name of a file that this test should match when diff --git a/src/test/compiletest/procsrv.rs b/src/test/compiletest/procsrv.rs index 582e093e6f13e..99f746e6b742c 100644 --- a/src/test/compiletest/procsrv.rs +++ b/src/test/compiletest/procsrv.rs @@ -27,7 +27,7 @@ type reqchan = chan[request]; type handle = {task: option::t[task], chan: reqchan}; tag request { - exec(str, str, str[], chan[response]); + exec(str, str, [str], chan[response]); stop; } @@ -189,7 +189,7 @@ fn clone_str(s: &str) -> str { new } -fn clone_ivecstr(v: &str[]) -> str[] { +fn clone_ivecstr(v: &[str]) -> [str] { let r = ~[]; for t: str in ivec::slice(v, 0u, ivec::len(v)) { r += ~[clone_str(t)]; diff --git a/src/test/pretty/ivec-type.pp b/src/test/pretty/ivec-type.pp new file mode 100644 index 0000000000000..717b50be9e3d4 --- /dev/null +++ b/src/test/pretty/ivec-type.pp @@ -0,0 +1,5 @@ +// pp-exact:ivec-type.pp + +fn f1(x: [int]) { } + +fn g1() { f1(~[1, 2, 3]); } diff --git a/src/test/pretty/ivec-type.rs b/src/test/pretty/ivec-type.rs new file mode 100644 index 0000000000000..717b50be9e3d4 --- /dev/null +++ b/src/test/pretty/ivec-type.rs @@ -0,0 +1,5 @@ +// pp-exact:ivec-type.pp + +fn f1(x: [int]) { } + +fn g1() { f1(~[1, 2, 3]); } diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs index bc4aa52ce97d1..f2b81d41b0b15 100644 --- a/src/test/run-pass/alloca-from-derived-tydesc.rs +++ b/src/test/run-pass/alloca-from-derived-tydesc.rs @@ -1,7 +1,7 @@ tag option[T] { some(T); none; } -type r[T] = {mutable v: (option[T])[]}; +type r[T] = {mutable v: [option[T]]}; -fn f[T]() -> T[] { ret ~[]; } +fn f[T]() -> [T] { ret ~[]; } -fn main() { let r: r[int] = {mutable v: ~[]}; r.v = f(); } \ No newline at end of file +fn main() { let r: r[int] = {mutable v: ~[]}; r.v = f(); } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 935fbef1acf2f..6688068021300 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -1,9 +1,9 @@ -fn f[T](x: &T[]) -> T { ret x.(0); } +fn f[T](x: &[T]) -> T { ret x.(0); } -fn g(act: fn(&int[]) -> int ) -> int { ret act(~[1, 2, 3]); } +fn g(act: fn(&[int]) -> int ) -> int { ret act(~[1, 2, 3]); } fn main() { assert (g(f) == 1); - let f1: fn(&str[]) -> str = f; + let f1: fn(&[str]) -> str = f; assert (f1(~["x", "y", "z"]) == "x"); -} \ No newline at end of file +} diff --git a/src/test/run-pass/infer-fn-tail-expr.rs b/src/test/run-pass/infer-fn-tail-expr.rs index 311bfdb5301a3..9134f3a78de52 100644 --- a/src/test/run-pass/infer-fn-tail-expr.rs +++ b/src/test/run-pass/infer-fn-tail-expr.rs @@ -1,5 +1,5 @@ // issue #680 -fn f() -> int[] { ~[] } +fn f() -> [int] { ~[] } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/run-pass/interior-vec.rs b/src/test/run-pass/interior-vec.rs index 50cb704b88166..dec51540cff42 100644 --- a/src/test/run-pass/interior-vec.rs +++ b/src/test/run-pass/interior-vec.rs @@ -3,11 +3,11 @@ import rusti::ivec_len; native "rust-intrinsic" mod rusti { - fn ivec_len[T](v: &T[]) -> uint; + fn ivec_len[T](v: &[T]) -> uint; } fn main() { - let v: int[] = ~[]; + let v: [int] = ~[]; assert (ivec_len(v) == 0u); // zero-length let x = ~[1, 2]; assert (ivec_len(x) == 2u); // on stack diff --git a/src/test/run-pass/issue-687.rs b/src/test/run-pass/issue-687.rs index 200dd6273035f..2e682e2154ea1 100644 --- a/src/test/run-pass/issue-687.rs +++ b/src/test/run-pass/issue-687.rs @@ -1,20 +1,20 @@ use std; import std::ivec; -tag msg { closed; received(u8[]); } +tag msg { closed; received([u8]); } -fn producer(c: chan[u8[]]) { +fn producer(c: chan[[u8]]) { c <| ~[1u8, 2u8, 3u8, 4u8]; - let empty: u8[] = ~[]; + let empty: [u8] = ~[]; c <| empty; } -fn packager(cb: chan[chan[u8[]]], msg: chan[msg]) { - let p: port[u8[]] = port(); +fn packager(cb: chan[chan[[u8]]], msg: chan[msg]) { + let p: port[[u8]] = port(); cb <| chan(p); while true { log "waiting for bytes"; - let data: u8[]; + let data: [u8]; p |> data; log "got bytes"; if ivec::len[u8](data) == 0u { @@ -33,10 +33,10 @@ fn packager(cb: chan[chan[u8[]]], msg: chan[msg]) { fn main() { let p: port[msg] = port(); - let recv_reader: port[chan[u8[]]] = port(); + let recv_reader: port[chan[[u8]]] = port(); let pack = spawn packager(chan(recv_reader), chan(p)); - let source_chan: chan[u8[]]; + let source_chan: chan[[u8]]; recv_reader |> source_chan; let prod: task = spawn producer(source_chan); @@ -52,4 +52,4 @@ fn main() { } } } -} \ No newline at end of file +} diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 18ea2f23273c2..edf42f2fa9106 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -1,6 +1,6 @@ -fn double[T](a: &T) -> T[] { ret ~[a] + ~[a]; } +fn double[T](a: &T) -> [T] { ret ~[a] + ~[a]; } -fn double_int(a: int) -> int[] { ret ~[a] + ~[a]; } +fn double_int(a: int) -> [int] { ret ~[a] + ~[a]; } fn main() { let d = double(1); diff --git a/src/test/run-pass/ivec-pass-by-value.rs b/src/test/run-pass/ivec-pass-by-value.rs index cd0eadc459548..213e13846581f 100644 --- a/src/test/run-pass/ivec-pass-by-value.rs +++ b/src/test/run-pass/ivec-pass-by-value.rs @@ -1,3 +1,3 @@ -fn f(a: int[]) { } +fn f(a: [int]) { } fn main() { f(~[1, 2, 3, 4, 5]); } diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index 4d59964f6c6da..24c27b5212ce3 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -1,14 +1,14 @@ use std; -fn producer(c: chan[u8[]]) { +fn producer(c: chan[[u8]]) { c <| ~[1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8, 13u8 ]; } fn main() { - let p: port[u8[]] = port(); + let p: port[[u8]] = port(); let prod: task = spawn producer(chan(p)); - let data: u8[]; + let data: [u8]; p |> data; } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 6ca323faddf79..35dfab9f229ce 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -16,11 +16,11 @@ fn test_rec() { } fn test_vec() { - let po: port[int[]] = port(); - let ch: chan[int[]] = chan(po); - let v0: int[] = ~[0, 1, 2]; + let po: port[[int]] = port(); + let ch: chan[[int]] = chan(po); + let v0: [int] = ~[0, 1, 2]; ch <| v0; - let v1: int[]; + let v1: [int]; po |> v1; assert (v1.(0) == 0); assert (v1.(1) == 1); @@ -72,4 +72,4 @@ fn test_chan() { assert (i == 10); } -fn main() { test_rec(); test_vec(); test_str(); test_tag(); test_chan(); } \ No newline at end of file +fn main() { test_rec(); test_vec(); test_str(); test_tag(); test_chan(); } diff --git a/src/test/stdtest/either.rs b/src/test/stdtest/either.rs index 97ed9ef1000de..677abeda4125b 100644 --- a/src/test/stdtest/either.rs +++ b/src/test/stdtest/either.rs @@ -27,14 +27,14 @@ fn test_lefts() { #[test] fn test_lefts_none() { - let input: (t[int, int])[] = ~[right(10), right(10)]; + let input: [t[int, int]] = ~[right(10), right(10)]; let result = lefts(input); assert (len(result) == 0u); } #[test] fn test_lefts_empty() { - let input: (t[int, int])[] = ~[]; + let input: [t[int, int]] = ~[]; let result = lefts(input); assert (len(result) == 0u); } @@ -48,14 +48,14 @@ fn test_rights() { #[test] fn test_rights_none() { - let input: (t[int, int])[] = ~[left(10), left(10)]; + let input: [t[int, int]] = ~[left(10), left(10)]; let result = rights(input); assert (len(result) == 0u); } #[test] fn test_rights_empty() { - let input: (t[int, int])[] = ~[]; + let input: [t[int, int]] = ~[]; let result = rights(input); assert (len(result) == 0u); } @@ -73,7 +73,7 @@ fn test_partition() { #[test] fn test_partition_no_lefts() { - let input: (t[int, int])[] = ~[right(10), right(11)]; + let input: [t[int, int]] = ~[right(10), right(11)]; let result = partition(input); assert (len(result.lefts) == 0u); assert (len(result.rights) == 2u); @@ -81,7 +81,7 @@ fn test_partition_no_lefts() { #[test] fn test_partition_no_rights() { - let input: (t[int, int])[] = ~[left(10), left(11)]; + let input: [t[int, int]] = ~[left(10), left(11)]; let result = partition(input); assert (len(result.lefts) == 2u); assert (len(result.rights) == 0u); @@ -89,8 +89,8 @@ fn test_partition_no_rights() { #[test] fn test_partition_empty() { - let input: (t[int, int])[] = ~[]; + let input: [t[int, int]] = ~[]; let result = partition(input); assert (len(result.lefts) == 0u); assert (len(result.rights) == 0u); -} \ No newline at end of file +} diff --git a/src/test/stdtest/ivec.rs b/src/test/stdtest/ivec.rs index ab486b46e0b08..766587e6c76cb 100644 --- a/src/test/stdtest/ivec.rs +++ b/src/test/stdtest/ivec.rs @@ -19,7 +19,7 @@ fn add(x: &uint, y: &uint) -> uint { ret x + y; } #[test] fn test_reserve_and_on_heap() { - let v: int[] = ~[1, 2]; + let v: [int] = ~[1, 2]; assert (!ivec::on_heap(v)); ivec::reserve(v, 8u); assert (ivec::on_heap(v)); diff --git a/src/test/stdtest/sort_ivec.rs b/src/test/stdtest/sort_ivec.rs index 14654a89ad9bf..3e52de4ad2e74 100644 --- a/src/test/stdtest/sort_ivec.rs +++ b/src/test/stdtest/sort_ivec.rs @@ -1,7 +1,7 @@ use std; -fn check_sort(v1: &int[], v2: &int[]) { +fn check_sort(v1: &[int], v2: &[int]) { let len = std::ivec::len[int](v1); fn lteq(a: &int, b: &int) -> bool { ret a <= b; } let f = lteq; @@ -18,11 +18,11 @@ fn test() { check_sort(v1, v2); } { let v1 = ~[1, 1, 1]; let v2 = ~[1, 1, 1]; check_sort(v1, v2); } - { let v1: int[] = ~[]; let v2: int[] = ~[]; check_sort(v1, v2); } + { let v1: [int] = ~[]; let v2: [int] = ~[]; check_sort(v1, v2); } { let v1 = ~[9]; let v2 = ~[9]; check_sort(v1, v2); } { let v1 = ~[9, 3, 3, 3, 9]; let v2 = ~[3, 3, 3, 9, 9]; check_sort(v1, v2); } -} \ No newline at end of file +}