diff options
| author | Michael Sullivan <sully@msully.net> | 2012-06-25 20:00:46 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-06-25 20:00:46 -0700 |
| commit | 329eca6044fdf376a7a89ec7a96dba7a8b884cf7 (patch) | |
| tree | 7008814278a066914b6ba36818388d5212ffda9f /src/rustc | |
| parent | c087aaf56b1109163126fea4c2760f8414ffbe56 (diff) | |
| download | rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.tar.gz rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.zip | |
Make vectors uglier ([]/~). Sorry. Should be temporary. Closes #2725.
Diffstat (limited to 'src/rustc')
71 files changed, 1552 insertions, 1509 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 4875fbd69ca..44c801fb6a5 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -292,27 +292,27 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, type provided_metas = {name: option<@str>, vers: option<@str>, - cmh_items: [@ast::meta_item]}; + cmh_items: [@ast::meta_item]/~}; fn provided_link_metas(sess: session, c: ast::crate) -> provided_metas { let mut name: option<@str> = none; let mut vers: option<@str> = none; - let mut cmh_items: [@ast::meta_item] = []; + let mut cmh_items: [@ast::meta_item]/~ = []/~; let linkage_metas = attr::find_linkage_metas(c.node.attrs); attr::require_unique_names(sess.diagnostic(), linkage_metas); for linkage_metas.each {|meta| if *attr::get_meta_item_name(meta) == "name" { alt attr::get_meta_item_value_str(meta) { some(v) { name = some(v); } - none { cmh_items += [meta]; } + none { cmh_items += [meta]/~; } } } else if *attr::get_meta_item_name(meta) == "vers" { alt attr::get_meta_item_value_str(meta) { some(v) { vers = some(v); } - none { cmh_items += [meta]; } + none { cmh_items += [meta]/~; } } - } else { cmh_items += [meta]; } + } else { cmh_items += [meta]/~; } } ret {name: name, vers: vers, cmh_items: cmh_items}; } @@ -320,7 +320,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, // This calculates CMH as defined above fn crate_meta_extras_hash(sha: sha1, _crate: ast::crate, metas: provided_metas, - dep_hashes: [@str]) -> str { + dep_hashes: [@str]/~) -> str { fn len_and_str(s: str) -> str { ret #fmt["%u_%s", str::len(s), s]; } @@ -490,7 +490,7 @@ fn mangle(ss: path) -> str { } fn exported_name(path: path, hash: @str, vers: @str) -> str { - ret mangle(path + [path_name(hash)] + [path_name(vers)]); + ret mangle(path + [path_name(hash)]/~ + [path_name(vers)]/~); } fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str { @@ -503,12 +503,12 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, str { let s = @util::ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); - ret mangle([path_name(name), path_name(s), path_name(@hash)]); + ret mangle([path_name(name), path_name(s), path_name(@hash)]/~); } fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, flav: @str) -> str { - ret mangle(path + [path_name(@ccx.names(*flav))]); + ret mangle(path + [path_name(@ccx.names(*flav))]/~); } fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str { @@ -577,8 +577,8 @@ fn link_binary(sess: session, // The invocations of cc share some flags across platforms let mut cc_args = - [stage] + sess.targ_cfg.target_strs.cc_args + - ["-o", output, obj_filename]; + [stage]/~ + sess.targ_cfg.target_strs.cc_args + + ["-o", output, obj_filename]/~; let mut lib_cmd; let os = sess.targ_cfg.os; @@ -591,18 +591,18 @@ fn link_binary(sess: session, let cstore = sess.cstore; for cstore::get_used_crate_files(cstore).each {|cratepath| if str::ends_with(cratepath, ".rlib") { - cc_args += [cratepath]; + cc_args += [cratepath]/~; cont; } let cratepath = cratepath; let dir = path::dirname(cratepath); - if dir != "" { cc_args += ["-L" + dir]; } + if dir != "" { cc_args += ["-L" + dir]/~; } let libarg = unlib(sess.targ_cfg, path::basename(cratepath)); - cc_args += ["-l" + libarg]; + cc_args += ["-l" + libarg]/~; } let ula = cstore::get_used_link_args(cstore); - for ula.each {|arg| cc_args += [arg]; } + for ula.each {|arg| cc_args += [arg]/~; } // # Native library linking @@ -613,37 +613,37 @@ fn link_binary(sess: session, // forces to make sure that library can be found at runtime. let addl_paths = sess.opts.addl_lib_search_paths; - for addl_paths.each {|path| cc_args += ["-L" + path]; } + for addl_paths.each {|path| cc_args += ["-L" + path]/~; } // The names of the native libraries let used_libs = cstore::get_used_libraries(cstore); - for used_libs.each {|l| cc_args += ["-l" + l]; } + for used_libs.each {|l| cc_args += ["-l" + l]/~; } if sess.building_library { - cc_args += [lib_cmd]; + cc_args += [lib_cmd]/~; // On mac we need to tell the linker to let this library // be rpathed if sess.targ_cfg.os == session::os_macos { cc_args += ["-Wl,-install_name,@rpath/" - + path::basename(output)]; + + path::basename(output)]/~; } } if !sess.debugging_opt(session::no_rt) { // Always want the runtime linked in - cc_args += ["-lrustrt"]; + cc_args += ["-lrustrt"]/~; } // On linux librt and libdl are an indirect dependencies via rustrt, // and binutils 2.22+ won't add them automatically if sess.targ_cfg.os == session::os_linux { - cc_args += ["-lrt", "-ldl"]; + cc_args += ["-lrt", "-ldl"]/~; // LLVM implements the `frem` instruction as a call to `fmod`, // which lives in libm. Similar to above, on some linuxes we // have to be explicit about linking to it. See #2510 - cc_args += ["-lm"]; + cc_args += ["-lm"]/~; } if sess.targ_cfg.os == session::os_freebsd { @@ -653,7 +653,7 @@ fn link_binary(sess: session, "-L/usr/local/lib/gcc44", "-lstdc++", "-Wl,-z,origin", "-Wl,-rpath,/usr/local/lib/gcc46", - "-Wl,-rpath,/usr/local/lib/gcc44"]; + "-Wl,-rpath,/usr/local/lib/gcc44"]/~; } // OS X 10.6 introduced 'compact unwind info', which is produced by the @@ -661,11 +661,11 @@ fn link_binary(sess: session, // understand how to unwind our __morestack frame, so we have to turn it // off. This has impacted some other projects like GHC. if sess.targ_cfg.os == session::os_macos { - cc_args += ["-Wl,-no_compact_unwind"]; + cc_args += ["-Wl,-no_compact_unwind"]/~; } // Stack growth requires statically linking a __morestack function - cc_args += ["-lmorestack"]; + cc_args += ["-lmorestack"]/~; // FIXME (#2397): At some point we want to rpath our guesses as to where // native libraries might live, based on the addl_lib_search_paths @@ -685,7 +685,7 @@ fn link_binary(sess: session, // Clean up on Darwin if sess.targ_cfg.os == session::os_macos { - run::run_program("dsymutil", [output]); + run::run_program("dsymutil", [output]/~); } // Remove the temporary object file if we aren't saving temps diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index e37d4270215..dbe70a8085f 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -13,12 +13,12 @@ pure fn not_win32(os: session::os) -> bool { } } -fn get_rpath_flags(sess: session::session, out_filename: str) -> [str] { +fn get_rpath_flags(sess: session::session, out_filename: str) -> [str]/~ { let os = sess.targ_cfg.os; // No rpath on windows if os == session::os_win32 { - ret []; + ret []/~; } #debug("preparing the RPATH!"); @@ -29,7 +29,7 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> [str] { let libs = cstore::get_used_crate_files(sess.cstore); // We don't currently rpath native libraries, but we know // where rustrt is and we know every rust program needs it - let libs = libs + [get_sysroot_absolute_rt_lib(sess)]; + let libs = libs + [get_sysroot_absolute_rt_lib(sess)]/~; let target_triple = sess.opts.target_triple; let rpaths = get_rpaths(os, cwd, sysroot, output, libs, target_triple); @@ -37,20 +37,20 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> [str] { } fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path { - let path = [sess.filesearch.sysroot()] + let path = [sess.filesearch.sysroot()]/~ + filesearch::relative_target_lib_path( sess.opts.target_triple) - + [os::dll_filename("rustrt")]; + + [os::dll_filename("rustrt")]/~; path::connect_many(path) } -fn rpaths_to_flags(rpaths: [str]) -> [str] { +fn rpaths_to_flags(rpaths: [str]/~) -> [str]/~ { vec::map(rpaths, { |rpath| #fmt("-Wl,-rpath,%s",rpath)}) } fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, - output: path::path, libs: [path::path], - target_triple: str) -> [str] { + output: path::path, libs: [path::path]/~, + target_triple: str) -> [str]/~ { #debug("cwd: %s", cwd); #debug("sysroot: %s", sysroot); #debug("output: %s", output); @@ -70,9 +70,9 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, let abs_rpaths = get_absolute_rpaths(cwd, libs); // And a final backup rpath to the global library location. - let fallback_rpaths = [get_install_prefix_rpath(cwd, target_triple)]; + let fallback_rpaths = [get_install_prefix_rpath(cwd, target_triple)]/~; - fn log_rpaths(desc: str, rpaths: [str]) { + fn log_rpaths(desc: str, rpaths: [str]/~) { #debug("%s rpaths:", desc); for rpaths.each {|rpath| #debug(" %s", rpath); @@ -93,7 +93,7 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, fn get_rpaths_relative_to_output(os: session::os, cwd: path::path, output: path::path, - libs: [path::path]) -> [str] { + libs: [path::path]/~) -> [str]/~ { vec::map(libs, {|a| check not_win32(os); get_rpath_relative_to_output(os, cwd, output, a) @@ -139,8 +139,8 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { start_idx += 1u; } - let mut path = []; - for uint::range(start_idx, len1 - 1u) {|_i| path += [".."]; }; + let mut path = []/~; + for uint::range(start_idx, len1 - 1u) {|_i| vec::push(path, ".."); }; path += vec::slice(split2, start_idx, len2 - 1u); @@ -151,7 +151,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { } } -fn get_absolute_rpaths(cwd: path::path, libs: [path::path]) -> [str] { +fn get_absolute_rpaths(cwd: path::path, libs: [path::path]/~) -> [str]/~ { vec::map(libs, {|a|get_absolute_rpath(cwd, a)}) } @@ -174,17 +174,17 @@ fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str { fail "rustc compiled without CFG_PREFIX environment variable"; } - let path = [install_prefix] + let path = [install_prefix]/~ + filesearch::relative_target_lib_path(target_triple); get_absolute(cwd, path::connect_many(path)) } -fn minimize_rpaths(rpaths: [str]) -> [str] { +fn minimize_rpaths(rpaths: [str]/~) -> [str]/~ { let set = map::str_hash::<()>(); - let mut minimized = []; + let mut minimized = []/~; for rpaths.each {|rpath| if !set.contains_key(rpath) { - minimized += [rpath]; + minimized += [rpath]/~; set.insert(rpath, ()); } } @@ -195,8 +195,8 @@ fn minimize_rpaths(rpaths: [str]) -> [str] { mod test { #[test] fn test_rpaths_to_flags() { - let flags = rpaths_to_flags(["path1", "path2"]); - assert flags == ["-Wl,-rpath,path1", "-Wl,-rpath,path2"]; + let flags = rpaths_to_flags(["path1", "path2"]/~); + assert flags == ["-Wl,-rpath,path1", "-Wl,-rpath,path2"]/~; } #[test] @@ -230,15 +230,15 @@ mod test { #[test] fn test_minimize1() { - let res = minimize_rpaths(["rpath1", "rpath2", "rpath1"]); - assert res == ["rpath1", "rpath2"]; + let res = minimize_rpaths(["rpath1", "rpath2", "rpath1"]/~); + assert res == ["rpath1", "rpath2"]/~; } #[test] fn test_minimize2() { let res = minimize_rpaths(["1a", "2", "2", "1a", "4a", - "1a", "2", "3", "4a", "3"]); - assert res == ["1a", "2", "4a", "3"]; + "1a", "2", "3", "4a", "3"]/~); + assert res == ["1a", "2", "4a", "3"]/~; } #[test] diff --git a/src/rustc/back/target_strs.rs b/src/rustc/back/target_strs.rs index cc40746b71c..24665c2ab36 100644 --- a/src/rustc/back/target_strs.rs +++ b/src/rustc/back/target_strs.rs @@ -3,5 +3,5 @@ type t = { meta_sect_name: str, data_layout: str, target_triple: str, - cc_args: [str] + cc_args: [str]/~ }; diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index 2cae381431d..98dc3200b89 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -33,10 +33,10 @@ fn declare_upcalls(targ_cfg: @session::config, tydesc_type: TypeRef, llmod: ModuleRef) -> @upcalls { fn decl(llmod: ModuleRef, prefix: str, name: str, - tys: [TypeRef], rv: TypeRef) -> + tys: [TypeRef]/~, rv: TypeRef) -> ValueRef { - let mut arg_tys: [TypeRef] = []; - for tys.each {|t| arg_tys += [t]; } + let mut arg_tys: [TypeRef]/~ = []/~; + for tys.each {|t| arg_tys += [t]/~; } let fn_ty = T_fn(arg_tys, rv); ret base::decl_cdecl_fn(llmod, prefix + name, fn_ty); } @@ -51,61 +51,61 @@ fn declare_upcalls(targ_cfg: @session::config, ret @{_fail: dv("fail", [T_ptr(T_i8()), T_ptr(T_i8()), - size_t]), + size_t]/~), trace: dv("trace", [T_ptr(T_i8()), T_ptr(T_i8()), - int_t]), + int_t]/~), malloc: nothrow(d("malloc", - [T_ptr(tydesc_type), int_t], + [T_ptr(tydesc_type), int_t]/~, T_ptr(T_i8()))), free: - nothrow(dv("free", [T_ptr(T_i8())])), + nothrow(dv("free", [T_ptr(T_i8())]/~)), exchange_malloc: nothrow(d("exchange_malloc", - [T_ptr(tydesc_type), int_t], + [T_ptr(tydesc_type), int_t]/~, T_ptr(T_i8()))), exchange_free: - nothrow(dv("exchange_free", [T_ptr(T_i8())])), + nothrow(dv("exchange_free", [T_ptr(T_i8())]/~)), validate_box: - nothrow(dv("validate_box", [T_ptr(T_i8())])), + nothrow(dv("validate_box", [T_ptr(T_i8())]/~)), mark: - d("mark", [T_ptr(T_i8())], int_t), + d("mark", [T_ptr(T_i8())]/~, int_t), vec_grow: - nothrow(dv("vec_grow", [T_ptr(T_ptr(T_i8())), int_t])), + nothrow(dv("vec_grow", [T_ptr(T_ptr(T_i8())), int_t]/~)), str_new_uniq: - nothrow(d("str_new_uniq", [T_ptr(T_i8()), int_t], + nothrow(d("str_new_uniq", [T_ptr(T_i8()), int_t]/~, T_ptr(T_i8()))), str_new_shared: - nothrow(d("str_new_shared", [T_ptr(T_i8()), int_t], + nothrow(d("str_new_shared", [T_ptr(T_i8()), int_t]/~, T_ptr(T_i8()))), str_concat: nothrow(d("str_concat", [T_ptr(T_i8()), - T_ptr(T_i8())], + T_ptr(T_i8())]/~, T_ptr(T_i8()))), cmp_type: dv("cmp_type", [T_ptr(T_i1()), T_ptr(tydesc_type), T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()), - T_i8()]), + T_i8()]/~), log_type: dv("log_type", [T_ptr(tydesc_type), - T_ptr(T_i8()), T_i32()]), + T_ptr(T_i8()), T_i32()]/~), alloc_c_stack: - d("alloc_c_stack", [size_t], T_ptr(T_i8())), + d("alloc_c_stack", [size_t]/~, T_ptr(T_i8())), call_shim_on_c_stack: d("call_shim_on_c_stack", // arguments: void *args, void *fn_ptr - [T_ptr(T_i8()), T_ptr(T_i8())], + [T_ptr(T_i8()), T_ptr(T_i8())]/~, int_t), call_shim_on_rust_stack: d("call_shim_on_rust_stack", - [T_ptr(T_i8()), T_ptr(T_i8())], int_t), + [T_ptr(T_i8()), T_ptr(T_i8())]/~, int_t), rust_personality: - nothrow(d("rust_personality", [], T_i32())), + nothrow(d("rust_personality", []/~, T_i32())), reset_stack_limit: - nothrow(dv("reset_stack_limit", [])) + nothrow(dv("reset_stack_limit", []/~)) }; } // diff --git a/src/rustc/back/x86.rs b/src/rustc/back/x86.rs index a7febe457dd..df68aee37e5 100644 --- a/src/rustc/back/x86.rs +++ b/src/rustc/back/x86.rs @@ -35,7 +35,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { session::os_freebsd { "i686-unknown-freebsd" } }, - cc_args: ["-m32"] + cc_args: ["-m32"]/~ }; } diff --git a/src/rustc/back/x86_64.rs b/src/rustc/back/x86_64.rs index 3210a2333f4..6936b3cec7d 100644 --- a/src/rustc/back/x86_64.rs +++ b/src/rustc/back/x86_64.rs @@ -42,7 +42,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { session::os_freebsd { "x86_64-unknown-freebsd" } }, - cc_args: ["-m64"] + cc_args: ["-m64"]/~ }; } diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 553db7695a8..13c0035011c 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -56,7 +56,7 @@ fn default_configuration(sess: session, argv0: str, input: input) -> mk(@"target_libc", libc), // Build bindings. mk(@"build_compiler", argv0), - mk(@"build_input", source_name(input))]; + mk(@"build_input", source_name(input))]/~; } fn build_configuration(sess: session, argv0: str, input: input) -> @@ -70,19 +70,19 @@ fn build_configuration(sess: session, argv0: str, input: input) -> { if sess.opts.test && !attr::contains_name(user_cfg, "test") { - [attr::mk_word_item(@"test")] - } else { [] } + [attr::mk_word_item(@"test")]/~ + } else { []/~ } }; ret user_cfg + gen_cfg + default_cfg; } // Convert strings provided as --cfg [cfgspec] into a crate_cfg -fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg { +fn parse_cfgspecs(cfgspecs: [str]/~) -> ast::crate_cfg { // FIXME (#2399): It would be nice to use the parser to parse all // varieties of meta_item here. At the moment we just support the // meta_word variant. - let mut words = []; - for cfgspecs.each {|s| words += [attr::mk_word_item(@s)]; } + let mut words = []/~; + for cfgspecs.each {|s| vec::push(words, attr::mk_word_item(@s)); } ret words; } @@ -563,7 +563,7 @@ fn parse_pretty(sess: session, &&name: str) -> pp_mode { "`identified`"); } -fn opts() -> [getopts::opt] { +fn opts() -> [getopts::opt]/~ { ret [optflag("h"), optflag("help"), optflag("v"), optflag("version"), optflag("emit-llvm"), optflagopt("pretty"), optflag("ls"), optflag("parse-only"), optflag("no-trans"), @@ -577,7 +577,7 @@ fn opts() -> [getopts::opt] { optmulti("Z"), optmulti("cfg"), optflag("test"), - optflag("lib"), optflag("bin"), optflag("static"), optflag("gc")]; + optflag("lib"), optflag("bin"), optflag("static"), optflag("gc")]/~; } type output_filenames = @{out_filename: str, obj_filename:str}; @@ -692,7 +692,7 @@ mod test { #[test] fn test_switch_implies_cfg_test() { let match = - alt getopts::getopts(["--test"], opts()) { + alt getopts::getopts(["--test"]/~, opts()) { ok(m) { m } err(f) { fail "test_switch_implies_cfg_test: " + getopts::fail_str(f); } @@ -708,7 +708,7 @@ mod test { #[test] fn test_switch_implies_cfg_test_unless_cfg_test() { let match = - alt getopts::getopts(["--test", "--cfg=test"], opts()) { + alt getopts::getopts(["--test", "--cfg=test"]/~, opts()) { ok(m) { m } err(f) { fail "test_switch_implies_cfg_test_unless_cfg_test: " + getopts::fail_str(f); } diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 634d5587f17..1d99f3a7012 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -109,7 +109,7 @@ fn describe_debug_flags() { } } -fn run_compiler(args: [str], demitter: diagnostic::emitter) { +fn run_compiler(args: [str]/~, demitter: diagnostic::emitter) { // Don't display log spew by default. Can override with RUST_LOG. logging::console_off(); @@ -250,7 +250,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { to get further details and report the results \ to github.com/mozilla/rust/issues" - ].each {|note| + ]/~.each {|note| diagnostic::emit(none, note, diagnostic::note) } } @@ -260,7 +260,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { } } -fn main(args: [str]) { +fn main(args: [str]/~) { monitor {|demitter| run_compiler(args, demitter); } diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 9645d919b04..263343d63d7 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -36,7 +36,7 @@ const trace: uint = 128u; // It should be removed const no_rt: uint = 256u; -fn debugging_opts_map() -> [(str, str, uint)] { +fn debugging_opts_map() -> [(str, str, uint)]/~ { [("ppregions", "prettyprint regions with \ internal repr details", ppregions), ("time-passes", "measure time of each rustc pass", time_passes), @@ -48,7 +48,7 @@ fn debugging_opts_map() -> [(str, str, uint)] { ("no-verify", "skip LLVM verification", no_verify), ("trace", "emit trace logs", trace), ("no-rt", "do not link to the runtime", no_rt) - ] + ]/~ } type options = @@ -59,10 +59,10 @@ type options = optimize: uint, debuginfo: bool, extra_debuginfo: bool, - lint_opts: [(lint::lint, lint::level)], + lint_opts: [(lint::lint, lint::level)]/~, save_temps: bool, output_type: back::link::output_type, - addl_lib_search_paths: [str], + addl_lib_search_paths: [str]/~, maybe_sysroot: option<str>, target_triple: str, cfg: ast::crate_cfg, @@ -72,7 +72,7 @@ type options = debugging_opts: uint, }; -type crate_metadata = {name: str, data: [u8]}; +type crate_metadata = {name: str, data: [u8]/~}; type session = @{targ_cfg: @config, opts: @options, @@ -172,13 +172,13 @@ fn basic_options() -> @options { optimize: 0u, debuginfo: false, extra_debuginfo: false, - lint_opts: [], + lint_opts: []/~, save_temps: false, output_type: link::output_type_exe, - addl_lib_search_paths: [], + addl_lib_search_paths: []/~, maybe_sysroot: none, target_triple: driver::host_triple(), - cfg: [], + cfg: []/~, test: false, parse_only: false, no_trans: false, @@ -238,14 +238,14 @@ mod test { } fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { - let mut attrs = []; - if with_bin { attrs += [make_crate_type_attr("bin")]; } - if with_lib { attrs += [make_crate_type_attr("lib")]; } + let mut attrs = []/~; + if with_bin { attrs += [make_crate_type_attr("bin")]/~; } + if with_lib { attrs += [make_crate_type_attr("lib")]/~; } @ast_util::respan(ast_util::dummy_sp(), { - directives: [], - module: {view_items: [], items: []}, + directives: []/~, + module: {view_items: []/~, items: []/~}, attrs: attrs, - config: [] + config: []/~ }) } diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index 57c1f587f8c..079e8fb71cb 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -4,7 +4,7 @@ export strip_unconfigured_items; export metas_in_cfg; export strip_items; -type in_cfg_pred = fn@([ast::attribute]) -> bool; +type in_cfg_pred = fn@([ast::attribute]/~) -> bool; type ctxt = @{ in_cfg: in_cfg_pred @@ -100,11 +100,11 @@ fn native_item_in_cfg(cx: ctxt, item: @ast::native_item) -> bool { // 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 { metas_in_cfg(cfg, attr::attr_metas(attrs)) } -fn metas_in_cfg(cfg: ast::crate_cfg, metas: [@ast::meta_item]) -> bool { +fn metas_in_cfg(cfg: ast::crate_cfg, metas: [@ast::meta_item]/~) -> bool { // The "cfg" attributes on the item let cfg_metas = attr::find_meta_items_by_name(metas, "cfg"); diff --git a/src/rustc/front/core_inject.rs b/src/rustc/front/core_inject.rs index bc7048f8f09..c15f08e561f 100644 --- a/src/rustc/front/core_inject.rs +++ b/src/rustc/front/core_inject.rs @@ -30,18 +30,18 @@ fn inject_libcore_ref(sess: session, let n1 = sess.next_node_id(); let n2 = sess.next_node_id(); - let vi1 = @{node: ast::view_item_use(@"core", [], n1), - attrs: [], + let vi1 = @{node: ast::view_item_use(@"core", []/~, n1), + attrs: []/~, vis: ast::public, span: dummy_sp()}; let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), @"core"), n2)); - let vi2 = @{node: ast::view_item_import([vp]), - attrs: [], + let vi2 = @{node: ast::view_item_import([vp]/~), + attrs: []/~, vis: ast::public, span: dummy_sp()}; - let vis = [vi1, vi2] + crate.node.module.view_items; + let vis = [vi1, vi2]/~ + crate.node.module.view_items; ret @{node: {module: { view_items: vis with crate.node.module } with crate.node} with *crate } diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index 8919265fb87..06f8bbe92c9 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -12,7 +12,7 @@ fn inject_intrinsic(sess: session, let item = parse::parse_item_from_source_str("<intrinsic>", intrinsic_module, sess.opts.cfg, - [], ast::public, + []/~, ast::public, sess.parse_sess); let item = alt item { @@ -22,7 +22,7 @@ fn inject_intrinsic(sess: session, } }; - let items = [item] + crate.node.module.items; + let items = [item]/~ + crate.node.module.items; ret @{node: {module: { items: items with crate.node.module } with crate.node} with *crate } diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 3f5fca12e2a..d9240dc8877 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -15,12 +15,13 @@ export modify_for_testing; type node_id_gen = fn@() -> ast::node_id; -type test = {span: span, path: [ast::ident], ignore: bool, should_fail: bool}; +type test = {span: span, path: [ast::ident]/~, + ignore: bool, should_fail: bool}; type test_ctxt = @{sess: session::session, crate: @ast::crate, - mut path: [ast::ident], + mut path: [ast::ident]/~, testfns: dvec<test>}; // Traverse the crate, collecting all the test functions, eliding any @@ -40,7 +41,7 @@ fn generate_test_harness(sess: session::session, let cx: test_ctxt = @{sess: sess, crate: crate, - mut path: [], + mut path: []/~, testfns: dvec()}; let precursor = @@ -97,7 +98,7 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) -> fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> @ast::item { - cx.path += [i.ident]; + cx.path += [i.ident]/~; #debug("current path: %s", ast_util::path_name_i(cx.path)); if is_test_fn(i) { @@ -160,7 +161,7 @@ fn should_fail(i: @ast::item) -> bool { fn add_test_module(cx: test_ctxt, m: ast::_mod) -> ast::_mod { let testmod = mk_test_module(cx); - ret {items: m.items + [testmod] with m}; + ret {items: m.items + [testmod]/~ with m}; } /* @@ -169,11 +170,11 @@ We're going to be building a module that looks more or less like: mod __test { - fn main(args: [str]) -> int { + fn main(args: [str]/~) -> int { 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 ... } } @@ -187,14 +188,14 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { // The synthesized main function which will call the console test runner // with our list of tests let mainfn = mk_main(cx); - let testmod: ast::_mod = {view_items: [], items: [mainfn, testsfn]}; + let testmod: ast::_mod = {view_items: []/~, items: [mainfn, testsfn]/~}; let item_ = ast::item_mod(testmod); // This attribute tells resolve to let us call unexported functions let resolve_unexported_attr = attr::mk_attr(attr::mk_word_item(@"!resolve_unexported")); let item: ast::item = {ident: @"__test", - attrs: [resolve_unexported_attr], + attrs: [resolve_unexported_attr]/~, id: cx.sess.next_node_id(), node: item_, vis: ast::public, @@ -209,31 +210,31 @@ fn nospan<T: copy>(t: T) -> ast::spanned<T> { ret {node: t, span: dummy_sp()}; } -fn path_node(ids: [ast::ident]) -> @ast::path { - @{span: dummy_sp(), global: false, idents: ids, rp: none, types: []} +fn path_node(ids: [ast::ident]/~) -> @ast::path { + @{span: dummy_sp(), global: false, idents: ids, rp: none, types: []/~} } fn mk_tests(cx: test_ctxt) -> @ast::item { let ret_ty = mk_test_desc_vec_ty(cx); let decl: ast::fn_decl = - {inputs: [], + {inputs: []/~, output: ret_ty, purity: ast::impure_fn, cf: ast::return_val, - constraints: []}; + constraints: []/~}; // The vector of test_descs for this crate let test_descs = mk_test_desc_vec(cx); let body_: ast::blk_ = - default_block([], option::some(test_descs), cx.sess.next_node_id()); + default_block([]/~, option::some(test_descs), cx.sess.next_node_id()); let body = nospan(body_); - let item_ = ast::item_fn(decl, [], body); + let item_ = ast::item_fn(decl, []/~, body); let item: ast::item = {ident: @"tests", - attrs: [], + attrs: []/~, id: cx.sess.next_node_id(), node: item_, vis: ast::public, @@ -241,7 +242,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item { ret @item; } -fn mk_path(cx: test_ctxt, path: [ast::ident]) -> [ast::ident] { +fn mk_path(cx: test_ctxt, path: [ast::ident]/~) -> [ast::ident]/~ { // For tests that are inside of std we don't want to prefix // the paths with std:: let is_std = { @@ -251,12 +252,12 @@ fn mk_path(cx: test_ctxt, path: [ast::ident]) -> [ast::ident] { _ { false } } }; - (if is_std { [] } else { [@"std"] }) + path + (if is_std { []/~ } else { [@"std"]/~ }) + path } -// The ast::ty of [std::test::test_desc] +// The ast::ty of [std::test::test_desc]/~ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { - let test_desc_ty_path = path_node(mk_path(cx, [@"test", @"test_desc"])); + let test_desc_ty_path = path_node(mk_path(cx, [@"test", @"test_desc"]/~)); let test_desc_ty: ast::ty = {id: cx.sess.next_node_id(), @@ -275,9 +276,9 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr { #debug("building test vector from %u tests", cx.testfns.len()); - let mut descs = []; + let mut descs = []/~; for cx.testfns.each {|test| - descs += [mk_test_desc_rec(cx, test)]; + descs += [mk_test_desc_rec(cx, test)]/~; } let inner_expr = @{id: cx.sess.next_node_id(), @@ -337,7 +338,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { nospan({mutbl: ast::m_imm, ident: @"should_fail", expr: @fail_expr}); let desc_rec_: ast::expr_ = - ast::expr_rec([name_field, fn_field, ignore_field, fail_field], + ast::expr_rec([name_field, fn_field, ignore_field, fail_field]/~, option::none); let desc_rec: ast::expr = {id: cx.sess.next_node_id(), node: desc_rec_, span: span}; @@ -352,7 +353,7 @@ fn mk_test_wrapper(cx: test_ctxt, span: span) -> @ast::expr { let call_expr: ast::expr = { id: cx.sess.next_node_id(), - node: ast::expr_call(@fn_path_expr, [], false), + node: ast::expr_call(@fn_path_expr, []/~, false), span: span }; @@ -360,16 +361,16 @@ fn mk_test_wrapper(cx: test_ctxt, ast::stmt_semi(@call_expr, cx.sess.next_node_id())); let wrapper_decl: ast::fn_decl = { - inputs: [], + inputs: []/~, output: @{id: cx.sess.next_node_id(), node: ast::ty_nil, span: span}, purity: ast::impure_fn, cf: ast::return_val, - constraints: [] + constraints: []/~ }; let wrapper_body: ast::blk = nospan({ - view_items: [], - stmts: [@call_stmt], + view_items: []/~, + stmts: [@call_stmt]/~, expr: option::none, id: cx.sess.next_node_id(), rules: ast::default_blk @@ -378,7 +379,7 @@ fn mk_test_wrapper(cx: test_ctxt, let wrapper_expr: ast::expr = { id: cx.sess.next_node_id(), node: ast::expr_fn(ast::proto_bare, wrapper_decl, - wrapper_body, @[]), + wrapper_body, @[]/~), span: span }; @@ -386,7 +387,7 @@ fn mk_test_wrapper(cx: test_ctxt, } fn mk_main(cx: test_ctxt) -> @ast::item { - let str_pt = path_node([@"str"]); + let str_pt = path_node([@"str"]/~); let str_ty = @{id: cx.sess.next_node_id(), node: ast::ty_path(str_pt, cx.sess.next_node_id()), span: dummy_sp()}; @@ -410,23 +411,23 @@ fn mk_main(cx: test_ctxt) -> @ast::item { span: dummy_sp()}; let decl: ast::fn_decl = - {inputs: [args_arg], + {inputs: [args_arg]/~, output: @ret_ty, purity: ast::impure_fn, cf: ast::return_val, - constraints: []}; + constraints: []/~}; let test_main_call_expr = mk_test_main_call(cx); let body_: ast::blk_ = - default_block([], option::some(test_main_call_expr), + default_block([]/~, option::some(test_main_call_expr), cx.sess.next_node_id()); let body = {node: body_, span: dummy_sp()}; - let item_ = ast::item_fn(decl, [], body); + let item_ = ast::item_fn(decl, []/~, body); let item: ast::item = {ident: @"main", - attrs: [], + attrs: []/~, id: cx.sess.next_node_id(), node: item_, vis: ast::public, @@ -437,7 +438,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { // Get the args passed to main so we can pass the to test_main - let args_path = path_node([@"args"]); + let args_path = path_node([@"args"]/~); let args_path_expr_: ast::expr_ = ast::expr_path(args_path); @@ -445,20 +446,20 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { {id: cx.sess.next_node_id(), node: args_path_expr_, span: dummy_sp()}; // Call __test::test to generate the vector of test_descs - let test_path = path_node([@"tests"]); + let test_path = path_node([@"tests"]/~); let test_path_expr_: ast::expr_ = ast::expr_path(test_path); let test_path_expr: ast::expr = {id: cx.sess.next_node_id(), node: test_path_expr_, span: dummy_sp()}; - let test_call_expr_ = ast::expr_call(@test_path_expr, [], false); + let test_call_expr_ = ast::expr_call(@test_path_expr, []/~, false); let test_call_expr: ast::expr = {id: cx.sess.next_node_id(), node: test_call_expr_, span: dummy_sp()}; // Call std::test::test_main - let test_main_path = path_node(mk_path(cx, [@"test", @"test_main"])); + let test_main_path = path_node(mk_path(cx, [@"test", @"test_main"]/~)); let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path); @@ -468,7 +469,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { let test_main_call_expr_: ast::expr_ = ast::expr_call(@test_main_path_expr, - [@args_path_expr, @test_call_expr], false); + [@args_path_expr, @test_call_expr]/~, false); let test_main_call_expr: ast::expr = {id: cx.sess.next_node_id(), node: test_main_call_expr_, diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 1c5d41b0939..e43f73697c7 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -981,21 +981,22 @@ fn mk_type_names() -> type_names { } fn type_to_str(names: type_names, ty: TypeRef) -> str { - ret type_to_str_inner(names, [], ty); + 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 { alt type_has_name(names, ty) { option::some(n) { ret n; } _ {} } - let outer = outer0 + [ty]; + let outer = outer0 + [ty]/~; let kind = 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 mut s: str = ""; let mut first: bool = true; for tys.each {|t| @@ -1021,7 +1022,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) -> let mut s = "fn("; let out_ty: TypeRef = llvm::LLVMGetReturnType(ty); let n_args = llvm::LLVMCountParamTypes(ty) as uint; - let args: [TypeRef] = vec::from_elem::<TypeRef>(n_args, 0 as TypeRef); + let args = vec::from_elem(n_args, 0 as TypeRef); unsafe { llvm::LLVMGetParamTypes(ty, vec::unsafe::to_ptr(args)); } @@ -1033,7 +1034,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) -> Struct { let mut s: str = "{"; let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint; - let elts: [TypeRef] = vec::from_elem::<TypeRef>(n_elts, 0 as TypeRef); + let elts = vec::from_elem(n_elts, 0 as TypeRef); unsafe { llvm::LLVMGetStructElementTypes(ty, vec::unsafe::to_ptr(elts)); } @@ -1082,7 +1083,7 @@ fn float_width(llt: TypeRef) -> uint { }; } -fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] unsafe { +fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef]/~ unsafe { let args = vec::from_elem(llvm::LLVMCountParamTypes(fn_ty) as uint, 0 as TypeRef); llvm::LLVMGetParamTypes(fn_ty, vec::unsafe::to_ptr(args)); diff --git a/src/rustc/metadata/astencode.rs b/src/rustc/metadata/astencode.rs index b6b0060b5fb..391ab8bfda4 100644 --- a/src/rustc/metadata/astencode.rs +++ b/src/rustc/metadata/astencode.rs @@ -68,7 +68,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt, ii: ast::inlined_item) { #debug["> Encoding inlined item: %s::%s (%u)", ast_map::path_to_str(path), ii.ident(), - ebml_w.writer.tell()]; + ebml_w.writer.tell()]/~; let id_range = compute_id_range_for_inlined_item(ii); ebml_w.wr_tag(c::tag_ast as uint) {|| @@ -79,7 +79,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt, #debug["< Encoded inlined fn: %s::%s (%u)", ast_map::path_to_str(path), ii.ident(), - ebml_w.writer.tell()]; + ebml_w.writer.tell()]/~; } fn decode_inlined_item(cdata: cstore::crate_metadata, @@ -103,7 +103,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, #debug["Fn named: %s", ii.ident()]; decode_side_tables(xcx, ast_doc); #debug["< Decoded inlined fn: %s::%s", - ast_map::path_to_str(path), ii.ident()]; + ast_map::path_to_str(path), ii.ident()]/~; alt ii { ast::ii_item(i) { #debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", @@ -522,7 +522,7 @@ impl helpers for ebml::writer { e::write_type(ecx, self, ty) } - fn emit_tys(ecx: @e::encode_ctxt, tys: [ty::t]) { + fn emit_tys(ecx: @e::encode_ctxt, tys: [ty::t]/~) { self.emit_from_vec(tys) {|ty| e::write_type(ecx, self, ty) } @@ -707,7 +707,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, impl decoder for ebml::doc { fn as_int() -> int { ebml::doc_as_u64(self) as int } - fn [](tag: c::astencode_tag) -> ebml::doc { + fn []/~(tag: c::astencode_tag) -> ebml::doc { ebml::get_doc(self, tag as uint) } fn opt_child(tag: c::astencode_tag) -> option<ebml::doc> { @@ -727,11 +727,11 @@ impl decoder for ebml::ebml_deserializer { xcx.tr_def_id(_)) } - fn read_tys(xcx: extended_decode_ctxt) -> [ty::t] { + fn read_tys(xcx: extended_decode_ctxt) -> [ty::t]/~ { self.read_to_vec {|| self.read_ty(xcx) } } - fn read_bounds(xcx: extended_decode_ctxt) -> @[ty::param_bound] { + fn read_bounds(xcx: extended_decode_ctxt) -> @[ty::param_bound]/~ { tydecode::parse_bounds_data( self.parent.data, self.pos, xcx.dcx.cdata.cnum, xcx.dcx.tcx, xcx.tr_def_id(_)) @@ -765,7 +765,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt, #debug[">> Side table document with tag 0x%x \ found for id %d (orig %d)", - tag, id, id0]; + tag, id, id0]/~; if tag == (c::tag_table_mutbl as uint) { dcx.maps.mutbl_map.insert(id, ()); @@ -859,7 +859,7 @@ type fake_session = (); #[cfg(test)] impl of fake_ext_ctxt for fake_session { - fn cfg() -> ast::crate_cfg { [] } + fn cfg() -> ast::crate_cfg { []/~ } fn parse_sess() -> parse::parse_sess { new_parse_sess() } } @@ -922,13 +922,13 @@ fn test_simplification() { let item_in = ast::ii_item(#ast(item) { fn new_int_alist<B: copy>() -> alist<int, B> { fn eq_int(&&a: int, &&b: int) -> bool { a == b } - ret {eq_fn: eq_int, mut data: []}; + ret {eq_fn: eq_int, mut data: []/~}; } }); let item_out = simplify_ast(item_in); let item_exp = ast::ii_item(#ast(item) { fn new_int_alist<B: copy>() -> alist<int, B> { - ret {eq_fn: eq_int, mut data: []}; + ret {eq_fn: eq_int, mut data: []/~}; } }); alt (item_out, item_exp) { diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index c63d03ce239..c9146135bca 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -43,7 +43,7 @@ type cache_entry = { cnum: int, span: span, hash: @str, - metas: @[@ast::meta_item] + metas: @[@ast::meta_item]/~ }; fn dump_crates(crate_cache: dvec<cache_entry>) { @@ -54,7 +54,7 @@ fn dump_crates(crate_cache: dvec<cache_entry>) { #debug("hash: %?", entry.hash); let attrs = [ attr::mk_attr(attr::mk_list_item(@"link", *entry.metas)) - ]; + ]/~; for attr::find_linkage_attrs(attrs).each {|attr| #debug("meta: %s", pprust::attr_to_str(attr)); } @@ -62,7 +62,7 @@ fn dump_crates(crate_cache: dvec<cache_entry>) { } fn warn_if_multiple_versions(diag: span_handler, - crate_cache: [cache_entry]) { + crate_cache: [cache_entry]/~) { import either::*; if crate_cache.len() != 0u { @@ -86,7 +86,7 @@ fn warn_if_multiple_versions(diag: span_handler, diag.span_note(match.span, "used here"); let attrs = [ attr::mk_attr(attr::mk_list_item(@"link", *match.metas)) - ]; + ]/~; loader::note_linkage_attrs(diag, attrs); } } @@ -161,21 +161,21 @@ fn visit_item(e: env, i: @ast::item) { } fn metas_with(ident: ast::ident, key: ast::ident, - metas: [@ast::meta_item]) -> [@ast::meta_item] { + metas: [@ast::meta_item]/~) -> [@ast::meta_item]/~ { let name_items = attr::find_meta_items_by_name(metas, *key); if name_items.is_empty() { - metas + [attr::mk_name_value_item_str(key, *ident)] + metas + [attr::mk_name_value_item_str(key, *ident)]/~ } else { metas } } fn metas_with_ident(ident: ast::ident, - metas: [@ast::meta_item]) -> [@ast::meta_item] { + metas: [@ast::meta_item]/~) -> [@ast::meta_item]/~ { metas_with(ident, @"name", metas) } -fn existing_match(e: env, metas: [@ast::meta_item], hash: str) -> +fn existing_match(e: env, metas: [@ast::meta_item]/~, hash: str) -> option<int> { for e.crate_cache.each {|c| @@ -187,7 +187,7 @@ fn existing_match(e: env, metas: [@ast::meta_item], hash: str) -> ret none; } -fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item], +fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item]/~, hash: str, span: span) -> ast::crate_num { let metas = metas_with_ident(ident, metas); @@ -241,7 +241,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 { #debug("resolving deps of external crate"); // The map from crate numbers in the crate we're resolving to local crate // numbers @@ -249,7 +249,7 @@ fn resolve_crate_deps(e: env, cdata: @[u8]) -> cstore::cnum_map { for decoder::get_crate_deps(cdata).each {|dep| let extrn_cnum = dep.cnum; let cname = dep.name; - let cmetas = metas_with(dep.vers, @"vers", []); + let cmetas = metas_with(dep.vers, @"vers", []/~); #debug("resolving dep crate %s ver: %s hash: %s", *dep.name, *dep.vers, *dep.hash); alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index f65f6110388..f5d628622b2 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -39,12 +39,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] { - let mut result = []; + path: [ast::ident]/~) -> [ast::def]/~ { + let mut result = []/~; #debug("lookup_defs: path = %? cnum = %?", path, cnum); for resolve_path(cstore, cnum, path).each {|elt| let (c, data, def) = elt; - result += [decoder::lookup_def(c, data, def)]; + result += [decoder::lookup_def(c, data, def)]/~; } ret result; } @@ -60,21 +60,21 @@ fn lookup_method_purity(cstore: cstore::cstore, did: ast::def_id) /* Returns a vector of possible def IDs for a given path, in a given crate */ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num, - path: [ast::ident]) -> - [(ast::crate_num, @[u8], ast::def_id)] { + path: [ast::ident]/~) -> + [(ast::crate_num, @[u8]/~, ast::def_id)]/~ { let cm = cstore::get_crate_data(cstore, cnum); #debug("resolve_path %s in crates[%d]:%s", ast_util::path_name_i(path), cnum, cm.name); - let mut result = []; + let mut result = []/~; for decoder::resolve_path(path, cm.data).each {|def| if def.crate == ast::local_crate { - result += [(cnum, cm.data, def)]; + result += [(cnum, cm.data, def)]/~; } else { if cm.cnum_map.contains_key(def.crate) { // This reexport is itself a reexport from another crate let next_cnum = cm.cnum_map.get(def.crate); let next_cm_data = cstore::get_crate_data(cstore, next_cnum); - result += [(next_cnum, next_cm_data.data, def)]; + result += [(next_cnum, next_cm_data.data, def)]/~; } } } @@ -88,7 +88,7 @@ fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path { // FIXME #1920: This path is not always correct if the crate is not linked // into the root namespace. - [ast_map::path_mod(@cdata.name)] + path + [ast_map::path_mod(@cdata.name)]/~ + path } enum found_ast { @@ -109,7 +109,8 @@ fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::def_id, decode_inlined_item) } -fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] { +fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) + -> [ty::variant_info]/~ { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); ret decoder::get_enum_variants(cdata, def.node, tcx) @@ -117,20 +118,20 @@ fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] { fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id, name: option<ast::ident>) - -> @[@decoder::_impl] { + -> @[@decoder::_impl]/~ { let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_impls_for_mod(cdata, def.node, name) {|cnum| cstore::get_crate_data(cstore, cnum) } } -fn get_iface_methods(tcx: ty::ctxt, def: ast::def_id) -> @[ty::method] { +fn get_iface_methods(tcx: ty::ctxt, def: ast::def_id) -> @[ty::method]/~ { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_iface_methods(cdata, def.node, tcx) } -fn get_class_fields(tcx: ty::ctxt, def: ast::def_id) -> [ty::field_ty] { +fn get_class_fields(tcx: ty::ctxt, def: ast::def_id) -> [ty::field_ty]/~ { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); decoder::get_class_fields(cdata, def.node) @@ -159,7 +160,7 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, class_id, def)}); #debug("got field data %?", the_field); let ty = decoder::item_type(def, the_field, tcx, cdata); - ret {bounds: @[], rp: ast::rp_none, ty: ty}; + ret {bounds: @[]/~, rp: ast::rp_none, ty: ty}; } // Given a def_id for an impl or class, return the iface it implements, diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index ebfa8df3b10..7f7468faea5 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -40,7 +40,7 @@ type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>; type mod_path_map = map::hashmap<ast::def_id, @str>; type crate_metadata = @{name: str, - data: @[u8], + data: @[u8]/~, cnum_map: cnum_map, cnum: ast::crate_num}; @@ -55,9 +55,9 @@ type cstore_private = @{metas: map::hashmap<ast::crate_num, crate_metadata>, use_crate_map: use_crate_map, mod_path_map: mod_path_map, - mut used_crate_files: [str], - mut used_libraries: [str], - mut used_link_args: [str]}; + mut used_crate_files: [str]/~, + mut used_libraries: [str]/~, + mut 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>; @@ -74,9 +74,9 @@ fn mk_cstore() -> cstore { ret private(@{metas: meta_cache, use_crate_map: crate_map, mod_path_map: mod_path_map, - mut used_crate_files: [], - mut used_libraries: [], - mut used_link_args: []}); + mut used_crate_files: []/~, + mut used_libraries: []/~, + mut used_link_args: []/~}); } fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata { @@ -113,11 +113,11 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) { fn add_used_crate_file(cstore: cstore, lib: str) { if !vec::contains(p(cstore).used_crate_files, lib) { - p(cstore).used_crate_files += [lib]; + p(cstore).used_crate_files += [lib]/~; } } -fn get_used_crate_files(cstore: cstore) -> [str] { +fn get_used_crate_files(cstore: cstore) -> [str]/~ { ret p(cstore).used_crate_files; } @@ -125,11 +125,11 @@ fn add_used_library(cstore: cstore, lib: str) -> bool { assert lib != ""; if vec::contains(p(cstore).used_libraries, lib) { ret false; } - p(cstore).used_libraries += [lib]; + p(cstore).used_libraries += [lib]/~; ret true; } -fn get_used_libraries(cstore: cstore) -> [str] { +fn get_used_libraries(cstore: cstore) -> [str]/~ { ret p(cstore).used_libraries; } @@ -137,7 +137,7 @@ fn add_used_link_args(cstore: cstore, args: str) { p(cstore).used_link_args += str::split_char(args, ' '); } -fn get_used_link_args(cstore: cstore) -> [str] { +fn get_used_link_args(cstore: cstore) -> [str]/~ { ret p(cstore).used_link_args; } @@ -153,15 +153,15 @@ fn find_use_stmt_cnum(cstore: cstore, // returns hashes of crates directly used by this crate. Hashes are // sorted by crate name. -fn get_dep_hashes(cstore: cstore) -> [@str] { +fn get_dep_hashes(cstore: cstore) -> [@str]/~ { type crate_hash = {name: @str, hash: @str}; - let mut result = []; + let mut result = []/~; for p(cstore).use_crate_map.each_value {|cnum| let cdata = cstore::get_crate_data(cstore, cnum); let hash = decoder::get_crate_hash(cdata.data); #debug("Add hash[%s]: %s", cdata.name, *hash); - result += [{name: @cdata.name, hash: hash}]; + result += [{name: @cdata.name, hash: hash}]/~; }; fn lteq(a: crate_hash, b: crate_hash) -> bool { ret *a.name <= *b.name; @@ -175,9 +175,9 @@ fn get_dep_hashes(cstore: cstore) -> [@str] { ret vec::map(sorted, mapper); } -fn get_path(cstore: cstore, d: ast::def_id) -> [ast::ident] { +fn get_path(cstore: cstore, d: ast::def_id) -> [ast::ident]/~ { // let f = bind str::split_str(_, "::"); - option::map_default(p(cstore).mod_path_map.find(d), [], + option::map_default(p(cstore).mod_path_map.find(d), []/~, {|ds| str::split_str(*ds, "::").map({|x|@x})}) } // Local Variables: diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 8f25281f4a8..9979bda226c 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -53,8 +53,8 @@ export translate_def_id; // what crate that's in and give us a def_id that makes sense for the current // build. -fn lookup_hash(d: ebml::doc, eq_fn: fn@([u8]) -> bool, hash: uint) -> - [ebml::doc] { +fn lookup_hash(d: ebml::doc, eq_fn: fn@([u8]/~) -> bool, hash: uint) -> + [ebml::doc]/~ { let index = ebml::get_doc(d, tag_index); let table = ebml::get_doc(index, tag_index_table); let hash_pos = table.start + hash % 256u * 4u; @@ -62,19 +62,19 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn@([u8]) -> bool, hash: uint) -> let {tag:_, doc:bucket} = ebml::doc_at(d.data, pos); // Awkward logic because we can't ret from foreach yet - let mut result: [ebml::doc] = []; + let mut result: [ebml::doc]/~ = []/~; let belt = tag_index_buckets_bucket_elt; ebml::tagged_docs(bucket, belt) {|elt| let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint; if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) { - result += [ebml::doc_at(d.data, pos).doc]; + result += [ebml::doc_at(d.data, pos).doc]/~; } }; ret result; } fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> { - fn eq_item(bytes: [u8], item_id: int) -> bool { + fn eq_item(bytes: [u8]/~, item_id: int) -> bool { ret io::u64_from_be_bytes(bytes, 0u, 4u) as int == item_id; } let eqer = {|a|eq_item(a, item_id)}; @@ -90,7 +90,7 @@ fn find_item(item_id: int, items: ebml::doc) -> ebml::doc { // Looks up an item in the given metadata and returns an ebml doc pointing // to the item data. -fn lookup_item(item_id: int, data: @[u8]) -> ebml::doc { +fn lookup_item(item_id: int, data: @[u8]/~) -> ebml::doc { let items = ebml::get_doc(ebml::doc(data), tag_items); alt maybe_find_item(item_id, items) { none { fail(#fmt("lookup_item: id not found: %d", item_id)); } @@ -164,13 +164,13 @@ fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) } fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) - -> @[ty::param_bounds] { - let mut bounds = []; + -> @[ty::param_bounds]/~ { + let mut bounds = []/~; ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) {|p| let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, {|did| translate_def_id(cdata, did) }); - bounds += [bd]; + bounds += [bd]/~; } @bounds } @@ -194,31 +194,31 @@ fn item_ty_param_count(item: ebml::doc) -> uint { n } -fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> [ast::def_id] { - let mut ids: [ast::def_id] = []; +fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> [ast::def_id]/~ { + let mut ids: [ast::def_id]/~ = []/~; let v = tag_items_data_item_variant; ebml::tagged_docs(item, v) {|p| let ext = parse_def_id(ebml::doc_data(p)); - ids += [{crate: cdata.cnum, node: ext.node}]; + ids += [{crate: cdata.cnum, node: ext.node}]/~; }; ret ids; } // Given a path and serialized crate metadata, returns the IDs of the // definitions the path may refer 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::from_bytes(data), s); } let s = ast_util::path_name_i(path); let md = ebml::doc(data); let paths = ebml::get_doc(md, tag_paths); let eqer = {|a|eq_item(a, s)}; - let mut result: [ast::def_id] = []; + let mut result: [ast::def_id]/~ = []/~; #debug("resolve_path: looking up %s", s); for lookup_hash(paths, eqer, hash_path(s)).each {|doc| let did_doc = ebml::get_doc(doc, tag_def_id); - result += [parse_def_id(ebml::doc_data(did_doc))]; + result += [parse_def_id(ebml::doc_data(did_doc))]/~; } ret result; } @@ -229,16 +229,16 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path { let len_doc = ebml::get_doc(path_doc, tag_path_len); let len = ebml::doc_as_u32(len_doc) as uint; - let mut result = []; + let mut result = []/~; vec::reserve(result, len); ebml::docs(path_doc) {|tag, elt_doc| if tag == tag_path_elt_mod { let str = ebml::doc_as_str(elt_doc); - result += [ast_map::path_mod(@str)]; + result += [ast_map::path_mod(@str)]/~; } else if tag == tag_path_elt_name { let str = ebml::doc_as_str(elt_doc); - result += [ast_map::path_name(@str)]; + result += [ast_map::path_name(@str)]/~; } else { // ignore tag_path_len element } @@ -252,11 +252,11 @@ fn item_name(item: ebml::doc) -> ast::ident { @str::from_bytes(ebml::doc_data(name)) } -fn lookup_item_name(data: @[u8], id: ast::node_id) -> ast::ident { +fn lookup_item_name(data: @[u8]/~, id: ast::node_id) -> ast::ident { item_name(lookup_item(id, data)) } -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); @@ -288,12 +288,12 @@ fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let t = item_type({crate: cdata.cnum, node: id}, item, tcx, cdata); let tp_bounds = if family_has_type_params(item_family(item)) { item_ty_param_bounds(item, tcx, cdata) - } else { @[] }; + } else { @[]/~ }; let rp = item_ty_region_param(item); ret {bounds: tp_bounds, rp: rp, 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 { item_ty_param_count(lookup_item(id, data)) } @@ -351,7 +351,7 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> { found } -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)); } @@ -392,11 +392,11 @@ fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt, } fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) - -> [ty::variant_info] { + -> [ty::variant_info]/~ { let data = cdata.data; let items = ebml::get_doc(ebml::doc(data), tag_items); let item = find_item(id, items); - let mut infos: [ty::variant_info] = []; + let mut infos: [ty::variant_info]/~ = []/~; let variant_ids = enum_variant_ids(item, cdata); let mut disr_val = 0; for variant_ids.each {|did| @@ -404,10 +404,10 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let ctor_ty = item_type({crate: cdata.cnum, node: id}, item, tcx, cdata); let name = item_name(item); - let mut arg_tys: [ty::t] = []; + let mut arg_tys: [ty::t]/~ = []/~; alt ty::get(ctor_ty).struct { ty::ty_fn(f) { - for f.inputs.each {|a| arg_tys += [a.ty]; } + for f.inputs.each {|a| arg_tys += [a.ty]/~; } } _ { /* Nullary enum variant. */ } } @@ -416,7 +416,7 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) _ { /* empty */ } } infos += [@{args: arg_tys, ctor_ty: ctor_ty, name: name, - id: did, disr_val: disr_val}]; + id: did, disr_val: disr_val}]/~; disr_val += 1; } ret infos; @@ -424,18 +424,18 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) // NB: These types are duplicated in resolve.rs type method_info = {did: ast::def_id, n_tps: uint, ident: ast::ident}; -type _impl = {did: ast::def_id, ident: ast::ident, methods: [@method_info]}; +type _impl = {did: ast::def_id, ident: ast::ident, methods: [@method_info]/~}; fn item_impl_methods(cdata: cmd, item: ebml::doc, base_tps: uint) - -> [@method_info] { - let mut rslt = []; + -> [@method_info]/~ { + let mut rslt = []/~; ebml::tagged_docs(item, tag_item_impl_method) {|doc| let m_did = parse_def_id(ebml::doc_data(doc)); let mth_item = lookup_item(m_did.node, cdata.data); rslt += [@{did: translate_def_id(cdata, m_did), /* FIXME (maybe #2323) tjc: take a look at this. */ n_tps: item_ty_param_count(mth_item) - base_tps, - ident: item_name(mth_item)}]; + ident: item_name(mth_item)}]/~; } rslt } @@ -443,10 +443,10 @@ fn item_impl_methods(cdata: cmd, item: ebml::doc, base_tps: uint) fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id, name: option<ast::ident>, get_cdata: fn(ast::crate_num) -> cmd) - -> @[@_impl] { + -> @[@_impl]/~ { let data = cdata.data; let mod_item = lookup_item(m_id, data); - let mut result = []; + let mut result = []/~; ebml::tagged_docs(mod_item, tag_mod_impl) {|doc| let did = parse_def_id(ebml::doc_data(doc)); let local_did = translate_def_id(cdata, did); @@ -461,7 +461,7 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id, result += [@{ did: local_did, ident: nm, methods: item_impl_methods(impl_cdata, item, base_tps) - }]; + }]/~; }; } @result @@ -469,10 +469,10 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id, /* Works for both classes and ifaces */ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) - -> @[ty::method] { + -> @[ty::method]/~ { let data = cdata.data; let item = lookup_item(id, data); - let mut result = []; + let mut result = []/~; ebml::tagged_docs(item, tag_item_iface_method) {|mth| let bounds = item_ty_param_bounds(mth, tcx, cdata); let name = item_name(mth); @@ -487,17 +487,17 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) 'u' { ast::unsafe_fn } 'f' { ast::impure_fn } 'p' { ast::pure_fn } - }, vis: ast::public}]; + }, vis: ast::public}]/~; } @result } // Helper function that gets either fields or methods fn get_class_members(cdata: cmd, id: ast::node_id, - p: fn(char) -> bool) -> [ty::field_ty] { + p: fn(char) -> bool) -> [ty::field_ty]/~ { let data = cdata.data; let item = lookup_item(id, data); - let mut result = []; + let mut result = []/~; ebml::tagged_docs(item, tag_item_field) {|an_item| let f = item_family(an_item); if p(f) { @@ -505,7 +505,7 @@ fn get_class_members(cdata: cmd, id: ast::node_id, let did = class_member_id(an_item, cdata); let mt = field_mutability(an_item); result += [{ident: name, id: did, vis: - family_to_visibility(f), mutability: mt}]; + family_to_visibility(f), mutability: mt}]/~; } } result @@ -519,7 +519,7 @@ pure fn family_to_visibility(family: char) -> ast::visibility { } /* 'g' for public field, 'j' for private field */ -fn get_class_fields(cdata: cmd, id: ast::node_id) -> [ty::field_ty] { +fn get_class_fields(cdata: cmd, id: ast::node_id) -> [ty::field_ty]/~ { get_class_members(cdata, id, {|f| f == 'g' || f == 'j'}) } @@ -576,12 +576,12 @@ fn item_family_to_str(fam: char) -> str { } } -fn get_meta_items(md: ebml::doc) -> [@ast::meta_item] { - let mut items: [@ast::meta_item] = []; +fn get_meta_items(md: ebml::doc) -> [@ast::meta_item]/~ { + let mut items: [@ast::meta_item]/~ = []/~; ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc| let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let n = str::from_bytes(ebml::doc_data(nd)); - items += [attr::mk_word_item(@n)]; + items += [attr::mk_word_item(@n)]/~; }; ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc| let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); @@ -590,19 +590,19 @@ fn get_meta_items(md: ebml::doc) -> [@ast::meta_item] { let v = str::from_bytes(ebml::doc_data(vd)); // FIXME (#623): Should be able to decode meta_name_value variants, // but currently the encoder just drops them - items += [attr::mk_name_value_item_str(@n, v)]; + items += [attr::mk_name_value_item_str(@n, v)]/~; }; ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc| let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let n = str::from_bytes(ebml::doc_data(nd)); let subitems = get_meta_items(meta_item_doc); - items += [attr::mk_list_item(@n, subitems)]; + items += [attr::mk_list_item(@n, subitems)]/~; }; ret items; } -fn get_attributes(md: ebml::doc) -> [ast::attribute] { - let mut attrs: [ast::attribute] = []; +fn get_attributes(md: ebml::doc) -> [ast::attribute]/~ { + let mut attrs: [ast::attribute]/~ = []/~; alt ebml::maybe_get_doc(md, tag_attributes) { option::some(attrs_d) { ebml::tagged_docs(attrs_d, tag_attribute) {|attr_doc| @@ -613,7 +613,7 @@ fn get_attributes(md: ebml::doc) -> [ast::attribute] { let meta_item = meta_items[0]; attrs += [{node: {style: ast::attr_outer, value: *meta_item}, - span: ast_util::dummy_sp()}]; + span: ast_util::dummy_sp()}]/~; }; } option::none { } @@ -637,15 +637,15 @@ fn list_crate_attributes(md: ebml::doc, hash: @str, out: io::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(ebml::doc(data)); } type crate_dep = {cnum: ast::crate_num, name: ast::ident, vers: @str, hash: @str}; -fn get_crate_deps(data: @[u8]) -> [crate_dep] { - let mut deps: [crate_dep] = []; +fn get_crate_deps(data: @[u8]/~) -> [crate_dep]/~ { + let mut deps: [crate_dep]/~ = []/~; let cratedoc = ebml::doc(data); let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps); let mut crate_num = 1; @@ -656,13 +656,13 @@ fn get_crate_deps(data: @[u8]) -> [crate_dep] { deps += [{cnum: crate_num, name: @docstr(depdoc, tag_crate_dep_name), vers: @docstr(depdoc, tag_crate_dep_vers), - hash: @docstr(depdoc, tag_crate_dep_hash)}]; + hash: @docstr(depdoc, tag_crate_dep_hash)}]/~; crate_num += 1; }; ret deps; } -fn list_crate_deps(data: @[u8], out: io::writer) { +fn list_crate_deps(data: @[u8]/~, out: io::writer) { out.write_str("=External Dependencies=\n"); for get_crate_deps(data).each {|dep| @@ -673,13 +673,13 @@ fn list_crate_deps(data: @[u8], out: io::writer) { out.write_str("\n"); } -fn get_crate_hash(data: @[u8]) -> @str { +fn get_crate_hash(data: @[u8]/~) -> @str { let cratedoc = ebml::doc(data); let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash); ret @str::from_bytes(ebml::doc_data(hashdoc)); } -fn get_crate_vers(data: @[u8]) -> @str { +fn get_crate_vers(data: @[u8]/~) -> @str { let attrs = decoder::get_crate_attributes(data); ret alt attr::last_meta_item_value_str_by_name( attr::find_linkage_metas(attrs), "vers") { @@ -688,7 +688,7 @@ fn get_crate_vers(data: @[u8]) -> @str { }; } -fn list_crate_items(bytes: @[u8], md: ebml::doc, out: io::writer) { +fn list_crate_items(bytes: @[u8]/~, md: ebml::doc, out: io::writer) { out.write_str("=Items=\n"); let items = ebml::get_doc(md, tag_items); iter_crate_items(bytes) {|path, did| @@ -697,7 +697,7 @@ fn list_crate_items(bytes: @[u8], md: ebml::doc, out: io::writer) { out.write_str("\n"); } -fn iter_crate_items(bytes: @[u8], proc: fn(str, ast::def_id)) { +fn iter_crate_items(bytes: @[u8]/~, proc: fn(str, ast::def_id)) { let md = ebml::doc(bytes); let paths = ebml::get_doc(md, tag_paths); let index = ebml::get_doc(paths, tag_index); @@ -714,14 +714,14 @@ fn iter_crate_items(bytes: @[u8], proc: fn(str, ast::def_id)) { }; } -fn get_crate_module_paths(bytes: @[u8]) -> [(ast::def_id, str)] { +fn get_crate_module_paths(bytes: @[u8]/~) -> [(ast::def_id, str)]/~ { fn mod_of_path(p: str) -> str { str::connect(vec::init(str::split_str(p, "::")), "::") } // find all module (path, def_ids), which are not // fowarded path due to renamed import or reexport - let mut res = []; + let mut res = []/~; let mods = map::str_hash(); iter_crate_items(bytes) {|path, did| let m = mod_of_path(path); @@ -732,7 +732,7 @@ fn get_crate_module_paths(bytes: @[u8]) -> [(ast::def_id, str)] { // Collect everything by now. There might be multiple // paths pointing to the same did. Those will be // unified later by using the mods map - res += [(did, path)]; + res += [(did, path)]/~; } ret vec::filter(res) {|x| let (_, xp) = x; @@ -740,7 +740,7 @@ fn get_crate_module_paths(bytes: @[u8]) -> [(ast::def_id, str)] { } } -fn list_crate_metadata(bytes: @[u8], out: io::writer) { +fn list_crate_metadata(bytes: @[u8]/~, out: io::writer) { let hash = get_crate_hash(bytes); let md = ebml::doc(bytes); list_crate_attributes(md, hash, out); diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 8390989e7dd..c9802da3b03 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -43,8 +43,8 @@ type encode_parms = { diag: span_handler, tcx: ty::ctxt, reachable: hashmap<ast::node_id, ()>, - reexports: [(str, def_id)], - impl_map: fn@(ast::node_id) -> [(ident, def_id)], + reexports: [(str, def_id)]/~, + impl_map: fn@(ast::node_id) -> [(ident, def_id)]/~, item_symbols: hashmap<ast::node_id, str>, discrim_symbols: hashmap<ast::node_id, str>, link_meta: link_meta, @@ -56,8 +56,8 @@ enum encode_ctxt = { diag: span_handler, tcx: ty::ctxt, reachable: hashmap<ast::node_id, ()>, - reexports: [(str, def_id)], - impl_map: fn@(ast::node_id) -> [(ident, def_id)], + reexports: [(str, def_id)]/~, + impl_map: fn@(ast::node_id) -> [(ident, def_id)]/~, item_symbols: hashmap<ast::node_id, str>, discrim_symbols: hashmap<ast::node_id, str>, link_meta: link_meta, @@ -108,8 +108,8 @@ fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) { type entry<T> = {val: T, pos: uint}; -fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant], - path: [ident], &index: [entry<str>]) { +fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant]/~, + path: [ident]/~, &index: [entry<str>]/~) { for variants.each {|variant| add_to_index(ebml_w, path, index, variant.node.name); ebml_w.wr_tag(tag_paths_data_item) {|| @@ -119,15 +119,15 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant], } } -fn add_to_index(ebml_w: ebml::writer, path: [ident], &index: [entry<str>], +fn add_to_index(ebml_w: ebml::writer, path: [ident]/~, &index: [entry<str>]/~, name: ident) { - let full_path = path + [name]; - index += - [{val: ast_util::path_name_i(full_path), pos: ebml_w.writer.tell()}]; + let full_path = path + [name]/~; + vec::push(index, {val: ast_util::path_name_i(full_path), + pos: ebml_w.writer.tell()}); } fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod, - path: [ident], &index: [entry<str>]) { + path: [ident]/~, &index: [entry<str>]/~) { for nmod.items.each {|nitem| add_to_index(ebml_w, path, index, nitem.ident); encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id)); @@ -135,7 +135,7 @@ fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod, } fn encode_class_item_paths(ebml_w: ebml::writer, - items: [@class_member], path: [ident], &index: [entry<str>]) { + items: [@class_member]/~, path: [ident]/~, &index: [entry<str>]/~) { for items.each {|it| alt ast_util::class_member_visibility(it) { private { cont; } @@ -152,8 +152,8 @@ fn encode_class_item_paths(ebml_w: ebml::writer, } fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, - module: _mod, path: [ident], - &index: [entry<str>]) { + module: _mod, path: [ident]/~, + &index: [entry<str>]/~) { for module.items.each {|it| if !reachable(ecx, it.id) || !ast_util::is_exported(it.ident, module) { cont; } @@ -170,7 +170,8 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, item_mod(_mod) { ebml_w.wr_tag(tag_paths_data_mod) {|| encode_name_and_def_id(ebml_w, it.ident, it.id); - encode_module_item_paths(ebml_w, ecx, _mod, path + [it.ident], + encode_module_item_paths(ebml_w, ecx, _mod, + path + [it.ident]/~, index); } } @@ -178,7 +179,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, ebml_w.wr_tag(tag_paths_data_mod) {|| encode_name_and_def_id(ebml_w, it.ident, it.id); encode_native_module_item_paths(ebml_w, nmod, - path + [it.ident], index); + path + [it.ident]/~, index); } } item_ty(_, tps, _) { @@ -196,7 +197,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, add_to_index(ebml_w, path, index, it.ident); encode_named_def_id(ebml_w, it.ident, local_def(ctor.node.id)); - encode_class_item_paths(ebml_w, items, path + [it.ident], + encode_class_item_paths(ebml_w, items, path + [it.ident]/~, index); } } @@ -223,9 +224,9 @@ fn encode_iface_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @iface_ref) { } fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate) - -> [entry<str>] { - let mut index: [entry<str>] = []; - let mut path: [ident] = []; + -> [entry<str>]/~ { + let mut index: [entry<str>]/~ = []/~; + let mut path: [ident]/~ = []/~; ebml_w.start_tag(tag_paths); encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index); encode_reexport_paths(ebml_w, ecx, index); @@ -234,10 +235,10 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate) } fn encode_reexport_paths(ebml_w: ebml::writer, - ecx: @encode_ctxt, &index: [entry<str>]) { + ecx: @encode_ctxt, &index: [entry<str>]/~) { for ecx.reexports.each {|reexport| let (path, def_id) = reexport; - index += [{val: path, pos: ebml_w.writer.tell()}]; + index += [{val: path, pos: ebml_w.writer.tell()}]/~; ebml_w.start_tag(tag_paths_data_item); encode_name(ebml_w, @path); encode_def_id(ebml_w, def_id); @@ -256,7 +257,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) { fn def_to_str(did: def_id) -> str { ret #fmt["%d:%d", did.crate, did.node]; } fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt, - params: [ty_param]) { + params: [ty_param]/~) { let ty_str_ctxt = @{diag: ecx.diag, ds: def_to_str, tcx: ecx.tcx, @@ -324,14 +325,14 @@ fn encode_parent_item(ebml_w: ebml::writer, id: def_id) { } fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer, - id: node_id, variants: [variant], - path: ast_map::path, index: @mut [entry<int>], - ty_params: [ty_param]) { + id: node_id, variants: [variant]/~, + path: ast_map::path, index: @mut [entry<int>]/~, + ty_params: [ty_param]/~) { let mut disr_val = 0; let mut i = 0; let vi = ty::enum_variants(ecx.tcx, {crate: local_crate, node: id}); for variants.each {|variant| - *index += [{val: variant.node.id, pos: ebml_w.writer.tell()}]; + *index += [{val: variant.node.id, pos: ebml_w.writer.tell()}]/~; ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(variant.node.id)); encode_family(ebml_w, 'v'); @@ -420,20 +421,20 @@ fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) { /* Returns an index of items in this class */ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id, path: ast_map::path, - class_tps: [ty_param], - items: [@class_member], - global_index: @mut[entry<int>]) -> [entry<int>] { + class_tps: [ty_param]/~, + items: [@class_member]/~, + global_index: @mut[entry<int>]/~) -> [entry<int>]/~ { /* Each class has its own index, since different classes may have fields with the same name */ - let index = @mut []; + let index = @mut []/~; let tcx = ecx.tcx; for items.each {|ci| /* We encode both private and public fields -- need to include private fields to get the offsets right */ alt ci.node { instance_var(nm, _, mt, id, vis) { - *index += [{val: id, pos: ebml_w.writer.tell()}]; - *global_index += [{val: id, pos: ebml_w.writer.tell()}]; + *index += [{val: id, pos: ebml_w.writer.tell()}]/~; + *global_index += [{val: id, pos: ebml_w.writer.tell()}]/~; ebml_w.start_tag(tag_items_data_item); #debug("encode_info_for_class: doing %s %d", *nm, id); encode_visibility(ebml_w, vis); @@ -447,9 +448,9 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, class_method(m) { alt m.vis { public { - *index += [{val: m.id, pos: ebml_w.writer.tell()}]; - *global_index += [{val: m.id, pos: ebml_w.writer.tell()}]; - let impl_path = path + [ast_map::path_name(m.ident)]; + *index += [{val: m.id, pos: ebml_w.writer.tell()}]/~; + *global_index += [{val: m.id, pos: ebml_w.writer.tell()}]/~; + let impl_path = path + [ast_map::path_name(m.ident)]/~; #debug("encode_info_for_class: doing %s %d", *m.ident, m.id); encode_info_for_method(ecx, ebml_w, impl_path, should_inline(m.attrs), id, m, @@ -465,7 +466,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id, ident: ident, path: ast_map::path, - item: option<inlined_item>, tps: [ty_param], + item: option<inlined_item>, tps: [ty_param]/~, decl: fn_decl) { ebml_w.start_tag(tag_items_data_item); encode_name(ebml_w, ident); @@ -491,7 +492,7 @@ fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer, fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer, impl_path: ast_map::path, should_inline: bool, parent_id: node_id, - m: @method, all_tps: [ty_param]) { + m: @method, all_tps: [ty_param]/~) { #debug("encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len()); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(m.id)); @@ -520,7 +521,7 @@ fn purity_fn_family(p: purity) -> char { } -fn should_inline(attrs: [attribute]) -> bool { +fn should_inline(attrs: [attribute]/~) -> bool { alt attr::find_inline_attr(attrs) { attr::ia_none { false } attr::ia_hint | attr::ia_always { true } @@ -529,7 +530,7 @@ fn should_inline(attrs: [attribute]) -> bool { fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, - index: @mut [entry<int>], path: ast_map::path) { + index: @mut [entry<int>]/~, path: ast_map::path) { let tcx = ecx.tcx; let must_write = @@ -537,8 +538,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, if !must_write && !reachable(ecx, item.id) { ret; } fn add_to_index_(item: @item, ebml_w: ebml::writer, - index: @mut [entry<int>]) { - *index += [{val: item.id, pos: ebml_w.writer.tell()}]; + index: @mut [entry<int>]/~) { + *index += [{val: item.id, pos: ebml_w.writer.tell()}]/~; } let add_to_index = {|copy ebml_w|add_to_index_(item, ebml_w, index)}; @@ -620,7 +621,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, items, index); /* Encode the dtor */ option::iter(m_dtor) {|dtor| - *index += [{val: dtor.node.id, pos: ebml_w.writer.tell()}]; + *index += [{val: dtor.node.id, pos: ebml_w.writer.tell()}]/~; encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident + "_dtor"), path, if tps.len() > 0u { some(ii_dtor(dtor, item.ident, tps, @@ -707,9 +708,9 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_path(ebml_w, path, ast_map::path_name(item.ident)); ebml_w.end_tag(); - let impl_path = path + [ast_map::path_name(item.ident)]; + let impl_path = path + [ast_map::path_name(item.ident)]/~; for methods.each {|m| - *index += [{val: m.id, pos: ebml_w.writer.tell()}]; + *index += [{val: m.id, pos: ebml_w.writer.tell()}]/~; encode_info_for_method(ecx, ebml_w, impl_path, should_inline(m.attrs), item.id, m, tps + m.tps); } @@ -741,10 +742,10 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer, nitem: @native_item, - index: @mut [entry<int>], + index: @mut [entry<int>]/~, path: ast_map::path, abi: native_abi) { if !reachable(ecx, nitem.id) { ret; } - *index += [{val: nitem.id, pos: ebml_w.writer.tell()}]; + *index += [{val: nitem.id, pos: ebml_w.writer.tell()}]/~; ebml_w.start_tag(tag_items_data_item); alt nitem.node { @@ -766,12 +767,12 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer, } fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, - crate: @crate) -> [entry<int>] { - let index = @mut []; + crate: @crate) -> [entry<int>]/~ { + let index = @mut []/~; ebml_w.start_tag(tag_items_data); - *index += [{val: crate_node_id, pos: ebml_w.writer.tell()}]; + *index += [{val: crate_node_id, pos: ebml_w.writer.tell()}]/~; encode_info_for_mod(ecx, ebml_w, crate.node.module, - crate_node_id, [], @""); + crate_node_id, []/~, @""); visit::visit_crate(*crate, (), visit::mk_vt(@{ visit_expr: {|_e, _cx, _v|}, visit_item: {|i, cx, v, copy ebml_w| @@ -784,7 +785,8 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, item_class(tps, _, _, ctor, m_dtor, _) { #debug("encoding info for ctor %s %d", *i.ident, ctor.node.id); - *index += [{val: ctor.node.id, pos: ebml_w.writer.tell()}]; + *index += + [{val: ctor.node.id, pos: ebml_w.writer.tell()}]/~; encode_info_for_fn(ecx, ebml_w, ctor.node.id, i.ident, *pt, if tps.len() > 0u { some(ii_ctor(ctor, i.ident, tps, @@ -813,30 +815,30 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, // Path and definition ID indexing -fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) -> - [@[entry<T>]] { - let mut buckets: [@mut [entry<T>]] = []; - for uint::range(0u, 256u) {|_i| buckets += [@mut []]; }; +fn create_index<T: copy>(index: [entry<T>]/~, hash_fn: fn@(T) -> uint) -> + [@[entry<T>]/~]/~ { + let mut buckets: [@mut [entry<T>]/~]/~ = []/~; + for uint::range(0u, 256u) {|_i| buckets += [@mut []/~]/~; }; for index.each {|elt| let h = hash_fn(elt.val); - *buckets[h % 256u] += [elt]; + vec::push(*buckets[h % 256u], elt); } - let mut buckets_frozen = []; + let mut buckets_frozen = []/~; for buckets.each {|bucket| - buckets_frozen += [@*bucket]; + vec::push(buckets_frozen, @*bucket); } ret buckets_frozen; } -fn encode_index<T>(ebml_w: ebml::writer, buckets: [@[entry<T>]], +fn encode_index<T>(ebml_w: ebml::writer, buckets: [@[entry<T>]/~]/~, write_fn: fn(io::writer, T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); - let mut bucket_locs: [uint] = []; + let mut bucket_locs: [uint]/~ = []/~; ebml_w.start_tag(tag_index_buckets); for buckets.each {|bucket| - bucket_locs += [ebml_w.writer.tell()]; + bucket_locs += [ebml_w.writer.tell()]/~; ebml_w.start_tag(tag_index_buckets_bucket); for vec::each(*bucket) {|elt| ebml_w.start_tag(tag_index_buckets_bucket_elt); @@ -896,7 +898,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) { } } -fn encode_attributes(ebml_w: ebml::writer, attrs: [attribute]) { +fn encode_attributes(ebml_w: ebml::writer, attrs: [attribute]/~) { ebml_w.start_tag(tag_attributes); for attrs.each {|attr| ebml_w.start_tag(tag_attribute); @@ -910,9 +912,9 @@ fn encode_attributes(ebml_w: ebml::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.link_meta.name != ""); @@ -929,47 +931,47 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> [attribute] { attr::remove_meta_items_by_name(tmp, @"vers") }; - let meta_items = [name_item, vers_item] + other_items; + let meta_items = [name_item, vers_item]/~ + other_items; let link_item = attr::mk_list_item(@"link", meta_items); ret attr::mk_attr(link_item); } - let mut attrs: [attribute] = []; + let mut attrs: [attribute]/~ = []/~; let mut found_link_attr = false; for crate.node.attrs.each {|attr| attrs += if *attr::get_attr_name(attr) != "link" { - [attr] + [attr]/~ } else { alt attr.node.value.node { meta_list(n, l) { found_link_attr = true;; - [synthesize_link_attr(ecx, l)] + [synthesize_link_attr(ecx, l)]/~ } - _ { [attr] } + _ { [attr]/~ } } }; } - if !found_link_attr { attrs += [synthesize_link_attr(ecx, [])]; } + if !found_link_attr { attrs += [synthesize_link_attr(ecx, []/~)]/~; } ret attrs; } fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) { - fn get_ordered_deps(cstore: cstore::cstore) -> [decoder::crate_dep] { + fn get_ordered_deps(cstore: cstore::cstore) -> [decoder::crate_dep]/~ { type hashkv = @{key: crate_num, val: cstore::crate_metadata}; type numdep = decoder::crate_dep; // Pull the cnums and name,vers,hash out of cstore - let mut deps: [mut numdep] = [mut]; + let mut deps: [mut numdep]/~ = [mut]/~; cstore::iter_crate_data(cstore) {|key, val| let dep = {cnum: key, name: @val.name, vers: decoder::get_crate_vers(val.data), hash: decoder::get_crate_hash(val.data)}; - deps += [mut dep]; + deps += [mut dep]/~; }; // Sort by cnum @@ -1018,7 +1020,7 @@ fn encode_hash(ebml_w: ebml::writer, hash: str) { ebml_w.end_tag(); } -fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8] { +fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8]/~ { let ecx: @encode_ctxt = @encode_ctxt({ diag: parms.diag, tcx: parms.tcx, diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index eeb44f80fd7..c66c02bce9c 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -25,29 +25,29 @@ fn pick_file(file: path, path: path) -> option<path> { iface filesearch { fn sysroot() -> path; - fn lib_search_paths() -> [path]; + fn lib_search_paths() -> [path]/~; fn get_target_lib_path() -> path; fn get_target_lib_file_path(file: path) -> path; } fn mk_filesearch(maybe_sysroot: option<path>, target_triple: str, - addl_lib_search_paths: [path]) -> filesearch { + addl_lib_search_paths: [path]/~) -> filesearch { type filesearch_impl = {sysroot: path, - addl_lib_search_paths: [path], + addl_lib_search_paths: [path]/~, target_triple: str}; impl of filesearch for filesearch_impl { fn sysroot() -> path { self.sysroot } - fn lib_search_paths() -> [path] { + fn lib_search_paths() -> [path]/~ { self.addl_lib_search_paths - + [make_target_lib_path(self.sysroot, self.target_triple)] + + [make_target_lib_path(self.sysroot, self.target_triple)]/~ + alt get_cargo_lib_path_nearest() { - result::ok(p) { [p] } - result::err(p) { [] } + result::ok(p) { [p]/~ } + result::err(p) { []/~ } } + alt get_cargo_lib_path() { - result::ok(p) { [p] } - result::err(p) { [] } + result::ok(p) { [p]/~ } + result::err(p) { []/~ } } } fn get_target_lib_path() -> path { @@ -85,13 +85,13 @@ fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option<T> { ret rslt; } -fn relative_target_lib_path(target_triple: str) -> [path] { - [libdir(), "rustc", target_triple, libdir()] +fn relative_target_lib_path(target_triple: str) -> [path]/~ { + [libdir(), "rustc", target_triple, libdir()]/~ } fn make_target_lib_path(sysroot: path, target_triple: str) -> path { - let path = [sysroot] + relative_target_lib_path(target_triple); + let path = [sysroot]/~ + relative_target_lib_path(target_triple); let path = path::connect_many(path); ret path; } @@ -113,7 +113,7 @@ fn get_sysroot(maybe_sysroot: option<path>) -> path { } fn get_cargo_sysroot() -> result<path, str> { - let path = [get_default_sysroot(), libdir(), "cargo"]; + let path = [get_default_sysroot(), libdir(), "cargo"]/~; result::ok(path::connect_many(path)) } diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index a5874aa29fa..e7fbdb96d56 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -33,13 +33,13 @@ type ctxt = { filesearch: filesearch, span: span, ident: ast::ident, - metas: [@ast::meta_item], + metas: [@ast::meta_item]/~, hash: str, os: os, static: bool }; -fn load_library_crate(cx: ctxt) -> {ident: str, data: @[u8]} { +fn load_library_crate(cx: ctxt) -> {ident: str, data: @[u8]/~} { alt find_library_crate(cx) { some(t) { ret t; } none { @@ -49,7 +49,7 @@ fn load_library_crate(cx: ctxt) -> {ident: str, data: @[u8]} { } } -fn find_library_crate(cx: ctxt) -> option<{ident: str, data: @[u8]}> { +fn find_library_crate(cx: ctxt) -> option<{ident: str, data: @[u8]/~}> { attr::require_unique_names(cx.diag, cx.metas); find_library_crate_aux(cx, libname(cx), cx.filesearch) } @@ -67,12 +67,12 @@ fn libname(cx: ctxt) -> {prefix: str, suffix: str} { fn find_library_crate_aux(cx: ctxt, nn: {prefix: str, suffix: str}, filesearch: filesearch::filesearch) -> - option<{ident: str, data: @[u8]}> { + option<{ident: str, data: @[u8]/~}> { let crate_name = crate_name_from_metas(cx.metas); let prefix: str = nn.prefix + *crate_name + "-"; let suffix: str = nn.suffix; - let mut matches = []; + let mut matches = []/~; filesearch::search(filesearch, { |path| #debug("inspecting file %s", path); let f: str = path::basename(path); @@ -89,7 +89,7 @@ fn find_library_crate_aux(cx: ctxt, option::none::<()> } else { #debug("found %s with matching metadata", path); - matches += [{ident: path, data: cvec}]; + matches += [{ident: path, data: cvec}]/~; option::none::<()> } } @@ -119,7 +119,7 @@ fn find_library_crate_aux(cx: ctxt, } } -fn crate_name_from_metas(metas: [@ast::meta_item]) -> @str { +fn crate_name_from_metas(metas: [@ast::meta_item]/~) -> @str { let name_items = attr::find_meta_items_by_name(metas, "name"); alt vec::last_opt(name_items) { some(i) { @@ -134,14 +134,14 @@ fn crate_name_from_metas(metas: [@ast::meta_item]) -> @str { } } -fn note_linkage_attrs(diag: span_handler, attrs: [ast::attribute]) { +fn note_linkage_attrs(diag: span_handler, attrs: [ast::attribute]/~) { for attr::find_linkage_attrs(attrs).each {|attr| diag.handler().note(#fmt("meta: %s", pprust::attr_to_str(attr))); } } -fn crate_matches(crate_data: @[u8], metas: [@ast::meta_item], hash: str) -> - bool { +fn crate_matches(crate_data: @[u8]/~, metas: [@ast::meta_item]/~, + hash: str) -> bool { let attrs = decoder::get_crate_attributes(crate_data); let linkage_metas = attr::find_linkage_metas(attrs); if hash.is_not_empty() { @@ -151,8 +151,8 @@ fn crate_matches(crate_data: @[u8], metas: [@ast::meta_item], hash: str) -> metadata_matches(linkage_metas, metas) } -fn metadata_matches(extern_metas: [@ast::meta_item], - local_metas: [@ast::meta_item]) -> bool { +fn metadata_matches(extern_metas: [@ast::meta_item]/~, + local_metas: [@ast::meta_item]/~) -> bool { #debug("matching %u metadata requirements against %u items", vec::len(local_metas), vec::len(extern_metas)); @@ -173,14 +173,14 @@ fn metadata_matches(extern_metas: [@ast::meta_item], } fn get_metadata_section(os: os, - filename: str) -> option<@[u8]> unsafe { + filename: str) -> option<@[u8]/~> unsafe { let mb = str::as_c_str(filename, {|buf| llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf) }); - if mb as int == 0 { ret option::none::<@[u8]>; } + if mb as int == 0 { ret option::none::<@[u8]/~>; } let of = alt mk_object_file(mb) { option::some(of) { of } - _ { ret option::none::<@[u8]>; } + _ { ret option::none::<@[u8]/~>; } }; let si = mk_section_iter(of.llof); while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False { @@ -196,7 +196,7 @@ fn get_metadata_section(os: os, } llvm::LLVMMoveToNextSection(si.llsi); } - ret option::none::<@[u8]>; + ret option::none::<@[u8]/~>; } fn meta_section_name(os: os) -> str { diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 794af5577e7..28eddf2b238 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -17,7 +17,7 @@ export parse_bounds_data; // Callback to translate defs to strs or back: type conv_did = fn(ast::def_id) -> ast::def_id; -type pstate = {data: @[u8], crate: int, mut pos: uint, tcx: ty::ctxt}; +type pstate = {data: @[u8]/~, crate: int, mut pos: uint, tcx: ty::ctxt}; fn peek(st: @pstate) -> char { st.data[st.pos] as char @@ -50,7 +50,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) -> } -fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, tcx: ty::ctxt, +fn parse_ty_data(data: @[u8]/~, crate_num: int, pos: uint, tcx: ty::ctxt, conv: conv_did) -> ty::t { let st = @{data: data, crate: crate_num, mut pos: pos, tcx: tcx}; parse_ty(st, conv) @@ -65,13 +65,13 @@ fn parse_ret_ty(st: @pstate, conv: conv_did) -> (ast::ret_style, ty::t) { fn parse_constrs_gen<T: copy>(st: @pstate, conv: conv_did, pser: fn(@pstate) - -> ast::constr_arg_general_<T>) -> [@ty::constr_general<T>] { - let mut rslt: [@ty::constr_general<T>] = []; + -> ast::constr_arg_general_<T>) -> [@ty::constr_general<T>]/~ { + let mut rslt: [@ty::constr_general<T>]/~ = []/~; alt peek(st) { ':' { loop { next(st); - rslt += [parse_constr(st, conv, pser)]; + rslt += [parse_constr(st, conv, pser)]/~; if peek(st) != ';' { break; } } } @@ -80,18 +80,18 @@ fn parse_constrs_gen<T: copy>(st: @pstate, conv: conv_did, rslt } -fn parse_constrs(st: @pstate, conv: conv_did) -> [@ty::constr] { +fn parse_constrs(st: @pstate, conv: conv_did) -> [@ty::constr]/~ { parse_constrs_gen(st, conv, parse_constr_arg) } -fn parse_ty_constrs(st: @pstate, conv: conv_did) -> [@ty::type_constr] { +fn parse_ty_constrs(st: @pstate, conv: conv_did) -> [@ty::type_constr]/~ { parse_constrs_gen(st, conv, parse_ty_constr_arg) } fn parse_path(st: @pstate) -> @ast::path { - let mut idents: [ast::ident] = []; + let mut idents: [ast::ident]/~ = []/~; fn is_last(c: char) -> bool { ret c == '(' || c == ':'; } - idents += [parse_ident_(st, is_last)]; + idents += [parse_ident_(st, is_last)]/~; loop { alt peek(st) { ':' { next(st); next(st); } @@ -99,8 +99,8 @@ fn parse_path(st: @pstate) -> @ast::path { if c == '(' { ret @{span: ast_util::dummy_sp(), global: false, idents: idents, - rp: none, types: []}; - } else { idents += [parse_ident_(st, is_last)]; } + rp: none, types: []/~}; + } else { idents += [parse_ident_(st, is_last)]/~; } } } }; @@ -124,7 +124,7 @@ fn parse_constr_arg(st: @pstate) -> ast::fn_constr_arg { /* else { auto lit = parse_lit(st, conv, ','); - args += [respan(st.span, ast::carg_lit(lit))]; + args += [respan(st.span, ast::carg_lit(lit))]/~; } */ } @@ -143,7 +143,7 @@ fn parse_constr<T: copy>(st: @pstate, conv: conv_did, -> @ty::constr_general<T> { // FIXME: use real spans and not a bogus one (#2407) let sp = ast_util::dummy_sp(); - let mut args: [@sp_constr_arg<T>] = []; + let mut args: [@sp_constr_arg<T>]/~ = []/~; let pth = parse_path(st); let mut ignore: char = next(st); assert (ignore == '('); @@ -151,7 +151,7 @@ fn parse_constr<T: copy>(st: @pstate, conv: conv_did, let mut an_arg: constr_arg_general_<T>; loop { an_arg = pser(st); - args += [@respan(sp, an_arg)]; + args += [@respan(sp, an_arg)]/~; ignore = next(st); if ignore != ';' { break; } } @@ -197,8 +197,8 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { let self_ty = parse_opt(st) {|| parse_ty(st, conv) }; assert next(st) == '['; - let mut params: [ty::t] = []; - while peek(st) != ']' { params += [parse_ty(st, conv)]; } + let mut params: [ty::t]/~ = []/~; + while peek(st) != ']' { params += [parse_ty(st, conv)]/~; } st.pos = st.pos + 1u; ret {self_r: self_r, @@ -320,18 +320,18 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'R' { assert (next(st) == '['); - let mut fields: [ty::field] = []; + let mut fields: [ty::field]/~ = []/~; while peek(st) != ']' { let name = @parse_str(st, '='); - fields += [{ident: name, mt: parse_mt(st, conv)}]; + fields += [{ident: name, mt: parse_mt(st, conv)}]/~; } st.pos = st.pos + 1u; ret ty::mk_rec(st.tcx, fields); } 'T' { assert (next(st) == '['); - let mut params = []; - while peek(st) != ']' { params += [parse_ty(st, conv)]; } + let mut params = []/~; + while peek(st) != ']' { params += [parse_ty(st, conv)]/~; } st.pos = st.pos + 1u; ret ty::mk_tup(st.tcx, params); } @@ -403,8 +403,8 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { } fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id { - let mut def = []; - while peek(st) != '|' { def += [next_byte(st)]; } + let mut def = []/~; + while peek(st) != '|' { def += [next_byte(st)]/~; } st.pos = st.pos + 1u; ret conv(parse_def_id(def)); } @@ -446,7 +446,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { let proto = parse_proto(next(st)); let purity = parse_purity(next(st)); assert (next(st) == '['); - let mut inputs: [ty::arg] = []; + let mut inputs: [ty::arg]/~ = []/~; while peek(st) != ']' { let mode = alt check peek(st) { '&' { ast::by_mutbl_ref } @@ -456,7 +456,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { '#' { ast::by_val } }; st.pos += 1u; - inputs += [{mode: ast::expl(mode), ty: parse_ty(st, conv)}]; + inputs += [{mode: ast::expl(mode), ty: parse_ty(st, conv)}]/~; } st.pos += 1u; // eat the ']' let cs = parse_constrs(st, conv); @@ -467,7 +467,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { // Rust metadata parsing -fn parse_def_id(buf: [u8]) -> ast::def_id { +fn parse_def_id(buf: [u8]/~) -> ast::def_id { let mut colon_idx = 0u; let len = vec::len(buf); while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } @@ -491,15 +491,15 @@ fn parse_def_id(buf: [u8]) -> ast::def_id { ret {crate: crate_num, node: def_num}; } -fn parse_bounds_data(data: @[u8], start: uint, +fn parse_bounds_data(data: @[u8]/~, start: uint, crate_num: int, tcx: ty::ctxt, conv: conv_did) - -> @[ty::param_bound] { + -> @[ty::param_bound]/~ { let st = @{data: data, crate: crate_num, mut pos: start, tcx: tcx}; parse_bounds(st, conv) } -fn parse_bounds(st: @pstate, conv: conv_did) -> @[ty::param_bound] { - let mut bounds = []; +fn parse_bounds(st: @pstate, conv: conv_did) -> @[ty::param_bound]/~ { + let mut bounds = []/~; loop { bounds += [alt check next(st) { 'S' { ty::bound_send } @@ -507,7 +507,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @[ty::param_bound] { 'K' { ty::bound_const } 'I' { ty::bound_iface(parse_ty(st, conv)) } '.' { break; } - }]; + }]/~; } @bounds } diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index dc1cbac434b..3f7c6ee648c 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -395,7 +395,7 @@ fn enc_ty_constr(w: io::writer, cx: @ctxt, c: @ty::type_constr) { }); } -fn enc_bounds(w: io::writer, cx: @ctxt, bs: @[ty::param_bound]) { +fn enc_bounds(w: io::writer, cx: @ctxt, bs: @[ty::param_bound]/~) { for vec::each(*bs) {|bound| alt bound { ty::bound_send { w.write_char('S'); } diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 2fae0850187..e463f371bf5 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -540,7 +540,7 @@ impl helpers for ebml::writer { e::write_type(ecx, self, ty) } - fn emit_tys(ecx: @e::encode_ctxt, tys: [ty::t]) { + fn emit_tys(ecx: @e::encode_ctxt, tys: [ty::t]/~) { self.emit_from_vec(tys) {|ty| e::write_type(ecx, self, ty) } @@ -741,11 +741,11 @@ impl decoder for ebml::ebml_deserializer { {|a|xcx.tr_def_id(a)}) } - fn read_tys(xcx: extended_decode_ctxt) -> [ty::t] { + fn read_tys(xcx: extended_decode_ctxt) -> [ty::t]/~ { self.read_to_vec {|| self.read_ty(xcx) } } - fn read_bounds(xcx: extended_decode_ctxt) -> @[ty::param_bound] { + fn read_bounds(xcx: extended_decode_ctxt) -> @[ty::param_bound]/~ { tydecode::parse_bounds_data( self.parent.data, self.pos, xcx.dcx.cdata.cnum, xcx.dcx.tcx, {|a|xcx.tr_def_id(a)}) @@ -861,7 +861,7 @@ type fake_session = (); #[cfg(test)] impl of fake_ext_ctxt for fake_session { - fn cfg() -> ast::crate_cfg { [] } + fn cfg() -> ast::crate_cfg { []/~ } fn parse_sess() -> parse::parse_sess { parse::new_parse_sess(none) } } @@ -924,13 +924,13 @@ fn test_simplification() { let item_in = ast::ii_item(#ast(item) { fn new_int_alist<B: copy>() -> alist<int, B> { fn eq_int(&&a: int, &&b: int) -> bool { a == b } - ret {eq_fn: eq_int, mut data: []}; + ret {eq_fn: eq_int, mut data: []/~}; } }); let item_out = simplify_ast(item_in); let item_exp = ast::ii_item(#ast(item) { fn new_int_alist<B: copy>() -> alist<int, B> { - ret {eq_fn: eq_int, mut data: []}; + ret {eq_fn: eq_int, mut data: []/~}; } }); alt (item_out, item_exp) { diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index c1a72dff3ac..af8e1860e53 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -23,7 +23,7 @@ enum check_loan_ctxt = @{ // we are in a ctor, we track the self id mut in_ctor: bool, mut declared_purity: ast::purity, - mut fn_args: @[ast::node_id] + mut fn_args: @[ast::node_id]/~ }; // if we are enforcing purity, why are we doing so? @@ -45,7 +45,7 @@ fn check_loans(bccx: borrowck_ctxt, reported: int_hash(), mut in_ctor: false, mut declared_purity: ast::impure_fn, - mut fn_args: @[]}); + mut fn_args: @[]/~}); let vt = visit::mk_vt(@{visit_expr: check_loans_in_expr, visit_local: check_loans_in_local, visit_block: check_loans_in_block, @@ -473,7 +473,7 @@ impl methods for check_loan_ctxt { callee: option<@ast::expr>, callee_id: ast::node_id, callee_span: span, - args: [@ast::expr]) { + args: [@ast::expr]/~) { alt self.purity(expr.id) { none {} some(pc) { @@ -618,7 +618,7 @@ fn check_loans_in_expr(expr: @ast::expr, none, ast_util::op_expr_callee_id(expr), expr.span, - [rval]); + [rval]/~); } ast::expr_unary(*) | ast::expr_index(*) if self.bccx.method_map.contains_key(expr.id) { @@ -626,7 +626,7 @@ fn check_loans_in_expr(expr: @ast::expr, none, ast_util::op_expr_callee_id(expr), expr.span, - []); + []/~); } _ { } } diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index df46a4cef8f..5c4b804164c 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -86,12 +86,11 @@ fn req_loans_in_expr(ex: @ast::expr, // passing the buck onto us to enforce this) // // FIXME (#2493): this handling is not really adequate. - // For example, if there is a type like, {f: [int]}, we + // For example, if there is a type like, {f: [int]/~}, we // will ignore it, but we ought to be requiring it to be // immutable (whereas something like {f:int} would be // fine). // - alt opt_deref_kind(arg_ty.ty) { some(deref_ptr(region_ptr)) | some(deref_ptr(unsafe_ptr)) { @@ -281,7 +280,7 @@ impl methods for gather_loan_ctxt { } none { self.req_maps.req_loan_map.insert( - scope_id, @dvec::from_vec([mut loans])); + scope_id, @dvec::from_vec([mut loans]/~)); } } } diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index fe7aeb8e5f0..07bf22aedce 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -60,7 +60,7 @@ fn check_capture_clause(tcx: ty::ctxt, fn compute_capture_vars(tcx: ty::ctxt, fn_expr_id: ast::node_id, fn_proto: ast::proto, - cap_clause: ast::capture_clause) -> [capture_var] { + cap_clause: ast::capture_clause) -> [capture_var]/~ { let freevars = freevars::get_freevars(tcx, fn_expr_id); let cap_map = map::int_hash(); @@ -119,7 +119,7 @@ fn compute_capture_vars(tcx: ty::ctxt, } } - let mut result = []; - for cap_map.each_value { |cap_var| result += [cap_var]; } + let mut result = []/~; + for cap_map.each_value { |cap_var| result += [cap_var]/~; } ret result; } diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 20bbce07d75..e9681c2d8cf 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -36,18 +36,18 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) { } // Check for unreachable patterns -fn check_arms(tcx: ty::ctxt, arms: [arm]) { - let mut seen = []; +fn check_arms(tcx: ty::ctxt, arms: [arm]/~) { + let mut seen = []/~; for arms.each {|arm| for arm.pats.each {|pat| - let v = [pat]; + let v = [pat]/~; alt is_useful(tcx, seen, v) { not_useful { tcx.sess.span_err(pat.span, "unreachable pattern"); } _ {} } - if option::is_none(arm.guard) { seen += [v]; } + if option::is_none(arm.guard) { seen += [v]/~; } } } } @@ -59,8 +59,8 @@ fn raw_pat(p: @pat) -> @pat { } } -fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) { - let ext = alt is_useful(tcx, vec::map(pats, {|p| [p]}), [wild()]) { +fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]/~) { + let ext = alt is_useful(tcx, vec::map(pats, {|p| [p]/~}), [wild()]/~) { not_useful { ret; } // This is good, wildcard pattern isn't reachable useful_ { none } useful(ty, ctor) { @@ -89,7 +89,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) { tcx.sess.span_err(sp, msg); } -type matrix = [[@pat]]; +type matrix = [[@pat]/~]/~; enum useful { useful(ty::t, ctor), useful_, not_useful } @@ -111,7 +111,7 @@ enum ctor { // checking (if a wildcard pattern is useful in relation to a matrix, the // matrix isn't exhaustive). -fn is_useful(tcx: ty::ctxt, m: matrix, v: [@pat]) -> useful { +fn is_useful(tcx: ty::ctxt, m: matrix, v: [@pat]/~) -> useful { if m.len() == 0u { ret useful_; } if m[0].len() == 0u { ret not_useful; } let real_pat = alt vec::find(m, {|r| r[0].id != 0}) { @@ -167,7 +167,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: [@pat]) -> useful { } } -fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: [@pat], ctor: ctor, +fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: [@pat]/~, ctor: ctor, arity: uint, lty: ty::t) -> useful { let ms = vec::filter_map(m, {|r| specialize(tcx, r, ctor, arity, lty)}); alt is_useful(tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))){ @@ -217,10 +217,10 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { ret some(single); } ty::ty_enum(eid, _) { - let mut found = []; + let mut found = []/~; for m.each {|r| option::iter(pat_ctor_id(tcx, r[0])) {|id| - if !vec::contains(found, id) { found += [id]; } + if !vec::contains(found, id) { found += [id]/~; } } } let variants = ty::enum_variants(tcx, eid); @@ -270,8 +270,8 @@ fn wild() -> @pat { @{id: 0, node: pat_wild, span: syntax::ast_util::dummy_sp()} } -fn specialize(tcx: ty::ctxt, r: [@pat], ctor_id: ctor, arity: uint, - left_ty: ty::t) -> option<[@pat]> { +fn specialize(tcx: ty::ctxt, r: [@pat]/~, ctor_id: ctor, arity: uint, + left_ty: ty::t) -> option<[@pat]/~> { let r0 = raw_pat(r[0]); alt r0.node { pat_wild { some(vec::from_elem(arity, wild()) + vec::tail(r)) } @@ -308,7 +308,7 @@ fn specialize(tcx: ty::ctxt, r: [@pat], ctor_id: ctor, arity: uint, some(args + vec::tail(r)) } pat_tup(args) { some(args + vec::tail(r)) } - pat_box(a) | pat_uniq(a) { some([a] + vec::tail(r)) } + pat_box(a) | pat_uniq(a) { some([a]/~ + vec::tail(r)) } pat_lit(expr) { let e_v = eval_const_expr(tcx, expr); let match = alt check ctor_id { @@ -334,7 +334,7 @@ fn specialize(tcx: ty::ctxt, r: [@pat], ctor_id: ctor, arity: uint, } } -fn default(tcx: ty::ctxt, r: [@pat]) -> option<[@pat]> { +fn default(tcx: ty::ctxt, r: [@pat]/~) -> option<[@pat]/~> { if is_wild(tcx, r[0]) { some(vec::tail(r)) } else { none } } diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index df6a718de1d..bbfc16b64b2 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -23,7 +23,7 @@ type freevar_entry = { def: ast::def, //< The variable being accessed free. span: span //< First span where it is accessed (there can be multiple) }; -type freevar_info = @[@freevar_entry]; +type freevar_info = @[@freevar_entry]/~; type freevar_map = hashmap<ast::node_id, freevar_info>; // Searches through part of the AST for all references to locals or @@ -34,7 +34,7 @@ type freevar_map = hashmap<ast::node_id, freevar_info>; fn collect_freevars(def_map: resolve::def_map, blk: ast::blk) -> freevar_info { let seen = int_hash(); - let refs = @mut []; + let refs = @mut []/~; fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { } @@ -64,7 +64,7 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk) if i == depth { // Made it to end of loop let dnum = ast_util::def_id_of_def(def).node; if !seen.contains_key(dnum) { - *refs += [@{def:def, span:expr.span}]; + *refs += [@{def:def, span:expr.span}]/~; seen.insert(dnum, ()); } } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 465799c850c..b34880de3f2 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -40,15 +40,15 @@ import lint::{non_implicitly_copyable_typarams,implicit_copies}; // types. fn kind_to_str(k: kind) -> str { - let mut kinds = []; + let mut kinds = []/~; if ty::kind_lteq(kind_const(), k) { - kinds += ["const"]; + vec::push(kinds, "const"); } if ty::kind_can_be_copied(k) { - kinds += ["copy"]; + vec::push(kinds, "copy"); } if ty::kind_can_be_sent(k) { - kinds += ["send"]; + vec::push(kinds, "send"); } str::connect(kinds, " ") } @@ -160,7 +160,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, let cap_clause = alt fk { visit::fk_anon(_, cc) | visit::fk_fn_block(cc) { cc } visit::fk_item_fn(*) | visit::fk_method(*) | - visit::fk_ctor(*) | visit::fk_dtor(*) { @[] } + visit::fk_ctor(*) | visit::fk_dtor(*) { @[]/~ } }; let captured_vars = (*cap_clause).map { |cap_item| let cap_def = cx.tcx.def_map.get(cap_item.id); diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 0561783f2f6..3c93bf5f5c5 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -134,7 +134,7 @@ fn get_lint_dict() -> lint_dict { desc: "implicit copies of non implicitly copyable data", default: warn}) - ]; + ]/~; hash_from_strs(v) } @@ -206,7 +206,7 @@ impl methods for ctxt { current lint context, call the provided function, then reset the warnings in effect to their previous state. "] - fn with_warn_attrs(attrs: [ast::attribute], f: fn(ctxt)) { + fn with_warn_attrs(attrs: [ast::attribute]/~, f: fn(ctxt)) { let mut new_ctxt = self; @@ -358,7 +358,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { fn check_native_fn(cx: ty::ctxt, fn_id: ast::node_id, decl: ast::fn_decl) { let tys = vec::map(decl.inputs) {|a| a.ty }; - for vec::each(tys + [decl.output]) {|ty| + for vec::each(tys + [decl.output]/~) {|ty| alt ty.node { ast::ty_path(_, id) { alt cx.def_map.get(id) { @@ -456,7 +456,7 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) { } ast::ty_path(@{span: _, global: _, idents: ids, rp: none, types: _}, _) - if ids == [@"str"] && (! uses_vstore.contains_key(t.id)) { + if ids == [@"str"]/~ && (! uses_vstore.contains_key(t.id)) { cx.sess.span_lint( old_strs, t.id, it.id, t.span, "deprecated str type"); diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 9ad4009c513..836dced30c4 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -220,9 +220,9 @@ class ir_maps { let live_node_map: hashmap<node_id, live_node>; let variable_map: hashmap<node_id, variable>; let field_map: hashmap<ident, variable>; - let capture_map: hashmap<node_id, @[capture_info]>; - let mut var_kinds: [var_kind]; - let mut lnks: [live_node_kind]; + let capture_map: hashmap<node_id, @[capture_info]/~>; + let mut var_kinds: [var_kind]/~; + let mut lnks: [live_node_kind]/~; new(tcx: ty::ctxt, method_map: typeck::method_map, last_use_map: last_use_map) { @@ -236,13 +236,13 @@ class ir_maps { self.variable_map = int_hash(); self.capture_map = int_hash(); self.field_map = box_str_hash(); - self.var_kinds = []; - self.lnks = []; + self.var_kinds = []/~; + self.lnks = []/~; } fn add_live_node(lnk: live_node_kind) -> live_node { let ln = live_node(self.num_live_nodes); - self.lnks += [lnk]; + self.lnks += [lnk]/~; self.num_live_nodes += 1u; #debug["%s is of kind %?", ln.to_str(), lnk]; @@ -259,7 +259,7 @@ class ir_maps { fn add_variable(vk: var_kind) -> variable { let v = variable(self.num_vars); - self.var_kinds += [vk]; + self.var_kinds += [vk]/~; self.num_vars += 1u; alt vk { @@ -297,11 +297,11 @@ class ir_maps { } } - fn set_captures(node_id: node_id, +cs: [capture_info]) { + fn set_captures(node_id: node_id, +cs: [capture_info]/~) { self.capture_map.insert(node_id, @cs); } - fn captures(expr: @expr) -> @[capture_info] { + fn captures(expr: @expr) -> @[capture_info]/~ { alt self.capture_map.find(expr.id) { some(caps) {caps} none { @@ -435,7 +435,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { let proto = ty::ty_fn_proto(ty::expr_ty(self.tcx, expr)); let cvs = capture::compute_capture_vars(self.tcx, expr.id, proto, cap_clause); - let mut call_caps = []; + let mut call_caps = []/~; for cvs.each { |cv| alt relevant_def(cv.def) { some(rv) { @@ -444,7 +444,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { cap_move | cap_drop {true} // var must be dead afterwards cap_copy | cap_ref {false} // var can still be used }; - call_caps += [{ln: cv_ln, is_move: is_move, rv: rv}]; + call_caps += [{ln: cv_ln, is_move: is_move, rv: rv}]/~; } none {} } @@ -511,8 +511,8 @@ class liveness { let tcx: ty::ctxt; let ir: @ir_maps; let s: specials; - let successors: [mut live_node]; - let users: [mut users]; + let successors: [mut live_node]/~; + let users: [mut users]/~; let mut break_ln: live_node; let mut cont_ln: live_node; @@ -887,7 +887,8 @@ class liveness { succ } - fn propagate_through_exprs(exprs: [@expr], succ: live_node) -> live_node { + fn propagate_through_exprs(exprs: [@expr]/~, + succ: live_node) -> live_node { exprs.foldr(succ) { |expr, succ| self.propagate_through_expr(expr, succ) } @@ -1095,7 +1096,7 @@ class liveness { expr_log(_, l, r) | expr_index(l, r) | expr_binary(_, l, r) { - self.propagate_through_exprs([l, r], succ) + self.propagate_through_exprs([l, r]/~, succ) } expr_assert(e) | diff --git a/src/rustc/middle/pat_util.rs b/src/rustc/middle/pat_util.rs index 706a6fb2264..fa5ab8fc5c5 100644 --- a/src/rustc/middle/pat_util.rs +++ b/src/rustc/middle/pat_util.rs @@ -49,8 +49,8 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat, } } -fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> [node_id] { - let mut found = []; - pat_bindings(dm, pat) {|b_id, _sp, _pt| found += [b_id]; }; +fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> [node_id]/~ { + let mut found = []/~; + pat_bindings(dm, pat) {|b_id, _sp, _pt| found += [b_id]/~; }; ret found; } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index e17343a0b9e..6b79b3c6aa8 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -214,14 +214,14 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, scope_b: ast::node_id) -> option<ast::node_id> { fn ancestors_of(region_map: region_map, scope: ast::node_id) - -> [ast::node_id] { - let mut result = [scope]; + -> [ast::node_id]/~ { + let mut result = [scope]/~; let mut scope = scope; loop { alt region_map.find(scope) { none { ret result; } some(superscope) { - result += [superscope]; + result += [superscope]/~; scope = superscope; } } @@ -235,7 +235,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, let mut a_index = vec::len(a_ancestors) - 1u; let mut b_index = vec::len(b_ancestors) - 1u; - // Here, [ab]_ancestors is a vector going from narrow to broad. + // Here, [ab]/~_ancestors is a vector going from narrow to broad. // The end of each vector will be the item where the scope is // defined; if there are any common ancestors, then the tails of // the vector will be the same. So basically we want to walk diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index b693d83e193..340f05e4616 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -34,13 +34,13 @@ enum scope { scope_toplevel, scope_crate, scope_item(@ast::item), - scope_bare_fn(ast::fn_decl, node_id, [ast::ty_param]), - scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]), + scope_bare_fn(ast::fn_decl, node_id, [ast::ty_param]/~), + scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]/~), scope_native_item(@ast::native_item), scope_loop(@ast::local), // there's only 1 decl per loop. scope_block(ast::blk, @mut uint, @mut uint), scope_arm(ast::arm), - scope_method(node_id, [ast::ty_param]), + scope_method(node_id, [ast::ty_param]/~), } type scopes = @list<scope>; @@ -50,13 +50,13 @@ fn top_scope() -> scopes { } enum import_state { - todo(ast::ident, @[ast::ident], span, scopes), - is_glob(@[ast::ident], scopes, span), + todo(ast::ident, @[ast::ident]/~, span, scopes), + is_glob(@[ast::ident]/~, scopes, span), resolving(span), resolved(option<def>, /* value */ option<def>, /* type */ option<def>, /* module */ - @[@_impl], /* impls */ + @[@_impl]/~, /* impls */ /* used for reporting unused import warning */ ast::ident, span), } @@ -88,7 +88,7 @@ enum mod_index_entry { mie_item(@ast::item), mie_native_item(@ast::native_item), mie_enum_variant(/* variant index */uint, - /*parts of enum item*/ [variant], + /*parts of enum item*/ [variant]/~, node_id, span), } @@ -101,7 +101,7 @@ type indexed_mod = { m: option<ast::_mod>, index: mod_index, glob_imports: dvec<glob_imp_def>, - mut globbed_exports: [ident], + mut globbed_exports: [ident]/~, glob_imported_names: hashmap<ident, glob_import_state>, path: str }; @@ -111,12 +111,12 @@ type indexed_mod = { control.*/ type def_map = hashmap<node_id, def>; -type ext_map = hashmap<def_id, [ident]>; +type ext_map = hashmap<def_id, [ident]/~>; type impl_map = hashmap<node_id, iscopes>; -type impl_cache = hashmap<def_id, option<@[@_impl]>>; +type impl_cache = hashmap<def_id, option<@[@_impl]/~>>; type exp = {reexp: bool, id: def_id}; -type exp_map = hashmap<node_id, [exp]>; +type exp_map = hashmap<node_id, [exp]/~>; type env = {cstore: cstore::cstore, @@ -125,15 +125,15 @@ type env = imports: hashmap<node_id, import_state>, exp_map: exp_map, mod_map: hashmap<node_id, @indexed_mod>, - block_map: hashmap<node_id, [glob_imp_def]>, + block_map: hashmap<node_id, [glob_imp_def]/~>, ext_map: ext_map, impl_map: impl_map, impl_cache: impl_cache, ext_cache: ext_hash, used_imports: {mut track: bool, - mut data: [node_id]}, + mut data: [node_id]/~}, reported: dvec<{ident: ast::ident, sc: scope}>, - mut ignored_imports: [node_id], + mut ignored_imports: [node_id]/~, mut current_tp: option<uint>, mut resolve_unexported: bool, sess: session}; @@ -181,9 +181,9 @@ fn create_env(sess: session, amap: ast_map::map) -> @env { impl_map: int_hash(), impl_cache: new_def_hash(), ext_cache: new_ext_hash(), - used_imports: {mut track: false, mut data: []}, + used_imports: {mut track: false, mut data: []/~}, reported: dvec(), - mut ignored_imports: [], + mut ignored_imports: []/~, mut current_tp: none, mut resolve_unexported: false, sess: sess} @@ -243,7 +243,7 @@ fn map_crate(e: @env, c: @ast::crate) { ast::view_path_list(mod_path, idents, _) { for idents.each {|ident| let t = todo(ident.node.name, - @(mod_path.idents + [ident.node.name]), + @(mod_path.idents + [ident.node.name]/~), ident.span, sc); e.imports.insert(ident.node.id, t); } @@ -271,7 +271,7 @@ fn map_crate(e: @env, c: @ast::crate) { @{m: some(md), index: index_mod(md), glob_imports: dvec(), - mut globbed_exports: [], + mut globbed_exports: []/~, glob_imported_names: box_str_hash(), path: path_from_scope(sc, *i.ident)}); } @@ -280,7 +280,7 @@ fn map_crate(e: @env, c: @ast::crate) { @{m: none::<ast::_mod>, index: index_nmod(nmd), glob_imports: dvec(), - mut globbed_exports: [], + mut globbed_exports: []/~, glob_imported_names: box_str_hash(), path: path_from_scope(sc, *i.ident)}); } @@ -305,8 +305,8 @@ fn map_crate(e: @env, c: @ast::crate) { } scope_block(b, _, _) { let globs = alt e.block_map.find(b.node.id) { - some(globs) { globs + [glob] } - none { [glob] } + some(globs) { globs + [glob]/~ } + none { [glob]/~ } }; e.block_map.insert(b.node.id, globs); } @@ -339,7 +339,7 @@ fn map_crate(e: @env, c: @ast::crate) { @{m: some(c.node.module), index: index_mod(c.node.module), glob_imports: dvec(), - mut globbed_exports: [], + mut globbed_exports: []/~, glob_imported_names: box_str_hash(), path: ""}); @@ -476,7 +476,8 @@ fn resolve_names(e: @env, c: @ast::crate) { _ { } } } - fn walk_tps(e: @env, tps: [ast::ty_param], &&sc: scopes, v: vt<scopes>) { + fn walk_tps(e: @env, tps: [ast::ty_param]/~, + &&sc: scopes, v: vt<scopes>) { let outer_current_tp = e.current_tp; let mut current = 0u; for tps.each {|tp| @@ -557,7 +558,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item, for methods.each {|m| v.visit_ty_params(m.tps, sc, v); let msc = @cons(scope_method(m.self_id, tps + m.tps), sc); - v.visit_fn(visit::fk_method(m.ident, [], m), + v.visit_fn(visit::fk_method(m.ident, []/~, m), m.decl, m.body, m.span, m.id, msc, v); } } @@ -625,7 +626,7 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl, // is this a main fn declaration? alt fk { visit::fk_item_fn(nm, _) { - if is_main_name([ast_map::path_name(nm)]) && + if is_main_name([ast_map::path_name(nm)]/~) && !e.sess.building_library { // This is a main function -- set it in the session // as the main ID @@ -643,9 +644,9 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl, | visit::fk_ctor(_, tps, _, _) | visit::fk_dtor(tps, _, _) { scope_bare_fn(decl, id, tps) } visit::fk_anon(ast::proto_bare, _) { - scope_bare_fn(decl, id, []) } + scope_bare_fn(decl, id, []/~) } visit::fk_anon(_, _) | visit::fk_fn_block(_) { - scope_fn_expr(decl, id, []) } + scope_fn_expr(decl, id, []/~) } }; visit::visit_fn(fk, decl, body, sp, id, @cons(scope, sc), v); @@ -713,7 +714,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&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<def> { let path_len = vec::len(path); let mut dcur = lookup_in_scope_strict(e, sc, sp, path[0], ns_module); @@ -757,10 +758,10 @@ fn resolve_constr(e: @env, c: @ast::constr, &&sc: scopes, _v: vt<scopes>) { // Import resolution fn resolve_import(e: env, n_id: node_id, name: ast::ident, - ids: [ast::ident], sp: codemap::span, &&sc: scopes) { + ids: [ast::ident]/~, sp: codemap::span, &&sc: scopes) { fn register(e: env, id: node_id, cx: ctxt, sp: codemap::span, name: ast::ident, lookup: fn(namespace) -> option<def>, - impls: [@_impl]) { + impls: [@_impl]/~) { let val = lookup(ns_val), typ = lookup(ns_type), md = lookup(ns_module); if is_none(val) && is_none(typ) && is_none(md) && @@ -772,21 +773,21 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, } // Temporarily disable this import and the imports coming after during // resolution of this import. - fn find_imports_after(e: env, id: node_id, &&sc: scopes) -> [node_id] { - fn lst(my_id: node_id, vis: [@view_item]) -> [node_id] { - let mut imports = [], found = false; + fn find_imports_after(e: env, id: node_id, &&sc: scopes) -> [node_id]/~ { + fn lst(my_id: node_id, vis: [@view_item]/~) -> [node_id]/~ { + let mut imports = []/~, found = false; for vis.each {|vi| iter_effective_import_paths(*vi) {|vp| alt vp.node { view_path_simple(_, _, id) | view_path_glob(_, id) { if id == my_id { found = true; } - if found { imports += [id]; } + if found { imports += [id]/~; } } view_path_list(_, ids, _) { for ids.each {|id| if id.node.id == my_id { found = true; } - if found { imports += [id.node.id]; } + if found { imports += [id.node.id]/~; } } } } @@ -822,7 +823,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, let end_id = ids[n_idents - 1u]; if n_idents == 1u { register(e, n_id, in_scope(sc), sp, name, - {|ns| lookup_in_scope(e, sc, sp, end_id, ns, true) }, []); + {|ns| lookup_in_scope(e, sc, sp, end_id, ns, true) }, []/~); } else { alt lookup_in_scope(e, sc, sp, ids[0], ns_module, true) { none { @@ -832,7 +833,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, let mut dcur = dcur_, i = 1u; loop { if i == n_idents - 1u { - let mut impls = []; + let mut impls = []/~; find_impls_in_mod(e, dcur, impls, some(end_id)); register(e, n_id, in_mod(dcur), sp, name, {|ns| lookup_in_mod(e, dcur, sp, end_id, ns, outside) @@ -860,7 +861,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, // import alt e.imports.find(n_id) { some(resolving(sp)) { - e.imports.insert(n_id, resolved(none, none, none, @[], @"", sp)); + e.imports.insert(n_id, resolved(none, none, none, @[]/~, @"", sp)); } _ { } } @@ -910,7 +911,7 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) { path = @(e.mod_map.get(did.node).path + *path); } else if did.node != ast::crate_node_id { let paths = e.ext_map.get(did); - path = @str::connect((paths + [path]).map({|x|*x}), "::"); + path = @str::connect((paths + [path]/~).map({|x|*x}), "::"); } } } @@ -1110,7 +1111,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, ret none; } let mut left_fn = false; - let mut closing = []; + let mut closing = []/~; // Used to determine whether self is in scope let mut left_fn_level2 = false; let mut sc = sc; @@ -1150,7 +1151,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, } else if ns != ns_module { left_fn = scope_is_fn(hd); alt scope_closes(hd) { - some(node_id) { closing += [node_id]; } + some(node_id) { closing += [node_id]/~; } _ { } } } @@ -1160,7 +1161,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, }; } -fn lookup_in_ty_params(e: env, name: ident, ty_params: [ast::ty_param]) +fn lookup_in_ty_params(e: env, name: ident, ty_params: [ast::ty_param]/~) -> option<def> { let mut n = 0u; for ty_params.each {|tp| @@ -1183,7 +1184,7 @@ fn lookup_in_pat(e: env, name: ident, pat: @ast::pat) -> option<node_id> { } fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl, - ty_params: [ast::ty_param], + ty_params: [ast::ty_param]/~, ns: namespace) -> option<def> { alt ns { ns_val { @@ -1367,7 +1368,7 @@ fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace, // examining a module in an external crate let cached = e.ext_cache.find({did: defid, ident: name, ns: ns}); if !is_none(cached) { ret cached; } - let mut path = [name]; + let mut path = [name]/~; if defid.node != ast::crate_node_id { path = cstore::get_path(e.cstore, defid) + path; } @@ -1420,7 +1421,7 @@ fn lookup_import(e: env, n_id: node_id, ns: namespace) -> option<def> { } resolved(val, typ, md, _, _, _) { if e.used_imports.track { - e.used_imports.data += [n_id]; + e.used_imports.data += [n_id]/~; } ret alt ns { ns_val { val } ns_type { typ } ns_module { md } }; } @@ -1490,7 +1491,7 @@ fn lookup_in_local_mod(e: env, node_id: node_id, sp: span, id: ident, ret lookup_glob_in_mod(e, inf, sp, id, ns, outside); } -fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident, +fn lookup_in_globs(e: env, globs: [glob_imp_def]/~, sp: span, id: ident, ns: namespace, dr: dir) -> option<def> { fn lookup_in_mod_(e: env, def: glob_imp_def, sp: span, name: ident, ns: namespace, dr: dir) -> option<glob_imp_def> { @@ -1595,7 +1596,7 @@ fn add_to_index(index: hashmap<ident, @list<mod_index_entry>>, id: ident, } } -fn index_view_items(view_items: [@ast::view_item], +fn index_view_items(view_items: [@ast::view_item]/~, index: hashmap<ident, @list<mod_index_entry>>) { for view_items.each {|vi| alt vi.node { @@ -1684,7 +1685,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<def> { let mut result = none; for csearch::lookup_defs(e.sess.cstore, cnum, ids).each {|d| @@ -1757,9 +1758,9 @@ 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 mut x: [ast::ident] = []; - for tps.each {|tp| x += [tp.ident]; } + fn typaram_names(tps: [ast::ty_param]/~) -> [ident]/~ { + let mut x: [ast::ident]/~ = []/~; + for tps.each {|tp| x += [tp.ident]/~; } ret x; } visit::visit_item(i, x, v); @@ -1914,7 +1915,7 @@ fn add_name(ch: checker, sp: span, name: ident) { ch.seen.push(name); } -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 elts.each {|elt| add_name(ch, sp, id(elt)); } @@ -1942,7 +1943,7 @@ fn check_exports(e: @env) { let defs = [ found_def_item(item, ns_val), found_def_item(item, ns_type), - found_def_item(item, ns_module) ]; + found_def_item(item, ns_module) ]/~; for defs.each {|d| alt d { some(def) { @@ -1984,9 +1985,10 @@ fn check_exports(e: @env) { fn add_export(e: @env, export_id: node_id, target_id: def_id, reexp: bool) { let found = alt e.exp_map.find(export_id) { - some(f) { f } none { [] } + some(f) { f } none { []/~ } }; - e.exp_map.insert(export_id, found + [{reexp: reexp, id: target_id}]); + e.exp_map.insert(export_id, + found + [{reexp: reexp, id: target_id}]/~); } fn check_export(e: @env, ident: ident, _mod: @indexed_mod, @@ -2053,7 +2055,7 @@ fn check_exports(e: @env) { fn check_export_enum_list(e: @env, export_id: node_id, _mod: @indexed_mod, span: codemap::span, id: ast::ident, - ids: [ast::path_list_ident]) { + ids: [ast::path_list_ident]/~) { let parent_id = check_enum_ok(e, span, id, _mod); add_export(e, export_id, local_def(parent_id), false); for ids.each {|variant_id| @@ -2119,7 +2121,7 @@ fn check_exports(e: @env) { if ! glob_is_re_exported.contains_key(id) { cont; } iter_mod(*e, glob.def, glob.path.span, outside) {|ident, def| - _mod.globbed_exports += [ident]; + _mod.globbed_exports += [ident]/~; maybe_add_reexport(e, id, some(def)); } } @@ -2140,8 +2142,8 @@ type method_info = {did: def_id, n_tps: uint, ident: ast::ident}; is the ident of the iface that's being implemented * methods: the item's methods */ -type _impl = {did: def_id, ident: ast::ident, methods: [@method_info]}; -type iscopes = @list<@[@_impl]>; +type _impl = {did: def_id, ident: ast::ident, methods: [@method_info]/~}; +type iscopes = @list<@[@_impl]/~>; fn resolve_impls(e: @env, c: @ast::crate) { visit::visit_crate(*c, @nil, visit::mk_vt(@{ @@ -2153,9 +2155,9 @@ fn resolve_impls(e: @env, c: @ast::crate) { } fn find_impls_in_view_item(e: env, vi: @ast::view_item, - &impls: [@_impl], sc: option<iscopes>) { + &impls: [@_impl]/~, sc: option<iscopes>) { fn lookup_imported_impls(e: env, id: node_id, - act: fn(@[@_impl])) { + act: fn(@[@_impl]/~)) { alt e.imports.get(id) { resolved(_, _, _, is, _, _) { act(is); } todo(name, path, span, scopes) { @@ -2171,14 +2173,14 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item, iter_effective_import_paths(*vi) { |vp| alt vp.node { ast::view_path_simple(name, pt, id) { - let mut found = []; + let mut found = []/~; if vec::len(pt.idents) == 1u { option::iter(sc) {|sc| list::iter(sc) {|level| if vec::len(found) == 0u { for vec::each(*level) {|imp| if imp.ident == pt.idents[0] { - found += [@{ident: name with *imp}]; + found += [@{ident: name with *imp}]/~; } } if vec::len(found) > 0u { impls += found; } @@ -2188,7 +2190,7 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item, } else { lookup_imported_impls(e, id) {|is| for vec::each(*is) {|i| - impls += [@{ident: name with *i}]; + impls += [@{ident: name with *i}]/~; } } } @@ -2220,7 +2222,7 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item, item is a class; and none otherwise. Each record describes one interface implemented by i. */ -fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl], +fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl]/~, name: option<ident>, ck_exports: option<@indexed_mod>) { alt i.node { @@ -2236,7 +2238,7 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl], @{did: local_def(m.id), n_tps: vec::len(m.tps), ident: m.ident} - })}]; + })}]/~; } } ast::item_class(tps, ifces, items, _, _, _) { @@ -2250,14 +2252,14 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl], methods: vec::map(mthds, {|m| @{did: local_def(m.id), n_tps: n_tps + m.tps.len(), - ident: m.ident}})}]; + ident: m.ident}})}]/~; } } _ {} } } -fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: [@_impl], +fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: [@_impl]/~, name: option<ident>) { let mut cached; alt e.impl_cache.find(defid) { @@ -2266,7 +2268,7 @@ fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: [@_impl], none { e.impl_cache.insert(defid, none); cached = if defid.crate == ast::local_crate { - let mut tmp = []; + let mut tmp = []/~; let mi = e.mod_map.get(defid.node); let md = option::get(mi.m); for md.view_items.each {|vi| @@ -2285,14 +2287,14 @@ fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: [@_impl], alt name { some(n) { for vec::each(*cached) {|im| - if n == im.ident { impls += [im]; } + if n == im.ident { impls += [im]/~; } } } _ { impls += *cached; } } } -fn find_impls_in_mod(e: env, m: def, &impls: [@_impl], +fn find_impls_in_mod(e: env, m: def, &impls: [@_impl]/~, name: option<ident>) { alt m { ast::def_mod(defid) { @@ -2304,7 +2306,7 @@ fn find_impls_in_mod(e: env, m: def, &impls: [@_impl], fn visit_block_with_impl_scope(e: @env, b: ast::blk, &&sc: iscopes, v: vt<iscopes>) { - let mut impls = []; + let mut impls = []/~; for b.node.view_items.each {|vi| find_impls_in_view_item(*e, vi, impls, some(sc)); } @@ -2322,7 +2324,7 @@ fn visit_block_with_impl_scope(e: @env, b: ast::blk, &&sc: iscopes, fn visit_mod_with_impl_scope(e: @env, m: ast::_mod, s: span, id: node_id, &&sc: iscopes, v: vt<iscopes>) { - let mut impls = []; + let mut impls = []/~; for m.view_items.each {|vi| find_impls_in_view_item(*e, vi, impls, some(sc)); } diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index f3f53804c20..b7da0b82540 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -77,7 +77,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt { core::unreachable(); } -type bind_map = [{ident: ast::ident, val: ValueRef}]; +type bind_map = [{ident: ast::ident, val: ValueRef}]/~; fn assoc(key: ast::ident, list: bind_map) -> option<ValueRef> { for vec::each(list) {|elt| if str::eq(*elt.ident, *key) { ret some(elt.val); } @@ -86,12 +86,12 @@ fn assoc(key: ast::ident, list: bind_map) -> option<ValueRef> { } type match_branch = - @{pats: [@ast::pat], + @{pats: [@ast::pat]/~, bound: bind_map, data: @{bodycx: block, guard: option<@ast::expr>, id_map: pat_id_map}}; -type match = [match_branch]; +type match = [match_branch]/~; fn has_nested_bindings(m: match, col: uint) -> bool { for vec::each(m) {|br| @@ -104,28 +104,28 @@ fn has_nested_bindings(m: match, col: uint) -> bool { } fn expand_nested_bindings(m: match, col: uint, val: ValueRef) -> match { - let mut result = []; + let mut result = []/~; for vec::each(m) {|br| alt br.pats[col].node { ast::pat_ident(name, some(inner)) { - let pats = vec::slice(br.pats, 0u, col) + [inner] + + let pats = vec::slice(br.pats, 0u, col) + [inner]/~ + vec::slice(br.pats, col + 1u, br.pats.len()); result += [@{pats: pats, bound: br.bound + [{ident: path_to_ident(name), - val: val}] - with *br}]; + val: val}]/~ + with *br}]/~; } - _ { result += [br]; } + _ { result += [br]/~; } } } result } -type enter_pat = fn(@ast::pat) -> option<[@ast::pat]>; +type enter_pat = fn(@ast::pat) -> option<[@ast::pat]/~>; fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef, e: enter_pat) -> match { - let mut result = []; + let mut result = []/~; for vec::each(m) {|br| alt e(br.pats[col]) { some(sub) { @@ -134,11 +134,11 @@ fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef, let self = br.pats[col]; let bound = alt self.node { ast::pat_ident(name, none) if !pat_is_variant(dm, self) { - br.bound + [{ident: path_to_ident(name), val: val}] + br.bound + [{ident: path_to_ident(name), val: val}]/~ } _ { br.bound } }; - result += [@{pats: pats, bound: bound with *br}]; + result += [@{pats: pats, bound: bound with *br}]/~; } none { } } @@ -149,9 +149,9 @@ fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef, fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match { enter_match(dm, m, col, val) {|p| alt p.node { - ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some([]) } + ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some([]/~) } ast::pat_ident(_, none) if !pat_is_variant(dm, p) { - some([]) + some([]/~) } _ { none } } @@ -170,33 +170,33 @@ fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint, else { none } } ast::pat_ident(_, none) if pat_is_variant(tcx.def_map, p) { - if opt_eq(tcx, variant_opt(tcx, p.id), opt) { some([]) } + if opt_eq(tcx, variant_opt(tcx, p.id), opt) { some([]/~) } else { none } } ast::pat_lit(l) { - if opt_eq(tcx, lit(l), opt) { some([]) } else { none } + if opt_eq(tcx, lit(l), opt) { some([]/~) } else { none } } ast::pat_range(l1, l2) { - if opt_eq(tcx, range(l1, l2), opt) { some([]) } else { none } + if opt_eq(tcx, range(l1, l2), opt) { some([]/~) } else { none } } _ { some(vec::from_elem(variant_size, dummy)) } } } } -fn enter_rec(dm: def_map, m: match, col: uint, fields: [ast::ident], +fn enter_rec(dm: def_map, m: match, col: uint, fields: [ast::ident]/~, val: ValueRef) -> match { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; enter_match(dm, m, col, val) {|p| alt p.node { ast::pat_rec(fpats, _) { - let mut pats = []; + let mut pats = []/~; for vec::each(fields) {|fname| let mut pat = dummy; for vec::each(fpats) {|fpat| if str::eq(*fpat.ident, *fname) { pat = fpat.pat; break; } } - pats += [pat]; + pats += [pat]/~; } some(pats) } @@ -220,8 +220,8 @@ fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; enter_match(dm, m, col, val) {|p| alt p.node { - ast::pat_box(sub) { some([sub]) } - _ { some([dummy]) } + ast::pat_box(sub) { some([sub]/~) } + _ { some([dummy]/~) } } } } @@ -230,13 +230,13 @@ fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; enter_match(dm, m, col, val) {|p| alt p.node { - ast::pat_uniq(sub) { some([sub]) } - _ { some([dummy]) } + ast::pat_uniq(sub) { some([sub]/~) } + _ { some([dummy]/~) } } } } -fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> [opt] { +fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> [opt]/~ { fn add_to_set(tcx: ty::ctxt, &&set: dvec<opt>, val: opt) { if set.any({|l| opt_eq(tcx, l, val)}) {ret;} set.push(val); @@ -262,7 +262,7 @@ fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> [opt] { fn extract_variant_args(bcx: block, pat_id: ast::node_id, vdefs: {enm: def_id, var: def_id}, val: ValueRef) -> - {vals: [ValueRef], bcx: block} { + {vals: [ValueRef]/~, bcx: block} { let _icx = bcx.insn_ctxt("alt::extract_variant_args"); let ccx = bcx.fcx.ccx; let enum_ty_substs = alt check ty::get(node_id_type(bcx, pat_id)).struct { @@ -275,7 +275,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, if size > 0u && (*variants).len() != 1u { let enumptr = PointerCast(bcx, val, T_opaque_enum_ptr(ccx)); - blobptr = GEPi(bcx, enumptr, [0u, 1u]); + blobptr = GEPi(bcx, enumptr, [0u, 1u]/~); } let vdefs_tg = vdefs.enm; let vdefs_var = vdefs.var; @@ -286,14 +286,14 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, ret {vals: args, bcx: bcx}; } -fn collect_record_fields(m: match, col: uint) -> [ast::ident] { - let mut fields: [ast::ident] = []; +fn collect_record_fields(m: match, col: uint) -> [ast::ident]/~ { + let mut fields: [ast::ident]/~ = []/~; for vec::each(m) {|br| alt br.pats[col].node { ast::pat_rec(fs, _) { for vec::each(fs) {|f| if !vec::any(fields, {|x| str::eq(*f.ident, *x)}) { - fields += [f.ident]; + fields += [f.ident]/~; } } } @@ -375,8 +375,8 @@ fn pick_col(m: match) -> uint { ret best_col; } -fn compile_submatch(bcx: block, m: match, vals: [ValueRef], - chk: option<mk_fail>, &exits: [exit_node]) { +fn compile_submatch(bcx: block, m: match, vals: [ValueRef]/~, + chk: option<mk_fail>, &exits: [exit_node]/~) { let _icx = bcx.insn_ctxt("alt::compile_submatch"); let mut bcx = bcx; let tcx = bcx.tcx(), dm = tcx.def_map; @@ -405,7 +405,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], } if !bcx.unreachable { exits += [{bound: m[0].bound, from: bcx.llbb, - to: data.bodycx.llbb}]; + to: data.bodycx.llbb}]/~; } Br(bcx, data.bodycx.llbb); ret; @@ -433,10 +433,10 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], // Separate path for extracting and binding record fields if rec_fields.len() > 0u { let fields = ty::get_fields(node_id_type(bcx, pat_id)); - let mut rec_vals = []; + let mut rec_vals = []/~; for vec::each(rec_fields) {|field_name| let ix = option::get(ty::field_idx(field_name, fields)); - rec_vals += [GEPi(bcx, val, [0u, ix])]; + rec_vals += [GEPi(bcx, val, [0u, ix]/~)]/~; } compile_submatch(bcx, enter_rec(dm, m, col, rec_fields, val), rec_vals + vals_left, chk, exits); @@ -449,9 +449,9 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], ty::ty_tup(elts) { elts.len() } _ { ccx.sess.bug("non-tuple type in tuple pattern"); } }; - let mut tup_vals = [], i = 0u; + let mut tup_vals = []/~, i = 0u; while i < n_tup_elts { - tup_vals += [GEPi(bcx, val, [0u, i])]; + tup_vals += [GEPi(bcx, val, [0u, i]/~)]/~; i += 1u; } compile_submatch(bcx, enter_tup(dm, m, col, val, n_tup_elts), @@ -463,8 +463,9 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], if any_box_pat(m, col) { let box = Load(bcx, val); let box_no_addrspace = non_gc_box_cast(bcx, box); - let unboxed = GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]); - compile_submatch(bcx, enter_box(dm, m, col, val), [unboxed] + let unboxed = + GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]/~); + compile_submatch(bcx, enter_box(dm, m, col, val), [unboxed]/~ + vals_left, chk, exits); ret; } @@ -472,9 +473,10 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], if any_uniq_pat(m, col) { let box = Load(bcx, val); let box_no_addrspace = non_gc_box_cast(bcx, box); - let unboxed = GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]); + let unboxed = + GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]/~); compile_submatch(bcx, enter_uniq(dm, m, col, val), - [unboxed] + vals_left, chk, exits); + [unboxed]/~ + vals_left, chk, exits); ret; } @@ -491,7 +493,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], } else { let enumptr = PointerCast(bcx, val, T_opaque_enum_ptr(ccx)); - let discrimptr = GEPi(bcx, enumptr, [0u, 0u]); + let discrimptr = GEPi(bcx, enumptr, [0u, 0u]/~); test_val = Load(bcx, discrimptr); kind = switch; } @@ -567,7 +569,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], } } else if kind == compare { Br(bcx, else_cx.llbb); } let mut size = 0u; - let mut unpacked = []; + let mut unpacked = []/~; alt opt { var(_, vdef) { let args = extract_variant_args(opt_cx, pat_id, vdef, val); @@ -591,18 +593,18 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], } // Returns false for unreachable blocks -fn make_phi_bindings(bcx: block, map: [exit_node], +fn make_phi_bindings(bcx: block, map: [exit_node]/~, ids: pat_util::pat_id_map) -> bool { let _icx = bcx.insn_ctxt("alt::make_phi_bindings"); let our_block = bcx.llbb as uint; let mut success = true, bcx = bcx; for ids.each {|name, node_id| - let mut llbbs = []; - let mut vals = []; + let mut llbbs = []/~; + let mut vals = []/~; for vec::each(map) {|ex| if ex.to as uint == our_block { alt assoc(name, ex.bound) { - some(val) { llbbs += [ex.from]; vals += [val]; } + some(val) { llbbs += [ex.from]/~; vals += [val]/~; } none { } } } @@ -621,7 +623,7 @@ fn make_phi_bindings(bcx: block, map: [exit_node], fn trans_alt(bcx: block, alt_expr: @ast::expr, expr: @ast::expr, - arms: [ast::arm], + arms: [ast::arm]/~, mode: ast::alt_mode, dest: dest) -> block { let _icx = bcx.insn_ctxt("alt::trans_alt"); @@ -630,11 +632,11 @@ fn trans_alt(bcx: block, } } -fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm], +fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm]/~, mode: ast::alt_mode, dest: dest) -> block { let _icx = scope_cx.insn_ctxt("alt::trans_alt_inner"); let bcx = scope_cx, tcx = bcx.tcx(); - let mut bodies = [], match = []; + let mut bodies = []/~, match = []/~; let {bcx, val, _} = trans_temp_expr(bcx, expr); if bcx.unreachable { ret bcx; } @@ -642,12 +644,12 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm], for vec::each(arms) {|a| let body = scope_block(bcx, a.body.info(), "case_body"); let id_map = pat_util::pat_id_map(tcx.def_map, a.pats[0]); - bodies += [body]; + bodies += [body]/~; for vec::each(a.pats) {|p| - match += [@{pats: [p], - bound: [], + match += [@{pats: [p]/~, + bound: []/~, data: @{bodycx: body, guard: a.guard, - id_map: id_map}}]; + id_map: id_map}}]/~; } } @@ -667,21 +669,21 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm], } ast::alt_exhaustive { none } }; - let mut exit_map = []; + let mut exit_map = []/~; let t = node_id_type(bcx, expr.id); let spilled = spill_if_immediate(bcx, val, t); - compile_submatch(bcx, match, [spilled], mk_fail, exit_map); + compile_submatch(bcx, match, [spilled]/~, mk_fail, exit_map); - let mut arm_cxs = [], arm_dests = [], i = 0u; + let mut arm_cxs = []/~, arm_dests = []/~, i = 0u; for vec::each(arms) {|a| let body_cx = bodies[i]; let id_map = pat_util::pat_id_map(tcx.def_map, a.pats[0]); if make_phi_bindings(body_cx, exit_map, id_map) { let arm_dest = dup_for_join(dest); - arm_dests += [arm_dest]; + arm_dests += [arm_dest]/~; let mut arm_cx = trans_block(body_cx, a.body, arm_dest); arm_cx = trans_block_cleanups(arm_cx, body_cx); - arm_cxs += [arm_cx]; + arm_cxs += [arm_cx]/~; } i += 1u; } @@ -726,14 +728,14 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, let rec_fields = ty::get_fields(node_id_type(bcx, pat.id)); for vec::each(fields) {|f| let ix = option::get(ty::field_idx(f.ident, rec_fields)); - let fldptr = GEPi(bcx, val, [0u, ix]); + let fldptr = GEPi(bcx, val, [0u, ix]/~); bcx = bind_irrefutable_pat(bcx, f.pat, fldptr, make_copy); } } ast::pat_tup(elems) { let mut i = 0u; for vec::each(elems) {|elem| - let fldptr = GEPi(bcx, val, [0u, i]); + let fldptr = GEPi(bcx, val, [0u, i]/~); bcx = bind_irrefutable_pat(bcx, elem, fldptr, make_copy); i += 1u; } @@ -741,13 +743,13 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, ast::pat_box(inner) { let box = Load(bcx, val); let unboxed = - GEPi(bcx, box, [0u, abi::box_field_body]); + GEPi(bcx, box, [0u, abi::box_field_body]/~); bcx = bind_irrefutable_pat(bcx, inner, unboxed, true); } ast::pat_uniq(inner) { let box = Load(bcx, val); let unboxed = - GEPi(bcx, box, [0u, abi::box_field_body]); + GEPi(bcx, box, [0u, abi::box_field_body]/~); bcx = bind_irrefutable_pat(bcx, inner, unboxed, true); } ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) { } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 43eb9f8c58d..5c36bcc7cda 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -102,7 +102,7 @@ impl ccx_icx for @crate_ctxt { fn insn_ctxt(s: str) -> icx_popper { #debug("new insn_ctxt: %s", s); if self.sess.count_llvm_insns() { - *self.stats.llvm_insn_ctxt += [s]; + *self.stats.llvm_insn_ctxt += [s]/~; } icx_popper(self) } @@ -120,8 +120,8 @@ impl fcx_icx for fn_ctxt { } } -fn join_returns(parent_cx: block, in_cxs: [block], - in_ds: [dest], out_dest: dest) -> block { +fn join_returns(parent_cx: block, in_cxs: [block]/~, + in_ds: [dest]/~, out_dest: dest) -> block { let out = sub_block(parent_cx, "join"); let mut reachable = false, i = 0u, phi = none; for vec::each(in_cxs) {|cx| @@ -172,7 +172,7 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timespec, end: time::timespec) { let elapsed = 1000 * ((end.sec - start.sec) as int) + ((end.nsec as int) - (start.nsec as int)) / 1000000; - *ccx.stats.fn_times += [{ident: name, time: elapsed}]; + *ccx.stats.fn_times += [{ident: name, time: elapsed}]/~; } @@ -228,29 +228,29 @@ fn get_simple_extern_fn(cx: block, } fn trans_native_call(cx: block, externs: hashmap<str, ValueRef>, - llmod: ModuleRef, name: str, args: [ValueRef]) -> + llmod: ModuleRef, name: str, args: [ValueRef]/~) -> ValueRef { let _icx = cx.insn_ctxt("trans_native_call"); let n = args.len() as int; let llnative: ValueRef = get_simple_extern_fn(cx, externs, llmod, name, n); - let mut call_args: [ValueRef] = []; + let mut call_args: [ValueRef]/~ = []/~; for vec::each(args) {|a| - call_args += [a]; + call_args += [a]/~; } ret Call(cx, llnative, call_args); } fn trans_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt("trans_free"); - Call(cx, cx.ccx().upcalls.free, [PointerCast(cx, v, T_ptr(T_i8()))]); + Call(cx, cx.ccx().upcalls.free, [PointerCast(cx, v, T_ptr(T_i8()))]/~); cx } fn trans_unique_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt("trans_shared_free"); Call(cx, cx.ccx().upcalls.exchange_free, - [PointerCast(cx, v, T_ptr(T_i8()))]); + [PointerCast(cx, v, T_ptr(T_i8()))]/~); ret cx; } @@ -304,7 +304,7 @@ fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef { fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef { let _icx = bcx.insn_ctxt("ptr_offs"); let raw = PointerCast(bcx, base, T_ptr(T_i8())); - InBoundsGEP(bcx, raw, [sz]) + InBoundsGEP(bcx, raw, [sz]/~) } // Increment a pointer by a given amount and then cast it to be a pointer @@ -322,7 +322,7 @@ fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) -> // @llblobptr is the data part of a enum value; its actual type // is meaningless, as it will be cast away. fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, - variant_id: ast::def_id, ty_substs: [ty::t], + variant_id: ast::def_id, ty_substs: [ty::t]/~, ix: uint) -> ValueRef { let _icx = bcx.insn_ctxt("GEP_enum"); let ccx = bcx.ccx(); @@ -334,7 +334,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, }); let typed_blobptr = PointerCast(bcx, llblobptr, T_ptr(T_struct(arg_lltys))); - GEPi(bcx, typed_blobptr, [0u, ix]) + GEPi(bcx, typed_blobptr, [0u, ix]/~) } // Returns a pointer to the body for the box. The box may be an opaque @@ -348,7 +348,7 @@ fn opaque_box_body(bcx: block, let _icx = bcx.insn_ctxt("opaque_box_body"); let ccx = bcx.ccx(); let boxptr = PointerCast(bcx, boxptr, T_ptr(T_box_header(ccx))); - let bodyptr = GEPi(bcx, boxptr, [1u]); + let bodyptr = GEPi(bcx, boxptr, [1u]/~); PointerCast(bcx, bodyptr, T_ptr(type_of(ccx, body_t))) } @@ -376,7 +376,7 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, lazily_emit_all_tydesc_glue(ccx, copy static_ti); // Allocate space: - let rval = Call(bcx, upcall, [lltydesc, size]); + let rval = Call(bcx, upcall, [lltydesc, size]/~); ret PointerCast(bcx, rval, llty); } @@ -394,7 +394,7 @@ fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) -> let _icx = bcx.insn_ctxt("malloc_general"); let box = malloc_raw_dyn(bcx, t, heap, size); let non_gc_box = non_gc_box_cast(bcx, box); - let body = GEPi(bcx, non_gc_box, [0u, abi::box_field_body]); + let body = GEPi(bcx, non_gc_box, [0u, abi::box_field_body]/~); ret {box: box, body: body}; } @@ -462,7 +462,7 @@ fn set_inline_hint(f: ValueRef) { as c_ulonglong, 0u as c_ulonglong); } -fn set_inline_hint_if_appr(attrs: [ast::attribute], +fn set_inline_hint_if_appr(attrs: [ast::attribute]/~, llfn: ValueRef) { alt attr::find_inline_attr(attrs) { attr::ia_hint { set_inline_hint(llfn); } @@ -546,7 +546,7 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, helper: glue_helper) -> ValueRef { let _icx = ccx.insn_ctxt("make_generic_glue_inner"); - let fcx = new_fn_ctxt(ccx, [], llfn, none); + let fcx = new_fn_ctxt(ccx, []/~, llfn, none); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); ccx.stats.n_glues_created += 1u; // Any nontrivial glue is with values passed *by alias*; this is a @@ -628,7 +628,7 @@ fn emit_tydescs(ccx: @crate_ctxt) { C_shape(ccx, shape), // shape shape_tables, // shape_tables C_int(ccx, 0), // ununsed - C_int(ccx, 0)]); // unused + C_int(ccx, 0)]/~); // unused let gvar = ti.tydesc; llvm::LLVMSetInitializer(gvar, tydesc); @@ -660,7 +660,7 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { closure::make_fn_glue(bcx, v, t, take_ty) } ty::ty_iface(_, _) { - let box = Load(bcx, GEPi(bcx, v, [0u, 1u])); + let box = Load(bcx, GEPi(bcx, v, [0u, 1u]/~)); incr_refcnt_of_boxed(bcx, box); bcx } @@ -680,7 +680,7 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { let _icx = cx.insn_ctxt("incr_refcnt_of_boxed"); let ccx = cx.ccx(); maybe_validate_box(cx, box_ptr); - let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]); + let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]/~); let rc = Load(cx, rc_ptr); let rc = Add(cx, rc, C_int(ccx, 1)); Store(cx, rc, rc_ptr); @@ -706,14 +706,14 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { let bcx = alt ty::get(t).struct { ty::ty_box(body_mt) { let v = PointerCast(bcx, v, type_of(ccx, t)); - let body = GEPi(bcx, v, [0u, abi::box_field_body]); + let body = GEPi(bcx, v, [0u, abi::box_field_body]/~); let bcx = drop_ty(bcx, body, body_mt.ty); trans_free(bcx, v) } ty::ty_opaque_box { let v = PointerCast(bcx, v, type_of(ccx, t)); - let td = Load(bcx, GEPi(bcx, v, [0u, abi::box_field_tydesc])); - let valptr = GEPi(bcx, v, [0u, abi::box_field_body]); + let td = Load(bcx, GEPi(bcx, v, [0u, abi::box_field_tydesc]/~)); + let valptr = GEPi(bcx, v, [0u, abi::box_field_body]/~); call_tydesc_glue_full(bcx, valptr, td, abi::tydesc_field_drop_glue, none); trans_free(bcx, v) @@ -752,11 +752,11 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id, class_did: ast::def_id, substs: ty::substs) -> block { - let drop_flag = GEPi(bcx, v0, [0u, 0u]); + let drop_flag = GEPi(bcx, v0, [0u, 0u]/~); with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) {|cx| let mut bcx = cx; // We have to cast v0 - let classptr = GEPi(bcx, v0, [0u, 1u]); + let classptr = GEPi(bcx, v0, [0u, 1u]/~); // Find and call the actual destructor let dtor_addr = get_res_dtor(bcx.ccx(), dtor_did, class_did, substs.tps); // The second argument is the "self" argument for drop @@ -767,13 +767,13 @@ fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id, // of the output pointer and the environment (self) assert(params.len() == 2u); let self_arg = PointerCast(bcx, v0, params[1u]); - let args = [bcx.fcx.llretptr, self_arg]; + let args = [bcx.fcx.llretptr, self_arg]/~; Call(bcx, dtor_addr, args); // Drop the fields for vec::eachi(ty::class_items_as_mutable_fields(bcx.tcx(), class_did, substs)) {|i, fld| - let llfld_a = GEPi(bcx, classptr, [0u, i]); + let llfld_a = GEPi(bcx, classptr, [0u, i]/~); bcx = drop_ty(bcx, llfld_a, fld.mt.ty); } Store(bcx, C_u8(0u), drop_flag); @@ -814,7 +814,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { closure::make_fn_glue(bcx, v0, t, drop_ty) } ty::ty_iface(_, _) { - let box = Load(bcx, GEPi(bcx, v0, [0u, 1u])); + let box = Load(bcx, GEPi(bcx, v0, [0u, 1u]/~)); decr_refcnt_maybe_free(bcx, box, ty::mk_opaque_box(ccx.tcx)) } ty::ty_opaque_closure_ptr(ck) { @@ -831,7 +831,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { } fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, - parent_id: ast::def_id, substs: [ty::t]) + parent_id: ast::def_id, substs: [ty::t]/~) -> ValueRef { let _icx = ccx.insn_ctxt("trans_res_dtor"); if (substs.len() > 0u) { @@ -861,7 +861,7 @@ fn maybe_validate_box(_cx: block, _box_ptr: ValueRef) { // let ccx = cx.ccx(); // warn_not_to_commit(ccx, "validate_box() is uncommented"); // let raw_box_ptr = PointerCast(cx, box_ptr, T_ptr(T_i8())); - // Call(cx, ccx.upcalls.validate_box, [raw_box_ptr]); + // Call(cx, ccx.upcalls.validate_box, [raw_box_ptr]/~); } fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { @@ -872,7 +872,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { let llbox_ty = T_opaque_box_ptr(ccx); let box_ptr = PointerCast(bcx, box_ptr, llbox_ty); with_cond(bcx, IsNotNull(bcx, box_ptr)) {|bcx| - let rc_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_refcnt]); + let rc_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_refcnt]/~); let rc = Sub(bcx, Load(bcx, rc_ptr), C_int(ccx, 1)); Store(bcx, rc, rc_ptr); let zero_test = ICmp(bcx, lib::llvm::IntEQ, C_int(ccx, 0), rc); @@ -978,12 +978,12 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, type val_pair_fn = fn@(block, ValueRef, ValueRef) -> block; type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> block; -fn load_inbounds(cx: block, p: ValueRef, idxs: [uint]) -> ValueRef { +fn load_inbounds(cx: block, p: ValueRef, idxs: [uint]/~) -> ValueRef { ret Load(cx, GEPi(cx, p, idxs)); } fn store_inbounds(cx: block, v: ValueRef, p: ValueRef, - idxs: [uint]) { + idxs: [uint]/~) { Store(cx, v, GEPi(cx, p, idxs)); } @@ -993,7 +993,8 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let _icx = cx.insn_ctxt("iter_structural_ty"); fn iter_variant(cx: block, a_tup: ValueRef, - variant: ty::variant_info, tps: [ty::t], tid: ast::def_id, + variant: ty::variant_info, + tps: [ty::t]/~, tid: ast::def_id, f: val_and_ty_fn) -> block { let _icx = cx.insn_ctxt("iter_variant"); if variant.args.len() == 0u { ret cx; } @@ -1023,7 +1024,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, alt ty::get(t).struct { ty::ty_rec(fields) { for vec::eachi(fields) {|i, fld| - let llfld_a = GEPi(cx, av, [0u, i]); + let llfld_a = GEPi(cx, av, [0u, i]/~); cx = f(cx, llfld_a, fld.mt.ty); } } @@ -1034,7 +1035,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, } ty::ty_tup(args) { for vec::eachi(args) {|i, arg| - let llfld_a = GEPi(cx, av, [0u, i]); + let llfld_a = GEPi(cx, av, [0u, i]/~); cx = f(cx, llfld_a, arg); } } @@ -1051,8 +1052,8 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let ccx = cx.ccx(); let llenumty = T_opaque_enum_ptr(ccx); let av_enum = PointerCast(cx, av, llenumty); - let lldiscrim_a_ptr = GEPi(cx, av_enum, [0u, 0u]); - let llunion_a_ptr = GEPi(cx, av_enum, [0u, 1u]); + let lldiscrim_a_ptr = GEPi(cx, av_enum, [0u, 0u]/~); + let llunion_a_ptr = GEPi(cx, av_enum, [0u, 1u]/~); let lldiscrim_a = Load(cx, lldiscrim_a_ptr); // NB: we must hit the discriminant first so that structural @@ -1078,13 +1079,13 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, ty::ty_class(did, substs) { // Take the drop bit into account let classptr = if is_some(ty::ty_dtor(cx.tcx(), did)) { - GEPi(cx, av, [0u, 1u]) + GEPi(cx, av, [0u, 1u]/~) } else { av }; for vec::eachi(ty::class_items_as_mutable_fields(cx.tcx(), did, substs)) {|i, fld| - let llfld_a = GEPi(cx, classptr, [0u, i]); + let llfld_a = GEPi(cx, classptr, [0u, i]/~); cx = f(cx, llfld_a, fld.mt.ty); } } @@ -1201,7 +1202,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, let llfn = { alt static_glue_fn { none { - let llfnptr = GEPi(cx, tydesc, [0u, field]); + let llfnptr = GEPi(cx, tydesc, [0u, field]/~); Load(cx, llfnptr) } some(sgf) { sgf } @@ -1209,7 +1210,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, }; Call(cx, llfn, [C_null(T_ptr(T_nil())), C_null(T_ptr(T_nil())), - C_null(T_ptr(T_ptr(cx.ccx().tydesc_type))), llrawptr]); + C_null(T_ptr(T_ptr(cx.ccx().tydesc_type))), llrawptr]/~); } // See [Note-arg-mode] @@ -1235,13 +1236,13 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, let llrawrhsptr = BitCast(bcx, llrhs, T_ptr(T_i8())); let lltydesc = get_tydesc_simple(bcx.ccx(), t); let lltydescs = - Load(bcx, GEPi(bcx, lltydesc, [0u, abi::tydesc_field_first_param])); + Load(bcx, GEPi(bcx, lltydesc, [0u, abi::tydesc_field_first_param]/~)); let llfn = bcx.ccx().upcalls.cmp_type; let llcmpresultptr = alloca(bcx, T_i1()); Call(bcx, llfn, [llcmpresultptr, lltydesc, lltydescs, - llrawlhsptr, llrawrhsptr, llop]); + llrawlhsptr, llrawrhsptr, llop]/~); ret Load(bcx, llcmpresultptr); } @@ -1325,7 +1326,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, let size = IntCast(cx, n_bytes, ccx.int_type); let align = C_i32(1i32); let volatile = C_bool(false); - Call(cx, memmove, [dst_ptr, src_ptr, size, align, volatile]); + Call(cx, memmove, [dst_ptr, src_ptr, size, align, volatile]/~); } fn memmove_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) { @@ -1498,7 +1499,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, bcx, un_expr.info(), fty, expr_ty(bcx, un_expr), {|bcx| impl::trans_method_callee(bcx, callee_id, e, mentry) }, - arg_exprs([]), dest); + arg_exprs([]/~), dest); } _ {} } @@ -1749,7 +1750,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, // the expr. impl::trans_method_callee(bcx, callee_id, dst, origin) }, - arg_exprs([src]), save_in(target)); + arg_exprs([src]/~), save_in(target)); ret move_val(bcx, DROP_EXISTING, lhs_res.val, {bcx: bcx, val: target, kind: owned}, @@ -1758,7 +1759,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, _ {} } - // Special case for `+= [x]` + // Special case for `+= [x]/~` alt ty::get(t).struct { ty::ty_vec(_) { alt src.node { @@ -1826,7 +1827,7 @@ fn autoderef(cx: block, e_id: ast::node_id, alt ty::get(t1).struct { ty::ty_box(mt) { - let body = GEPi(cx, v1, [0u, abi::box_field_body]); + let body = GEPi(cx, v1, [0u, abi::box_field_body]/~); t1 = mt.ty; // Since we're changing levels of box indirection, we may have @@ -1891,7 +1892,8 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, if past_rhs.unreachable { ret store_in_dest(join, lhs, dest); } Br(past_rhs, join.llbb); - let phi = Phi(join, T_bool(), [lhs, rhs], [past_lhs.llbb, past_rhs.llbb]); + let phi = + Phi(join, T_bool(), [lhs, rhs]/~, [past_lhs.llbb, past_rhs.llbb]/~); ret store_in_dest(join, phi, dest); } @@ -1909,7 +1911,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, {|bcx| impl::trans_method_callee(bcx, callee_id, lhs, origin) }, - arg_exprs([rhs]), dest); + arg_exprs([rhs]/~), dest); } _ {} } @@ -1968,7 +1970,8 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, _ { else_cx } }; let else_bcx = trans_block_cleanups(else_bcx, else_cx); - ret join_returns(cx, [then_bcx, else_bcx], [then_dest, else_dest], dest); + ret join_returns(cx, + [then_bcx, else_bcx]/~, [then_dest, else_dest]/~, dest); } fn trans_while(cx: block, cond: @ast::expr, body: ast::blk) @@ -2052,39 +2055,39 @@ fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) } fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { - // FIXME[mono] could do this recursively. is that worthwhile? (#2529) + // FIXME[mono]/~ could do this recursively. is that worthwhile? (#2529) alt ty::get(ty).struct { ty::ty_box(mt) { some(ty::mk_opaque_box(tcx)) } ty::ty_fn(fty) { some(ty::mk_fn(tcx, {purity: ast::impure_fn, proto: fty.proto, - inputs: [], + inputs: []/~, output: ty::mk_nil(tcx), ret_style: ast::return_val, - constraints: []})) } + constraints: []/~})) } ty::ty_iface(_, _) { some(ty::mk_fn(tcx, {purity: ast::impure_fn, proto: ast::proto_box, - inputs: [], + inputs: []/~, output: ty::mk_nil(tcx), ret_style: ast::return_val, - constraints: []})) } + constraints: []/~})) } ty::ty_ptr(_) { some(ty::mk_uint(tcx)) } _ { none } } } -fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: [ty::t], +fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: [ty::t]/~, vtables: option<typeck::vtable_res>, - param_uses: option<[type_use::type_uses]>) -> mono_id { + param_uses: option<[type_use::type_uses]/~>) -> mono_id { let precise_param_ids = alt vtables { some(vts) { let bounds = ty::lookup_item_type(ccx.tcx, item).bounds; let mut i = 0u; vec::map2(*bounds, substs, {|bounds, subst| - let mut v = []; + let mut v = []/~; for vec::each(*bounds) {|bound| alt bound { ty::bound_iface(_) { - v += [impl::vtable_id(ccx, vts[i])]; + vec::push(v, impl::vtable_id(ccx, vts[i])); i += 1u; } _ {} @@ -2124,7 +2127,8 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: [ty::t], @{def: item, params: param_ids} } -fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], +fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, + real_substs: [ty::t]/~, vtables: option<typeck::vtable_res>, ref_id: option<ast::node_id>) -> {val: ValueRef, must_cast: bool} { @@ -2204,7 +2208,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], } ccx.monomorphizing.insert(fn_id, depth + 1u); - let pt = *pt + [path_name(@ccx.names(*name))]; + let pt = *pt + [path_name(@ccx.names(*name))]/~; let s = mangle_exported_name(ccx, pt, mono_ty); let mk_lldecl = {|| @@ -2252,10 +2256,10 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], ast_map::node_ctor(nm, tps, ctor, parent_id, _) { // ctors don't have attrs, at least not right now let d = mk_lldecl(); - let tp_tys: [ty::t] = ty::ty_params_to_tys(ccx.tcx, tps); + let tp_tys = ty::ty_params_to_tys(ccx.tcx, tps); trans_class_ctor(ccx, pt, ctor.node.dec, ctor.node.body, d, option::get_default(psubsts, - {tys:tp_tys, vtables: none, bounds: @[]}), + {tys:tp_tys, vtables: none, bounds: @[]/~}), fn_id.node, parent_id, ctor.span); d } @@ -2348,7 +2352,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) if (*impl_bnds).len() + mth.tps.len() == 0u { let llfn = get_item_val(ccx, mth.id); let path = ty::item_path(ccx.tcx, impl_did) + - [path_name(mth.ident)]; + [path_name(mth.ident)]/~; trans_fn(ccx, path, mth.decl, mth.body, llfn, impl_self(impl_ty), none, mth.id); } @@ -2373,7 +2377,7 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id) } fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, - tys: [ty::t], vtables: option<typeck::vtable_res>) + tys: [ty::t]/~, vtables: option<typeck::vtable_res>) -> lval_maybe_callee { let _icx = bcx.insn_ctxt("lval_static_fn_inner"); let ccx = bcx.ccx(), tcx = ccx.tcx; @@ -2509,7 +2513,7 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { // Nullary variant. let enum_ty = node_id_type(cx, id); let llenumptr = alloc_ty(cx, enum_ty); - let lldiscrimptr = GEPi(cx, llenumptr, [0u, 0u]); + let lldiscrimptr = GEPi(cx, llenumptr, [0u, 0u]/~); let lldiscrim_gv = lookup_discriminant(ccx, vid); let lldiscrim = Load(cx, lldiscrim_gv); Store(cx, lldiscrim, lldiscrimptr); @@ -2569,9 +2573,9 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, (If any other code does the same thing, that's a bug */ let val = if deref { - GEPi(bcx, GEPi(bcx, val, [0u, 1u]), [0u, ix]) + GEPi(bcx, GEPi(bcx, val, [0u, 1u]/~), [0u, ix]/~) } - else { GEPi(bcx, val, [0u, ix]) }; + else { GEPi(bcx, val, [0u, ix]/~) }; ret {bcx: bcx, val: val, kind: owned}; } @@ -2622,7 +2626,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, // fail: bad bounds check. trans_fail(bcx, some(ex.span), "bounds check") }; - let elt = InBoundsGEP(bcx, base, [ix_val]); + let elt = InBoundsGEP(bcx, base, [ix_val]/~); ret lval_owned(bcx, PointerCast(bcx, elt, T_ptr(llunitty))); } @@ -2706,11 +2710,11 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { let val = alt check ty::get(t).struct { ty::ty_box(_) { let non_gc_val = non_gc_box_cast(sub.bcx, sub.val); - GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body]) + GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body]/~) } ty::ty_uniq(_) { let non_gc_val = non_gc_box_cast(sub.bcx, sub.val); - GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body]) + GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body]/~) } ty::ty_enum(_, _) { let ety = expr_ty(cx, e); @@ -2857,7 +2861,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let cx = e_res.bcx; let llenumty = T_opaque_enum_ptr(ccx); let av_enum = PointerCast(cx, e_res.val, llenumty); - let lldiscrim_a_ptr = GEPi(cx, av_enum, [0u, 0u]); + let lldiscrim_a_ptr = GEPi(cx, av_enum, [0u, 0u]/~); let lldiscrim_a = Load(cx, lldiscrim_a_ptr); alt k_out { cast_integral {int_cast(e_res.bcx, ll_t_out, @@ -2889,7 +2893,7 @@ fn trans_loop_body(bcx: block, e: @ast::expr, ret_flag: option<ValueRef>, // temp_cleanups: cleanups that should run only if failure occurs before the // call takes place: fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, - &temp_cleanups: [ValueRef], ret_flag: option<ValueRef>, + &temp_cleanups: [ValueRef]/~, ret_flag: option<ValueRef>, derefs: uint) -> result { #debug("+++ trans_arg_expr on %s", expr_to_str(e)); @@ -2979,7 +2983,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, // In the event that failure occurs before the call actually // happens, have to cleanup this copy: add_clean_temp_mem(bcx, val, arg.ty); - temp_cleanups += [val]; + temp_cleanups += [val]/~; } } } @@ -2994,7 +2998,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, } // when invoking a method, an argument of type @T or ~T can be implicltly -// converted to an argument of type &T. Similarly, [T] can be converted to +// converted to an argument of type &T. Similarly, [T]/~ can be converted to // [T]/& and so on. If such a conversion (called borrowing) is necessary, // then the borrowings table will have an appropriate entry inserted. This // routine consults this table and performs these adaptations. It returns a @@ -3012,7 +3016,7 @@ fn adapt_borrowed_value(lv: lval_result, alt ty::get(e_ty).struct { ty::ty_uniq(mt) | ty::ty_box(mt) { let box_ptr = load_value_from_lval_result(lv, e_ty); - let body_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_body]); + let body_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_body]/~); let rptr_ty = ty::mk_rptr(bcx.tcx(), ty::re_static, mt); ret {lv: lval_temp(bcx, body_ptr), ty: rptr_ty}; } @@ -3030,14 +3034,14 @@ fn adapt_borrowed_value(lv: lval_result, let unit_ty = ty::sequence_element_type(ccx.tcx, e_ty); let llunit_ty = type_of(ccx, unit_ty); let (base, len) = tvec::get_base_and_len(bcx, val, e_ty); - let p = alloca(bcx, T_struct([T_ptr(llunit_ty), ccx.int_type])); + let p = alloca(bcx, T_struct([T_ptr(llunit_ty), ccx.int_type]/~)); #debug("adapt_borrowed_value: adapting %s to %s", val_str(bcx.ccx().tn, val), val_str(bcx.ccx().tn, p)); - Store(bcx, base, GEPi(bcx, p, [0u, abi::slice_elt_base])); - Store(bcx, len, GEPi(bcx, p, [0u, abi::slice_elt_len])); + Store(bcx, base, GEPi(bcx, p, [0u, abi::slice_elt_base]/~)); + Store(bcx, len, GEPi(bcx, p, [0u, abi::slice_elt_len]/~)); // this isn't necessarily the type that rust would assign but it's // close enough for trans purposes, as it will have the same runtime @@ -3058,8 +3062,8 @@ fn adapt_borrowed_value(lv: lval_result, } enum call_args { - arg_exprs([@ast::expr]), - arg_vals([ValueRef]) + arg_exprs([@ast::expr]/~), + arg_vals([ValueRef]/~) } // NB: must keep 4 fns in sync: @@ -3070,11 +3074,11 @@ enum call_args { // - trans_args fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, dest: dest, ret_flag: option<ValueRef>) - -> {bcx: block, args: [ValueRef], retslot: ValueRef} { + -> {bcx: block, args: [ValueRef]/~, retslot: ValueRef} { let _icx = cx.insn_ctxt("trans_args"); - let mut temp_cleanups = []; + let mut temp_cleanups = []/~; let arg_tys = ty::ty_fn_args(fn_ty); - let mut llargs: [ValueRef] = []; + let mut llargs: [ValueRef]/~ = []/~; let ccx = cx.ccx(); let mut bcx = cx; @@ -3091,10 +3095,10 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, by_val(_) { alloc_ty(bcx, retty) } }; - llargs += [llretslot]; + llargs += [llretslot]/~; // Arg 1: Env (closure-bindings / self value) - llargs += [llenv]; + llargs += [llenv]/~; // ... then explicit args. @@ -3110,7 +3114,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, e, temp_cleanups, if i == last { ret_flag } else { none }, 0u); bcx = r.bcx; - llargs += [r.val]; + llargs += [r.val]/~; } } arg_vals(vs) { @@ -3199,9 +3203,9 @@ fn trans_call_inner( faddr = load_if_immediate(bcx, faddr, fn_expr_ty); } let pair = faddr; - faddr = GEPi(bcx, pair, [0u, abi::fn_field_code]); + faddr = GEPi(bcx, pair, [0u, abi::fn_field_code]/~); faddr = Load(bcx, faddr); - let llclosure = GEPi(bcx, pair, [0u, abi::fn_field_box]); + let llclosure = GEPi(bcx, pair, [0u, abi::fn_field_box]/~); Load(bcx, llclosure) } }; @@ -3247,7 +3251,7 @@ fn trans_call_inner( } } -fn invoke(bcx: block, llfn: ValueRef, llargs: [ValueRef]) -> block { +fn invoke(bcx: block, llfn: ValueRef, llargs: [ValueRef]/~) -> block { let _icx = bcx.insn_ctxt("invoke_"); if bcx.unreachable { ret bcx; } if need_invoke(bcx) { @@ -3335,7 +3339,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { // The landing pad return type (the type being propagated). Not sure what // this represents but it's determined by the personality function and // this is what the EH proposal example uses. - let llretty = T_struct([T_ptr(T_i8()), T_i32()]); + let llretty = T_struct([T_ptr(T_i8()), T_i32()]/~); // The exception handling personality function. This is the C++ // personality function __gxx_personality_v0, wrapped in our naming // convention. @@ -3348,7 +3352,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { // Because we may have unwound across a stack boundary, we must call into // the runtime to figure out which stack segment we are on and place the // stack limit back into the TLS. - Call(pad_bcx, bcx.ccx().upcalls.reset_stack_limit, []); + Call(pad_bcx, bcx.ccx().upcalls.reset_stack_limit, []/~); // We store the retval in a function-central alloca, so that calls to // Resume can find it. @@ -3366,7 +3370,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { ret pad_bcx.llbb; } -fn trans_tup(bcx: block, elts: [@ast::expr], dest: dest) -> block { +fn trans_tup(bcx: block, elts: [@ast::expr]/~, dest: dest) -> block { let _icx = bcx.insn_ctxt("trans_tup"); let mut bcx = bcx; let addr = alt dest { @@ -3377,19 +3381,19 @@ fn trans_tup(bcx: block, elts: [@ast::expr], dest: dest) -> block { save_in(pos) { pos } _ { bcx.tcx().sess.bug("trans_tup: weird dest"); } }; - let mut temp_cleanups = []; + let mut temp_cleanups = []/~; for vec::eachi(elts) {|i, e| - let dst = GEPi(bcx, addr, [0u, i]); + let dst = GEPi(bcx, addr, [0u, i]/~); let e_ty = expr_ty(bcx, e); bcx = trans_expr_save_in(bcx, e, dst); add_clean_temp_mem(bcx, dst, e_ty); - temp_cleanups += [dst]; + temp_cleanups += [dst]/~; } for vec::each(temp_cleanups) {|cleanup| revoke_clean(bcx, cleanup); } ret bcx; } -fn trans_rec(bcx: block, fields: [ast::field], +fn trans_rec(bcx: block, fields: [ast::field]/~, base: option<@ast::expr>, id: ast::node_id, dest: dest) -> block { let _icx = bcx.insn_ctxt("trans_rec"); @@ -3407,15 +3411,15 @@ fn trans_rec(bcx: block, fields: [ast::field], let ty_fields = alt check ty::get(t).struct { ty::ty_rec(f) { f } }; - let mut temp_cleanups = []; + let mut temp_cleanups = []/~; for fields.each {|fld| let ix = option::get(vec::position(ty_fields, {|ft| str::eq(*fld.node.ident, *ft.ident) })); - let dst = GEPi(bcx, addr, [0u, ix]); + let dst = GEPi(bcx, addr, [0u, ix]/~); bcx = trans_expr_save_in(bcx, fld.node.expr, dst); add_clean_temp_mem(bcx, dst, ty_fields[ix].mt.ty); - temp_cleanups += [dst]; + temp_cleanups += [dst]/~; } alt base { some(bexp) { @@ -3424,8 +3428,8 @@ fn trans_rec(bcx: block, fields: [ast::field], // Copy over inherited fields for ty_fields.eachi {|i, tf| if !vec::any(fields, {|f| str::eq(*f.node.ident, *tf.ident)}) { - let dst = GEPi(bcx, addr, [0u, i]); - let base = GEPi(bcx, base_val, [0u, i]); + let dst = GEPi(bcx, addr, [0u, i]/~); + let base = GEPi(bcx, base_val, [0u, i]/~); let val = load_if_immediate(bcx, base, tf.mt.ty); bcx = copy_val(bcx, INIT, dst, val, tf.mt.ty); } @@ -3652,7 +3656,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { { |bcx| impl::trans_method_callee(bcx, callee_id, base, origin) }, - arg_exprs([idx]), dest); + arg_exprs([idx]/~), dest); } // These return nothing @@ -3765,7 +3769,8 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { #debug["voidval = %s", val_str(ccx.tn, voidval)]; let llval_ty = type_of(ccx, expr_ty(bcx, val)); - let args = [llsize_of(ccx, llval_ty), llalign_of(ccx, llval_ty)]; + let args = + [llsize_of(ccx, llval_ty), llalign_of(ccx, llval_ty)]/~; let origin = bcx.ccx().maps.method_map.get(alloc_id); let bcx = trans_call_inner( bcx, e.info(), node_id_type(bcx, alloc_id), void_ty, @@ -3867,7 +3872,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, ret trans_expr(bcx, lvl, ignore); } - let modpath = [path_mod(ccx.link_meta.name)] + + let modpath = [path_mod(ccx.link_meta.name)]/~ + vec::filter(bcx.fcx.path, {|e| alt e { path_mod(_) { true } _ { false } } }); @@ -3902,7 +3907,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, // Call the polymorphic log function. let val = spill_if_immediate(bcx, val, e_ty); let val = PointerCast(bcx, val, T_ptr(T_i8())); - Call(bcx, ccx.upcalls.log_type, [tydesc, val, level]); + Call(bcx, ccx.upcalls.log_type, [tydesc, val, level]/~); bcx } } @@ -3969,7 +3974,7 @@ fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: str) { let ccx = bcx.ccx(); let V_trace_str = PointerCast(bcx, V_trace_str, T_ptr(T_i8())); let V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8())); - let args = [V_trace_str, V_filename, C_int(ccx, V_line)]; + let args = [V_trace_str, V_filename, C_int(ccx, V_line)]/~; Call(bcx, ccx.upcalls.trace, args); } @@ -3998,7 +4003,7 @@ fn trans_fail_value(bcx: block, sp_opt: option<span>, }; let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8())); let V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8())); - let args = [V_str, V_filename, C_int(ccx, V_line)]; + let args = [V_str, V_filename, C_int(ccx, V_line)]/~; let bcx = invoke(bcx, bcx.ccx().upcalls._fail, args); Unreachable(bcx); ret bcx; @@ -4160,8 +4165,8 @@ fn new_block(cx: fn_ctxt, parent: option<block>, +kind: block_kind, } fn simple_block_scope() -> block_kind { - block_scope({loop_break: none, mut cleanups: [], - mut cleanup_paths: [], mut landing_pad: none}) + block_scope({loop_break: none, mut cleanups: []/~, + mut cleanup_paths: []/~, mut landing_pad: none}) } // Use this when you're at the top block of a function or the like. @@ -4181,8 +4186,8 @@ fn loop_scope_block(bcx: block, loop_break: block, n: str, opt_node_info: option<node_info>) -> block { ret new_block(bcx.fcx, some(bcx), block_scope({ loop_break: some(loop_break), - mut cleanups: [], - mut cleanup_paths: [], + mut cleanups: []/~, + mut cleanup_paths: []/~, mut landing_pad: none }), n, opt_node_info); } @@ -4259,7 +4264,7 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, } let sub_cx = sub_block(bcx, "cleanup"); Br(bcx, sub_cx.llbb); - inf.cleanup_paths += [{target: leave, dest: sub_cx.llbb}]; + inf.cleanup_paths += [{target: leave, dest: sub_cx.llbb}]/~; bcx = trans_block_cleanups_(sub_cx, cur, is_lpad); } _ {} @@ -4448,7 +4453,7 @@ fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef, // field of the fn_ctxt with fn create_llargs_for_fn_args(cx: fn_ctxt, ty_self: self_arg, - args: [ast::arg]) { + args: [ast::arg]/~) { let _icx = cx.insn_ctxt("create_llargs_for_fn_args"); // Skip the implicit arguments 0, and 1. let mut arg_n = first_real_arg; @@ -4472,8 +4477,8 @@ fn create_llargs_for_fn_args(cx: fn_ctxt, } } -fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: [ast::arg], - arg_tys: [ty::arg]) -> block { +fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: [ast::arg]/~, + arg_tys: [ty::arg]/~) -> block { let _icx = fcx.insn_ctxt("copy_args_to_allocas"); let tcx = bcx.tcx(); let mut arg_n: uint = 0u, bcx = bcx; @@ -4615,12 +4620,12 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, ident: @"arg", id: varg.id} }); - let fcx = new_fn_ctxt_w_id(ccx, [], llfndecl, variant.node.id, + let fcx = new_fn_ctxt_w_id(ccx, []/~, llfndecl, variant.node.id, param_substs, none); create_llargs_for_fn_args(fcx, no_self, fn_args); let ty_param_substs = alt param_substs { some(substs) { substs.tys } - none { [] } + none { []/~ } }; let bcx = top_scope_block(fcx, none), lltop = bcx.llbb; let arg_tys = ty::ty_fn_args(node_id_type(bcx, variant.node.id)); @@ -4632,9 +4637,9 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, } else { let llenumptr = PointerCast(bcx, fcx.llretptr, T_opaque_enum_ptr(ccx)); - let lldiscrimptr = GEPi(bcx, llenumptr, [0u, 0u]); + let lldiscrimptr = GEPi(bcx, llenumptr, [0u, 0u]/~); Store(bcx, C_int(ccx, disr), lldiscrimptr); - GEPi(bcx, llenumptr, [0u, 1u]) + GEPi(bcx, llenumptr, [0u, 1u]/~) }; let t_id = local_def(enum_id); let v_id = local_def(variant.node.id); @@ -4824,10 +4829,10 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl, parent_id)) { // Initialize the drop flag let one = C_u8(1u); - let flag = GEPi(bcx_top, selfptr, [0u, 0u]); + let flag = GEPi(bcx_top, selfptr, [0u, 0u]/~); Store(bcx_top, one, flag); // Select the pointer to the class itself - GEPi(bcx_top, selfptr, [0u, 1u]) + GEPi(bcx_top, selfptr, [0u, 1u]/~) } else { selfptr }; @@ -4839,7 +4844,7 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl, // drop their LHS for fields.each {|field| let ix = field_idx_strict(bcx.tcx(), sp, field.ident, fields); - bcx = zero_mem(bcx, GEPi(bcx, valptr, [0u, ix]), field.mt.ty); + bcx = zero_mem(bcx, GEPi(bcx, valptr, [0u, ix]/~), field.mt.ty); } // note we don't want to take *or* drop self. @@ -4872,7 +4877,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path, /* The dtor takes a (null) output pointer, and a self argument, and returns () */ let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))), - T_ptr(type_of(ccx, class_ty))], + T_ptr(type_of(ccx, class_ty))]/~, llvm::LLVMVoidType()); let s = get_dtor_symbol(ccx, path, dtor_id, psubsts); @@ -4901,11 +4906,11 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { ast::item_fn(decl, tps, body) { if decl.purity == ast::crust_fn { let llfndecl = get_item_val(ccx, item.id); - native::trans_crust_fn(ccx, *path + [path_name(item.ident)], + native::trans_crust_fn(ccx, *path + [path_name(item.ident)]/~, decl, body, llfndecl, item.id); } else if tps.len() == 0u { let llfndecl = get_item_val(ccx, item.id); - trans_fn(ccx, *path + [path_name(item.ident)], decl, body, + trans_fn(ccx, *path + [path_name(item.ident)]/~, decl, body, llfndecl, no_self, none, item.id); } else { for vec::each(body.node.stmts) {|stmt| @@ -4952,7 +4957,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { if tps.len() == 0u { let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps), vtables: none, - bounds: @[]}; + bounds: @[]/~}; trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body, get_item_val(ccx, ctor.node.id), psubsts, ctor.node.id, local_def(item.id), ctor.span); @@ -5014,7 +5019,7 @@ fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path, llfn } -// Create a _rust_main(args: [str]) function which will be called from the +// Create a _rust_main(args: [str]/~) function which will be called from the // runtime rust_start function fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, main_node_type: ty::t) { @@ -5041,19 +5046,21 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, {mode: ast::expl(ast::by_val), ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mutbl: ast::m_imm})}; let nt = ty::mk_nil(ccx.tcx); - let llfty = type_of_fn(ccx, [vecarg_ty], nt); + let llfty = type_of_fn(ccx, [vecarg_ty]/~, nt); let llfdecl = decl_fn(ccx.llmod, "_rust_main", lib::llvm::CCallConv, llfty); - let fcx = new_fn_ctxt(ccx, [], llfdecl, none); + let fcx = new_fn_ctxt(ccx, []/~, llfdecl, none); let bcx = top_scope_block(fcx, none); let lltop = bcx.llbb; let lloutputarg = llvm::LLVMGetParam(llfdecl, 0 as c_uint); let llenvarg = llvm::LLVMGetParam(llfdecl, 1 as c_uint); - let mut args = [lloutputarg, llenvarg]; - if takes_argv { args += [llvm::LLVMGetParam(llfdecl, 2 as c_uint)]; } + let mut args = [lloutputarg, llenvarg]/~; + if takes_argv { + args += [llvm::LLVMGetParam(llfdecl, 2 as c_uint)]/~; + } Call(bcx, main_llfn, args); build_return(bcx); @@ -5067,7 +5074,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, fn main_name() -> str { ret "WinMain@16"; } #[cfg(unix)] fn main_name() -> str { ret "main"; } - let llfty = T_fn([ccx.int_type, ccx.int_type], ccx.int_type); + let llfty = T_fn([ccx.int_type, ccx.int_type]/~, ccx.int_type); let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty); let llbb = str::as_c_str("top", {|buf| llvm::LLVMAppendBasicBlock(llfn, buf) @@ -5076,11 +5083,11 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, llvm::LLVMPositionBuilderAtEnd(bld, llbb); let crate_map = ccx.crate_map; let start_ty = T_fn([val_ty(rust_main), ccx.int_type, ccx.int_type, - val_ty(crate_map)], ccx.int_type); + val_ty(crate_map)]/~, ccx.int_type); let start = decl_cdecl_fn(ccx.llmod, "rust_start", start_ty); let args = [rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint), - llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map]; + llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map]/~; let result = unsafe { llvm::LLVMBuildCall(bld, start, vec::unsafe::to_ptr(args), args.len() as c_uint, noname()) @@ -5102,9 +5109,9 @@ fn create_real_fn_pair(cx: block, llfnty: TypeRef, llfn: ValueRef, fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) { let ccx = bcx.ccx(); - let code_cell = GEPi(bcx, pair, [0u, abi::fn_field_code]); + let code_cell = GEPi(bcx, pair, [0u, abi::fn_field_code]/~); Store(bcx, llfn, code_cell); - let env_cell = GEPi(bcx, pair, [0u, abi::fn_field_box]); + let env_cell = GEPi(bcx, pair, [0u, abi::fn_field_box]/~); let llenvblobptr = PointerCast(bcx, llenvptr, T_opaque_box_ptr(ccx)); Store(bcx, llenvblobptr, env_cell); } @@ -5112,7 +5119,7 @@ fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef, fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { *alt check ccx.tcx.items.get(i.id) { ast_map::node_item(_, p) { p } - } + [path_name(i.ident)] + } + [path_name(i.ident)]/~ } /* If there's already a symbol for the dtor with <id> and substs <substs>, @@ -5124,7 +5131,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, some(s) { s } none if is_none(substs) { let s = mangle_exported_name(ccx, - path + [path_name(@ccx.names("dtor"))], + path + [path_name(@ccx.names("dtor"))]/~, t); ccx.item_symbols.insert(id, s); s @@ -5136,7 +5143,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, some(ss) { let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, t); mangle_exported_name(ccx, path + - [path_name(@ccx.names("dtor"))], mono_ty) + [path_name(@ccx.names("dtor"))]/~, mono_ty) } none { ccx.sess.bug(#fmt("get_dtor_symbol: not monomorphizing and \ @@ -5155,7 +5162,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { let mut exprt = false; let val = alt check ccx.tcx.items.get(id) { ast_map::node_item(i, pth) { - let my_path = *pth + [path_name(i.ident)]; + let my_path = *pth + [path_name(i.ident)]/~; alt check i.node { ast::item_const(_, _) { let typ = ty::node_id_to_type(ccx.tcx, i.id); @@ -5181,17 +5188,17 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { exprt = true; let mty = ty::node_id_to_type(ccx.tcx, id); let pth = *pth + [path_name(@ccx.names("meth")), - path_name(m.ident)]; + path_name(m.ident)]/~; let llfn = register_fn_full(ccx, m.span, pth, id, mty); set_inline_hint_if_appr(m.attrs, llfn); llfn } ast_map::node_native_item(ni, _, pth) { exprt = true; - register_fn(ccx, ni.span, *pth + [path_name(ni.ident)], ni.id) + register_fn(ccx, ni.span, *pth + [path_name(ni.ident)]/~, ni.id) } ast_map::node_ctor(nm, tps, ctor, _, pt) { - let my_path = *pt + [path_name(nm)]; + let my_path = *pt + [path_name(nm)]/~; register_fn(ccx, ctor.span, my_path, ctor.node.id) } ast_map::node_dtor(tps, dt, parent_id, pt) { @@ -5205,7 +5212,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { // This code shouldn't be reached if the class is generic assert !ty::type_has_params(class_ty); let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))), - T_ptr(type_of(ccx, class_ty))], + T_ptr(type_of(ccx, class_ty))]/~, llvm::LLVMVoidType()); let s = get_dtor_symbol(ccx, *pt, dt.node.id, none); @@ -5217,7 +5224,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ast_map::node_variant(v, enm, pth) { assert v.node.args.len() != 0u; - let pth = *pth + [path_name(enm.ident), path_name(v.node.name)]; + let pth = *pth + [path_name(enm.ident), path_name(v.node.name)]/~; let llfn = alt check enm.node { ast::item_enum(_, _, _) { register_fn(ccx, v.span, pth, id) @@ -5247,7 +5254,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { let path = item_path(ccx, it); for vec::each(variants) {|variant| let p = path + [path_name(variant.node.name), - path_name(@"discrim")]; + path_name(@"discrim")]/~; let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx)); let disr_val = vi[i].disr_val; note_unique_llvm_symbol(ccx, s); @@ -5283,22 +5290,24 @@ fn p2i(ccx: @crate_ctxt, v: ValueRef) -> ValueRef { } fn declare_intrinsics(llmod: ModuleRef) -> hashmap<str, ValueRef> { - let T_memmove32_args: [TypeRef] = - [T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()]; - let T_memmove64_args: [TypeRef] = - [T_ptr(T_i8()), T_ptr(T_i8()), T_i64(), T_i32(), T_i1()]; - let T_memset32_args: [TypeRef] = - [T_ptr(T_i8()), T_i8(), T_i32(), T_i32(), T_i1()]; - let T_memset64_args: [TypeRef] = - [T_ptr(T_i8()), T_i8(), T_i64(), T_i32(), T_i1()]; - let T_trap_args: [TypeRef] = []; - let T_frameaddress_args: [TypeRef] = [T_i32()]; + let T_memmove32_args: [TypeRef]/~ = + [T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()]/~; + let T_memmove64_args: [TypeRef]/~ = + [T_ptr(T_i8()), T_ptr(T_i8()), T_i64(), T_i32(), T_i1()]/~; + let T_memset32_args: [TypeRef]/~ = + [T_ptr(T_i8()), T_i8(), T_i32(), T_i32(), T_i1()]/~; + let T_memset64_args: [TypeRef]/~ = + [T_ptr(T_i8()), T_i8(), T_i64(), T_i32(), T_i1()]/~; + let T_trap_args: [TypeRef]/~ = []/~; + let T_frameaddress_args: [TypeRef]/~ = [T_i32()]/~; let gcroot = decl_cdecl_fn(llmod, "llvm.gcroot", - T_fn([T_ptr(T_ptr(T_i8())), T_ptr(T_i8())], T_void())); + T_fn([T_ptr(T_ptr(T_i8())), T_ptr(T_i8())]/~, + T_void())); let gcread = decl_cdecl_fn(llmod, "llvm.gcread", - T_fn([T_ptr(T_i8()), T_ptr(T_ptr(T_i8()))], T_void())); + T_fn([T_ptr(T_i8()), T_ptr(T_ptr(T_i8()))]/~, + T_void())); let memmove32 = decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i32", T_fn(T_memmove32_args, T_void())); @@ -5311,7 +5320,8 @@ fn declare_intrinsics(llmod: ModuleRef) -> hashmap<str, ValueRef> { let memset64 = decl_cdecl_fn(llmod, "llvm.memset.p0i8.i64", T_fn(T_memset64_args, T_void())); - let trap = decl_cdecl_fn(llmod, "llvm.trap", T_fn(T_trap_args, T_void())); + let trap = decl_cdecl_fn(llmod, "llvm.trap", T_fn(T_trap_args, + T_void())); let frameaddress = decl_cdecl_fn(llmod, "llvm.frameaddress", T_fn(T_frameaddress_args, T_ptr(T_i8()))); @@ -5331,16 +5341,17 @@ fn declare_dbg_intrinsics(llmod: ModuleRef, intrinsics: hashmap<str, ValueRef>) { let declare = decl_cdecl_fn(llmod, "llvm.dbg.declare", - T_fn([T_metadata(), T_metadata()], T_void())); + T_fn([T_metadata(), T_metadata()]/~, T_void())); let value = decl_cdecl_fn(llmod, "llvm.dbg.value", - T_fn([T_metadata(), T_i64(), T_metadata()], T_void())); + T_fn([T_metadata(), T_i64(), T_metadata()]/~, + T_void())); intrinsics.insert("llvm.dbg.declare", declare); intrinsics.insert("llvm.dbg.value", value); } fn trap(bcx: block) { - let v: [ValueRef] = []; + let v: [ValueRef]/~ = []/~; alt bcx.ccx().intrinsics.find("llvm.trap") { some(x) { Call(bcx, x, v); } _ { bcx.sess().bug("unbound llvm.trap in trap"); } @@ -5348,20 +5359,20 @@ fn trap(bcx: block) { } fn create_module_map(ccx: @crate_ctxt) -> ValueRef { - let elttype = T_struct([ccx.int_type, ccx.int_type]); + let elttype = T_struct([ccx.int_type, ccx.int_type]/~); let maptype = T_array(elttype, ccx.module_data.size() + 1u); let map = str::as_c_str("_rust_mod_map", {|buf| llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) }); lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); - let mut elts: [ValueRef] = []; + let mut elts: [ValueRef]/~ = []/~; for ccx.module_data.each {|key, val| let elt = C_struct([p2i(ccx, C_cstr(ccx, key)), - p2i(ccx, val)]); - elts += [elt]; + p2i(ccx, val)]/~); + elts += [elt]/~; }; - let term = C_struct([C_int(ccx, 0), C_int(ccx, 0)]); - elts += [term]; + let term = C_struct([C_int(ccx, 0), C_int(ccx, 0)]/~); + elts += [term]/~; llvm::LLVMSetInitializer(map, C_array(elttype, elts)); ret map; } @@ -5379,7 +5390,7 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta, } else { "toplevel" }; let sym_name = "_rust_crate_map_" + mapname; let arrtype = T_array(int_type, n_subcrates as uint); - let maptype = T_struct([int_type, arrtype]); + let maptype = T_struct([int_type, arrtype]/~); let map = str::as_c_str(sym_name, {|buf| llvm::LLVMAddGlobal(llmod, maptype, buf) }); @@ -5388,7 +5399,7 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta, } fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { - let mut subcrates: [ValueRef] = []; + let mut subcrates: [ValueRef]/~ = []/~; let mut i = 1; let cstore = ccx.sess.cstore; while cstore::have_crate_data(cstore, i) { @@ -5399,13 +5410,13 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { let cr = str::as_c_str(nm, {|buf| llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf) }); - subcrates += [p2i(ccx, cr)]; + subcrates += [p2i(ccx, cr)]/~; i += 1; } - subcrates += [C_int(ccx, 0)]; + subcrates += [C_int(ccx, 0)]/~; llvm::LLVMSetInitializer(map, C_struct( [p2i(ccx, create_module_map(ccx)), - C_array(ccx.int_type, subcrates)])); + C_array(ccx.int_type, subcrates)]/~)); } fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) @@ -5427,8 +5438,8 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) encode_inlined_item: encode_inlined_item }; - fn reexports(cx: @crate_ctxt) -> [(str, ast::def_id)] { - let mut reexports = []; + fn reexports(cx: @crate_ctxt) -> [(str, ast::def_id)]/~ { + let mut reexports = []/~; for cx.exp_map.each {|exp_id, defs| for defs.each {|def| if !def.reexp { cont; } @@ -5437,14 +5448,14 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) ast_map::path_to_str(*path) } }; - reexports += [(path, def.id)]; + reexports += [(path, def.id)]/~; } } ret reexports; } fn impl_map(cx: @crate_ctxt, - id: ast::node_id) -> [(ast::ident, ast::def_id)] { + id: ast::node_id) -> [(ast::ident, ast::def_id)]/~ { alt *cx.maps.impl_map.get(id) { list::cons(impls, @list::nil) { (*impls).map {|i| @@ -5463,7 +5474,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { if !cx.sess.building_library { ret; } let encode_parms = crate_ctxt_to_encode_parms(cx); let llmeta = C_bytes(encoder::encode_metadata(encode_parms, crate)); - let llconst = C_struct([llmeta]); + let llconst = C_struct([llmeta]/~); let mut llglobal = str::as_c_str("rust_metadata", {|buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf) }); @@ -5479,7 +5490,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf) }); lib::llvm::SetLinkage(llvm_used, lib::llvm::AppendingLinkage); - llvm::LLVMSetInitializer(llvm_used, C_array(t_ptr_i8, [llglobal])); + llvm::LLVMSetInitializer(llvm_used, C_array(t_ptr_i8, [llglobal]/~)); } // Writes the current ABI version into the crate. @@ -5577,9 +5588,9 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, mut n_glues_created: 0u, mut n_null_glues: 0u, mut n_real_glues: 0u, - llvm_insn_ctxt: @mut [], + llvm_insn_ctxt: @mut []/~, llvm_insns: str_hash(), - fn_times: @mut []}, + fn_times: @mut []/~}, upcalls: upcall::declare_upcalls(targ_cfg, tn, tydesc_type, llmod), diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 6932dbda0bb..ca18bd25289 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -79,7 +79,7 @@ fn Ret(cx: block, V: ValueRef) { llvm::LLVMBuildRet(B(cx), V); } -fn AggregateRet(cx: block, RetVals: [ValueRef]) { +fn AggregateRet(cx: block, RetVals: [ValueRef]/~) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; @@ -134,7 +134,7 @@ fn noname() -> *libc::c_char unsafe { ret unsafe::reinterpret_cast(ptr::addr_of(cnull)); } -fn Invoke(cx: block, Fn: ValueRef, Args: [ValueRef], +fn Invoke(cx: block, Fn: ValueRef, Args: [ValueRef]/~, Then: BasicBlockRef, Catch: BasicBlockRef) { if cx.unreachable { ret; } assert (!cx.terminated); @@ -151,7 +151,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: [ValueRef], } } -fn FastInvoke(cx: block, Fn: ValueRef, Args: [ValueRef], +fn FastInvoke(cx: block, Fn: ValueRef, Args: [ValueRef]/~, Then: BasicBlockRef, Catch: BasicBlockRef) { if cx.unreachable { ret; } assert (!cx.terminated); @@ -417,7 +417,7 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) { llvm::LLVMBuildStore(B(cx), Val, Ptr); } -fn GEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]) -> ValueRef { +fn GEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]/~) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { count_insn(cx, "gep"); @@ -428,14 +428,14 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]) -> ValueRef { // Simple wrapper around GEP that takes an array of ints and wraps them // in C_i32() -fn GEPi(cx: block, base: ValueRef, ixs: [uint]) -> ValueRef { - let mut v: [ValueRef] = []; - for vec::each(ixs) {|i| v += [C_i32(i as i32)]; } +fn GEPi(cx: block, base: ValueRef, ixs: [uint]/~) -> ValueRef { + let mut v: [ValueRef]/~ = []/~; + for vec::each(ixs) {|i| v += [C_i32(i as i32)]/~; } count_insn(cx, "gepi"); ret InBoundsGEP(cx, base, v); } -fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]) -> +fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]/~) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { @@ -607,7 +607,7 @@ fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef { ret llvm::LLVMBuildPhi(B(cx), Ty, noname()); } -fn Phi(cx: block, Ty: TypeRef, vals: [ValueRef], bbs: [BasicBlockRef]) +fn Phi(cx: block, Ty: TypeRef, vals: [ValueRef]/~, bbs: [BasicBlockRef]/~) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } assert vals.len() == bbs.len(); @@ -657,15 +657,15 @@ fn add_comment(bcx: block, text: str) { let asm = str::as_c_str(comment_text, {|c| str::as_c_str("", {|e| count_insn(bcx, "inlineasm"); - llvm::LLVMConstInlineAsm(T_fn([], T_void()), c, e, + llvm::LLVMConstInlineAsm(T_fn([]/~, T_void()), c, e, False, False) }) }); - Call(bcx, asm, []); + Call(bcx, asm, []/~); } } -fn Call(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef { +fn Call(cx: block, Fn: ValueRef, Args: [ValueRef]/~) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { count_insn(cx, "call"); @@ -679,7 +679,7 @@ fn Call(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef { } } -fn FastCall(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef { +fn FastCall(cx: block, Fn: ValueRef, Args: [ValueRef]/~) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { count_insn(cx, "fastcall"); @@ -690,7 +690,7 @@ fn FastCall(cx: block, Fn: ValueRef, Args: [ValueRef]) -> ValueRef { } } -fn CallWithConv(cx: block, Fn: ValueRef, Args: [ValueRef], +fn CallWithConv(cx: block, Fn: ValueRef, Args: [ValueRef]/~, Conv: CallConv) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { @@ -779,7 +779,7 @@ fn Trap(cx: block) { llvm::LLVMGetNamedFunction(M, buf) }); assert (T as int != 0); - let Args: [ValueRef] = []; + let Args: [ValueRef]/~ = []/~; unsafe { count_insn(cx, "trap"); llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args), diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 745c25f6f79..51a1bba1162 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -122,9 +122,9 @@ fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t { // Given a closure ty, emits a corresponding tuple ty fn mk_closure_tys(tcx: ty::ctxt, - bound_values: [environment_value]) - -> (ty::t, [ty::t]) { - let mut bound_tys = []; + bound_values: [environment_value]/~) + -> (ty::t, [ty::t]/~) { + let mut bound_tys = []/~; // Compute the closed over data for vec::each(bound_values) {|bv| @@ -133,12 +133,12 @@ fn mk_closure_tys(tcx: ty::ctxt, env_move(_, t, _) { t } env_ref(_, t, _) { t } env_expr(_, t) { t } - }]; + }]/~; } let bound_data_ty = ty::mk_tup(tcx, bound_tys); - // FIXME[mono] remove tuple of tydescs from closure types (#2531) - let cdata_ty = ty::mk_tup(tcx, [ty::mk_tup(tcx, []), - bound_data_ty]); + // FIXME[mono]/~ remove tuple of tydescs from closure types (#2531) + let cdata_ty = ty::mk_tup(tcx, [ty::mk_tup(tcx, []/~), + bound_data_ty]/~); #debug["cdata_ty=%s", ty_to_str(tcx, cdata_ty)]; ret (cdata_ty, bound_tys); } @@ -146,7 +146,7 @@ fn mk_closure_tys(tcx: ty::ctxt, fn allocate_cbox(bcx: block, ck: ty::closure_kind, cdata_ty: ty::t) - -> (block, ValueRef, [ValueRef]) { + -> (block, ValueRef, [ValueRef]/~) { let _icx = bcx.insn_ctxt("closure::allocate_cbox"); let ccx = bcx.ccx(), tcx = ccx.tcx; @@ -155,7 +155,7 @@ fn allocate_cbox(bcx: block, // Initialize ref count to arbitrary value for debugging: let ccx = bcx.ccx(); let box = PointerCast(bcx, box, T_opaque_box_ptr(ccx)); - let ref_cnt = GEPi(bcx, box, [0u, abi::box_field_refcnt]); + let ref_cnt = GEPi(bcx, box, [0u, abi::box_field_refcnt]/~); let rc = C_int(ccx, 0x12345678); Store(bcx, rc, ref_cnt); } @@ -164,7 +164,7 @@ fn allocate_cbox(bcx: block, cdata_ty: ty::t, box: ValueRef, &ti: option<@tydesc_info>) -> block { - let bound_tydesc = GEPi(bcx, box, [0u, abi::box_field_tydesc]); + let bound_tydesc = GEPi(bcx, box, [0u, abi::box_field_tydesc]/~); let td = base::get_tydesc(bcx.ccx(), cdata_ty, ti); Store(bcx, td, bound_tydesc); bcx @@ -172,7 +172,7 @@ fn allocate_cbox(bcx: block, // Allocate and initialize the box: let mut ti = none; - let mut temp_cleanups = []; + let mut temp_cleanups = []/~; let (bcx, box) = alt ck { ty::ck_box { get_tydesc(ccx, cdata_ty, ti); @@ -209,7 +209,7 @@ type closure_result = { // heap allocated closure that copies the upvars into environment. // Otherwise, it is stack allocated and copies pointers to the upvars. fn store_environment(bcx: block, - bound_values: [environment_value], + bound_values: [environment_value]/~, ck: ty::closure_kind) -> closure_result { let _icx = bcx.insn_ctxt("closure::store_environment"); let ccx = bcx.ccx(), tcx = ccx.tcx; @@ -242,12 +242,12 @@ fn store_environment(bcx: block, } let bound_data = GEPi(bcx, llbox, - [0u, abi::box_field_body, abi::closure_body_bindings, i]); + [0u, abi::box_field_body, abi::closure_body_bindings, i]/~); alt bv { env_expr(e, _) { bcx = base::trans_expr_save_in(bcx, e, bound_data); add_clean_temp_mem(bcx, bound_data, bound_tys[i]); - temp_cleanups += [bound_data]; + temp_cleanups += [bound_data]/~; } env_copy(val, ty, owned) { let val1 = load_if_immediate(bcx, val, ty); @@ -283,13 +283,13 @@ fn store_environment(bcx: block, // Given a context and a list of upvars, build a closure. This just // collects the upvars and packages them up for store_environment. fn build_closure(bcx0: block, - cap_vars: [capture::capture_var], + cap_vars: [capture::capture_var]/~, ck: ty::closure_kind, id: ast::node_id, include_ret_handle: option<ValueRef>) -> closure_result { let _icx = bcx0.insn_ctxt("closure::build_closure"); // If we need to, package up the iterator body to call - let mut env_vals = []; + let mut env_vals = []/~; let mut bcx = bcx0; let ccx = bcx.ccx(), tcx = ccx.tcx; @@ -303,18 +303,18 @@ fn build_closure(bcx0: block, capture::cap_ref { assert ck == ty::ck_block; ty = ty::mk_mut_ptr(tcx, ty); - env_vals += [env_ref(lv.val, ty, lv.kind)]; + env_vals += [env_ref(lv.val, ty, lv.kind)]/~; } capture::cap_copy { let mv = alt check ccx.maps.last_use_map.find(id) { none { false } some(vars) { (*vars).contains(nid) } }; - if mv { env_vals += [env_move(lv.val, ty, lv.kind)]; } - else { env_vals += [env_copy(lv.val, ty, lv.kind)]; } + if mv { env_vals += [env_move(lv.val, ty, lv.kind)]/~; } + else { env_vals += [env_copy(lv.val, ty, lv.kind)]/~; } } capture::cap_move { - env_vals += [env_move(lv.val, ty, lv.kind)]; + env_vals += [env_move(lv.val, ty, lv.kind)]/~; } capture::cap_drop { assert lv.kind == owned; @@ -331,7 +331,7 @@ fn build_closure(bcx0: block, let nil_ret = PointerCast(bcx, our_ret, T_ptr(T_nil())); env_vals += [env_ref(flagptr, ty::mk_mut_ptr(tcx, ty::mk_bool(tcx)), owned), - env_ref(nil_ret, ty::mk_nil_ptr(tcx), owned)]; + env_ref(nil_ret, ty::mk_nil_ptr(tcx), owned)]/~; } ret store_environment(bcx, env_vals, ck); } @@ -341,7 +341,7 @@ fn build_closure(bcx0: block, // with the upvars and type descriptors. fn load_environment(fcx: fn_ctxt, cdata_ty: ty::t, - cap_vars: [capture::capture_var], + cap_vars: [capture::capture_var]/~, load_ret_handle: bool, ck: ty::closure_kind) { let _icx = fcx.insn_ctxt("closure::load_environment"); @@ -357,7 +357,7 @@ fn load_environment(fcx: fn_ctxt, capture::cap_drop { /* ignore */ } _ { let mut upvarptr = - GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, i]); + GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, i]/~); alt ck { ty::ck_block { upvarptr = Load(bcx, upvarptr); } ty::ck_uniq | ty::ck_box { } @@ -370,9 +370,10 @@ fn load_environment(fcx: fn_ctxt, } if load_ret_handle { let flagptr = Load(bcx, GEPi(bcx, llcdata, - [0u, abi::closure_body_bindings, i])); - let retptr = Load(bcx, GEPi(bcx, llcdata, - [0u, abi::closure_body_bindings, i+1u])); + [0u, abi::closure_body_bindings, i]/~)); + let retptr = Load(bcx, + GEPi(bcx, llcdata, + [0u, abi::closure_body_bindings, i+1u]/~)); fcx.loop_ret = some({flagptr: flagptr, retptr: retptr}); } } @@ -390,7 +391,7 @@ fn trans_expr_fn(bcx: block, let ccx = bcx.ccx(), bcx = bcx; let fty = node_id_type(bcx, id); let llfnty = type_of_fn_from_ty(ccx, fty); - let sub_path = bcx.fcx.path + [path_name(@"anon")]; + let sub_path = bcx.fcx.path + [path_name(@"anon")]/~; let s = mangle_internal_name_by_path(ccx, sub_path); let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); @@ -428,13 +429,13 @@ fn trans_expr_fn(bcx: block, fn trans_bind_1(cx: block, outgoing_fty: ty::t, f_res: lval_maybe_callee, - args: [option<@ast::expr>], pair_ty: ty::t, + args: [option<@ast::expr>]/~, pair_ty: ty::t, dest: dest) -> block { let _icx = cx.insn_ctxt("closure::trans_bind1"); let ccx = cx.ccx(); - let mut bound: [@ast::expr] = []; + let mut bound: [@ast::expr]/~ = []/~; for vec::each(args) {|argopt| - alt argopt { none { } some(e) { bound += [e]; } } + alt argopt { none { } some(e) { bound += [e]/~; } } } let mut bcx = f_res.bcx; if dest == ignore { @@ -453,22 +454,22 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t, // Arrange for the bound function to live in the first binding spot // if the function is not statically known. let (env_vals, target_info) = alt f_res.env { - null_env { ([], target_static(f_res.val)) } + null_env { ([]/~, target_static(f_res.val)) } is_closure { // Cast the function we are binding to be the type that the // closure will expect it to have. The type the closure knows // about has the type parameters substituted with the real types. let llclosurety = T_ptr(type_of(ccx, outgoing_fty)); let src_loc = PointerCast(bcx, f_res.val, llclosurety); - ([env_copy(src_loc, pair_ty, owned)], target_closure) + ([env_copy(src_loc, pair_ty, owned)]/~, target_closure) } self_env(slf, slf_t, none) { - ([env_copy(slf, slf_t, owned)], target_static_self(f_res.val)) + ([env_copy(slf, slf_t, owned)]/~, target_static_self(f_res.val)) } self_env(_, slf_t, some(slf)) { let cast = PointerCast(bcx, f_res.val, T_ptr(T_nil())); ([env_copy(cast, ty::mk_nil_ptr(ccx.tcx), owned_imm), - env_copy(slf, slf_t, owned_imm)], target_self) + env_copy(slf, slf_t, owned_imm)]/~, target_self) } }; @@ -498,7 +499,7 @@ fn make_fn_glue( let tcx = cx.tcx(); let fn_env = fn@(ck: ty::closure_kind) -> block { - let box_cell_v = GEPi(cx, v, [0u, abi::fn_field_box]); + let box_cell_v = GEPi(cx, v, [0u, abi::fn_field_box]/~); let box_ptr_v = Load(cx, box_cell_v); with_cond(cx, IsNotNull(cx, box_ptr_v)) {|bcx| let closure_ty = ty::mk_opaque_closure_ptr(tcx, ck); @@ -536,28 +537,28 @@ fn make_opaque_cbox_take_glue( with_cond(bcx, IsNotNull(bcx, cbox_in)) {|bcx| // Load the size from the type descr found in the cbox let cbox_in = PointerCast(bcx, cbox_in, llopaquecboxty); - let tydescptr = GEPi(bcx, cbox_in, [0u, abi::box_field_tydesc]); + let tydescptr = GEPi(bcx, cbox_in, [0u, abi::box_field_tydesc]/~); let tydesc = Load(bcx, tydescptr); let tydesc = PointerCast(bcx, tydesc, T_ptr(ccx.tydesc_type)); - let sz = Load(bcx, GEPi(bcx, tydesc, [0u, abi::tydesc_field_size])); + let sz = Load(bcx, GEPi(bcx, tydesc, [0u, abi::tydesc_field_size]/~)); // Adjust sz to account for the rust_opaque_box header fields let sz = Add(bcx, sz, shape::llsize_of(ccx, T_box_header(ccx))); // Allocate memory, update original ptr, and copy existing data let malloc = ccx.upcalls.exchange_malloc; - let cbox_out = Call(bcx, malloc, [tydesc, sz]); + let cbox_out = Call(bcx, malloc, [tydesc, sz]/~); let cbox_out = PointerCast(bcx, cbox_out, llopaquecboxty); call_memmove(bcx, cbox_out, cbox_in, sz); Store(bcx, cbox_out, cboxptr); // Take the (deeply cloned) type descriptor - let tydesc_out = GEPi(bcx, cbox_out, [0u, abi::box_field_tydesc]); + let tydesc_out = GEPi(bcx, cbox_out, [0u, abi::box_field_tydesc]/~); let bcx = take_ty(bcx, tydesc_out, ty::mk_type(tcx)); // Take the data in the tuple let ti = none; - let cdata_out = GEPi(bcx, cbox_out, [0u, abi::box_field_body]); + let cdata_out = GEPi(bcx, cbox_out, [0u, abi::box_field_body]/~); call_tydesc_glue_full(bcx, cdata_out, tydesc, abi::tydesc_field_take_glue, ti); bcx @@ -599,13 +600,13 @@ fn make_opaque_cbox_free_glue( // Load the type descr found in the cbox let lltydescty = T_ptr(ccx.tydesc_type); let cbox = PointerCast(bcx, cbox, T_opaque_cbox_ptr(ccx)); - let tydescptr = GEPi(bcx, cbox, [0u, abi::box_field_tydesc]); + let tydescptr = GEPi(bcx, cbox, [0u, abi::box_field_tydesc]/~); let tydesc = Load(bcx, tydescptr); let tydesc = PointerCast(bcx, tydesc, lltydescty); // Drop the tuple data then free the descriptor let ti = none; - let cdata = GEPi(bcx, cbox, [0u, abi::box_field_body]); + let cdata = GEPi(bcx, cbox, [0u, abi::box_field_body]/~); call_tydesc_glue_full(bcx, cdata, tydesc, abi::tydesc_field_drop_glue, ti); @@ -634,14 +635,14 @@ fn trans_bind_thunk(ccx: @crate_ctxt, path: path, incoming_fty: ty::t, outgoing_fty: ty::t, - args: [option<@ast::expr>], + args: [option<@ast::expr>]/~, cdata_ty: ty::t, target_info: target_info) -> {val: ValueRef, ty: TypeRef} { let _icx = ccx.insn_ctxt("closure::trans_bind_thunk"); let tcx = ccx.tcx; #debug["trans_bind_thunk[incoming_fty=%s,outgoing_fty=%s,\ - cdata_ty=%s]", + cdata_ty=%s]/~", ty_to_str(tcx, incoming_fty), ty_to_str(tcx, outgoing_fty), ty_to_str(tcx, cdata_ty)]; @@ -701,22 +702,25 @@ fn trans_bind_thunk(ccx: @crate_ctxt, (fptr, llvm::LLVMGetUndef(T_opaque_cbox_ptr(ccx)), 0u) } target_closure { - let pair = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 0u]); + let pair = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 0u]/~); let lltargetenv = - Load(bcx, GEPi(bcx, pair, [0u, abi::fn_field_box])); + Load(bcx, GEPi(bcx, pair, [0u, abi::fn_field_box]/~)); let lltargetfn = Load - (bcx, GEPi(bcx, pair, [0u, abi::fn_field_code])); + (bcx, GEPi(bcx, pair, [0u, abi::fn_field_code]/~)); (lltargetfn, lltargetenv, 1u) } target_self { let fptr = Load(bcx, GEPi(bcx, llcdata, - [0u, abi::closure_body_bindings, 0u])); - let slfbox = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 1u]); - let selfptr = GEPi(bcx, Load(bcx, slfbox), [0u, abi::box_field_body]); + [0u, abi::closure_body_bindings, 0u]/~)); + let slfbox = + GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 1u]/~); + let selfptr = + GEPi(bcx, Load(bcx, slfbox), [0u, abi::box_field_body]/~); (fptr, PointerCast(bcx, selfptr, T_opaque_cbox_ptr(ccx)), 2u) } target_static_self(fptr) { - let slfptr = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 0u]); + let slfptr = + GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 0u]/~); (fptr, PointerCast(bcx, slfptr, T_opaque_cbox_ptr(ccx)), 1u) } }; @@ -728,7 +732,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt, let outgoing_args = ty::ty_fn_args(outgoing_fty); // Set up the three implicit arguments to the thunk. - let mut llargs: [ValueRef] = [fcx.llretptr, lltargetenv]; + let mut llargs: [ValueRef]/~ = [fcx.llretptr, lltargetenv]/~; let mut a: uint = first_real_arg; // retptr, env come first let mut b: uint = starting_idx; @@ -740,7 +744,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt, // closure. some(e) { let mut val = - GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, b]); + GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, b]/~); alt ty::resolved_mode(tcx, out_arg.mode) { ast::by_val { @@ -754,13 +758,13 @@ fn trans_bind_thunk(ccx: @crate_ctxt, } ast::by_ref | ast::by_mutbl_ref | ast::by_move { } } - llargs += [val]; + llargs += [val]/~; b += 1u; } // Arg will be provided when the thunk is invoked. none { - llargs += [llvm::LLVMGetParam(llthunk, a as c_uint)]; + llargs += [llvm::LLVMGetParam(llthunk, a as c_uint)]/~; a += 1u; } } diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 8c0abd5166e..109b533b007 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -58,9 +58,9 @@ type stats = mut n_glues_created: uint, mut n_null_glues: uint, mut n_real_glues: uint, - llvm_insn_ctxt: @mut [str], + llvm_insn_ctxt: @mut [str]/~, llvm_insns: hashmap<str, uint>, - fn_times: @mut [{ident: str, time: int}]}; + fn_times: @mut [{ident: str, time: int}]/~}; class BuilderRef_res { let B: BuilderRef; @@ -92,7 +92,7 @@ type crate_ctxt = { monomorphized: hashmap<mono_id, ValueRef>, monomorphizing: hashmap<ast::def_id, uint>, // Cache computed type parameter uses (see type_use.rs) - type_use_cache: hashmap<ast::def_id, [type_use::type_uses]>, + type_use_cache: hashmap<ast::def_id, [type_use::type_uses]/~>, // Cache generated vtables vtables: hashmap<mono_id, ValueRef>, // Cache of constant strings, @@ -129,9 +129,9 @@ type val_self_pair = {v: ValueRef, t: ty::t}; enum local_val { local_mem(ValueRef), local_imm(ValueRef), } -type param_substs = {tys: [ty::t], +type param_substs = {tys: [ty::t]/~, vtables: option<typeck::vtable_res>, - bounds: @[ty::param_bounds]}; + bounds: @[ty::param_bounds]/~}; // Function context. Every LLVM function we create will have one of // these. @@ -217,7 +217,7 @@ type cleanup_path = {target: option<BasicBlockRef>, dest: BasicBlockRef}; fn scope_clean_changed(info: scope_info) { - if info.cleanup_paths.len() > 0u { info.cleanup_paths = []; } + if info.cleanup_paths.len() > 0u { info.cleanup_paths = []/~; } info.landing_pad = none; } @@ -237,7 +237,7 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) { let cleanup_type = cleanup_type(cx.tcx(), ty); in_scope_cx(cx) {|info| info.cleanups += [clean({|a|base::drop_ty(a, val, ty)}, - cleanup_type)]; + cleanup_type)]/~; scope_clean_changed(info); } } @@ -257,7 +257,7 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { } in_scope_cx(cx) {|info| info.cleanups += [clean_temp(val, {|a|do_drop(a, val, ty)}, - cleanup_type)]; + cleanup_type)]/~; scope_clean_changed(info); } } @@ -269,7 +269,7 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) { let cleanup_type = cleanup_type(cx.tcx(), ty); in_scope_cx(cx) {|info| info.cleanups += [clean_temp(val, {|a|base::drop_ty(a, val, ty)}, - cleanup_type)]; + cleanup_type)]/~; scope_clean_changed(info); } } @@ -278,7 +278,7 @@ fn add_clean_free(cx: block, ptr: ValueRef, shared: bool) { else { {|a|base::trans_free(a, ptr)} }; in_scope_cx(cx) {|info| info.cleanups += [clean_temp(ptr, free_fn, - normal_exit_and_unwind)]; + normal_exit_and_unwind)]/~; scope_clean_changed(info); } } @@ -318,10 +318,10 @@ type scope_info = { // A list of functions that must be run at when leaving this // block, cleaning up any variables that were introduced in the // block. - mut cleanups: [cleanup], + mut cleanups: [cleanup]/~, // Existing cleanup paths that may be reused, indexed by destination and // cleared when the set of cleanups changes. - mut cleanup_paths: [cleanup_path], + mut cleanup_paths: [cleanup_path]/~, // Unwinding landing pad. Also cleared when cleanups change. mut landing_pad: option<BasicBlockRef>, }; @@ -551,21 +551,21 @@ fn T_size_t(targ_cfg: @session::config) -> TypeRef { ret T_int(targ_cfg); } -fn T_fn(inputs: [TypeRef], output: TypeRef) -> TypeRef unsafe { +fn T_fn(inputs: [TypeRef]/~, output: TypeRef) -> TypeRef unsafe { ret llvm::LLVMFunctionType(output, to_ptr(inputs), inputs.len() as c_uint, False); } fn T_fn_pair(cx: @crate_ctxt, tfn: TypeRef) -> TypeRef { - ret T_struct([T_ptr(tfn), T_opaque_cbox_ptr(cx)]); + ret T_struct([T_ptr(tfn), T_opaque_cbox_ptr(cx)]/~); } fn T_ptr(t: TypeRef) -> TypeRef { ret llvm::LLVMPointerType(t, 0u as c_uint); } -fn T_struct(elts: [TypeRef]) -> TypeRef unsafe { +fn T_struct(elts: [TypeRef]/~) -> TypeRef unsafe { ret llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False); } @@ -574,12 +574,12 @@ fn T_named_struct(name: str) -> TypeRef { ret str::as_c_str(name, {|buf| llvm::LLVMStructCreateNamed(c, buf) }); } -fn set_struct_body(t: TypeRef, elts: [TypeRef]) unsafe { +fn set_struct_body(t: TypeRef, elts: [TypeRef]/~) unsafe { llvm::LLVMStructSetBody(t, to_ptr(elts), elts.len() as c_uint, False); } -fn T_empty_struct() -> TypeRef { ret T_struct([]); } +fn T_empty_struct() -> TypeRef { ret T_struct([]/~); } // A vtable is, in reality, a vtable pointer followed by zero or more pointers // to tydescs and other vtables that it closes over. But the types and number @@ -604,7 +604,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef { let t_int = T_int(targ_cfg); let elems = [t_int, t_int, t_int, t_int, - t_int, t_int, t_int, t_int]; + t_int, t_int, t_int, t_int]/~; set_struct_body(t, elems); ret t; } @@ -612,7 +612,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef { fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { // Bit of a kludge: pick the fn typeref out of the tydesc.. - let tydesc_elts: [TypeRef] = + let tydesc_elts: [TypeRef]/~ = vec::from_elem::<TypeRef>(abi::n_tydesc_fields, T_nil()); llvm::LLVMGetStructElementTypes(cx.tydesc_type, @@ -635,14 +635,14 @@ fn T_tydesc(targ_cfg: @session::config) -> TypeRef { let pvoid = T_ptr(T_i8()); let glue_fn_ty = T_ptr(T_fn([T_ptr(T_nil()), T_ptr(T_nil()), tydescpp, - pvoid], T_void())); + pvoid]/~, T_void())); let int_type = T_int(targ_cfg); let elems = [tydescpp, int_type, int_type, glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, int_type, int_type, int_type, int_type, - T_ptr(T_i8()), T_ptr(T_i8()), int_type, int_type]; + T_ptr(T_i8()), T_ptr(T_i8()), int_type, int_type]/~; set_struct_body(tydesc, elems); ret tydesc; } @@ -655,7 +655,7 @@ fn T_array(t: TypeRef, n: uint) -> TypeRef { fn T_vec2(targ_cfg: @session::config, t: TypeRef) -> TypeRef { ret T_struct([T_int(targ_cfg), // fill T_int(targ_cfg), // alloc - T_array(t, 0u)]); // elements + T_array(t, 0u)]/~); // elements } fn T_vec(ccx: @crate_ctxt, t: TypeRef) -> TypeRef { @@ -674,12 +674,12 @@ fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { let ptr = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm}); ret ty::mk_tup(tcx, [ty::mk_uint(tcx), ty::mk_type(tcx), ptr, ptr, - t]); + t]/~); } -fn T_box_header_fields(cx: @crate_ctxt) -> [TypeRef] { +fn T_box_header_fields(cx: @crate_ctxt) -> [TypeRef]/~ { let ptr = T_ptr(T_i8()); - ret [cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr]; + ret [cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr]/~; } fn T_box_header(cx: @crate_ctxt) -> TypeRef { @@ -687,7 +687,7 @@ fn T_box_header(cx: @crate_ctxt) -> TypeRef { } fn T_box(cx: @crate_ctxt, t: TypeRef) -> TypeRef { - ret T_struct(T_box_header_fields(cx) + [t]); + ret T_struct(T_box_header_fields(cx) + [t]/~); } fn T_box_ptr(t: TypeRef) -> TypeRef { @@ -704,7 +704,7 @@ fn T_opaque_box_ptr(cx: @crate_ctxt) -> TypeRef { } fn T_unique(cx: @crate_ctxt, t: TypeRef) -> TypeRef { - ret T_struct(T_box_header_fields(cx) + [t]); + ret T_struct(T_box_header_fields(cx) + [t]/~); } fn T_unique_ptr(t: TypeRef) -> TypeRef { @@ -713,12 +713,12 @@ fn T_unique_ptr(t: TypeRef) -> TypeRef { } fn T_port(cx: @crate_ctxt, _t: TypeRef) -> TypeRef { - ret T_struct([cx.int_type]); // Refcount + ret T_struct([cx.int_type]/~); // Refcount } fn T_chan(cx: @crate_ctxt, _t: TypeRef) -> TypeRef { - ret T_struct([cx.int_type]); // Refcount + ret T_struct([cx.int_type]/~); // Refcount } @@ -749,7 +749,7 @@ fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef { fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef { let s = "opaque_enum"; alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} } - let t = T_struct([T_enum_discrim(cx), T_i8()]); + let t = T_struct([T_enum_discrim(cx), T_i8()]/~); associate_type(cx.tn, s, t); ret t; } @@ -763,7 +763,7 @@ fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef { } fn T_opaque_iface(cx: @crate_ctxt) -> TypeRef { - T_struct([T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)]) + T_struct([T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)]/~) } fn T_opaque_port_ptr() -> TypeRef { ret T_ptr(T_i8()); } @@ -836,7 +836,7 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { fn C_estr_slice(cx: @crate_ctxt, s: str) -> ValueRef { let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s), T_ptr(T_i8())); - C_struct([cs, C_uint(cx, str::len(s) + 1u /* +1 for null */)]) + C_struct([cs, C_uint(cx, str::len(s) + 1u /* +1 for null */)]/~) } // Returns a Plain Old LLVM String: @@ -848,34 +848,34 @@ fn C_postr(s: str) -> ValueRef { fn C_zero_byte_arr(size: uint) -> ValueRef unsafe { let mut i = 0u; - let mut elts: [ValueRef] = []; - while i < size { elts += [C_u8(0u)]; i += 1u; } + let mut elts: [ValueRef]/~ = []/~; + while i < size { elts += [C_u8(0u)]/~; i += 1u; } ret llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts), elts.len() as c_uint); } -fn C_struct(elts: [ValueRef]) -> ValueRef unsafe { +fn C_struct(elts: [ValueRef]/~) -> ValueRef unsafe { ret llvm::LLVMConstStruct(vec::unsafe::to_ptr(elts), elts.len() as c_uint, False); } -fn C_named_struct(T: TypeRef, elts: [ValueRef]) -> ValueRef unsafe { +fn C_named_struct(T: TypeRef, elts: [ValueRef]/~) -> ValueRef unsafe { ret llvm::LLVMConstNamedStruct(T, vec::unsafe::to_ptr(elts), elts.len() as c_uint); } -fn C_array(ty: TypeRef, elts: [ValueRef]) -> ValueRef unsafe { +fn C_array(ty: TypeRef, elts: [ValueRef]/~) -> ValueRef unsafe { ret llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts), elts.len() as c_uint); } -fn C_bytes(bytes: [u8]) -> ValueRef unsafe { +fn C_bytes(bytes: [u8]/~) -> ValueRef unsafe { ret llvm::LLVMConstString( unsafe::reinterpret_cast(vec::unsafe::to_ptr(bytes)), bytes.len() as c_uint, 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 = str::as_c_str(ccx.names("shape"), {|buf| llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) @@ -892,11 +892,11 @@ fn get_param(fndecl: ValueRef, param: uint) -> ValueRef { // Used to identify cached monomorphized functions and vtables enum mono_param_id { - mono_precise(ty::t, option<[mono_id]>), + mono_precise(ty::t, option<[mono_id]/~>), mono_any, mono_repr(uint /* size */, uint /* align */), } -type mono_id = @{def: ast::def_id, params: [mono_param_id]}; +type mono_id = @{def: ast::def_id, params: [mono_param_id]/~}; fn hash_mono_id(&&mi: mono_id) -> uint { let mut h = syntax::ast_util::hash_def(mi.def); for vec::each(mi.params) {|param| @@ -954,7 +954,7 @@ fn node_id_type(bcx: block, id: ast::node_id) -> ty::t { fn expr_ty(bcx: block, ex: @ast::expr) -> ty::t { node_id_type(bcx, ex.id) } -fn node_id_type_params(bcx: block, id: ast::node_id) -> [ty::t] { +fn node_id_type_params(bcx: block, id: ast::node_id) -> [ty::t]/~ { let tcx = bcx.tcx(); let params = ty::node_id_to_type_params(tcx, id); alt bcx.fcx.param_substs { @@ -966,7 +966,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> [ty::t] { } fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident, - fields: [ty::field]) + fields: [ty::field]/~) -> uint { alt ty::field_idx(ident, fields) { none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \ @@ -975,7 +975,7 @@ fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident, } } -fn dummy_substs(tps: [ty::t]) -> ty::substs { +fn dummy_substs(tps: [ty::t]/~) -> ty::substs { {self_r: some(ty::re_bound(ty::br_self)), self_ty: none, tps: tps} diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 48a087d0c27..219658cebb9 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -64,7 +64,7 @@ fn lli64(val: int) -> ValueRef { fn lli1(bval: bool) -> ValueRef { C_bool(bval) } -fn llmdnode(elems: [ValueRef]) -> ValueRef unsafe { +fn llmdnode(elems: [ValueRef]/~) -> ValueRef unsafe { llvm::LLVMMDNode(vec::unsafe::to_ptr(elems), vec::len(elems) as libc::c_uint) } @@ -99,9 +99,9 @@ fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { let existing = if cache.contains_key(mdtag) { cache.get(mdtag) } else { - [] + []/~ }; - cache.insert(mdtag, existing + [val]); + cache.insert(mdtag, existing + [val]/~); } type metadata<T> = {node: ValueRef, data: T}; @@ -115,7 +115,7 @@ type block_md = {start: codemap::loc, end: codemap::loc}; type argument_md = {id: ast::node_id}; type retval_md = {id: ast::node_id}; -type metadata_cache = hashmap<int, [debug_metadata]>; +type metadata_cache = hashmap<int, [debug_metadata]/~>; enum debug_metadata { file_metadata(@metadata<file_md>), @@ -183,7 +183,7 @@ fn create_compile_unit(cx: @crate_ctxt) lli1(cx.sess.opts.optimize != 0u), llstr(""), // flags (???) lli32(0) // runtime version (???) - ]; + ]/~; let unit_node = llmdnode(unit_metadata); add_named_metadata(cx, "llvm.dbg.cu", unit_node); let mdval = @{node: unit_node, data: {name: crate_name}}; @@ -220,7 +220,7 @@ fn create_file(cx: @crate_ctxt, full_path: str) -> @metadata<file_md> { let file_md = [lltag(tg), llstr(file_path), llstr(work_dir), - unit_node]; + unit_node]/~; let val = llmdnode(file_md); let mdval = @{node: val, data: {path: full_path}}; update_cache(cache, tg, file_metadata(mdval)); @@ -268,7 +268,7 @@ fn create_block(cx: block) -> @metadata<block_md> { lli32(start.col as int), file_node.node, lli32(unique_id) - ]; + ]/~; let val = llmdnode(lldata); let mdval = @{node: val, data: {start: start, end: end}}; //update_cache(cache, tg, block_metadata(mdval)); @@ -328,7 +328,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) lli64(align * 8), // alignment in bits lli64(0), //XXX offset? lli32(0), //XXX flags? - lli32(encoding)]; + lli32(encoding)]/~; let llnode = llmdnode(lldata); let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; update_cache(cache, tg, tydesc_metadata(mdval)); @@ -362,7 +362,7 @@ type struct_ctxt = { file: ValueRef, name: str, line: int, - mut members: [ValueRef], + mut members: [ValueRef]/~, mut total_size: int, align: int }; @@ -378,7 +378,7 @@ fn create_structure(file: @metadata<file_md>, name: str, line: int) let cx = @{file: file.node, name: name, line: line, - mut members: [], + mut members: []/~, mut total_size: 0, align: 64 //XXX different alignment per arch? }; @@ -397,7 +397,7 @@ fn create_derived_type(type_tag: int, file: ValueRef, name: str, line: int, lli64(align), lli64(offset), lli32(0), - ty]; + ty]/~; ret llmdnode(lldata); } @@ -405,11 +405,11 @@ fn add_member(cx: @struct_ctxt, name: str, line: int, size: int, align: int, ty: ValueRef) { cx.members += [create_derived_type(MemberTag, cx.file, name, line, size * 8, align * 8, cx.total_size, - ty)]; + ty)]/~; cx.total_size += size * 8; } -fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field], +fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field]/~, span: span) -> @metadata<tydesc_md> { let fname = filename_from_span(cx, span); let file_node = create_file(cx, fname); @@ -461,7 +461,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, fn create_composite_type(type_tag: int, name: str, file: ValueRef, line: int, size: int, align: int, offset: int, derived: option<ValueRef>, - members: option<[ValueRef]>) + members: option<[ValueRef]/~>) -> ValueRef { let lldata = [lltag(type_tag), file, @@ -484,7 +484,7 @@ fn create_composite_type(type_tag: int, name: str, file: ValueRef, line: int, }, lli32(0), // runtime language llnull() - ]; + ]/~; ret llmdnode(lldata); } @@ -501,12 +501,12 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, sys::min_align_of::<libc::size_t>() as int, size_t_type.node); add_member(scx, "alloc", 0, sys::size_of::<libc::size_t>() as int, sys::min_align_of::<libc::size_t>() as int, size_t_type.node); - let subrange = llmdnode([lltag(SubrangeTag), lli64(0), lli64(0)]); + let subrange = llmdnode([lltag(SubrangeTag), lli64(0), lli64(0)]/~); let (arr_size, arr_align) = size_and_align_of(cx, elem_t); let data_ptr = create_composite_type(ArrayTypeTag, "", file_node.node, 0, arr_size, arr_align, 0, option::some(elem_ty_md.node), - option::some([subrange])); + option::some([subrange]/~)); add_member(scx, "data", 0, 0, // clang says the size should be 0 sys::min_align_of::<u8>() as int, data_ptr); let llnode = finish_structure(scx); @@ -548,12 +548,12 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) ty::ty_uniq(mt) { ast::ty_uniq({ty: t_to_ty(cx, mt.ty, span), mutbl: mt.mutbl}) } ty::ty_rec(fields) { - let fs = []; + let fs = []/~; for field in fields { fs += [{node: {ident: field.ident, mt: {ty: t_to_ty(cx, field.mt.ty, span), mutbl: field.mt.mutbl}}, - span: span}]; + span: span}]/~; } ast::ty_rec(fs) } @@ -630,7 +630,7 @@ fn create_var(type_tag: int, context: ValueRef, name: str, file: ValueRef, lli32(line), ret_ty, lli32(0) - ]; + ]/~; ret llmdnode(lldata); } @@ -678,7 +678,7 @@ fn create_local_var(bcx: block, local: @ast::local) } } }; - let declargs = [llmdnode([llptr]), mdnode]; + let declargs = [llmdnode([llptr]/~), mdnode]/~; trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"), declargs); ret mdval; @@ -709,7 +709,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let llptr = alt fcx.llargs.get(arg.id) { local_mem(v) | local_imm(v) { v } }; - let declargs = [llmdnode([llptr]), mdnode]; + let declargs = [llmdnode([llptr]/~), mdnode]/~; trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"), declargs); ret mdval; @@ -725,7 +725,7 @@ fn update_source_pos(cx: block, s: span) { let scopedata = [lli32(loc.line as int), lli32(loc.col as int), blockmd.node, - llnull()]; + llnull()]/~; let dbgscope = llmdnode(scopedata); llvm::LLVMSetCurrentDebugLocation(trans::build::B(cx), dbgscope); } @@ -796,7 +796,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { }; let sub_node = create_composite_type(SubroutineTag, "", file_node, 0, 0, 0, 0, option::none, - option::some([ty_node])); + option::some([ty_node]/~)); let fn_metadata = [lltag(SubprogramTag), llunused(), @@ -818,7 +818,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { //list of template params //func decl descriptor //list of func vars - ]; + ]/~; let val = llmdnode(fn_metadata); add_named_metadata(cx, "llvm.dbg.sp", val); let mdval = @{node: val, data: {id: id}}; diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index 514a7372660..b38fa05f465 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -16,14 +16,14 @@ import lib::llvm::llvm::LLVMGetParam; import std::map::hashmap; fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, - methods: [@ast::method], tps: [ast::ty_param]) { + methods: [@ast::method]/~, tps: [ast::ty_param]/~) { let _icx = ccx.insn_ctxt("impl::trans_impl"); if tps.len() > 0u { ret; } - let sub_path = path + [path_name(name)]; + let sub_path = path + [path_name(name)]/~; for vec::each(methods) {|m| if m.tps.len() == 0u { let llfn = get_item_val(ccx, m.id); - trans_fn(ccx, sub_path + [path_name(m.ident)], m.decl, m.body, + trans_fn(ccx, sub_path + [path_name(m.ident)]/~, m.decl, m.body, llfn, impl_self(ty::node_id_to_type(ccx.tcx, m.self_id)), none, m.id); } @@ -34,14 +34,14 @@ fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { let _icx = bcx.insn_ctxt("impl::trans_self_arg"); let basety = expr_ty(bcx, base); let m_by_ref = ast::expl(ast::by_ref); - let mut temp_cleanups = []; + let mut temp_cleanups = []/~; let result = trans_arg_expr(bcx, {mode: m_by_ref, ty: basety}, T_ptr(type_of::type_of(bcx.ccx(), basety)), base, temp_cleanups, none, derefs); // by-ref self argument should not require cleanup in the case of // other arguments failing: - assert temp_cleanups == []; + assert temp_cleanups == []/~; ret result; } @@ -73,7 +73,8 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, } } -fn method_from_methods(ms: [@ast::method], name: ast::ident) -> ast::def_id { +fn method_from_methods(ms: [@ast::method]/~, name: ast::ident) + -> ast::def_id { local_def(option::get(vec::find(ms, {|m| m.ident == name})).id) } @@ -147,16 +148,16 @@ fn trans_iface_callee(bcx: block, val: ValueRef, -> lval_maybe_callee { let _icx = bcx.insn_ctxt("impl::trans_iface_callee"); let ccx = bcx.ccx(); - let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, [0u, 0u]), + let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, [0u, 0u]/~), T_ptr(T_ptr(T_vtable())))); - let box = Load(bcx, GEPi(bcx, val, [0u, 1u])); - // FIXME[impl] I doubt this is alignment-safe (#2534) - let self = GEPi(bcx, box, [0u, abi::box_field_body]); + let box = Load(bcx, GEPi(bcx, val, [0u, 1u]/~)); + // FIXME[impl]/~ I doubt this is alignment-safe (#2534) + let self = GEPi(bcx, box, [0u, abi::box_field_body]/~); let env = self_env(self, ty::mk_opaque_box(bcx.tcx()), some(box)); let llfty = type_of::type_of_fn_from_ty(ccx, callee_ty); let vtable = PointerCast(bcx, vtable, T_ptr(T_array(T_ptr(llfty), n_method + 1u))); - let mptr = Load(bcx, GEPi(bcx, vtable, [0u, n_method])); + let mptr = Load(bcx, GEPi(bcx, vtable, [0u, n_method]/~)); {bcx: bcx, val: mptr, kind: owned, env: env} } @@ -234,7 +235,7 @@ fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin) } } -fn make_vtable(ccx: @crate_ctxt, ptrs: [ValueRef]) -> ValueRef { +fn make_vtable(ccx: @crate_ctxt, ptrs: [ValueRef]/~) -> ValueRef { let _icx = ccx.insn_ctxt("impl::make_vtable"); let tbl = C_struct(ptrs); let vt_gvar = str::as_c_str(ccx.names("vtable"), {|buf| @@ -246,7 +247,7 @@ fn make_vtable(ccx: @crate_ctxt, ptrs: [ValueRef]) -> ValueRef { vt_gvar } -fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: [ty::t], +fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: [ty::t]/~, vtables: typeck::vtable_res) -> ValueRef { let _icx = ccx.insn_ctxt("impl::make_impl_vtable"); let tcx = ccx.tcx; @@ -288,12 +289,12 @@ fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) let bcx = trans_expr_save_in(bcx, val, body); revoke_clean(bcx, box); let result = get_dest_addr(dest); - Store(bcx, box, PointerCast(bcx, GEPi(bcx, result, [0u, 1u]), + Store(bcx, box, PointerCast(bcx, GEPi(bcx, result, [0u, 1u]/~), T_ptr(val_ty(box)))); let orig = ccx.maps.vtable_map.get(id)[0]; let orig = resolve_vtable_in_fn_ctxt(bcx.fcx, orig); let vtable = get_vtable(bcx.ccx(), orig); - Store(bcx, vtable, PointerCast(bcx, GEPi(bcx, result, [0u, 0u]), + Store(bcx, vtable, PointerCast(bcx, GEPi(bcx, result, [0u, 0u]/~), T_ptr(val_ty(vtable)))); bcx } diff --git a/src/rustc/middle/trans/native.rs b/src/rustc/middle/trans/native.rs index fcc7f370f74..da687c8a3c8 100644 --- a/src/rustc/middle/trans/native.rs +++ b/src/rustc/middle/trans/native.rs @@ -44,7 +44,7 @@ fn is_sse(++c: x86_64_reg_class) -> bool { }; } -fn is_ymm(cls: [x86_64_reg_class]) -> bool { +fn is_ymm(cls: [x86_64_reg_class]/~) -> bool { let len = vec::len(cls); ret (len > 2u && is_sse(cls[0]) && @@ -56,13 +56,13 @@ fn is_ymm(cls: [x86_64_reg_class]) -> bool { cls[3] == sseup_class); } -fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] { +fn classify_ty(ty: TypeRef) -> [x86_64_reg_class]/~ { fn align(off: uint, ty: TypeRef) -> uint { let a = ty_align(ty); ret (off + a - 1u) / a * a; } - fn struct_tys(ty: TypeRef) -> [TypeRef] { + fn struct_tys(ty: TypeRef) -> [TypeRef]/~ { let n = llvm::LLVMCountStructElementTypes(ty); let elts = vec::from_elem(n as uint, ptr::null()); vec::as_buf(elts) {|buf| @@ -119,13 +119,13 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] { }; } - fn all_mem(cls: [mut x86_64_reg_class]) { + fn all_mem(cls: [mut x86_64_reg_class]/~) { for uint::range(0u, cls.len()) { |i| cls[i] = memory_class; } } - fn unify(cls: [mut x86_64_reg_class], + fn unify(cls: [mut x86_64_reg_class]/~, i: uint, newv: x86_64_reg_class) { if cls[i] == newv { @@ -150,8 +150,8 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] { } } - fn classify_struct(tys: [TypeRef], - cls: [mut x86_64_reg_class], i: uint, + fn classify_struct(tys: [TypeRef]/~, + cls: [mut x86_64_reg_class]/~, i: uint, off: uint) { if vec::is_empty(tys) { classify(T_i64(), cls, i, off); @@ -166,7 +166,7 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] { } fn classify(ty: TypeRef, - cls: [mut x86_64_reg_class], ix: uint, + cls: [mut x86_64_reg_class]/~, ix: uint, off: uint) { let t_align = ty_align(ty); let t_size = ty_size(ty); @@ -216,7 +216,7 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] { } } - fn fixup(ty: TypeRef, cls: [mut x86_64_reg_class]) { + fn fixup(ty: TypeRef, cls: [mut x86_64_reg_class]/~) { let mut i = 0u; let llty = llvm::LLVMGetTypeKind(ty) as int; let e = vec::len(cls); @@ -274,8 +274,8 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] { ret vec::from_mut(cls); } -fn llreg_ty(cls: [x86_64_reg_class]) -> TypeRef { - fn llvec_len(cls: [x86_64_reg_class]) -> uint { +fn llreg_ty(cls: [x86_64_reg_class]/~) -> TypeRef { + fn llvec_len(cls: [x86_64_reg_class]/~) -> uint { let mut len = 1u; for vec::each(cls) {|c| if c != sseup_class { @@ -286,27 +286,27 @@ fn llreg_ty(cls: [x86_64_reg_class]) -> TypeRef { ret len; } - let mut tys = []; + let mut tys = []/~; let mut i = 0u; let e = vec::len(cls); while i < e { alt cls[i] { integer_class { - tys += [T_i64()]; + tys += [T_i64()]/~; } sse_fv_class { let vec_len = llvec_len(vec::tailn(cls, i + 1u)) * 2u; let vec_ty = llvm::LLVMVectorType(T_f32(), vec_len as c_uint); - tys += [vec_ty]; + tys += [vec_ty]/~; i += vec_len; cont; } sse_fs_class { - tys += [T_f32()]; + tys += [T_f32()]/~; } sse_ds_class { - tys += [T_f64()]; + tys += [T_f64()]/~; } _ { fail "llregtype: unhandled class"; @@ -323,13 +323,13 @@ type x86_64_llty = { }; type x86_64_tys = { - arg_tys: [x86_64_llty], + arg_tys: [x86_64_llty]/~, ret_ty: x86_64_llty, - attrs: [option<Attribute>], + attrs: [option<Attribute>]/~, sret: bool }; -fn x86_64_tys(atys: [TypeRef], +fn x86_64_tys(atys: [TypeRef]/~, rty: TypeRef, ret_def: bool) -> x86_64_tys { fn is_reg_ty(ty: TypeRef) -> bool { @@ -342,18 +342,18 @@ fn x86_64_tys(atys: [TypeRef], }; } - fn is_pass_byval(cls: [x86_64_reg_class]) -> bool { + fn is_pass_byval(cls: [x86_64_reg_class]/~) -> bool { ret cls[0] == memory_class || cls[0] == x87_class || cls[0] == complex_x87_class; } - fn is_ret_bysret(cls: [x86_64_reg_class]) -> bool { + fn is_ret_bysret(cls: [x86_64_reg_class]/~) -> bool { ret cls[0] == memory_class; } fn x86_64_ty(ty: TypeRef, - is_mem_cls: fn(cls: [x86_64_reg_class]) -> bool, + is_mem_cls: fn(cls: [x86_64_reg_class]/~) -> bool, attr: Attribute) -> (x86_64_llty, option<Attribute>) { let mut cast = false; let mut ty_attr = option::none; @@ -371,22 +371,22 @@ fn x86_64_tys(atys: [TypeRef], ret ({ cast: cast, ty: llty }, ty_attr); } - let mut arg_tys = []; - let mut attrs = []; + let mut arg_tys = []/~; + let mut attrs = []/~; for vec::each(atys) {|t| let (ty, attr) = x86_64_ty(t, is_pass_byval, ByValAttribute); - arg_tys += [ty]; - attrs += [attr]; + arg_tys += [ty]/~; + attrs += [attr]/~; } let mut (ret_ty, ret_attr) = x86_64_ty(rty, is_ret_bysret, StructRetAttribute); let sret = option::is_some(ret_attr); if sret { - arg_tys = [ret_ty] + arg_tys; + arg_tys = [ret_ty]/~ + arg_tys; ret_ty = { cast: false, ty: T_void() }; - attrs = [ret_attr] + attrs; + attrs = [ret_attr]/~ + attrs; } else if !ret_def { ret_ty = { cast: false, ty: T_void() @@ -427,7 +427,7 @@ fn link_name(i: @ast::native_item) -> str { } type c_stack_tys = { - arg_tys: [TypeRef], + arg_tys: [TypeRef]/~, ret_ty: TypeRef, ret_def: bool, bundle_ty: TypeRef, @@ -436,7 +436,7 @@ type c_stack_tys = { }; fn c_arg_and_ret_lltys(ccx: @crate_ctxt, - id: ast::node_id) -> ([TypeRef], TypeRef, ty::t) { + id: ast::node_id) -> ([TypeRef]/~, TypeRef, ty::t) { alt ty::get(ty::node_id_to_type(ccx.tcx, id)).struct { ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) { let llargtys = type_of_explicit_args(ccx, arg_tys); @@ -450,7 +450,7 @@ fn c_arg_and_ret_lltys(ccx: @crate_ctxt, fn c_stack_tys(ccx: @crate_ctxt, id: ast::node_id) -> @c_stack_tys { let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, id); - let bundle_ty = T_struct(llargtys + [T_ptr(llretty)]); + let bundle_ty = T_struct(llargtys + [T_ptr(llretty)]/~); let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty); let x86_64 = if ccx.sess.targ_cfg.arch == arch_x86_64 { option::some(x86_64_tys(llargtys, llretty, ret_def)) @@ -462,13 +462,13 @@ fn c_stack_tys(ccx: @crate_ctxt, ret_ty: llretty, ret_def: ret_def, bundle_ty: bundle_ty, - shim_fn_ty: T_fn([T_ptr(bundle_ty)], T_void()), + shim_fn_ty: T_fn([T_ptr(bundle_ty)]/~, T_void()), x86_64_tys: x86_64 }; } type shim_arg_builder = fn(bcx: block, tys: @c_stack_tys, - llargbundle: ValueRef) -> [ValueRef]; + llargbundle: ValueRef) -> [ValueRef]/~; type shim_ret_builder = fn(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef, llretval: ValueRef); @@ -485,7 +485,7 @@ fn build_shim_fn_(ccx: @crate_ctxt, ccx.llmod, shim_name, tys.shim_fn_ty); // Declare the body of the shim function: - let fcx = new_fn_ctxt(ccx, [], llshimfn, none); + let fcx = new_fn_ctxt(ccx, []/~, llshimfn, none); let bcx = top_scope_block(fcx, none); let lltop = bcx.llbb; let llargbundle = get_param(llshimfn, 0u); @@ -519,7 +519,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt, ret_builder: wrap_ret_builder) { let _icx = ccx.insn_ctxt("native::build_wrap_fn_"); - let fcx = new_fn_ctxt(ccx, [], llwrapfn, none); + let fcx = new_fn_ctxt(ccx, []/~, llwrapfn, none); let bcx = top_scope_block(fcx, none); let lltop = bcx.llbb; @@ -530,7 +530,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt, // Create call itself. let llshimfnptr = PointerCast(bcx, llshimfn, T_ptr(T_i8())); let llrawargbundle = PointerCast(bcx, llargbundle, T_ptr(T_i8())); - Call(bcx, shim_upcall, [llrawargbundle, llshimfnptr]); + Call(bcx, shim_upcall, [llrawargbundle, llshimfnptr]/~); ret_builder(bcx, tys, llargbundle); tie_up_header_blocks(fcx, lltop); @@ -588,9 +588,9 @@ fn trans_native_mod(ccx: @crate_ctxt, let _icx = ccx.insn_ctxt("native::build_shim_fn"); fn build_args(bcx: block, tys: @c_stack_tys, - llargbundle: ValueRef) -> [ValueRef] { + llargbundle: ValueRef) -> [ValueRef]/~ { let _icx = bcx.insn_ctxt("native::shim::build_args"); - let mut llargvals = []; + let mut llargvals = []/~; let mut i = 0u; let n = vec::len(tys.arg_tys); @@ -599,33 +599,33 @@ fn trans_native_mod(ccx: @crate_ctxt, let mut atys = x86_64.arg_tys; let mut attrs = x86_64.attrs; if x86_64.sret { - let llretptr = GEPi(bcx, llargbundle, [0u, n]); + let llretptr = GEPi(bcx, llargbundle, [0u, n]/~); let llretloc = Load(bcx, llretptr); - llargvals = [llretloc]; + llargvals = [llretloc]/~; atys = vec::tail(atys); attrs = vec::tail(attrs); } while i < n { let llargval = if atys[i].cast { let arg_ptr = GEPi(bcx, llargbundle, - [0u, i]); + [0u, i]/~); let arg_ptr = BitCast(bcx, arg_ptr, T_ptr(atys[i].ty)); Load(bcx, arg_ptr) } else if option::is_some(attrs[i]) { - GEPi(bcx, llargbundle, [0u, i]) + GEPi(bcx, llargbundle, [0u, i]/~) } else { - load_inbounds(bcx, llargbundle, [0u, i]) + load_inbounds(bcx, llargbundle, [0u, i]/~) }; - llargvals += [llargval]; + llargvals += [llargval]/~; i += 1u; } } _ { while i < n { let llargval = load_inbounds(bcx, llargbundle, - [0u, i]); - llargvals += [llargval]; + [0u, i]/~); + llargvals += [llargval]/~; i += 1u; } } @@ -652,7 +652,7 @@ fn trans_native_mod(ccx: @crate_ctxt, ret; } let n = vec::len(tys.arg_tys); - let llretptr = GEPi(bcx, llargbundle, [0u, n]); + let llretptr = GEPi(bcx, llargbundle, [0u, n]/~); let llretloc = Load(bcx, llretptr); if x86_64.ret_ty.cast { let tmp_ptr = BitCast(bcx, llretloc, @@ -666,7 +666,7 @@ fn trans_native_mod(ccx: @crate_ctxt, if tys.ret_def { let n = vec::len(tys.arg_tys); // R** llretptr = &args->r; - let llretptr = GEPi(bcx, llargbundle, [0u, n]); + let llretptr = GEPi(bcx, llargbundle, [0u, n]/~); // R* llretloc = *llretptr; /* (args->r) */ let llretloc = Load(bcx, llretptr); // *args->r = r; @@ -705,7 +705,7 @@ fn trans_native_mod(ccx: @crate_ctxt, fn build_direct_fn(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item, tys: @c_stack_tys, cc: lib::llvm::CallConv) { - let fcx = new_fn_ctxt(ccx, [], decl, none); + let fcx = new_fn_ctxt(ccx, []/~, decl, none); let bcx = top_scope_block(fcx, none), lltop = bcx.llbb; let llbasefn = base_fn(ccx, link_name(item), tys, cc); let ty = ty::lookup_item_type(ccx.tcx, @@ -736,11 +736,11 @@ fn trans_native_mod(ccx: @crate_ctxt, let implicit_args = first_real_arg; // ret + env while i < n { let llargval = get_param(llwrapfn, i + implicit_args); - store_inbounds(bcx, llargval, llargbundle, [0u, i]); + store_inbounds(bcx, llargval, llargbundle, [0u, i]/~); i += 1u; } let llretptr = get_param(llwrapfn, 0u); - store_inbounds(bcx, llretptr, llargbundle, [0u, n]); + store_inbounds(bcx, llretptr, llargbundle, [0u, n]/~); } fn build_ret(bcx: block, _tys: @c_stack_tys, @@ -786,9 +786,9 @@ fn trans_native_mod(ccx: @crate_ctxt, } }; let psubsts = { - tys: [], + tys: []/~, vtables: none, - bounds: @[] + bounds: @[]/~ }; trans_intrinsic(ccx, llwrapfn, native_item, *path, psubsts, none); @@ -894,7 +894,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item, } "frame_address" { let frameaddress = ccx.intrinsics.get("llvm.frameaddress"); - let frameaddress_val = Call(bcx, frameaddress, [C_i32(0i32)]); + let frameaddress_val = Call(bcx, frameaddress, [C_i32(0i32)]/~); let fty = ty::mk_fn(bcx.tcx(), { purity: ast::impure_fn, proto: ast::proto_any, @@ -903,10 +903,10 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item, ty: ty::mk_imm_ptr( bcx.tcx(), ty::mk_mach_uint(bcx.tcx(), ast::ty_u8)) - }], + }]/~, output: ty::mk_nil(bcx.tcx()), ret_style: ast::return_val, - constraints: [] + constraints: []/~ }); bcx = trans_call_inner(bcx, none, fty, ty::mk_nil(bcx.tcx()), { |bcx| @@ -915,7 +915,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item, get_param(decl, first_real_arg), temporary) }, - arg_vals([frameaddress_val]), ignore); + arg_vals([frameaddress_val]/~), ignore); } } build_return(bcx); @@ -933,7 +933,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let _icx = ccx.insn_ctxt("native::crust::build_rust_fn"); let t = ty::node_id_to_type(ccx.tcx, id); let ps = link::mangle_internal_name_by_path( - ccx, path + [ast_map::path_name(@"__rust_abi")]); + ccx, path + [ast_map::path_name(@"__rust_abi")]/~); let llty = type_of_fn_from_ty(ccx, t); let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty); trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id); @@ -946,18 +946,18 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let _icx = ccx.insn_ctxt("native::crust::build_shim_fn"); fn build_args(bcx: block, tys: @c_stack_tys, - llargbundle: ValueRef) -> [ValueRef] { + llargbundle: ValueRef) -> [ValueRef]/~ { let _icx = bcx.insn_ctxt("native::crust::shim::build_args"); - let mut llargvals = []; + let mut llargvals = []/~; let mut i = 0u; let n = vec::len(tys.arg_tys); - let llretptr = load_inbounds(bcx, llargbundle, [0u, n]); - llargvals += [llretptr]; + let llretptr = load_inbounds(bcx, llargbundle, [0u, n]/~); + llargvals += [llretptr]/~; let llenvptr = C_null(T_opaque_box_ptr(bcx.ccx())); - llargvals += [llenvptr]; + llargvals += [llenvptr]/~; while i < n { - let llargval = load_inbounds(bcx, llargbundle, [0u, i]); - llargvals += [llargval]; + let llargval = load_inbounds(bcx, llargbundle, [0u, i]/~); + llargvals += [llargval]/~; i += 1u; } ret llargvals; @@ -970,7 +970,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, } let shim_name = link::mangle_internal_name_by_path( - ccx, path + [ast_map::path_name(@"__rust_stack_shim")]); + ccx, path + [ast_map::path_name(@"__rust_stack_shim")]/~); ret build_shim_fn_(ccx, shim_name, llrustfn, tys, lib::llvm::CCallConv, build_args, build_ret); @@ -1007,18 +1007,20 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let mut argval = get_param(llwrapfn, i + j); if option::is_some(attrs[i]) { argval = Load(bcx, argval); - store_inbounds(bcx, argval, llargbundle, [0u, i]); + store_inbounds(bcx, argval, llargbundle, + [0u, i]/~); } else if atys[i].cast { - let argptr = GEPi(bcx, llargbundle, [0u, i]); + let argptr = GEPi(bcx, llargbundle, [0u, i]/~); let argptr = BitCast(bcx, argptr, T_ptr(atys[i].ty)); Store(bcx, argval, argptr); } else { - store_inbounds(bcx, argval, llargbundle, [0u, i]); + store_inbounds(bcx, argval, llargbundle, + [0u, i]/~); } i += 1u; } - store_inbounds(bcx, llretptr, llargbundle, [0u, n]); + store_inbounds(bcx, llretptr, llargbundle, [0u, n]/~); } _ { let llretptr = alloca(bcx, tys.ret_ty); @@ -1026,9 +1028,9 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, for uint::range(0u, n) {|i| let llargval = get_param(llwrapfn, i); store_inbounds(bcx, llargval, llargbundle, - [0u, i]); + [0u, i]/~); }; - store_inbounds(bcx, llretptr, llargbundle, [0u, n]); + store_inbounds(bcx, llretptr, llargbundle, [0u, n]/~); } } } @@ -1043,7 +1045,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, ret; } let n = vec::len(tys.arg_tys); - let llretval = load_inbounds(bcx, llargbundle, [0u, n]); + let llretval = load_inbounds(bcx, llargbundle, [0u, n]/~); let llretval = if x86_64.ret_ty.cast { let retptr = BitCast(bcx, llretval, T_ptr(x86_64.ret_ty.ty)); @@ -1055,7 +1057,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, } _ { let n = vec::len(tys.arg_tys); - let llretval = load_inbounds(bcx, llargbundle, [0u, n]); + let llretval = load_inbounds(bcx, llargbundle, [0u, n]/~); let llretval = Load(bcx, llretval); Ret(bcx, llretval); } diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 86da0c72ecc..a745c347853 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -31,7 +31,7 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::exp_map, rmap } -fn traverse_exports(cx: ctx, vis: [@view_item]) -> bool { +fn traverse_exports(cx: ctx, vis: [@view_item]/~) -> bool { let mut found_export = false; for vec::each(vis) {|vi| alt vi.node { diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 0ca89ac6a94..bad3d52f147 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -12,7 +12,7 @@ import util::ppaux::ty_to_str; enum reflector = { visitor_val: ValueRef, - visitor_methods: @[ty::method], + visitor_methods: @[ty::method]/~, mut bcx: block }; @@ -31,15 +31,15 @@ impl methods for reflector { do_spill_noroot(self.bcx, ss) } - fn c_size_and_align(t: ty::t) -> [ValueRef] { + fn c_size_and_align(t: ty::t) -> [ValueRef]/~ { let tr = type_of::type_of(self.bcx.ccx(), t); let s = shape::llsize_of_real(self.bcx.ccx(), tr); let a = shape::llalign_of_min(self.bcx.ccx(), tr); ret [self.c_uint(s), - self.c_uint(a)]; + self.c_uint(a)]/~; } - fn visit(ty_name: str, args: [ValueRef]) { + fn visit(ty_name: str, args: [ValueRef]/~) { let tcx = self.bcx.tcx(); let mth_idx = option::get(ty::method_idx(@("visit_" + ty_name), *self.visitor_methods)); @@ -69,33 +69,33 @@ impl methods for reflector { abi::tydesc_field_visit_glue); } - fn bracketed_t(bracket_name: str, t: ty::t, extra: [ValueRef]) { + fn bracketed_t(bracket_name: str, t: ty::t, extra: [ValueRef]/~) { self.visit("enter_" + bracket_name, extra); self.visit_tydesc(t); self.visit("leave_" + bracket_name, extra); } - fn bracketed_mt(bracket_name: str, mt: ty::mt, extra: [ValueRef]) { + fn bracketed_mt(bracket_name: str, mt: ty::mt, extra: [ValueRef]/~) { self.bracketed_t(bracket_name, mt.ty, - [self.c_uint(mt.mutbl as uint)] + extra); + [self.c_uint(mt.mutbl as uint)]/~ + extra); } fn vstore_name_and_extra(t: ty::t, vstore: ty::vstore, - f: fn(str,[ValueRef])) { + f: fn(str,[ValueRef]/~)) { alt vstore { ty::vstore_fixed(n) { - let extra = [self.c_uint(n)] + self.c_size_and_align(t); + let extra = [self.c_uint(n)]/~ + self.c_size_and_align(t); f("fixed", extra) } - ty::vstore_slice(_) { f("slice", []) } - ty::vstore_uniq { f("uniq", []);} - ty::vstore_box { f("box", []); } + ty::vstore_slice(_) { f("slice", []/~) } + ty::vstore_uniq { f("uniq", []/~);} + ty::vstore_box { f("box", []/~); } } } fn leaf(name: str) { - self.visit(name, []); + self.visit(name, []/~); } // Entrypoint @@ -125,7 +125,7 @@ impl methods for reflector { ty::ty_float(ast::ty_f64) { self.leaf("f64") } ty::ty_str { self.leaf("str") } - ty::ty_vec(mt) { self.bracketed_mt("vec", mt, []) } + ty::ty_vec(mt) { self.bracketed_mt("vec", mt, []/~) } ty::ty_estr(vst) { self.vstore_name_and_extra(t, vst) {|name, extra| self.visit("estr_" + name, extra) @@ -136,29 +136,29 @@ impl methods for reflector { self.bracketed_mt("evec_" + name, mt, extra) } } - ty::ty_box(mt) { self.bracketed_mt("box", mt, []) } - ty::ty_uniq(mt) { self.bracketed_mt("uniq", mt, []) } - ty::ty_ptr(mt) { self.bracketed_mt("ptr", mt, []) } - ty::ty_rptr(_, mt) { self.bracketed_mt("rptr", mt, []) } + ty::ty_box(mt) { self.bracketed_mt("box", mt, []/~) } + ty::ty_uniq(mt) { self.bracketed_mt("uniq", mt, []/~) } + ty::ty_ptr(mt) { self.bracketed_mt("ptr", mt, []/~) } + ty::ty_rptr(_, mt) { self.bracketed_mt("rptr", mt, []/~) } ty::ty_rec(fields) { - let extra = ([self.c_uint(vec::len(fields))] + let extra = ([self.c_uint(vec::len(fields))]/~ + self.c_size_and_align(t)); self.visit("enter_rec", extra); for fields.eachi {|i, field| self.bracketed_mt("rec_field", field.mt, [self.c_uint(i), - self.c_slice(*field.ident)]); + self.c_slice(*field.ident)]/~); } self.visit("leave_rec", extra); } ty::ty_tup(tys) { - let extra = ([self.c_uint(vec::len(tys))] + let extra = ([self.c_uint(vec::len(tys))]/~ + self.c_size_and_align(t)); self.visit("enter_tup", extra); for tys.eachi {|i, t| - self.bracketed_t("tup_field", t, [self.c_uint(i)]); + self.bracketed_t("tup_field", t, [self.c_uint(i)]/~); } self.visit("leave_tup", extra); } @@ -186,7 +186,7 @@ impl methods for reflector { let extra = [self.c_uint(pureval), self.c_uint(protoval), self.c_uint(vec::len(fty.inputs)), - self.c_uint(retval)]; + self.c_uint(retval)]/~; self.visit("enter_fn", extra); for fty.inputs.eachi {|i, arg| let modeval = alt arg.mode { @@ -203,10 +203,10 @@ impl methods for reflector { }; self.bracketed_t("fn_input", arg.ty, [self.c_uint(i), - self.c_uint(modeval)]); + self.c_uint(modeval)]/~); } self.bracketed_t("fn_output", fty.output, - [self.c_uint(retval)]); + [self.c_uint(retval)]/~); self.visit("leave_fn", extra); } @@ -214,14 +214,14 @@ impl methods for reflector { let bcx = self.bcx; let tcx = bcx.ccx().tcx; let fields = ty::class_items_as_fields(tcx, did, substs); - let extra = ([self.c_uint(vec::len(fields))] + let extra = ([self.c_uint(vec::len(fields))]/~ + self.c_size_and_align(t)); self.visit("enter_class", extra); for fields.eachi {|i, field| self.bracketed_mt("class_field", field.mt, [self.c_uint(i), - self.c_slice(*field.ident)]); + self.c_slice(*field.ident)]/~); } self.visit("leave_class", extra); } @@ -234,7 +234,7 @@ impl methods for reflector { let bcx = self.bcx; let tcx = bcx.ccx().tcx; let variants = ty::substd_enum_variants(tcx, did, substs); - let extra = ([self.c_uint(vec::len(variants))] + let extra = ([self.c_uint(vec::len(variants))]/~ + self.c_size_and_align(t)); self.visit("enter_enum", extra); @@ -242,11 +242,11 @@ impl methods for reflector { let extra = [self.c_uint(i), self.c_int(v.disr_val), self.c_uint(vec::len(v.args)), - self.c_slice(*v.name)]; + self.c_slice(*v.name)]/~; self.visit("enter_enum_variant", extra); for v.args.eachi {|j, a| self.bracketed_t("enum_variant_field", a, - [self.c_uint(j)]); + [self.c_uint(j)]/~); } self.visit("leave_enum_variant", extra); } @@ -257,20 +257,20 @@ impl methods for reflector { ty::ty_iface(_, _) { self.leaf("iface") } ty::ty_var(_) { self.leaf("var") } ty::ty_var_integral(_) { self.leaf("var_integral") } - ty::ty_param(n, _) { self.visit("param", [self.c_uint(n)]) } + ty::ty_param(n, _) { self.visit("param", [self.c_uint(n)]/~) } ty::ty_self { self.leaf("self") } ty::ty_type { self.leaf("type") } ty::ty_opaque_box { self.leaf("opaque_box") } - ty::ty_constr(t, _) { self.bracketed_t("constr", t, []) } + ty::ty_constr(t, _) { self.bracketed_t("constr", t, []/~) } ty::ty_opaque_closure_ptr(ck) { let ckval = alt ck { ty::ck_block { 0u } ty::ck_box { 1u } ty::ck_uniq { 2u } }; - self.visit("closure_ptr", [self.c_uint(ckval)]) + self.visit("closure_ptr", [self.c_uint(ckval)]/~) } - ty::ty_unboxed_vec(mt) { self.bracketed_mt("vec", mt, []) } + ty::ty_unboxed_vec(mt) { self.bracketed_mt("vec", mt, []/~) } } } } diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 4ef40f4f924..9b8f99e4c36 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -22,11 +22,11 @@ import std::map::hashmap; import ty_ctxt = middle::ty::ctxt; type nominal_id = @{did: ast::def_id, parent_id: option<ast::def_id>, - tps: [ty::t]}; + tps: [ty::t]/~}; fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id, parent_id: option<ast::def_id>, - tps: [ty::t]) -> nominal_id { + tps: [ty::t]/~) -> nominal_id { let tps_norm = tps.map { |t| ty::normalize_ty(tcx, t) }; @{did: did, parent_id: parent_id, tps: tps_norm} } @@ -197,44 +197,46 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt { llshapetables: llshapetables}; } -fn add_bool(&dest: [u8], val: bool) { dest += [if val { 1u8 } else { 0u8 }]; } +fn add_bool(&dest: [u8]/~, val: bool) { + dest += [if val { 1u8 } else { 0u8 }]/~; +} -fn add_u16(&dest: [u8], val: u16) { - dest += [(val & 0xffu16) as u8, (val >> 8u16) as u8]; +fn add_u16(&dest: [u8]/~, val: u16) { + dest += [(val & 0xffu16) as u8, (val >> 8u16) as u8]/~; } -fn add_substr(&dest: [u8], src: [u8]) { +fn add_substr(&dest: [u8]/~, src: [u8]/~) { add_u16(dest, vec::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]/~ { alt ty::get(t).struct { ty::ty_nil | ty::ty_bool | ty::ty_uint(ast::ty_u8) | - ty::ty_bot { [shape_u8] } - ty::ty_int(ast::ty_i) { [s_int(ccx.tcx)] } - ty::ty_float(ast::ty_f) { [s_float(ccx.tcx)] } - ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) { [s_uint(ccx.tcx)] } - ty::ty_type { [s_tydesc(ccx.tcx)] } - ty::ty_int(ast::ty_i8) { [shape_i8] } - ty::ty_uint(ast::ty_u16) { [shape_u16] } - ty::ty_int(ast::ty_i16) { [shape_i16] } - ty::ty_uint(ast::ty_u32) { [shape_u32] } - ty::ty_int(ast::ty_i32) | ty::ty_int(ast::ty_char) { [shape_i32] } - ty::ty_uint(ast::ty_u64) { [shape_u64] } - ty::ty_int(ast::ty_i64) { [shape_i64] } - ty::ty_float(ast::ty_f32) { [shape_f32] } - ty::ty_float(ast::ty_f64) { [shape_f64] } + ty::ty_bot { [shape_u8]/~ } + ty::ty_int(ast::ty_i) { [s_int(ccx.tcx)]/~ } + ty::ty_float(ast::ty_f) { [s_float(ccx.tcx)]/~ } + ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) { [s_uint(ccx.tcx)]/~ } + ty::ty_type { [s_tydesc(ccx.tcx)]/~ } + ty::ty_int(ast::ty_i8) { [shape_i8]/~ } + ty::ty_uint(ast::ty_u16) { [shape_u16]/~ } + ty::ty_int(ast::ty_i16) { [shape_i16]/~ } + ty::ty_uint(ast::ty_u32) { [shape_u32]/~ } + ty::ty_int(ast::ty_i32) | ty::ty_int(ast::ty_char) { [shape_i32]/~ } + ty::ty_uint(ast::ty_u64) { [shape_u64]/~ } + ty::ty_int(ast::ty_i64) { [shape_i64]/~ } + ty::ty_float(ast::ty_f32) { [shape_f32]/~ } + ty::ty_float(ast::ty_f64) { [shape_f64]/~ } ty::ty_estr(ty::vstore_uniq) | ty::ty_str { shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t)) } ty::ty_enum(did, substs) { alt enum_kind(ccx, did) { - tk_unit { [s_variant_enum_t(ccx.tcx)] } - tk_enum { [s_variant_enum_t(ccx.tcx)] } + tk_unit { [s_variant_enum_t(ccx.tcx)]/~ } + tk_enum { [s_variant_enum_t(ccx.tcx)]/~ } tk_newtype | tk_complex { - let mut s = [shape_enum], id; + let mut s = [shape_enum]/~, id; let nom_id = mk_nominal_id(ccx.tcx, did, none, substs.tps); alt ccx.shape_cx.tag_id_to_index.find(nom_id) { none { @@ -257,14 +259,14 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } ty::ty_estr(ty::vstore_box) | ty::ty_evec(_, ty::vstore_box) | - ty::ty_box(_) | ty::ty_opaque_box { [shape_box] } + ty::ty_box(_) | ty::ty_opaque_box { [shape_box]/~ } ty::ty_uniq(mt) { - let mut s = [shape_uniq]; + let mut s = [shape_uniq]/~; add_substr(s, shape_of(ccx, mt.ty)); s } ty::ty_unboxed_vec(mt) { - let mut s = [shape_unboxed_vec]; + let mut s = [shape_unboxed_vec]/~; add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty)); add_substr(s, shape_of(ccx, mt.ty)); s @@ -275,7 +277,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } ty::ty_estr(ty::vstore_fixed(n)) { - let mut s = [shape_fixedvec]; + let mut s = [shape_fixedvec]/~; let u8_t = ty::mk_mach_uint(ccx.tcx, ast::ty_u8); assert (n + 1u) <= 0xffffu; add_u16(s, (n + 1u) as u16); @@ -285,7 +287,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } ty::ty_evec(mt, ty::vstore_fixed(n)) { - let mut s = [shape_fixedvec]; + let mut s = [shape_fixedvec]/~; assert n <= 0xffffu; add_u16(s, n as u16); add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty)); @@ -294,7 +296,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } ty::ty_estr(ty::vstore_slice(r)) { - let mut s = [shape_slice]; + let mut s = [shape_slice]/~; let u8_t = ty::mk_mach_uint(ccx.tcx, ast::ty_u8); add_bool(s, true); // is_pod add_bool(s, true); // is_str @@ -303,7 +305,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } ty::ty_evec(mt, ty::vstore_slice(r)) { - let mut s = [shape_slice]; + let mut s = [shape_slice]/~; add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty)); add_bool(s, false); // is_str add_substr(s, shape_of(ccx, mt.ty)); @@ -311,7 +313,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } ty::ty_rec(fields) { - let mut s = [shape_struct], sub = []; + let mut s = [shape_struct]/~, sub = []/~; for vec::each(fields) {|f| sub += shape_of(ccx, f.mt.ty); } @@ -319,22 +321,22 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { s } ty::ty_tup(elts) { - let mut s = [shape_struct], sub = []; + let mut s = [shape_struct]/~, sub = []/~; for vec::each(elts) {|elt| sub += shape_of(ccx, elt); } add_substr(s, sub); s } - ty::ty_iface(_, _) { [shape_box_fn] } + ty::ty_iface(_, _) { [shape_box_fn]/~ } ty::ty_class(did, substs) { // same as records, unless there's a dtor let tps = substs.tps; let m_dtor_did = ty::ty_dtor(ccx.tcx, did); let mut s = if option::is_some(m_dtor_did) { - [shape_res] + [shape_res]/~ } - else { [shape_struct] }, sub = []; + else { [shape_struct]/~ }, sub = []/~; option::iter(m_dtor_did) {|dtor_did| let ri = @{did: dtor_did, parent_id: some(did), tps: tps}; let id = interner::intern(ccx.shape_cx.resources, ri); @@ -351,19 +353,19 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { s } ty::ty_rptr(_, mt) { - let mut s = [shape_rptr]; + let mut s = [shape_rptr]/~; add_substr(s, shape_of(ccx, mt.ty)); s } ty::ty_param(*) { ccx.tcx.sess.bug("non-monomorphized type parameter"); } - ty::ty_fn({proto: ast::proto_box, _}) { [shape_box_fn] } - ty::ty_fn({proto: ast::proto_uniq, _}) { [shape_uniq_fn] } + ty::ty_fn({proto: ast::proto_box, _}) { [shape_box_fn]/~ } + ty::ty_fn({proto: ast::proto_uniq, _}) { [shape_uniq_fn]/~ } ty::ty_fn({proto: ast::proto_block, _}) | - ty::ty_fn({proto: ast::proto_any, _}) { [shape_stack_fn] } - ty::ty_fn({proto: ast::proto_bare, _}) { [shape_bare_fn] } - ty::ty_opaque_closure_ptr(_) { [shape_opaque_closure_ptr] } + ty::ty_fn({proto: ast::proto_any, _}) { [shape_stack_fn]/~ } + ty::ty_fn({proto: ast::proto_bare, _}) { [shape_bare_fn]/~ } + ty::ty_opaque_closure_ptr(_) { [shape_opaque_closure_ptr]/~ } ty::ty_constr(inner_t, _) { shape_of(ccx, inner_t) } ty::ty_var(_) | ty::ty_var_integral(_) | ty::ty_self { ccx.sess.bug("shape_of: unexpected type struct found"); @@ -371,8 +373,8 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { } } -fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> [u8] { - let mut s = []; +fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> [u8]/~ { + let mut s = []/~; for vec::each(v.args) {|t| s += shape_of(ccx, t); } ret s; } @@ -381,23 +383,23 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { // Loop over all the enum variants and write their shapes into a // data buffer. As we do this, it's possible for us to discover // new enums, so we must do this first. - let mut data = []; - let mut offsets = []; + let mut data = []/~; + let mut offsets = []/~; let mut i = 0u; - let mut enum_variants = []; + let mut enum_variants = []/~; while i < ccx.shape_cx.tag_order.len() { let {did, substs} = ccx.shape_cx.tag_order[i]; let variants = @ty::substd_enum_variants(ccx.tcx, did, substs); vec::iter(*variants) {|v| - offsets += [vec::len(data) as u16]; + offsets += [vec::len(data) as u16]/~; let variant_shape = shape_of_variant(ccx, v); add_substr(data, variant_shape); - let zname = str::bytes(*v.name) + [0u8]; + let zname = str::bytes(*v.name) + [0u8]/~; add_substr(data, zname); } - enum_variants += [variants]; + enum_variants += [variants]/~; i += 1u; } @@ -405,8 +407,8 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { // info records for each enum) and the info space (which contains offsets // to each variant shape). As we do so, build up the header. - let mut header = []; - let mut inf = []; + let mut header = []/~; + let mut inf = []/~; let header_sz = 2u16 * ccx.shape_cx.next_tag_id; let data_sz = vec::len(data) as u16; @@ -421,7 +423,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { // variant. Also construct the largest-variant table for each enum, which // contains the variants that the size-of operation needs to look at. - let mut lv_table = []; + let mut lv_table = []/~; let mut i = 0u; for enum_variants.each { |variants| add_u16(inf, vec::len(*variants) as u16); @@ -445,7 +447,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { // Write in the static size and alignment of the enum. add_u16(inf, size_align.size); - inf += [size_align.align]; + inf += [size_align.align]/~; // Now write in the offset of each variant. for vec::each(*variants) {|_v| @@ -467,14 +469,14 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { /* tjc: Not annotating FIXMEs in this module because of #1498 */ fn largest_variants(ccx: @crate_ctxt, - variants: @[ty::variant_info]) -> [uint] { + variants: @[ty::variant_info]/~) -> [uint]/~ { // Compute the minimum and maximum size and alignment for each // variant. // // NB: We could do better here; e.g. we know that any // variant that contains (T,T) must be as least as large as // any variant that contains just T. - let mut ranges = []; + let mut ranges = []/~; for vec::each(*variants) {|variant| let mut bounded = true; let mut min_size = 0u, min_align = 0u; @@ -493,12 +495,12 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { ranges += [{size: {min: min_size, bounded: bounded}, - align: {min: min_align, bounded: bounded}}]; + align: {min: min_align, bounded: bounded}}]/~; } // Initialize the candidate set to contain all variants. - let mut candidates = [mut]; - for vec::each(*variants) {|_v| candidates += [mut true]; } + let mut candidates = [mut]/~; + for vec::each(*variants) {|_v| candidates += [mut true]/~; } // Do a pairwise comparison among all variants still in the // candidate set. Throw out any variant that we know has size @@ -531,24 +533,25 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { } // Return the resulting set. - let mut result = []; + let mut result = []/~; let mut i = 0u; while i < vec::len(candidates) { - if candidates[i] { result += [i]; } + if candidates[i] { vec::push(result, i); } i += 1u; } ret result; } - fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: [uint], - variants: @[ty::variant_info]) -> size_align { + fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: [uint]/~, + variants: @[ty::variant_info]/~) + -> size_align { let mut max_size = 0u16; let mut max_align = 1u8; for vec::each(largest_variants) {|vid| // We increment a "virtual data pointer" to compute the size. - let mut lltys = []; + let mut lltys = []/~; for vec::each(variants[vid].args) {|typ| - lltys += [type_of::type_of(ccx, typ)]; + lltys += [type_of::type_of(ccx, typ)]/~; } let llty = trans::common::T_struct(lltys); @@ -574,13 +577,13 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { } fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef { - let mut dtors = []; + let mut dtors = []/~; let len = interner::len(ccx.shape_cx.resources); for uint::range(0u, len) {|i| let ri = interner::get(ccx.shape_cx.resources, i); for ri.tps.each() {|s| assert !ty::type_has_params(s); } option::iter(ri.parent_id) {|id| - dtors += [trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)]; + dtors += [trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)]/~; } } ret mk_global(ccx, "resource_shapes", C_struct(dtors), true); @@ -591,11 +594,11 @@ fn gen_shape_tables(ccx: @crate_ctxt) { let llresourcestable = gen_resource_shapes(ccx); trans::common::set_struct_body(ccx.shape_cx.llshapetablesty, [val_ty(lltagstable), - val_ty(llresourcestable)]); + val_ty(llresourcestable)]/~); let lltables = C_named_struct(ccx.shape_cx.llshapetablesty, - [lltagstable, llresourcestable]); + [lltagstable, llresourcestable]/~); lib::llvm::llvm::LLVMSetInitializer(ccx.shape_cx.llshapetables, lltables); lib::llvm::llvm::LLVMSetGlobalConstant(ccx.shape_cx.llshapetables, True); lib::llvm::SetLinkage(ccx.shape_cx.llshapetables, @@ -724,10 +727,10 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { ty::ty_evec(_, ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_uniq) | ty::ty_estr(ty::vstore_box) | ty::ty_ptr(_) | ty::ty_rptr(_,_) { nilptr(tcx) } - ty::ty_fn(_) { ty::mk_tup(tcx, [nilptr(tcx), nilptr(tcx)]) } + ty::ty_fn(_) { ty::mk_tup(tcx, [nilptr(tcx), nilptr(tcx)]/~) } ty::ty_evec(_, ty::vstore_slice(_)) | ty::ty_estr(ty::vstore_slice(_)) { - ty::mk_tup(tcx, [nilptr(tcx), ty::mk_int(tcx)]) + ty::mk_tup(tcx, [nilptr(tcx), ty::mk_int(tcx)]/~) } _ { typ } } @@ -736,7 +739,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { } // Given a tag type `ty`, returns the offset of the payload. -//fn tag_payload_offs(bcx: block, tag_id: ast::def_id, tps: [ty::t]) +//fn tag_payload_offs(bcx: block, tag_id: ast::def_id, tps: [ty::t]/~) // -> ValueRef { // alt tag_kind(tag_id) { // tk_unit | tk_enum | tk_newtype { C_int(bcx.ccx(), 0) } diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index d05629b990f..7bc0ca50608 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -36,30 +36,30 @@ fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef { let _icx = bcx.insn_ctxt("tvec::get_fill"); - Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill])) + Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]/~)) } fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) { - Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill])); + Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]/~)); } fn get_alloc(bcx: block, vptr: ValueRef) -> ValueRef { - Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc])) + Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]/~)) } fn get_bodyptr(bcx: block, vptr: ValueRef) -> ValueRef { - non_gc_box_cast(bcx, GEPi(bcx, vptr, [0u, abi::box_field_body])) + non_gc_box_cast(bcx, GEPi(bcx, vptr, [0u, abi::box_field_body]/~)) } fn get_dataptr(bcx: block, vptr: ValueRef) -> ValueRef { let _icx = bcx.insn_ctxt("tvec::get_dataptr"); - GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u]) + GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u]/~) } fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { let _icx = bcx.insn_ctxt("tvec::pointer_add"); let old_ty = val_ty(ptr); let bptr = PointerCast(bcx, ptr, T_ptr(T_i8())); - ret PointerCast(bcx, InBoundsGEP(bcx, bptr, [bytes]), old_ty); + ret PointerCast(bcx, InBoundsGEP(bcx, bptr, [bytes]/~), old_ty); } fn alloc_raw(bcx: block, unit_ty: ty::t, @@ -71,8 +71,8 @@ fn alloc_raw(bcx: block, unit_ty: ty::t, let vecsize = Add(bcx, alloc, llsize_of(ccx, ccx.opaque_vec_type)); let {box, body} = base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize); - Store(bcx, fill, GEPi(bcx, body, [0u, abi::vec_elt_fill])); - Store(bcx, alloc, GEPi(bcx, body, [0u, abi::vec_elt_alloc])); + Store(bcx, fill, GEPi(bcx, body, [0u, abi::vec_elt_fill]/~)); + Store(bcx, alloc, GEPi(bcx, body, [0u, abi::vec_elt_alloc]/~)); ret {bcx: bcx, val: box}; } fn alloc_uniq_raw(bcx: block, unit_ty: ty::t, @@ -119,7 +119,7 @@ fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> } else { bcx } } -fn trans_evec(bcx: block, args: [@ast::expr], +fn trans_evec(bcx: block, args: [@ast::expr]/~, vst: ast::vstore, id: ast::node_id, dest: dest) -> block { let _icx = bcx.insn_ctxt("tvec::trans_evec"); let ccx = bcx.ccx(); @@ -158,9 +158,9 @@ fn trans_evec(bcx: block, args: [@ast::expr], let len = Mul(bcx, n, unit_sz); let p = base::alloca(bcx, T_struct([T_ptr(llunitty), - ccx.int_type])); - Store(bcx, vp, GEPi(bcx, p, [0u, abi::slice_elt_base])); - Store(bcx, len, GEPi(bcx, p, [0u, abi::slice_elt_len])); + ccx.int_type]/~)); + Store(bcx, vp, GEPi(bcx, p, [0u, abi::slice_elt_base]/~)); + Store(bcx, len, GEPi(bcx, p, [0u, abi::slice_elt_len]/~)); {bcx: bcx, val: p, dataptr: vp} } @@ -182,12 +182,12 @@ fn trans_evec(bcx: block, args: [@ast::expr], // Store the individual elements. - let mut i = 0u, temp_cleanups = [val]; + let mut i = 0u, temp_cleanups = [val]/~; #debug("trans_evec: v: %s, dataptr: %s", val_str(ccx.tn, val), val_str(ccx.tn, dataptr)); for vec::each(args) {|e| - let lleltptr = InBoundsGEP(bcx, dataptr, [C_uint(ccx, i)]); + let lleltptr = InBoundsGEP(bcx, dataptr, [C_uint(ccx, i)]/~); bcx = base::trans_expr_save_in(bcx, e, lleltptr); add_clean_temp_mem(bcx, lleltptr, unit_ty); vec::push(temp_cleanups, lleltptr); @@ -242,14 +242,14 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) alt vstore { ty::vstore_fixed(n) { - let base = GEPi(cx, v, [0u, 0u]); + let base = GEPi(cx, v, [0u, 0u]/~); let n = if ty::type_is_str(e_ty) { n + 1u } else { n }; let len = Mul(cx, C_uint(ccx, n), unit_sz); (base, len) } ty::vstore_slice(_) { - let base = Load(cx, GEPi(cx, v, [0u, abi::slice_elt_base])); - let len = Load(cx, GEPi(cx, v, [0u, abi::slice_elt_len])); + let base = Load(cx, GEPi(cx, v, [0u, abi::slice_elt_base]/~)); + let len = Load(cx, GEPi(cx, v, [0u, abi::slice_elt_len]/~)); (base, len) } ty::vstore_uniq | ty::vstore_box { @@ -268,7 +268,7 @@ fn trans_estr(bcx: block, s: @str, vstore: ast::vstore, let c = alt vstore { ast::vstore_fixed(_) { - // "hello"/_ => "hello"/5 => [i8 x 6] in llvm + // "hello"/_ => "hello"/5 => [i8 x 6]/~ in llvm #debug("trans_estr: fixed: %s", *s); C_postr(*s) } @@ -282,7 +282,7 @@ fn trans_estr(bcx: block, s: @str, vstore: ast::vstore, ast::vstore_uniq { let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8())); let len = C_uint(ccx, str::len(*s)); - let c = Call(bcx, ccx.upcalls.str_new_uniq, [cs, len]); + let c = Call(bcx, ccx.upcalls.str_new_uniq, [cs, len]/~); PointerCast(bcx, c, T_unique_ptr(T_unique(ccx, T_vec(ccx, T_i8())))) } @@ -290,7 +290,7 @@ fn trans_estr(bcx: block, s: @str, vstore: ast::vstore, ast::vstore_box { let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8())); let len = C_uint(ccx, str::len(*s)); - let c = Call(bcx, ccx.upcalls.str_new_shared, [cs, len]); + let c = Call(bcx, ccx.upcalls.str_new_shared, [cs, len]/~); PointerCast(bcx, c, T_box_ptr(T_box(ccx, T_vec(ccx, T_i8())))) } @@ -317,7 +317,7 @@ fn trans_append(bcx: block, vec_ty: ty::t, lhsptr: ValueRef, let opaque_lhs = PointerCast(bcx, lhsptr, T_ptr(T_ptr(T_i8()))); Call(bcx, ccx.upcalls.vec_grow, - [opaque_lhs, new_fill]); + [opaque_lhs, new_fill]/~); // Was overwritten if we resized let lhs = Load(bcx, lhsptr); let rhs = Select(bcx, self_append, lhs, rhs); @@ -333,14 +333,14 @@ fn trans_append(bcx: block, vec_ty: ty::t, lhsptr: ValueRef, let write_ptr = Load(bcx, write_ptr_ptr); let bcx = copy_val(bcx, INIT, write_ptr, load_if_immediate(bcx, addr, unit_ty), unit_ty); - Store(bcx, InBoundsGEP(bcx, write_ptr, [C_int(ccx, 1)]), + Store(bcx, InBoundsGEP(bcx, write_ptr, [C_int(ccx, 1)]/~), write_ptr_ptr); bcx }) } fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t, - vals: [@ast::expr]) -> block { + vals: [@ast::expr]/~) -> block { let _icx = bcx.insn_ctxt("tvec::trans_append_literal"); let mut bcx = bcx, ccx = bcx.ccx(); let elt_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); @@ -357,7 +357,7 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t, bcx = base::with_cond(bcx, do_grow) {|bcx| let pt = PointerCast(bcx, vptrptr, T_ptr(T_ptr(T_i8()))); - Call(bcx, ccx.upcalls.vec_grow, [pt, new_fill]); + Call(bcx, ccx.upcalls.vec_grow, [pt, new_fill]/~); bcx }; let vptr = get_bodyptr(bcx, Load(bcx, vptrptr)); @@ -380,7 +380,7 @@ fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef, if ty::get(vec_ty).struct == ty::ty_str { let lhs = PointerCast(bcx, lhs, T_ptr(T_i8())); let rhs = PointerCast(bcx, rhs, T_ptr(T_i8())); - let n = Call(bcx, ccx.upcalls.str_concat, [lhs, rhs]); + let n = Call(bcx, ccx.upcalls.str_concat, [lhs, rhs]/~); let n = PointerCast( bcx, n, T_unique_ptr(T_unique(ccx, T_vec(ccx, llunitty)))); ret base::store_in_dest(bcx, n, dest); @@ -401,7 +401,7 @@ fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef, let write_ptr = Load(bcx, write_ptr_ptr); let bcx = copy_val(bcx, INIT, write_ptr, load_if_immediate(bcx, addr, unit_ty), unit_ty); - Store(bcx, InBoundsGEP(bcx, write_ptr, [C_int(ccx, 1)]), + Store(bcx, InBoundsGEP(bcx, write_ptr, [C_int(ccx, 1)]/~), write_ptr_ptr); ret bcx; }; @@ -430,7 +430,8 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, // Now perform the iteration. let header_cx = sub_block(bcx, "iter_vec_loop_header"); Br(bcx, header_cx.llbb); - let data_ptr = Phi(header_cx, val_ty(data_ptr), [data_ptr], [bcx.llbb]); + let data_ptr = + Phi(header_cx, val_ty(data_ptr), [data_ptr]/~, [bcx.llbb]/~); let not_yet_at_end = ICmp(header_cx, lib::llvm::IntULT, data_ptr, data_end_ptr); let body_cx = sub_block(header_cx, "iter_vec_loop_body"); @@ -438,7 +439,7 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, CondBr(header_cx, not_yet_at_end, body_cx.llbb, next_cx.llbb); let body_cx = f(body_cx, data_ptr, unit_ty); AddIncomingToPhi(data_ptr, InBoundsGEP(body_cx, data_ptr, - [C_int(bcx.ccx(), 1)]), + [C_int(bcx.ccx(), 1)]/~), body_cx.llbb); Br(body_cx, header_cx.llbb); ret next_cx; diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index 2b610a99662..db459ddae00 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -14,7 +14,8 @@ export type_of_fn_from_ty; export type_of_fn; export type_of_non_gc_box; -fn type_of_explicit_args(cx: @crate_ctxt, inputs: [ty::arg]) -> [TypeRef] { +fn type_of_explicit_args(cx: @crate_ctxt, + inputs: [ty::arg]/~) -> [TypeRef]/~ { vec::map(inputs) {|arg| let arg_ty = arg.ty; let llty = type_of(cx, arg_ty); @@ -25,14 +26,15 @@ fn type_of_explicit_args(cx: @crate_ctxt, inputs: [ty::arg]) -> [TypeRef] { } } -fn type_of_fn(cx: @crate_ctxt, inputs: [ty::arg], output: ty::t) -> TypeRef { - let mut atys: [TypeRef] = []; +fn type_of_fn(cx: @crate_ctxt, inputs: [ty::arg]/~, + output: ty::t) -> TypeRef { + let mut atys: [TypeRef]/~ = []/~; // Arg 0: Output pointer. - atys += [T_ptr(type_of(cx, output))]; + atys += [T_ptr(type_of(cx, output))]/~; // Arg 1: Environment - atys += [T_opaque_box_ptr(cx)]; + atys += [T_opaque_box_ptr(cx)]/~; // ... then explicit args. atys += type_of_explicit_args(cx, inputs); @@ -115,12 +117,12 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_evec(mt, ty::vstore_slice(_)) { T_struct([T_ptr(type_of(cx, mt.ty)), - T_uint_ty(cx, ast::ty_u)]) + T_uint_ty(cx, ast::ty_u)]/~) } ty::ty_estr(ty::vstore_slice(_)) { T_struct([T_ptr(T_i8()), - T_uint_ty(cx, ast::ty_u)]) + T_uint_ty(cx, ast::ty_u)]/~) } ty::ty_estr(ty::vstore_fixed(n)) { @@ -132,10 +134,10 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { } ty::ty_rec(fields) { - let mut tys: [TypeRef] = []; + let mut tys: [TypeRef]/~ = []/~; for vec::each(fields) {|f| let mt_ty = f.mt.ty; - tys += [type_of(cx, mt_ty)]; + tys += [type_of(cx, mt_ty)]/~; } T_struct(tys) } @@ -143,9 +145,9 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_iface(_, _) { T_opaque_iface(cx) } ty::ty_type { T_ptr(cx.tydesc_type) } ty::ty_tup(elts) { - let mut tys = []; + let mut tys = []/~; for vec::each(elts) {|elt| - tys += [type_of(cx, elt)]; + tys += [type_of(cx, elt)]/~; } T_struct(tys) } @@ -180,7 +182,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { if ty::ty_dtor(cx.tcx, did) != none { // resource type - tys = [T_i8(), T_struct(tys)]; + tys = [T_i8(), T_struct(tys)]/~; } common::set_struct_body(llty, tys); @@ -213,13 +215,13 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) let degen = (*ty::enum_variants(cx.tcx, did)).len() == 1u; let size = shape::static_size_of_enum(cx, t); if !degen { - [T_enum_discrim(cx), T_array(T_i8(), size)] + [T_enum_discrim(cx), T_array(T_i8(), size)]/~ } else if size == 0u { - [T_enum_discrim(cx)] + [T_enum_discrim(cx)]/~ } else { - [T_array(T_i8(), size)] + [T_array(T_i8(), size)]/~ } }; @@ -250,7 +252,7 @@ fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> str { fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef { T_fn([T_ptr(type_of(ccx, ty::mk_nil(ccx.tcx))), - T_ptr(type_of(ccx, self_ty))], + T_ptr(type_of(ccx, self_ty))]/~, llvm::LLVMVoidType()) } diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index fb0b983ae65..325647bfe44 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -31,10 +31,10 @@ const use_repr: uint = 1u; // Dependency on size/alignment and take/drop glue const use_tydesc: uint = 2u; // Takes the tydesc, or compares type ctx = {ccx: @crate_ctxt, - uses: [mut type_uses]}; + uses: [mut type_uses]/~}; fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) - -> [type_uses] { + -> [type_uses]/~ { alt ccx.type_use_cache.find(fn_id) { some(uses) { ret uses; } none {} diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index a3325fc4904..ec4fd7680ba 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -56,9 +56,9 @@ fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { let bcx = copy_val(bcx, INIT, dst_body, src_body, content_ty); let src_tydesc_ptr = GEPi(bcx, src_box, - [0u, back::abi::box_field_tydesc]); + [0u, back::abi::box_field_tydesc]/~); let dst_tydesc_ptr = GEPi(bcx, dst_box, - [0u, back::abi::box_field_tydesc]); + [0u, back::abi::box_field_tydesc]/~); let td = Load(bcx, src_tydesc_ptr); Store(bcx, td, dst_tydesc_ptr); diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index d20cbcfe4d4..0427e480181 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -7,13 +7,13 @@ import aux::{num_constraints, get_fn_info, crate_ctxt, add_node}; import ann::empty_ann; import pat_util::pat_binding_ids; -fn collect_ids_expr(e: @expr, rs: @mut [node_id]) { vec::push(*rs, e.id); } +fn collect_ids_expr(e: @expr, rs: @mut [node_id]/~) { vec::push(*rs, e.id); } -fn collect_ids_block(b: blk, rs: @mut [node_id]) { +fn collect_ids_block(b: blk, rs: @mut [node_id]/~) { vec::push(*rs, b.node.id); } -fn collect_ids_stmt(s: @stmt, rs: @mut [node_id]) { +fn collect_ids_stmt(s: @stmt, rs: @mut [node_id]/~) { alt s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { #debug["node_id %s", int::str(id)]; @@ -23,11 +23,11 @@ fn collect_ids_stmt(s: @stmt, rs: @mut [node_id]) { } } -fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mut [node_id]) { +fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mut [node_id]/~) { *rs += pat_binding_ids(tcx.def_map, l.node.pat); } -fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut [node_id]) { +fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut [node_id]/~) { let collect_ids = visit::mk_simple_visitor(@{visit_expr: {|a|collect_ids_expr(a, rs)}, visit_block: {|a|collect_ids_block(a, rs)}, @@ -38,7 +38,7 @@ fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut [node_id]) { collect_ids.visit_block(body, (), 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 node_ids.each {|i| log(debug, int::str(i) + " |-> " + uint::str(len)); add_node(ccx, i, empty_ann(len)); @@ -46,7 +46,7 @@ fn init_vecs(ccx: crate_ctxt, node_ids: [node_id], len: uint) { } fn visit_fn(ccx: crate_ctxt, num_constraints: uint, body: blk) { - let node_ids: @mut [node_id] = @mut []; + let node_ids: @mut [node_id]/~ = @mut []/~; node_ids_in_fn(ccx.tcx, body, node_ids); let node_id_vec = *node_ids; init_vecs(ccx, node_id_vec, num_constraints); diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index 5fb79dc1318..eee67f1a1f7 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -34,7 +34,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 mut rslt = ""; let mut comma = false; for args.each {|a| @@ -93,7 +93,7 @@ fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { log(error, tritv_to_str(fcx, v)); } -fn tos(v: [uint]) -> str { +fn tos(v: [uint]/~) -> str { let mut rslt = ""; for v.each {|i| if i == 0u { @@ -103,9 +103,9 @@ fn tos(v: [uint]) -> str { ret rslt; } -fn log_cond(v: [uint]) { log(debug, tos(v)); } +fn log_cond(v: [uint]/~) { log(debug, tos(v)); } -fn log_cond_err(v: [uint]) { log(error, tos(v)); } +fn log_cond_err(v: [uint]/~) { log(error, tos(v)); } fn log_pp(pp: pre_and_post) { let p1 = tritv::to_vec(pp.precondition); @@ -145,7 +145,7 @@ fn log_states_err(pp: pre_and_post_state) { fn print_ident(i: ident) { log(debug, " " + *i + " "); } -fn print_idents(&idents: [ident]) { +fn print_idents(&idents: [ident]/~) { if vec::len::<ident>(idents) == 0u { ret; } log(debug, "an ident: " + *vec::pop::<ident>(idents)); print_idents(idents); @@ -180,7 +180,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_>; @@ -203,7 +203,7 @@ type constraint = { type tsconstr = { path: @path, def_id: def_id, - args: [@constr_arg_use] + args: [@constr_arg_use]/~ }; type sp_constr = spanned<tsconstr>; @@ -224,11 +224,11 @@ type fn_info = {constrs: constr_map, num_constraints: uint, cf: ret_style, - used_vars: @mut [node_id], + used_vars: @mut [node_id]/~, ignore: bool}; /* mapping from node ID to typestate annotation */ -type node_ann_table = @mut [mut ts_ann]; +type node_ann_table = @mut [mut ts_ann]/~; /* mapping from function name to fn_info map */ @@ -436,7 +436,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: [mut ts_ann] = [mut]; + let na: [mut ts_ann]/~ = [mut]/~; ret {tcx: cx, node_anns: @mut na, fm: int_hash::<fn_info>()}; } @@ -450,10 +450,10 @@ fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> ret_style { } } -fn constraints_expr(cx: ty::ctxt, e: @expr) -> [@ty::constr] { +fn constraints_expr(cx: ty::ctxt, e: @expr) -> [@ty::constr]/~ { alt ty::get(ty::node_id_to_type(cx, e.id)).struct { ty::ty_fn(f) { ret f.constraints; } - _ { ret []; } + _ { ret []/~; } } } @@ -471,14 +471,14 @@ fn node_id_to_def(ccx: crate_ctxt, id: node_id) -> option<def> { ret ccx.tcx.def_map.find(id); } -fn norm_a_constraint(id: def_id, c: constraint) -> [norm_constraint] { - let mut rslt: [norm_constraint] = []; +fn norm_a_constraint(id: def_id, c: constraint) -> [norm_constraint]/~ { + let mut rslt: [norm_constraint]/~ = []/~; for (*c.descs).each {|pd| rslt += [{bit_num: pd.node.bit_num, c: respan(pd.span, {path: c.path, def_id: id, - args: pd.node.args})}]; + args: pd.node.args})}]/~; } ret rslt; } @@ -486,8 +486,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 mut rslt: [norm_constraint] = []; +fn constraints(fcx: fn_ctxt) -> [norm_constraint]/~ { + let mut rslt: [norm_constraint]/~ = []/~; for fcx.enclosing.constrs.each {|key, val| rslt += norm_a_constraint(key, val); }; @@ -497,7 +497,7 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] { // FIXME (#2539): Would rather take an immutable vec as an argument, // should freeze it at some earlier point. fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>, - occ: [@constr_arg_use]) -> uint { + occ: [@constr_arg_use]/~) -> uint { #debug("match_args: looking at %s", constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, occ)); for (*occs).each {|pd| @@ -549,10 +549,11 @@ 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 = {|a|expr_to_constr_arg(tcx, a)}; - let mut rslt: [@constr_arg_use] = []; - for args.each {|e| rslt += [f(e)]; } + let mut rslt: [@constr_arg_use]/~ = []/~; + for args.each {|e| rslt += [f(e)]/~; } rslt } @@ -584,18 +585,18 @@ 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 mut rslt: [@constr_arg_use] = []; + let mut rslt: [@constr_arg_use]/~ = []/~; for c.node.args.each {|a| - rslt += [substitute_arg(cx, actuals, a)]; + rslt += [substitute_arg(cx, actuals, a)]/~; } ret {path: c.node.path, def_id: c.node.id, args: 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 = vec::len(actuals); alt a.node { @@ -611,7 +612,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 mut i = 0u; @@ -637,8 +638,8 @@ fn pred_args_matches(pattern: [constr_arg_general_<inst>], ret true; } -fn find_instance_(pattern: [constr_arg_general_<inst>], - descs: [pred_args]) -> +fn find_instance_(pattern: [constr_arg_general_<inst>]/~, + descs: [pred_args]/~) -> option<uint> { for descs.each {|d| if pred_args_matches(pattern, d) { ret some(d.node.bit_num); } @@ -653,13 +654,13 @@ enum dest { call // RHS is passed to a function } -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}] { + c: constraint) -> [{from: uint, to: uint}]/~ { - if vec::len(subst) == 0u { ret []; } - let mut res = []; + if vec::len(subst) == 0u { ret []/~; } + let mut res = []/~; (*c.descs).swap { |v| let v <- vec::from_mut(v); for v.each { |d| @@ -667,7 +668,7 @@ fn find_instances(_fcx: fn_ctxt, subst: subst, let old_bit_num = d.node.bit_num; let newv = replace(subst, d); alt find_instance_(newv, v) { - some(d1) {res += [{from: old_bit_num, to: d1}]} + some(d1) {res += [{from: old_bit_num, to: d1}]/~} _ {} } } else {} @@ -688,7 +689,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 mut rslt = "<"; for stuff.each {|i| rslt += @@ -696,25 +697,25 @@ fn insts_to_str(stuff: [constr_arg_general_<inst>]) -> str { alt i { carg_ident(p) { *p.ident } carg_base { "*" } - carg_lit(_) { "[lit]" } + carg_lit(_) { "[lit]/~" } } + " "; } rslt += ">"; rslt } -fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>] { - let mut rslt: [constr_arg_general_<inst>] = []; +fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>]/~ { + let mut rslt: [constr_arg_general_<inst>]/~ = []/~; for d.node.args.each {|c| alt c.node { carg_ident(p) { alt find_in_subst(p.node, subst) { - some(newv) { rslt += [carg_ident(newv)]; } - _ { rslt += [c.node]; } + some(newv) { rslt += [carg_ident(newv)]/~; } + _ { rslt += [c.node]/~; } } } _ { - rslt += [c.node]; + rslt += [c.node]/~; } } } @@ -796,11 +797,11 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate, ty: oper_type) { let mut subst; alt ty { - oper_swap { subst = [{from: dest, to: src}, {from: src, to: dest}]; } + oper_swap { subst = [{from: dest, to: src}, {from: src, to: dest}]/~; } oper_assign_op { ret; // Don't do any propagation } - _ { subst = [{from: src, to: dest}]; } + _ { subst = [{from: src, to: dest}]/~; } } @@ -845,19 +846,19 @@ fn forget_in_poststate(fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool { ret changed; } -fn any_eq(v: [node_id], d: node_id) -> bool { +fn any_eq(v: [node_id]/~, d: node_id) -> bool { for v.each {|i| if i == d { ret true; } } false } fn constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id) -> bool { - ret args_mention(c.c.node.args, any_eq, [v]); + ret args_mention(c.c.node.args, any_eq, [v]/~); } -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 { for args.each {|a| alt a.node { carg_ident(p1) { if q(s, p1.node) { ret true; } } _ { } } @@ -865,7 +866,7 @@ fn args_mention<T>(args: [@constr_arg_use], ret false; } -fn use_var(fcx: fn_ctxt, v: node_id) { *fcx.enclosing.used_vars += [v]; } +fn use_var(fcx: fn_ctxt, v: node_id) { *fcx.enclosing.used_vars += [v]/~; } fn op_to_oper_ty(io: init_op) -> oper_type { alt io { init_move { oper_move } _ { oper_assign } } @@ -878,9 +879,10 @@ fn do_nothing<T>(_fk: visit::fn_kind, _decl: fn_decl, _body: blk, } -fn args_to_constr_args(tcx: ty::ctxt, args: [arg], - indices: [@sp_constr_arg<uint>]) -> [@constr_arg_use] { - let mut actuals: [@constr_arg_use] = []; +fn args_to_constr_args(tcx: ty::ctxt, args: [arg]/~, + indices: [@sp_constr_arg<uint>]/~) + -> [@constr_arg_use]/~ { + let mut actuals: [@constr_arg_use]/~ = []/~; let num_args = vec::len(args); for indices.each {|a| actuals += @@ -898,12 +900,12 @@ fn args_to_constr_args(tcx: ty::ctxt, args: [arg], } } carg_lit(l) { carg_lit(l) } - })]; + })]/~; } 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 {path: tconstr.node.path, @@ -911,35 +913,35 @@ fn ast_constr_to_ts_constr(tcx: ty::ctxt, args: [arg], c: @constr) -> args: args_to_constr_args(tcx, args, tconstr.node.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: [dest], rhs: option<initializer>}; +type binding = {lhs: [dest]/~, rhs: option<initializer>}; fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding { - let mut lhs = []; + let mut lhs = []/~; pat_bindings(tcx.def_map, loc.node.pat) {|p_id, _s, name| - lhs += [local_dest({ident: path_to_ident(name), node: p_id})]; + lhs += [local_dest({ident: path_to_ident(name), node: p_id})]/~; }; {lhs: lhs, rhs: loc.node.init} } -fn locals_to_bindings(tcx: ty::ctxt, locals: [@local]) -> [binding] { - let mut rslt = []; - for locals.each {|loc| rslt += [local_to_bindings(tcx, loc)]; } +fn locals_to_bindings(tcx: ty::ctxt, locals: [@local]/~) -> [binding]/~ { + let mut rslt = []/~; + for locals.each {|loc| rslt += [local_to_bindings(tcx, loc)]/~; } ret rslt; } -fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [mode] { +fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [mode]/~ { let ty = ty::type_autoderef(fcx.ccx.tcx, ty::node_id_to_type(fcx.ccx.tcx, callee)); alt ty::get(ty).struct { ty::ty_fn({inputs: args, _}) { - let mut modes = []; - for args.each {|arg| modes += [arg.mode]; } + let mut modes = []/~; + for args.each {|arg| modes += [arg.mode]/~; } ret modes; } _ { @@ -950,7 +952,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [mode] { } } -fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> [init_op] { +fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> [init_op]/~ { vec::map(callee_modes(fcx, callee)) {|m| alt ty::resolved_mode(fcx.ccx.tcx, m) { by_move { init_move } @@ -959,11 +961,12 @@ fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> [init_op] { } } -fn arg_bindings(ops: [init_op], es: [@expr]) -> [binding] { - let mut bindings: [binding] = []; +fn arg_bindings(ops: [init_op]/~, es: [@expr]/~) -> [binding]/~ { + let mut bindings: [binding]/~ = []/~; let mut i = 0u; for ops.each {|op| - bindings += [{lhs: [call], rhs: some({op: op, expr: es[i]})}]; + vec::push(bindings, + {lhs: [call]/~, rhs: some({op: op, expr: es[i]})}); i += 1u; } ret bindings; diff --git a/src/rustc/middle/tstate/bitvectors.rs b/src/rustc/middle/tstate/bitvectors.rs index 4524684bc60..c1ca98d5f90 100644 --- a/src/rustc/middle/tstate/bitvectors.rs +++ b/src/rustc/middle/tstate/bitvectors.rs @@ -45,7 +45,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 = vec::len(ps); if sz >= 1u { let prev = tritv_clone(ps[0]); @@ -58,11 +58,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 = vec::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]/~, idx: uint, first: pre_and_post) -> precond { let mut idx = idx; diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index 33a5b1ab0b0..bf22f4287bb 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -10,12 +10,12 @@ import aux::*; import std::map::hashmap; import dvec::{dvec, extensions}; -type ctxt = {cs: @mut [sp_constr], tcx: ty::ctxt}; +type ctxt = {cs: @mut [sp_constr]/~, tcx: ty::ctxt}; fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) { alt e.node { - expr_check(_, ch) { *cx.cs += [expr_to_constr(cx.tcx, ch)]; } - expr_if_check(ex, _, _) { *cx.cs += [expr_to_constr(cx.tcx, ex)]; } + expr_check(_, ch) { *cx.cs += [expr_to_constr(cx.tcx, ch)]/~; } + expr_if_check(ex, _, _) { *cx.cs += [expr_to_constr(cx.tcx, ex)]/~; } // If it's a call, generate appropriate instances of the // call's constraints. @@ -24,7 +24,7 @@ fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) { let ct: sp_constr = respan(c.span, aux::substitute_constr_args(cx.tcx, operands, c)); - *cx.cs += [ct]; + *cx.cs += [ct]/~; } } _ { } @@ -39,7 +39,7 @@ fn find_locals(tcx: ty::ctxt, f_body: blk, sp: span, id: node_id) -> ctxt { - let cx: ctxt = {cs: @mut [], tcx: tcx}; + let cx: ctxt = {cs: @mut []/~, tcx: tcx}; let visitor = visit::default_visitor::<ctxt>(); let visitor = @{visit_expr: collect_pred, @@ -130,7 +130,7 @@ fn mk_fn_info(ccx: crate_ctxt, } } - let v: @mut [node_id] = @mut []; + let v: @mut [node_id]/~ = @mut []/~; let rslt = {constrs: res_map, num_constraints: next, diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index aa7a3d6e344..cc157ff4356 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -63,7 +63,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 <args>, and the postcondition in a to be the union of all postconditions for <args> */ -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 vec::len::<@expr>(args) > 0u { #debug["find_pre_post_exprs: oper = %s", expr_to_str(args[0])]; } @@ -84,7 +84,8 @@ fn find_pre_post_loop(fcx: fn_ctxt, index: @expr, body: blk, id: node_id) { find_pre_post_block(fcx, body); let loop_precond = - seq_preconds(fcx, [expr_pp(fcx.ccx, index), block_pp(fcx.ccx, body)]); + seq_preconds(fcx, [expr_pp(fcx.ccx, index), + block_pp(fcx.ccx, body)]/~); let loop_postcond = intersect_states(expr_postcond(fcx.ccx, index), block_postcond(fcx.ccx, body)); @@ -111,7 +112,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, let precond_res = seq_preconds(fcx, [expr_pp(fcx.ccx, antec), - block_pp(fcx.ccx, conseq)]); + block_pp(fcx.ccx, conseq)]/~); set_pre_and_post(fcx.ccx, id, precond_res, expr_poststate(fcx.ccx, antec)); } @@ -124,11 +125,12 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, find_pre_post_expr(fcx, altern); let precond_false_case = seq_preconds(fcx, - [expr_pp(fcx.ccx, antec), expr_pp(fcx.ccx, altern)]); + [expr_pp(fcx.ccx, antec), + expr_pp(fcx.ccx, altern)]/~); let postcond_false_case = seq_postconds(fcx, [expr_postcond(fcx.ccx, antec), - expr_postcond(fcx.ccx, altern)]); + expr_postcond(fcx.ccx, altern)]/~); /* Be sure to set the bit for the check condition here, so that it's *not* set in the alternative. */ @@ -142,14 +144,14 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, let precond_true_case = seq_preconds(fcx, [expr_pp(fcx.ccx, antec), - block_pp(fcx.ccx, conseq)]); + block_pp(fcx.ccx, conseq)]/~); let postcond_true_case = seq_postconds(fcx, [expr_postcond(fcx.ccx, antec), - block_postcond(fcx.ccx, conseq)]); + block_postcond(fcx.ccx, conseq)]/~); let precond_res = - seq_postconds(fcx, [precond_true_case, precond_false_case]); + seq_postconds(fcx, [precond_true_case, precond_false_case]/~); let postcond_res = intersect_states(postcond_true_case, postcond_false_case); set_pre_and_post(fcx.ccx, id, precond_res, postcond_res); @@ -168,10 +170,10 @@ fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id, set_pre_and_post(fcx.ccx, larger_id, p.precondition, p.postcondition); } - _ { find_pre_post_exprs(fcx, [lhs, rhs], larger_id); } + _ { find_pre_post_exprs(fcx, [lhs, rhs]/~, larger_id); } } } - _ { find_pre_post_exprs(fcx, [lhs, rhs], larger_id); } + _ { find_pre_post_exprs(fcx, [lhs, rhs]/~, larger_id); } } } @@ -226,8 +228,8 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, } } -fn forget_args_moved_in(fcx: fn_ctxt, parent: @expr, modes: [mode], - operands: [@expr]) { +fn forget_args_moved_in(fcx: fn_ctxt, parent: @expr, modes: [mode]/~, + operands: [@expr]/~) { vec::iteri(modes) {|i,mode| alt ty::resolved_mode(fcx.ccx.tcx, mode) { by_move { forget_in_postcond(fcx, parent.id, operands[i].id); } @@ -253,7 +255,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { /* copy */ let mut args = operands; - args += [operator]; + args += [operator]/~; find_pre_post_exprs(fcx, args, e.id); /* see if the call has any constraints on its type */ @@ -285,10 +287,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { clear_pp(rslt); } expr_new(p, _, v) { - find_pre_post_exprs(fcx, [p, v], e.id); + find_pre_post_exprs(fcx, [p, v]/~, e.id); } expr_log(_, lvl, arg) { - find_pre_post_exprs(fcx, [lvl, arg], e.id); + find_pre_post_exprs(fcx, [lvl, arg]/~, e.id); } expr_fn(_, _, _, cap_clause) | expr_fn_block(_, _, cap_clause) { find_pre_post_expr_fn_upvars(fcx, e); @@ -312,7 +314,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_rec(fields, maybe_base) { let mut es = field_exprs(fields); - alt maybe_base { none {/* no-op */ } some(b) { es += [b]; } } + alt maybe_base { none {/* no-op */ } some(b) { es += [b]/~; } } find_pre_post_exprs(fcx, es, e.id); } expr_tup(elts) { find_pre_post_exprs(fcx, elts, e.id); } @@ -323,7 +325,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { /* Different from expr_assign in that the lhs *must* already be initialized */ - find_pre_post_exprs(fcx, [lhs, rhs], e.id); + find_pre_post_exprs(fcx, [lhs, rhs]/~, e.id); forget_in_postcond(fcx, e.id, lhs.id); } expr_lit(_) { clear_pp(expr_pp(fcx.ccx, e)); } @@ -349,11 +351,12 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, l); find_pre_post_expr(fcx, r); let overall_pre = - seq_preconds(fcx, [expr_pp(fcx.ccx, l), expr_pp(fcx.ccx, r)]); + seq_preconds(fcx, + [expr_pp(fcx.ccx, l), expr_pp(fcx.ccx, r)]/~); set_precondition(node_id_to_ts_ann(fcx.ccx, e.id), overall_pre); set_postcondition(node_id_to_ts_ann(fcx.ccx, e.id), expr_postcond(fcx.ccx, l)); - } else { find_pre_post_exprs(fcx, [l, r], e.id); } + } else { find_pre_post_exprs(fcx, [l, r]/~, e.id); } } expr_addr_of(_, x) | expr_cast(x, _) | expr_unary(_, x) | expr_loop_body(x) | expr_do_body(x) | expr_assert(x) | expr_copy(x) { @@ -366,7 +369,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { set_pre_and_post(fcx.ccx, e.id, seq_preconds(fcx, [expr_pp(fcx.ccx, test), - block_pp(fcx.ccx, body)]), + block_pp(fcx.ccx, body)]/~), intersect_states(expr_postcond(fcx.ccx, test), block_postcond(fcx.ccx, body))); } @@ -383,7 +386,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { set_pre_and_post(fcx.ccx, e.id, block_precond(fcx.ccx, body), loop_postcond); } - expr_index(val, sub) { find_pre_post_exprs(fcx, [val, sub], e.id); } + expr_index(val, sub) { find_pre_post_exprs(fcx, [val, sub]/~, e.id); } expr_alt(ex, alts, _) { find_pre_post_expr(fcx, ex); fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post { @@ -394,11 +397,11 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { find_pre_post_block(fcx, an_alt.body); ret block_pp(fcx.ccx, an_alt.body); } - let mut alt_pps = []; - for alts.each {|a| alt_pps += [do_an_alt(fcx, a)]; } + let mut alt_pps = []/~; + for alts.each {|a| alt_pps += [do_an_alt(fcx, a)]/~; } fn combine_pp(antec: pre_and_post, fcx: fn_ctxt, &&pp: pre_and_post, &&next: pre_and_post) -> pre_and_post { - union(pp.precondition, seq_preconds(fcx, [antec, next])); + union(pp.precondition, seq_preconds(fcx, [antec, next]/~)); intersect(pp.postcondition, next.postcondition); ret pp; } @@ -494,7 +497,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { guaranteed */ let e_pp = expr_pp(fcx.ccx, an_init.expr); tritv_copy(prev_pp.precondition, - seq_preconds(fcx, [prev_pp, e_pp])); + seq_preconds(fcx, [prev_pp, e_pp]/~)); /* Include the LHSs too, since those aren't in the postconds of the RHSs themselves */ @@ -551,21 +554,21 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) { let do_inner = {|a|do_inner_(fcx, a)}; option::map::<@expr, ()>(b.node.expr, do_inner); - let mut pps: [pre_and_post] = []; - for b.node.stmts.each {|s| pps += [stmt_pp(fcx.ccx, *s)]; } + let mut pps: [pre_and_post]/~ = []/~; + for b.node.stmts.each {|s| pps += [stmt_pp(fcx.ccx, *s)]/~; } alt b.node.expr { none {/* no-op */ } - some(e) { pps += [expr_pp(fcx.ccx, e)]; } + some(e) { pps += [expr_pp(fcx.ccx, e)]/~; } } let block_precond = seq_preconds(fcx, pps); - let mut postconds = []; - for pps.each {|pp| postconds += [get_post(pp)]; } + let mut postconds = []/~; + for pps.each {|pp| postconds += [get_post(pp)]/~; } /* A block may be empty, so this next line ensures that the postconds vector is non-empty. */ - postconds += [block_precond]; + postconds += [block_precond]/~; let mut block_postcond = empty_poststate(nv); /* conservative approximation */ diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index 4883422a908..64748a43b99 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -54,7 +54,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 mut changed = false; let mut post = tritv_clone(pres); @@ -166,7 +166,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, ops: [init_op], bs: [@expr], + id: node_id, ops: [init_op]/~, bs: [@expr]/~, cf: ret_style) -> bool { let mut changed = find_pre_post_state_expr(fcx, pres, a); // FIXME (#2178): This could be a typestate constraint (except we're @@ -183,8 +183,8 @@ 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, - ops: [init_op], es: [@expr], cf: ret_style) -> - bool { + ops: [init_op]/~, es: [@expr]/~, + cf: ret_style) -> bool { let rs = seq_states(fcx, pres, arg_bindings(ops, es)); let mut changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres); /* if this is a failing call, it sets everything as initialized */ @@ -404,7 +404,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { /* conservative approximation: if a loop contains a break or cont, we assume nothing about the poststate */ - /* which is still unsound -- see [Break-unsound] */ + /* which is still unsound -- see [Break-unsound]/~ */ if has_nonlocal_exits(body) { ret changed | set_poststate_ann(fcx.ccx, e.id, pres); } else { @@ -423,7 +423,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { /* conservative approximation: if a loop contains a break or cont, we assume nothing about the poststate (so, we set all predicates to "don't know" */ - /* which is still unsound -- see [Break-unsound] */ + /* which is still unsound -- see [Break-unsound]/~ */ if may_break(body) { /* Only do this if there are *breaks* not conts. An infinite loop with conts is still an infinite loop. diff --git a/src/rustc/middle/tstate/tritv.rs b/src/rustc/middle/tstate/tritv.rs index 7bcc4840d25..b66cfe00b3f 100644 --- a/src/rustc/middle/tstate/tritv.rs +++ b/src/rustc/middle/tstate/tritv.rs @@ -249,16 +249,16 @@ fn tritv_doesntcare(v: t) -> bool { ret true; } -fn to_vec(v: t) -> [uint] { +fn to_vec(v: t) -> [uint]/~ { let mut i: uint = 0u; - let mut rslt: [uint] = []; + let mut rslt: [uint]/~ = []/~; while i < v.nbits { rslt += [alt tritv_get(v, i) { dont_care { 2u } ttrue { 1u } tfalse { 0u } - }]; + }]/~; i += 1u; } ret rslt; diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index c5aa42186bc..d766f8b2960 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -172,15 +172,15 @@ type arg = {mode: ast::mode, ty: t}; type field = {ident: ast::ident, mt: mt}; -type param_bounds = @[param_bound]; +type param_bounds = @[param_bound]/~; type method = {ident: ast::ident, - tps: @[param_bounds], + tps: @[param_bounds]/~, fty: fn_ty, purity: ast::purity, vis: ast::visibility}; -type constr_table = hashmap<ast::node_id, [constr]>; +type constr_table = hashmap<ast::node_id, [constr]/~>; type mt = {ty: t, mutbl: ast::mutability}; @@ -234,7 +234,7 @@ type ctxt = // of this node. This only applies to nodes that refer to entities // parameterized by type parameters, such as generic fns, types, or // other items. - node_type_substs: hashmap<node_id, [t]>, + node_type_substs: hashmap<node_id, [t]/~>, items: ast_map::map, intrinsic_ifaces: hashmap<ast::ident, (ast::def_id, t)>, @@ -246,8 +246,8 @@ type ctxt = needs_unwind_cleanup_cache: hashmap<t, bool>, kind_cache: hashmap<t, kind>, ast_ty_to_ty_cache: hashmap<@ast::ty, ast_ty_to_ty_cache_entry>, - enum_var_cache: hashmap<def_id, @[variant_info]>, - iface_method_cache: hashmap<def_id, @[method]>, + enum_var_cache: hashmap<def_id, @[variant_info]/~>, + iface_method_cache: hashmap<def_id, @[method]/~>, ty_param_bounds: hashmap<ast::node_id, param_bounds>, inferred_modes: hashmap<ast::node_id, ast::mode>, // maps the id of borrowed expr to scope of borrowed ptr @@ -305,10 +305,10 @@ enum closure_kind { type fn_ty = {purity: ast::purity, proto: ast::proto, - inputs: [arg], + inputs: [arg]/~, output: t, ret_style: ret_style, - constraints: [@constr]}; + constraints: [@constr]/~}; // See discussion at head of region.rs enum region { @@ -340,7 +340,7 @@ type opt_region = option<region>; type substs = { self_r: opt_region, self_ty: option<ty::t>, - tps: [t] + tps: [t]/~ }; // NB: If you change this, you'll probably want to change the corresponding @@ -361,18 +361,18 @@ enum sty { ty_evec(mt, vstore), ty_ptr(mt), ty_rptr(region, mt), - ty_rec([field]), + ty_rec([field]/~), ty_fn(fn_ty), ty_iface(def_id, substs), ty_class(def_id, substs), - ty_tup([t]), + ty_tup([t]/~), ty_var(tv_vid), // type variable during typechecking ty_var_integral(tvi_vid), // type variable during typechecking, for // integral types only ty_param(uint, def_id), // type parameter ty_self, // special, implicit `self` type parameter - ty_constr(t, [@type_constr]), + ty_constr(t, [@type_constr]/~), // "Fake" types, used for trans purposes ty_type, // type_desc* @@ -471,7 +471,7 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind { kind } -type ty_param_bounds_and_ty = {bounds: @[param_bounds], +type ty_param_bounds_and_ty = {bounds: @[param_bounds]/~, rp: ast::region_param, ty: t}; @@ -691,13 +691,13 @@ fn mk_mut_unboxed_vec(cx: ctxt, ty: t) -> t { } -fn mk_rec(cx: ctxt, fs: [field]) -> t { mk_t(cx, ty_rec(fs)) } +fn mk_rec(cx: ctxt, fs: [field]/~) -> t { mk_t(cx, ty_rec(fs)) } -fn mk_constr(cx: ctxt, t: t, cs: [@type_constr]) -> t { +fn mk_constr(cx: ctxt, t: t, cs: [@type_constr]/~) -> t { mk_t(cx, ty_constr(t, cs)) } -fn mk_tup(cx: ctxt, ts: [t]) -> t { mk_t(cx, ty_tup(ts)) } +fn mk_tup(cx: ctxt, ts: [t]/~) -> t { mk_t(cx, ty_tup(ts)) } fn mk_fn(cx: ctxt, fty: fn_ty) -> t { mk_t(cx, ty_fn(fty)) } @@ -992,7 +992,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t { } // Substitute *only* type parameters. Used in trans where regions are erased. -fn subst_tps(cx: ctxt, tps: [t], typ: t) -> t { +fn subst_tps(cx: ctxt, tps: [t]/~, typ: t) -> t { if tps.len() == 0u { ret typ; } let tb = ty::get(typ); if !tbox_has_flag(tb, has_params) { ret typ; } @@ -1598,7 +1598,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { // True if instantiating an instance of `ty` requires an instance of `r_ty`. fn is_instantiable(cx: ctxt, r_ty: t) -> bool { - fn type_requires(cx: ctxt, seen: @mut [def_id], + fn type_requires(cx: ctxt, seen: @mut [def_id]/~, r_ty: t, ty: t) -> bool { #debug["type_requires(%s, %s)?", ty_to_str(cx, r_ty), @@ -1616,7 +1616,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ret r; } - fn subtypes_require(cx: ctxt, seen: @mut [def_id], + fn subtypes_require(cx: ctxt, seen: @mut [def_id]/~, r_ty: t, ty: t) -> bool { #debug["subtypes_require(%s, %s)?", ty_to_str(cx, r_ty), @@ -1713,7 +1713,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ret r; } - let seen = @mut []; + let seen = @mut []/~; !subtypes_require(cx, seen, r_ty, r_ty) } @@ -1973,7 +1973,7 @@ fn hash_type_structure(st: sty) -> uint { (h << 2u) + (did.node as uint) } fn hash_subty(id: uint, subty: t) -> uint { (id << 2u) + type_id(subty) } - fn hash_subtys(id: uint, subtys: [t]) -> uint { + fn hash_subtys(id: uint, subtys: [t]/~) -> uint { let mut h = id; for subtys.each {|s| h = (h << 2u) + type_id(s) } h @@ -2094,8 +2094,8 @@ fn arg_eq<T>(eq: fn(T, T) -> bool, } fn args_eq<T>(eq: fn(T, T) -> bool, - a: [@sp_constr_arg<T>], - b: [@sp_constr_arg<T>]) -> bool { + a: [@sp_constr_arg<T>]/~, + b: [@sp_constr_arg<T>]/~) -> bool { let mut i: uint = 0u; for a.each {|arg| if !arg_eq(eq, arg, b[i]) { ret false; } @@ -2110,7 +2110,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 vec::len(cs) != vec::len(ds) { ret false; } let mut i = 0u; for cs.each {|c| if !constr_eq(c, ds[i]) { ret false; } i += 1u; } @@ -2125,9 +2125,9 @@ fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { } } -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 cx.node_type_substs.find(id) { - none { ret []; } + none { ret []/~; } some(ts) { ret ts; } } } @@ -2137,7 +2137,7 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { } // Type accessors for substructures of types -fn ty_fn_args(fty: t) -> [arg] { +fn ty_fn_args(fty: t) -> [arg]/~ { alt get(fty).struct { ty_fn(f) { f.inputs } _ { fail "ty_fn_args() called on non-fn type"; } @@ -2173,8 +2173,8 @@ fn is_fn_ty(fty: t) -> bool { } // Returns a vec of all the input and output types of fty. -fn tys_in_fn_ty(fty: fn_ty) -> [t] { - fty.inputs.map({|a| a.ty}) + [fty.output] +fn tys_in_fn_ty(fty: fn_ty) -> [t]/~ { + fty.inputs.map({|a| a.ty}) + [fty.output]/~ } // Just checks whether it's a fn that returns bool, @@ -2222,7 +2222,8 @@ fn expr_ty(cx: ctxt, expr: @ast::expr) -> t { ret node_id_to_type(cx, expr.id); } -fn expr_ty_params_and_ty(cx: ctxt, expr: @ast::expr) -> {params: [t], ty: t} { +fn expr_ty_params_and_ty(cx: ctxt, + expr: @ast::expr) -> {params: [t]/~, ty: t} { ret {params: node_id_to_type_params(cx, expr.id), ty: node_id_to_type(cx, expr.id)}; } @@ -2249,7 +2250,7 @@ fn stmt_node_id(s: @ast::stmt) -> ast::node_id { } } -fn field_idx(id: ast::ident, fields: [field]) -> option<uint> { +fn field_idx(id: ast::ident, fields: [field]/~) -> option<uint> { let mut i = 0u; for fields.each {|f| if f.ident == id { ret some(i); } i += 1u; } ret none; @@ -2261,13 +2262,13 @@ fn get_field(rec_ty: t, id: ast::ident) -> field { } } -fn get_fields(rec_ty:t) -> [field] { +fn get_fields(rec_ty:t) -> [field]/~ { alt check get(rec_ty).struct { ty_rec(fields) { fields } } } -fn method_idx(id: ast::ident, meths: [method]) -> option<uint> { +fn method_idx(id: ast::ident, meths: [method]/~) -> option<uint> { let mut i = 0u; for meths.each {|m| if m.ident == id { ret some(i); } i += 1u; } ret none; @@ -2277,10 +2278,10 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { // Returns a vec of all the type variables occurring in `ty`. It may // contain duplicates. (Integral type vars aren't counted.) - fn vars_in_type(ty: t) -> [tv_vid] { - let mut rslt = []; + fn vars_in_type(ty: t) -> [tv_vid]/~ { + let mut rslt = []/~; walk_ty(ty) {|ty| - alt get(ty).struct { ty_var(v) { rslt += [v]; } _ { } } + alt get(ty).struct { ty_var(v) { rslt += [v]/~; } _ { } } } rslt } @@ -2501,11 +2502,11 @@ fn def_has_ty_params(def: ast::def) -> bool { } } -fn store_iface_methods(cx: ctxt, id: ast::node_id, ms: @[method]) { +fn store_iface_methods(cx: ctxt, id: ast::node_id, ms: @[method]/~) { cx.iface_method_cache.insert(ast_util::local_def(id), ms); } -fn iface_methods(cx: ctxt, id: ast::def_id) -> @[method] { +fn iface_methods(cx: ctxt, id: ast::def_id) -> @[method]/~ { alt cx.iface_method_cache.find(id) { some(ms) { ret ms; } _ {} @@ -2553,12 +2554,12 @@ fn ty_to_def_id(ty: t) -> option<ast::def_id> { } // Enum information -type variant_info = @{args: [t], ctor_ty: t, name: ast::ident, +type variant_info = @{args: [t]/~, ctor_ty: t, name: ast::ident, id: ast::def_id, disr_val: int}; fn substd_enum_variants(cx: ctxt, id: ast::def_id, - substs: substs) -> [variant_info] { + substs: substs) -> [variant_info]/~ { vec::map(*enum_variants(cx, id)) { |variant_info| let substd_args = vec::map(variant_info.args) {|aty| subst(cx, substs, aty) @@ -2609,26 +2610,26 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { ast_map::path_name(item.ident) } }; - *path + [item_elt] + *path + [item_elt]/~ } ast_map::node_native_item(nitem, _, path) { - *path + [ast_map::path_name(nitem.ident)] + *path + [ast_map::path_name(nitem.ident)]/~ } ast_map::node_method(method, _, path) { - *path + [ast_map::path_name(method.ident)] + *path + [ast_map::path_name(method.ident)]/~ } ast_map::node_variant(variant, _, path) { - vec::init(*path) + [ast_map::path_name(variant.node.name)] + vec::init(*path) + [ast_map::path_name(variant.node.name)]/~ } ast_map::node_ctor(nm, _, _, _, path) { - *path + [ast_map::path_name(nm)] + *path + [ast_map::path_name(nm)]/~ } ast_map::node_dtor(_, _, _, path) { - *path + [ast_map::path_name(@"dtor")] + *path + [ast_map::path_name(@"dtor")]/~ } @@ -2645,7 +2646,7 @@ fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool { vec::len(*enum_variants(cx, id)) == 1u } -fn enum_variants(cx: ctxt, id: ast::def_id) -> @[variant_info] { +fn enum_variants(cx: ctxt, id: ast::def_id) -> @[variant_info]/~ { alt cx.enum_var_cache.find(id) { some(variants) { ret variants; } _ { /* fallthrough */ } @@ -2667,7 +2668,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @[variant_info] { let arg_tys = { if vec::len(variant.node.args) > 0u { ty_fn_args(ctor_ty).map { |a| a.ty } - } else { [] } + } else { []/~ } }; alt variant.node.disr_expr { some (ex) { @@ -2751,7 +2752,7 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id, // Look up the list of field names and IDs for a given class // Fails if the id is not bound to a class. -fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> [field_ty] { +fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> [field_ty]/~ { if did.crate == ast::local_crate { alt cx.items.find(did.node) { some(ast_map::node_item(i,_)) { @@ -2782,7 +2783,7 @@ fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id) } } -fn lookup_public_fields(cx: ctxt, did: ast::def_id) -> [field_ty] { +fn lookup_public_fields(cx: ctxt, did: ast::def_id) -> [field_ty]/~ { vec::filter(lookup_class_fields(cx, did), is_public) } @@ -2796,7 +2797,7 @@ pure fn is_public(f: field_ty) -> bool { // Look up the list of method names and IDs for a given class // Fails if the id is not bound to a class. fn lookup_class_method_ids(cx: ctxt, did: ast::def_id) - : is_local(did) -> [{name: ident, id: node_id, vis: visibility}] { + : is_local(did) -> [{name: ident, id: node_id, vis: visibility}]/~ { alt cx.items.find(did.node) { some(ast_map::node_item(@{node: item_class(_,_,items,_,_,_), _}, _)) { let (_,ms) = split_class_items(items); @@ -2831,13 +2832,13 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, } } -fn class_field_tys(items: [@class_member]) -> [field_ty] { - let mut rslt = []; +fn class_field_tys(items: [@class_member]/~) -> [field_ty]/~ { + let mut rslt = []/~; for items.each {|it| alt it.node { instance_var(nm, _, cm, id, vis) { rslt += [{ident: nm, id: ast_util::local_def(id), - vis: vis, mutability: cm}]; + vis: vis, mutability: cm}]/~; } class_method(_) { } } @@ -2852,14 +2853,14 @@ fn class_field_tys(items: [@class_member]) -> [field_ty] { // mutable, regardless of how they were declared. It's meant to // be used in trans. fn class_items_as_mutable_fields(cx:ctxt, did: ast::def_id, - substs: substs) -> [field] { + substs: substs) -> [field]/~ { class_item_fields(cx, did, substs, {|_mt| m_mutbl}) } // Same as class_items_as_mutable_fields, but doesn't change // mutability. fn class_items_as_fields(cx:ctxt, did: ast::def_id, - substs: substs) -> [field] { + substs: substs) -> [field]/~ { class_item_fields(cx, did, substs, {|mt| alt mt { class_mutable { m_mutbl } class_immutable { m_imm }}}) @@ -2868,14 +2869,14 @@ fn class_items_as_fields(cx:ctxt, did: ast::def_id, fn class_item_fields(cx:ctxt, did: ast::def_id, substs: substs, frob_mutability: fn(class_mutability) -> mutability) - -> [field] { - let mut rslt = []; + -> [field]/~ { + let mut rslt = []/~; for lookup_class_fields(cx, did).each {|f| // consider all instance vars mut, because the // constructor may mutate all vars rslt += [{ident: f.ident, mt: {ty: lookup_field_type(cx, did, f.id, substs), - mutbl: frob_mutability(f.mutability)}}]; + mutbl: frob_mutability(f.mutability)}}]/~; } rslt } @@ -2942,14 +2943,14 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { /*. add, shift, bit . sub, rel, logic . mult, eq, */ - /*other*/ [f, f, f, f, t, t, f, f], - /*bool*/ [f, f, f, f, t, t, t, t], - /*int*/ [t, t, t, t, t, t, t, f], - /*float*/ [t, t, t, f, t, t, f, f], - /*str*/ [t, f, f, f, t, t, f, f], - /*vec*/ [t, f, f, f, t, t, f, f], - /*bot*/ [f, f, f, f, t, t, f, f], - /*struct*/ [t, t, t, t, t, t, t, t]]; + /*other*/ [f, f, f, f, t, t, f, f]/~, + /*bool*/ [f, f, f, f, t, t, t, t]/~, + /*int*/ [t, t, t, t, t, t, t, f]/~, + /*float*/ [t, t, t, f, t, t, f, f]/~, + /*str*/ [t, f, f, f, t, t, f, f]/~, + /*vec*/ [t, f, f, f, t, t, f, f]/~, + /*bot*/ [f, f, f, f, t, t, f, f]/~, + /*struct*/ [t, t, t, t, t, t, t, t]/~]/~; ret tbl[tycat(ty)][opcat(op)]; } @@ -2972,7 +2973,7 @@ fn ast_constr_to_constr<T>(tcx: ctxt, c: @ast::constr_general<T>) -> } } -fn ty_params_to_tys(tcx: ty::ctxt, tps: [ast::ty_param]) -> [t] { +fn ty_params_to_tys(tcx: ty::ctxt, tps: [ast::ty_param]/~) -> [t]/~ { vec::from_fn(tps.len(), {|i| ty::mk_param(tcx, i, ast_util::local_def(tps[i].id)) }) diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index ad1a613e739..95f4e6c0c95 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -120,7 +120,7 @@ type method_map_entry = { type method_map = hashmap<ast::node_id, method_map_entry>; // Resolutions for bounds of all parameters, left to right, for a given path. -type vtable_res = @[vtable_origin]; +type vtable_res = @[vtable_origin]/~; enum vtable_origin { /* @@ -128,7 +128,7 @@ enum vtable_origin { from whence comes the vtable, and tys are the type substs. vtable_res is the vtable itself */ - vtable_static(ast::def_id, [ty::t], vtable_res), + vtable_static(ast::def_id, [ty::t]/~, vtable_res), /* Dynamic vtable, comes from a parameter that has a bound on it: fn foo<T: quux, baz, bar>(a: T) -- a's vtable would have a @@ -142,7 +142,7 @@ enum vtable_origin { Dynamic vtable, comes from something known to have an interface type. def_id refers to the iface item, tys are the substs */ - vtable_iface(ast::def_id, [ty::t]), + vtable_iface(ast::def_id, [ty::t]/~), } type vtable_map = hashmap<ast::node_id, vtable_res>; @@ -163,7 +163,7 @@ fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) { } fn write_substs_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, - +substs: [ty::t]) { + +substs: [ty::t]/~) { if substs.len() > 0u { tcx.node_type_substs.insert(node_id, substs); } @@ -183,7 +183,7 @@ fn lookup_def_ccx(ccx: @crate_ctxt, sp: span, id: ast::node_id) -> ast::def { } fn no_params(t: ty::t) -> ty::ty_param_bounds_and_ty { - {bounds: @[], rp: ast::rp_none, ty: t} + {bounds: @[]/~, rp: ast::rp_none, ty: t} } fn require_same_types( @@ -259,7 +259,8 @@ fn check_main_fn_ty(ccx: @crate_ctxt, if !ok { tcx.sess.span_err(main_span, #fmt("Wrong type in main function: found `%s`, \ - expecting `native fn([str]) -> ()` or `native fn() -> ()`", + expecting `native fn([str]/~) -> ()` \ + or `native fn() -> ()`", ty_to_str(tcx, main_t))); } } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index c40b86d0530..101f3f6e44f 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -337,9 +337,9 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( "implied fixed length for bound"); } ast::ty_constr(t, cs) { - let mut out_cs = []; + let mut out_cs = []/~; for cs.each {|constr| - out_cs += [ty::ast_constr_to_constr(tcx, constr)]; + out_cs += [ty::ast_constr_to_constr(tcx, constr)]/~; } ty::mk_constr(tcx, ast_ty_to_ty(self, rscope, t), out_cs) } @@ -402,7 +402,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope copy>( {mode: mode, ty: ty} } -type expected_tys = option<{inputs: [ty::arg], +type expected_tys = option<{inputs: [ty::arg]/~, output: ty::t}>; fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy>( diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 5ba7c88d3cd..3ddbc505a28 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -89,7 +89,7 @@ type fn_ctxt = infcx: infer::infer_ctxt, locals: hashmap<ast::node_id, tv_vid>, - mut blocks: [ast::node_id], // stack of blocks in scope, may be empty + mut blocks: [ast::node_id]/~, // stack of blocks in scope, may be empty in_scope_regions: isr_alist, node_types: smallintmap::smallintmap<ty::t>, @@ -107,7 +107,7 @@ fn blank_fn_ctxt(ccx: @crate_ctxt, rty: ty::t) -> @fn_ctxt { purity: ast::pure_fn, infcx: infer::new_infer_ctxt(ccx.tcx), locals: int_hash(), - mut blocks: [], + mut blocks: []/~, in_scope_regions: @nil, node_types: smallintmap::mk(), node_type_substs: map::int_hash(), @@ -217,7 +217,7 @@ fn check_fn(ccx: @crate_ctxt, purity: purity, infcx: infcx, locals: locals, - mut blocks: [], + mut blocks: []/~, in_scope_regions: isr, node_types: node_types, node_type_substs: node_type_substs, @@ -257,7 +257,7 @@ fn check_fn(ccx: @crate_ctxt, fn gather_locals(fcx: @fn_ctxt, decl: ast::fn_decl, body: ast::blk, - arg_tys: [ty::t]) { + arg_tys: [ty::t]/~) { let tcx = fcx.ccx.tcx; let assign = fn@(nid: ast::node_id, ty_opt: option<ty::t>) { @@ -565,7 +565,7 @@ impl methods for @fn_ctxt { fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { let mut t1 = t; - let mut enum_dids = []; + let mut enum_dids = []/~; loop { let sty = structure_of(fcx, sp, t1); @@ -639,9 +639,10 @@ fn check_expr(fcx: @fn_ctxt, expr: @ast::expr, }; } -// determine the `self` type, using fresh variables for all variables declared -// on the impl declaration e.g., `impl<A,B> for [(A,B)]` would return ($0, $1) -// where $0 and $1 are freshly instantiated type variables. +// determine the `self` type, using fresh variables for all variables +// declared on the impl declaration e.g., `impl<A,B> for [(A,B)]/~` +// would return ($0, $1) where $0 and $1 are freshly instantiated type +// variables. fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty { let tcx = fcx.ccx.tcx; @@ -692,7 +693,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty { // Only for fields! Returns <none> for methods> // Indifferent to privacy flags fn lookup_field_ty(tcx: ty::ctxt, class_id: ast::def_id, - items:[ty::field_ty], fieldname: ast::ident, + items:[ty::field_ty]/~, fieldname: ast::ident, substs: ty::substs) -> option<ty::t> { let o_field = vec::find(items, {|f| f.ident == fieldname}); @@ -713,7 +714,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // expressions. fn check_call_or_bind( fcx: @fn_ctxt, sp: span, call_expr_id: ast::node_id, in_fty: ty::t, - args: [option<@ast::expr>]) -> {fty: ty::t, bot: bool} { + args: [option<@ast::expr>]/~) -> {fty: ty::t, bot: bool} { let mut bot = false; @@ -780,7 +781,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // functions. This is so that we have more information about the types // of arguments when we typecheck the functions. This isn't really the // right way to do this. - for [false, true].each { |check_blocks| + for [false, true]/~.each { |check_blocks| for args.eachi {|i, a_opt| alt a_opt { some(a) { @@ -816,7 +817,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // A generic function for doing all of the checking for call expressions fn check_call(fcx: @fn_ctxt, sp: span, call_expr_id: ast::node_id, - f: @ast::expr, args: [@ast::expr]) -> bool { + f: @ast::expr, args: [@ast::expr]/~) -> bool { let mut bot = check_expr(fcx, f, none); let fn_ty = fcx.expr_ty(f); @@ -889,11 +890,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr, self_ex: @ast::expr, self_t: ty::t, - opname: str, args: [option<@ast::expr>]) + opname: str, args: [option<@ast::expr>]/~) -> option<(ty::t, bool)> { let callee_id = ast_util::op_expr_callee_id(op_ex); let lkup = method::lookup(fcx, op_ex, self_ex, op_ex.id, - callee_id, @opname, self_t, [], false); + callee_id, @opname, self_t, []/~, false); alt lkup.method() { some(origin) { let {fty: method_ty, bot: bot} = { @@ -964,7 +965,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, some(name) { alt lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t, - name, [some(rhs)]) { + name, [some(rhs)]/~) { some(pair) { ret pair; } _ {} } @@ -982,7 +983,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn check_user_unop(fcx: @fn_ctxt, op_str: str, mname: str, ex: @ast::expr, rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t { - alt lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, []) { + alt lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, []/~) { some((ret_ty, _)) { ret_ty } _ { fcx.ccx.tcx.sess.span_err( @@ -1415,7 +1416,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fcx.write_ty(id, typ); } ast::expr_tup(elts) { - let mut elt_ts = []; + let mut elt_ts = []/~; vec::reserve(elt_ts, vec::len(elts)); let flds = unpack_expected(fcx, expected) {|sty| alt sty { ty::ty_tup(flds) { some(flds) } _ { none } } @@ -1423,7 +1424,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, for elts.eachi {|i, e| check_expr(fcx, e, flds.map {|fs| fs[i]}); let ety = fcx.expr_ty(e); - elt_ts += [ety]; + elt_ts += [ety]/~; } let typ = ty::mk_tup(tcx, elt_ts); fcx.write_ty(id, typ); @@ -1574,7 +1575,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let resolved = structurally_resolved_type(fcx, expr.span, raw_base_t); alt lookup_op_method(fcx, expr, base, resolved, "[]", - [some(idx)]) { + [some(idx)]/~) { some((ret_ty, _)) { fcx.write_ty(id, ret_ty); } _ { tcx.sess.span_fatal( @@ -1592,7 +1593,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let p_ty = fcx.expr_ty(p); let lkup = method::lookup(fcx, p, p, expr.id, alloc_id, - @"alloc", p_ty, [], false); + @"alloc", p_ty, []/~, false); alt lkup.method() { some(entry) { fcx.ccx.method_map.insert(alloc_id, entry); @@ -1607,10 +1608,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty::mk_fn(tcx, {purity: ast::impure_fn, proto: ast::proto_any, inputs: [{mode: m, ty: ty_uint}, - {mode: m, ty: ty_uint}], + {mode: m, ty: ty_uint}]/~, output: ty_nilp, ret_style: ast::return_val, - constraints: []}) + constraints: []/~}) }; demand::suptype(fcx, expr.span, @@ -1791,13 +1792,13 @@ fn check_instantiable(tcx: ty::ctxt, fn check_enum_variants(ccx: @crate_ctxt, sp: span, - vs: [ast::variant], + vs: [ast::variant]/~, id: ast::node_id) { let rty = ty::node_id_to_type(ccx.tcx, id); let fcx = blank_fn_ctxt(ccx, rty); - let mut disr_vals: [int] = []; + let mut disr_vals: [int]/~ = []/~; let mut disr_val = 0; - let mut variants = []; + let mut variants = []/~; for vs.each {|v| alt v.node.disr_expr { some(e) { @@ -1825,14 +1826,14 @@ fn check_enum_variants(ccx: @crate_ctxt, ccx.tcx.sess.span_err(v.span, "discriminator value already exists"); } - disr_vals += [disr_val]; + disr_vals += [disr_val]/~; let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id); let arg_tys = if v.node.args.len() > 0u { ty::ty_fn_args(ctor_ty).map {|a| a.ty } - } else { [] }; + } else { []/~ }; variants += [@{args: arg_tys, ctor_ty: ctor_ty, name: v.node.name, id: local_def(v.node.id), - disr_val: disr_val}]; + disr_val: disr_val}]/~; disr_val += 1; } @@ -1906,10 +1907,11 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { ret bot; } -fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr], args: [ast::arg]) { +fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr]/~, + args: [ast::arg]/~) { let num_args = vec::len(args); for cs.each {|c| - let mut c_args = []; + let mut c_args = []/~; for c.node.args.each {|a| c_args += [ // "base" should not occur in a fn type thing, as of @@ -1935,8 +1937,8 @@ fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr], args: [ast::arg]) { ast::carg_ident(i) { if i < num_args { let p = @{span: a.span, global: false, - idents: [args[i].ident], - rp: none, types: []}; + idents: [args[i].ident]/~, + rp: none, types: []/~}; let arg_occ_node_id = fcx.ccx.tcx.sess.next_node_id(); fcx.ccx.tcx.def_map.insert @@ -1951,7 +1953,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr], args: [ast::arg]) { carg_ident index out of bounds"); } } - }]; + }]/~; } let p_op: ast::expr_ = ast::expr_path(c.node.path); let oper: @ast::expr = @{id: c.node.id, node: p_op, span: c.span}; @@ -2017,7 +2019,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ast::def_fn(id, ast::crust_fn) { // Crust functions are just u8 pointers ret { - bounds: @[], + bounds: @[]/~, rp: ast::rp_none, ty: ty::mk_ptr( fcx.ccx.tcx, @@ -2167,7 +2169,7 @@ fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, fn check_bounds_are_used(ccx: @crate_ctxt, span: span, - tps: [ast::ty_param], + tps: [ast::ty_param]/~, rp: ast::region_param, ty: ty::t) { let mut r_used = alt rp { @@ -2218,26 +2220,26 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) { let tcx = ccx.tcx; let (n_tps, inputs, output) = alt *it.ident { "size_of" | - "pref_align_of" | "min_align_of" { (1u, [], ty::mk_uint(ccx.tcx)) } - "get_tydesc" { (1u, [], ty::mk_nil_ptr(tcx)) } - "init" { (1u, [], param(ccx, 0u)) } - "forget" { (1u, [arg(ast::by_move, param(ccx, 0u))], + "pref_align_of" | "min_align_of" { (1u, []/~, ty::mk_uint(ccx.tcx)) } + "get_tydesc" { (1u, []/~, ty::mk_nil_ptr(tcx)) } + "init" { (1u, []/~, param(ccx, 0u)) } + "forget" { (1u, [arg(ast::by_move, param(ccx, 0u))]/~, ty::mk_nil(tcx)) } - "reinterpret_cast" { (2u, [arg(ast::by_ref, param(ccx, 0u))], + "reinterpret_cast" { (2u, [arg(ast::by_ref, param(ccx, 0u))]/~, param(ccx, 1u)) } - "addr_of" { (1u, [arg(ast::by_ref, param(ccx, 0u))], + "addr_of" { (1u, [arg(ast::by_ref, param(ccx, 0u))]/~, ty::mk_imm_ptr(tcx, param(ccx, 0u))) } "move_val" | "move_val_init" { (1u, [arg(ast::by_mutbl_ref, param(ccx, 0u)), - arg(ast::by_move, param(ccx, 0u))], + arg(ast::by_move, param(ccx, 0u))]/~, ty::mk_nil(tcx)) } - "needs_drop" { (1u, [], ty::mk_bool(tcx)) } + "needs_drop" { (1u, []/~, ty::mk_bool(tcx)) } "visit_ty" { assert ccx.tcx.intrinsic_ifaces.contains_key(@"ty_visitor"); let (_, visitor_iface) = ccx.tcx.intrinsic_ifaces.get(@"ty_visitor"); - (1u, [arg(ast::by_ref, visitor_iface)], ty::mk_nil(tcx)) + (1u, [arg(ast::by_ref, visitor_iface)]/~, ty::mk_nil(tcx)) } "frame_address" { let fty = ty::mk_fn(ccx.tcx, { @@ -2248,12 +2250,12 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) { ty: ty::mk_imm_ptr( ccx.tcx, ty::mk_mach_uint(ccx.tcx, ast::ty_u8)) - }], + }]/~, output: ty::mk_nil(ccx.tcx), ret_style: ast::return_val, - constraints: [] + constraints: []/~ }); - (0u, [arg(ast::by_ref, fty)], ty::mk_nil(tcx)) + (0u, [arg(ast::by_ref, fty)]/~, ty::mk_nil(tcx)) } other { tcx.sess.span_err(it.span, "unrecognized intrinsic function: `" + @@ -2265,7 +2267,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) { proto: ast::proto_bare, inputs: inputs, output: output, ret_style: ast::return_val, - constraints: []}); + constraints: []/~}); let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id)); let i_n_tps = (*i_ty.bounds).len(); if i_n_tps != n_tps { diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index 7a1eca4fc25..9aa4d37fd77 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -4,7 +4,7 @@ import middle::typeck::infer::methods; // next_ty_var, fn check_alt(fcx: @fn_ctxt, expr: @ast::expr, discrim: @ast::expr, - arms: [ast::arm]) -> bool { + arms: [ast::arm]/~) -> bool { let tcx = fcx.ccx.tcx; let mut bot; @@ -52,7 +52,7 @@ type pat_ctxt = { }; fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, - subpats: option<[@ast::pat]>, expected: ty::t) { + subpats: option<[@ast::pat]/~>, expected: ty::t) { // Typecheck the path. let fcx = pcx.fcx; @@ -170,7 +170,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } } ast::pat_ident(path, c) { - check_pat_variant(pcx, pat, path, some([]), expected); + check_pat_variant(pcx, pat, path, some([]/~), expected); } ast::pat_enum(path, subpats) { check_pat_variant(pcx, pat, path, subpats, expected); diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 1c2d1234118..b54be2fadf1 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -23,7 +23,7 @@ class lookup { let mut self_ty: ty::t; let mut derefs: uint; let candidates: dvec<candidate>; - let supplied_tps: [ty::t]; + let supplied_tps: [ty::t]/~; let include_private: bool; new(fcx: @fn_ctxt, @@ -33,7 +33,7 @@ class lookup { node_id: ast::node_id, //node id where to store type of fn m_name: ast::ident, //b in a.b(...) self_ty: ty::t, //type of a in a.b(...) - supplied_tps: [ty::t], //Xs in a.b::<Xs>(...) + supplied_tps: [ty::t]/~, //Xs in a.b::<Xs>(...) include_private: bool) { self.fcx = fcx; diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index 5d9572e029d..7eebe1a31ca 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -12,7 +12,7 @@ fn replace_bound_regions_in_fn_ty( fn_ty: ty::fn_ty} { let mut all_tys = ty::tys_in_fn_ty(fn_ty); - for self_ty.each { |t| all_tys += [t] } + for self_ty.each { |t| all_tys += [t]/~ } #debug["replace_bound_regions_in_fn_ty(self_ty=%?, fn_ty=%s, all_tys=%?)", self_ty.map { |t| ty_to_str(tcx, t) }, @@ -50,7 +50,7 @@ fn replace_bound_regions_in_fn_ty( fn create_bound_region_mapping( tcx: ty::ctxt, isr: isr_alist, - tys: [ty::t], + tys: [ty::t]/~, to_r: fn(ty::bound_region) -> ty::region) -> isr_alist { // Takes `isr` (described above), `to_r` (described above), diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index d772f6861de..e86773bf76a 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -1,6 +1,6 @@ import check::{fn_ctxt, impl_self_ty, methods}; -fn has_iface_bounds(tps: [ty::param_bounds]) -> bool { +fn has_iface_bounds(tps: [ty::param_bounds]/~) -> bool { vec::any(tps, {|bs| vec::any(*bs, {|b| alt b { ty::bound_iface(_) { true } _ { false } } @@ -9,17 +9,17 @@ fn has_iface_bounds(tps: [ty::param_bounds]) -> bool { } fn lookup_vtables(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, - bounds: @[ty::param_bounds], substs: ty::substs, + bounds: @[ty::param_bounds]/~, substs: ty::substs, allow_unsafe: bool) -> vtable_res { let tcx = fcx.ccx.tcx; - let mut result = [], i = 0u; + let mut result = []/~, i = 0u; for substs.tps.each {|ty| for vec::each(*bounds[i]) {|bound| alt bound { ty::bound_iface(i_ty) { let i_ty = ty::subst(tcx, substs, i_ty); result += [lookup_vtable(fcx, isc, sp, ty, i_ty, - allow_unsafe)]; + allow_unsafe)]/~; } _ {} } @@ -105,7 +105,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, } _ { - let mut found = []; + let mut found = []/~; for list::each(isc) {|impls| /* For each impl in scope... */ @@ -144,7 +144,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, iface_tps, im.did); let subres = lookup_vtables(fcx, isc, sp, im_bs, substs_f, false); - found += [vtable_static(im.did, substs_f.tps, subres)]; + found += [vtable_static(im.did, substs_f.tps, subres)]/~; } alt found.len() { @@ -180,8 +180,8 @@ fn fixup_ty(fcx: @fn_ctxt, sp: span, ty: ty::t) -> ty::t { } } -fn connect_iface_tps(fcx: @fn_ctxt, sp: span, impl_tys: [ty::t], - iface_tys: [ty::t], impl_did: ast::def_id) { +fn connect_iface_tps(fcx: @fn_ctxt, sp: span, impl_tys: [ty::t]/~, + iface_tys: [ty::t]/~, impl_did: ast::def_id) { let tcx = fcx.ccx.tcx; let ity = option::get(ty::impl_iface(tcx, impl_did)); let iface_ty = ty::subst_tps(tcx, impl_tys, ity); @@ -251,7 +251,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { Map this expression to that vtable (that is: "ex has vtable <vtable>") */ - cx.vtable_map.insert(ex.id, @[vtable]); + cx.vtable_map.insert(ex.id, @[vtable]/~); } _ {} } diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index 9e4f3e58ae5..b0059fab251 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -40,10 +40,10 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) write_ty_to_tcx(tcx, id, t); alt fcx.opt_node_ty_substs(id) { some(substs) { - let mut new_tps = []; + let mut new_tps = []/~; for substs.tps.each {|subst| alt resolve_type_vars_in_type(fcx, sp, subst) { - some(t) { new_tps += [t]; } + some(t) { new_tps += [t]/~; } none { wbcx.success = false; ret none; } } } diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index ea04fd96b27..fdf455e398a 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -37,7 +37,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { ast::item_iface(_, _, _) { let def_id = { crate: ast::local_crate, node: intrinsic_item.id }; - let substs = {self_r: none, self_ty: none, tps: []}; + let substs = {self_r: none, self_ty: none, tps: []/~}; let ty = ty::mk_iface(ccx.tcx, def_id, substs); ccx.tcx.intrinsic_ifaces.insert (intrinsic_item.ident, (def_id, ty)); @@ -96,8 +96,8 @@ impl of ast_conv for @crate_ctxt { fn get_enum_variant_types(ccx: @crate_ctxt, enum_ty: ty::t, - variants: [ast::variant], - ty_params: [ast::ty_param], + variants: [ast::variant]/~, + ty_params: [ast::ty_param]/~, rp: ast::region_param) { let tcx = ccx.tcx; @@ -118,7 +118,7 @@ fn get_enum_variant_types(ccx: @crate_ctxt, inputs: args, output: enum_ty, ret_style: ast::return_val, - constraints: []}) + constraints: []/~}) }; let tpt = {bounds: ty_param_bounds(ccx, ty_params), rp: rp, @@ -130,7 +130,7 @@ fn get_enum_variant_types(ccx: @crate_ctxt, fn ensure_iface_methods(ccx: @crate_ctxt, id: ast::node_id) { fn store_methods<T>(ccx: @crate_ctxt, id: ast::node_id, - stuff: [T], f: fn@(T) -> ty::method) { + stuff: [T]/~, f: fn@(T) -> ty::method) { ty::store_iface_methods(ccx.tcx, id, @vec::map(stuff, f)); } @@ -224,11 +224,11 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, } fn check_methods_against_iface(ccx: @crate_ctxt, - tps: [ast::ty_param], + tps: [ast::ty_param]/~, rp: ast::region_param, selfty: ty::t, a_ifacety: @ast::iface_ref, - ms: [converted_method]) { + ms: [converted_method]/~) { let tcx = ccx.tcx; let (did, tpt) = instantiate_iface_ref(ccx, a_ifacety, rp); @@ -259,7 +259,7 @@ fn check_methods_against_iface(ccx: @crate_ctxt, fn convert_class_item(ccx: @crate_ctxt, rp: ast::region_param, - bounds: @[ty::param_bounds], + bounds: @[ty::param_bounds]/~, v: ast_util::ivar) { let tt = ccx.to_ty(type_rscope(rp), v.ty); write_ty_to_tcx(ccx.tcx, v.id, tt); @@ -270,10 +270,10 @@ fn convert_class_item(ccx: @crate_ctxt, type converted_method = {mty: ty::method, id: ast::node_id, span: span}; fn convert_methods(ccx: @crate_ctxt, - ms: [@ast::method], + ms: [@ast::method]/~, rp: ast::region_param, - rcvr_bounds: @[ty::param_bounds], - self_ty: ty::t) -> [converted_method] { + rcvr_bounds: @[ty::param_bounds]/~, + self_ty: ty::t) -> [converted_method]/~ { let tcx = ccx.tcx; vec::map(ms) { |m| @@ -344,7 +344,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { inputs: t_args, output: t_res, ret_style: ast::return_val, - constraints: []}); // tjc TODO + constraints: []/~}); // tjc TODO write_ty_to_tcx(tcx, ctor.node.id, t_ctor); tcx.tcache.insert(local_def(ctor.node.id), {bounds: tpt.bounds, @@ -549,26 +549,26 @@ fn ty_of_native_item(ccx: @crate_ctxt, it: @ast::native_item) } } fn ty_param_bounds(ccx: @crate_ctxt, - params: [ast::ty_param]) -> @[ty::param_bounds] { + params: [ast::ty_param]/~) -> @[ty::param_bounds]/~ { fn compute_bounds(ccx: @crate_ctxt, param: ast::ty_param) -> ty::param_bounds { @vec::flat_map(*param.bounds) { |b| alt b { - ast::bound_send { [ty::bound_send] } - ast::bound_copy { [ty::bound_copy] } - ast::bound_const { [ty::bound_const] } + ast::bound_send { [ty::bound_send]/~ } + ast::bound_copy { [ty::bound_copy]/~ } + ast::bound_const { [ty::bound_const]/~ } ast::bound_iface(t) { let ity = ast_ty_to_ty(ccx, empty_rscope, t); alt ty::get(ity).struct { ty::ty_iface(*) { - [ty::bound_iface(ity)] + [ty::bound_iface(ity)]/~ } _ { ccx.tcx.sess.span_err( t.span, "type parameter bounds must be \ interface types"); - [] + []/~ } } } @@ -590,7 +590,7 @@ fn ty_param_bounds(ccx: @crate_ctxt, fn ty_of_native_fn_decl(ccx: @crate_ctxt, decl: ast::fn_decl, - ty_params: [ast::ty_param], + ty_params: [ast::ty_param]/~, def_id: ast::def_id) -> ty::ty_param_bounds_and_ty { let bounds = ty_param_bounds(ccx, ty_params); @@ -603,14 +603,14 @@ fn ty_of_native_fn_decl(ccx: @crate_ctxt, inputs: input_tys, output: output_ty, ret_style: ast::return_val, - constraints: []}); + constraints: []/~}); let tpt = {bounds: bounds, rp: ast::rp_none, ty: t_fn}; ccx.tcx.tcache.insert(def_id, tpt); ret tpt; } -fn mk_ty_params(ccx: @crate_ctxt, atps: [ast::ty_param]) - -> {bounds: @[ty::param_bounds], params: [ty::t]} { +fn mk_ty_params(ccx: @crate_ctxt, atps: [ast::ty_param]/~) + -> {bounds: @[ty::param_bounds]/~, params: [ty::t]/~} { let mut i = 0u; let bounds = ty_param_bounds(ccx, atps); @@ -622,8 +622,8 @@ fn mk_ty_params(ccx: @crate_ctxt, atps: [ast::ty_param]) })} } -fn mk_substs(ccx: @crate_ctxt, atps: [ast::ty_param], rp: ast::region_param) - -> {bounds: @[ty::param_bounds], substs: ty::substs} { +fn mk_substs(ccx: @crate_ctxt, atps: [ast::ty_param]/~, rp: ast::region_param) + -> {bounds: @[ty::param_bounds]/~, substs: ty::substs} { let {bounds, params} = mk_ty_params(ccx, atps); let self_r = alt rp { diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index 1225908abb8..4652ddc2747 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -293,7 +293,7 @@ enum var_value<V:copy, T:copy> { type vals_and_bindings<V:copy, T:copy> = { vals: smallintmap<var_value<V, T>>, - mut bindings: [(V, var_value<V, T>)] + mut bindings: [(V, var_value<V, T>)]/~ }; enum node<V:copy, T:copy> = { @@ -346,9 +346,9 @@ type fres<T> = result::result<T, fixup_err>; fn new_infer_ctxt(tcx: ty::ctxt) -> infer_ctxt { infer_ctxt(@{tcx: tcx, - tvb: {vals: smallintmap::mk(), mut bindings: []}, - tvib: {vals: smallintmap::mk(), mut bindings: []}, - rb: {vals: smallintmap::mk(), mut bindings: []}, + tvb: {vals: smallintmap::mk(), mut bindings: []/~}, + tvib: {vals: smallintmap::mk(), mut bindings: []/~}, + rb: {vals: smallintmap::mk(), mut bindings: []/~}, ty_var_counter: @mut 0u, ty_var_integral_counter: @mut 0u, region_var_counter: @mut 0u})} @@ -556,8 +556,8 @@ impl transaction_methods for infer_ctxt { // TODO---could use a vec::clear() that ran destructors but kept // the vec at its currently allocated length - self.tvb.bindings = []; - self.rb.bindings = []; + self.tvb.bindings = []/~; + self.rb.bindings = []/~; ret r; } @@ -604,7 +604,7 @@ impl methods for infer_ctxt { ty::mk_var(self.tcx, self.next_ty_var_id()) } - fn next_ty_vars(n: uint) -> [ty::t] { + fn next_ty_vars(n: uint) -> [ty::t]/~ { vec::from_fn(n) {|_i| self.next_ty_var() } } @@ -1041,7 +1041,7 @@ impl unify_methods for infer_ctxt { } fn constrvecs( - as: [@ty::type_constr], bs: [@ty::type_constr]) -> ures { + as: [@ty::type_constr]/~, bs: [@ty::type_constr]/~) -> ures { if check vec::same_length(as, bs) { iter_vec2(as, bs) {|a,b| @@ -1082,8 +1082,8 @@ impl unify_methods for infer_ctxt { // resolution. The first is a shallow resolution: this only resolves // one layer, but does not resolve any nested variables. So, for // example, if we have two variables A and B, and the constraint that -// A <: [B] and B <: int, then shallow resolution on A would yield -// [B]. Deep resolution, on the other hand, would yield [int]. +// A <: [B]/~ and B <: int, then shallow resolution on A would yield +// [B]/~. Deep resolution, on the other hand, would yield [int]/~. // // But there is one more knob: the `force_level` variable controls // the behavior in the face of unconstrained type and region @@ -1107,8 +1107,8 @@ type resolve_state = @{ deep: bool, force_vars: force_level, mut err: option<fixup_err>, - mut r_seen: [region_vid], - mut v_seen: [tv_vid] + mut r_seen: [region_vid]/~, + mut v_seen: [tv_vid]/~ }; fn resolver(infcx: infer_ctxt, deep: bool, fvars: force_level) @@ -1117,8 +1117,8 @@ fn resolver(infcx: infer_ctxt, deep: bool, fvars: force_level) deep: deep, force_vars: fvars, mut err: none, - mut r_seen: [], - mut v_seen: []} + mut r_seen: []/~, + mut v_seen: []/~} } impl methods for resolve_state { @@ -1308,14 +1308,14 @@ impl methods for resolve_state { // // Assuming we have a bound from both sides, we will then examine // these bounds and see if they have the form (@M_a T_a, &rb.M_b T_b) -// (resp. ~M_a T_a, [M_a T_a], etc). If they do not, we fall back to +// (resp. ~M_a T_a, [M_a T_a]/~, etc). If they do not, we fall back to // subtyping. // // If they *do*, then we know that the two types could never be // subtypes of one another. We will then construct a type @const T_b // and ensure that type a is a subtype of that. This allows for the -// possibility of assigning from a type like (say) @[mut T1] to a type -// &[T2] where T1 <: T2. This might seem surprising, since the `@` +// possibility of assigning from a type like (say) @[mut T1]/~ to a type +// &[T2]/~ where T1 <: T2. This might seem surprising, since the `@` // points at mutable memory but the `&` points at immutable memory. // This would in fact be unsound, except for the borrowck, which comes // later and guarantees that such mutability conversions are safe. @@ -1533,7 +1533,7 @@ iface combine { fn mts(a: ty::mt, b: ty::mt) -> cres<ty::mt>; fn contratys(a: ty::t, b: ty::t) -> cres<ty::t>; fn tys(a: ty::t, b: ty::t) -> cres<ty::t>; - fn tps(as: [ty::t], bs: [ty::t]) -> cres<[ty::t]>; + fn tps(as: [ty::t]/~, bs: [ty::t]/~) -> cres<[ty::t]/~>; fn self_tys(a: option<ty::t>, b: option<ty::t>) -> cres<option<ty::t>>; fn substs(as: ty::substs, bs: ty::substs) -> cres<ty::substs>; fn fns(a: ty::fn_ty, b: ty::fn_ty) -> cres<ty::fn_ty>; @@ -1592,7 +1592,7 @@ fn super_substs<C:combine>( } fn super_tps<C:combine>( - self: C, as: [ty::t], bs: [ty::t]) -> cres<[ty::t]> { + self: C, as: [ty::t]/~, bs: [ty::t]/~) -> cres<[ty::t]/~> { // Note: type parameters are always treated as *invariant* // (otherwise the type system would be unsound). In the @@ -1692,8 +1692,8 @@ fn super_vstores<C:combine>( fn super_fns<C:combine>( self: C, a_f: ty::fn_ty, b_f: ty::fn_ty) -> cres<ty::fn_ty> { - fn argvecs<C:combine>( - self: C, a_args: [ty::arg], b_args: [ty::arg]) -> cres<[ty::arg]> { + fn argvecs<C:combine>(self: C, a_args: [ty::arg]/~, + b_args: [ty::arg]/~) -> cres<[ty::arg]/~> { if check vec::same_length(a_args, b_args) { map_vec2(a_args, b_args) {|a, b| self.args(a, b) } @@ -2061,7 +2061,7 @@ impl of combine for sub { super_substs(self, as, bs) } - fn tps(as: [ty::t], bs: [ty::t]) -> cres<[ty::t]> { + fn tps(as: [ty::t]/~, bs: [ty::t]/~) -> cres<[ty::t]/~> { super_tps(self, as, bs) } @@ -2247,7 +2247,7 @@ impl of combine for lub { super_substs(self, as, bs) } - fn tps(as: [ty::t], bs: [ty::t]) -> cres<[ty::t]> { + fn tps(as: [ty::t]/~, bs: [ty::t]/~) -> cres<[ty::t]/~> { super_tps(self, as, bs) } @@ -2446,7 +2446,7 @@ impl of combine for glb { super_substs(self, as, bs) } - fn tps(as: [ty::t], bs: [ty::t]) -> cres<[ty::t]> { + fn tps(as: [ty::t]/~, bs: [ty::t]/~) -> cres<[ty::t]/~> { super_tps(self, as, bs) } diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 381b5ce6a82..74c57007880 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -29,9 +29,9 @@ type flag = hashmap<str, ()>; fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; } -fn field_exprs(fields: [ast::field]) -> [@ast::expr] { - let mut es = []; - for fields.each {|f| es += [f.node.expr]; } +fn field_exprs(fields: [ast::field]/~) -> [@ast::expr]/~ { + let mut es = []/~; + for fields.each {|f| es += [f.node.expr]/~; } ret es; } diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index f44d43d35ed..5d2098a2e5f 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -96,7 +96,7 @@ fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> str { } } -fn tys_to_str(cx: ctxt, ts: [t]) -> str { +fn tys_to_str(cx: ctxt, ts: [t]/~) -> str { let mut rs = ""; for ts.each {|t| rs += ty_to_str(cx, t); } rs @@ -121,8 +121,8 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { } fn fn_to_str(cx: ctxt, purity: ast::purity, proto: ast::proto, ident: option<ast::ident>, - inputs: [arg], output: t, cf: ast::ret_style, - constrs: [@constr]) -> str { + inputs: [arg]/~, output: t, cf: ast::ret_style, + constrs: [@constr]/~) -> str { let mut s; s = alt purity { @@ -132,8 +132,8 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { s += proto_to_str(proto); alt ident { some(i) { s += " "; s += *i; } _ { } } s += "("; - let mut strs = []; - for inputs.each {|a| strs += [fn_input_to_str(cx, a)]; } + let mut strs = []/~; + for inputs.each {|a| strs += [fn_input_to_str(cx, a)]/~; } s += str::connect(strs, ", "); s += ")"; if ty::get(output).struct != ty_nil { @@ -189,13 +189,13 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { ty_unboxed_vec(tm) { "unboxed_vec<" + mt_to_str(cx, tm) + ">" } ty_type { "type" } ty_rec(elems) { - let mut strs: [str] = []; - for elems.each {|fld| strs += [field_to_str(cx, fld)]; } + let mut strs: [str]/~ = []/~; + for elems.each {|fld| strs += [field_to_str(cx, fld)]/~; } "{" + str::connect(strs, ",") + "}" } ty_tup(elems) { - let mut strs = []; - for elems.each {|elem| strs += [ty_to_str(cx, elem)]; } + let mut strs = []/~; + for elems.each {|elem| strs += [ty_to_str(cx, elem)]/~; } "(" + str::connect(strs, ",") + ")" } ty_fn(f) { @@ -205,7 +205,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { ty_var(v) { v.to_str() } ty_var_integral(v) { v.to_str() } ty_param(id, _) { - "'" + str::from_bytes([('a' as u8) + (id as u8)]) + "'" + str::from_bytes([('a' as u8) + (id as u8)]/~) } ty_self { "self" } ty_enum(did, substs) | ty_class(did, substs) { @@ -234,7 +234,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { fn parameterized(cx: ctxt, base: str, self_r: option<ty::region>, - tps: [ty::t]) -> str { + tps: [ty::t]/~) -> str { let r_str = alt self_r { none { "" } @@ -262,7 +262,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 mut s = ""; let mut colon = true; for constrs.each {|c| |
