diff options
| author | Michael Sullivan <sully@msully.net> | 2012-07-13 22:57:48 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-07-14 01:03:43 -0700 |
| commit | 92743dc2a6a14d042d4b278e4a4dde5ca198c886 (patch) | |
| tree | 2626211c99906387257880f127f96fee66a0bb4e /src/rustc | |
| parent | 5c5065e8bdd1a7b28810fea4b940577ff17c112c (diff) | |
Move the world over to using the new style string literals and types. Closes #2907.
Diffstat (limited to 'src/rustc')
80 files changed, 2239 insertions, 2212 deletions
diff --git a/src/rustc/back/abi.rs b/src/rustc/back/abi.rs index d6c0c5fa2dd..8213ff1576e 100644 --- a/src/rustc/back/abi.rs +++ b/src/rustc/back/abi.rs @@ -66,13 +66,13 @@ const worst_case_glue_call_args: uint = 7u; const abi_version: uint = 1u; -fn memcpy_glue_name() -> str { ret "rust_memcpy_glue"; } +fn memcpy_glue_name() -> ~str { ret ~"rust_memcpy_glue"; } -fn bzero_glue_name() -> str { ret "rust_bzero_glue"; } +fn bzero_glue_name() -> ~str { ret ~"rust_bzero_glue"; } -fn yield_glue_name() -> str { ret "rust_yield_glue"; } +fn yield_glue_name() -> ~str { ret ~"rust_yield_glue"; } -fn no_op_type_glue_name() -> str { ret "rust_no_op_type_glue"; } +fn no_op_type_glue_name() -> ~str { ret ~"rust_no_op_type_glue"; } // // Local Variables: // mode: rust diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 089bde35734..22a9150df56 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -25,11 +25,11 @@ enum output_type { output_type_exe, } -fn llvm_err(sess: session, msg: str) -> ! unsafe { +fn llvm_err(sess: session, msg: ~str) -> ! unsafe { let cstr = llvm::LLVMRustGetLastError(); if cstr == ptr::null() { sess.fatal(msg); - } else { sess.fatal(msg + ": " + str::unsafe::from_c_str(cstr)); } + } else { sess.fatal(msg + ~": " + str::unsafe::from_c_str(cstr)); } } mod write { @@ -43,15 +43,16 @@ mod write { // Decides what to call an intermediate file, given the name of the output // and the extension to use. - fn mk_intermediate_name(output_path: str, extension: str) -> str unsafe { + fn mk_intermediate_name(output_path: ~str, extension: ~str) -> + ~str unsafe { let stem = alt str::find_char(output_path, '.') { some(dot_pos) { str::slice(output_path, 0u, dot_pos) } none { output_path } }; - ret stem + "." + extension; + ret stem + ~"." + extension; } - fn run_passes(sess: session, llmod: ModuleRef, output: str) { + fn run_passes(sess: session, llmod: ModuleRef, output: ~str) { let opts = sess.opts; if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); } let mut pm = mk_pass_manager(); @@ -68,14 +69,14 @@ mod write { alt opts.output_type { output_type_bitcode { if opts.optimize != 0u { - let filename = mk_intermediate_name(output, "no-opt.bc"); + let filename = mk_intermediate_name(output, ~"no-opt.bc"); str::as_c_str(filename, |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf) }); } } _ { - let filename = mk_intermediate_name(output, "bc"); + let filename = mk_intermediate_name(output, ~"bc"); str::as_c_str(filename, |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf) }); @@ -147,7 +148,7 @@ mod write { if opts.save_temps { // Always output the bitcode file with --save-temps - let filename = mk_intermediate_name(output, "opt.bc"); + let filename = mk_intermediate_name(output, ~"opt.bc"); llvm::LLVMRunPassManager(pm.llpm, llmod); str::as_c_str(filename, |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf) @@ -287,28 +288,28 @@ mod write { * */ -fn build_link_meta(sess: session, c: ast::crate, output: str, +fn build_link_meta(sess: session, c: ast::crate, output: ~str, sha: sha1) -> link_meta { type provided_metas = - {name: option<@str/~>, - vers: option<@str/~>, + {name: option<@~str>, + vers: option<@~str>, 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 name: option<@~str> = none; + let mut vers: option<@~str> = none; 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" { + if *attr::get_meta_item_name(meta) == ~"name" { alt attr::get_meta_item_value_str(meta) { some(v) { name = some(v); } none { vec::push(cmh_items, meta); } } - } else if *attr::get_meta_item_name(meta) == "vers" { + } else if *attr::get_meta_item_name(meta) == ~"vers" { alt attr::get_meta_item_value_str(meta) { some(v) { vers = some(v); } none { vec::push(cmh_items, meta); } @@ -321,12 +322,12 @@ 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 { - fn len_and_str(s: str) -> str { + dep_hashes: ~[@~str]) -> ~str { + fn len_and_str(s: ~str) -> ~str { ret #fmt["%u_%s", str::len(s), s]; } - fn len_and_str_lit(l: ast::lit) -> str { + fn len_and_str_lit(l: ast::lit) -> ~str { ret len_and_str(pprust::lit_to_str(@l)); } @@ -343,7 +344,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, ast::meta_word(name) { sha.input_str(len_and_str(*name)); } ast::meta_list(_, _) { // FIXME (#607): Implement this - fail "unimplemented meta_item variant"; + fail ~"unimplemented meta_item variant"; } } } @@ -355,14 +356,14 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, ret truncated_sha1_result(sha); } - fn warn_missing(sess: session, name: str, default: str) { + fn warn_missing(sess: session, name: ~str, default: ~str) { if !sess.building_library { ret; } sess.warn(#fmt["missing crate link meta `%s`, using `%s` as default", name, default]); } fn crate_meta_name(sess: session, _crate: ast::crate, - output: str, metas: provided_metas) -> @str/~ { + output: ~str, metas: provided_metas) -> @~str { ret alt metas.name { some(v) { v } none { @@ -375,21 +376,21 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, appear to have an extension", output)); } vec::pop(os); - str::connect(os, ".") + str::connect(os, ~".") }; - warn_missing(sess, "name", name); + warn_missing(sess, ~"name", name); @name } }; } fn crate_meta_vers(sess: session, _crate: ast::crate, - metas: provided_metas) -> @str/~ { + metas: provided_metas) -> @~str { ret alt metas.vers { some(v) { v } none { - let vers = "0.0"; - warn_missing(sess, "vers", vers); + let vers = ~"0.0"; + warn_missing(sess, ~"vers", vers); @vers } }; @@ -405,30 +406,30 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, ret {name: name, vers: vers, extras_hash: extras_hash}; } -fn truncated_sha1_result(sha: sha1) -> str unsafe { +fn truncated_sha1_result(sha: sha1) -> ~str unsafe { ret str::slice(sha.result_str(), 0u, 16u); } // This calculates STH for a symbol, as defined above fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, - link_meta: link_meta) -> str { + link_meta: link_meta) -> ~str { // NB: do *not* use abbrevs here as we want the symbol names // to be independent of one another in the crate. sha.reset(); sha.input_str(*link_meta.name); - sha.input_str("-"); + sha.input_str(~"-"); sha.input_str(link_meta.extras_hash); - sha.input_str("-"); + sha.input_str(~"-"); sha.input_str(encoder::encoded_ty(tcx, t)); let hash = truncated_sha1_result(sha); // Prefix with _ so that it never blends into adjacent digits - ret "_" + hash; + ret ~"_" + hash; } -fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str { +fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { alt ccx.type_sha1s.find(t) { some(h) { ret h; } none { @@ -442,17 +443,17 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str { // Name sanitation. LLVM will happily accept identifiers with weird names, but // gas doesn't! -fn sanitize(s: str) -> str { - let mut result = ""; +fn sanitize(s: ~str) -> ~str { + let mut result = ~""; do str::chars_iter(s) |c| { alt c { - '@' { result += "_sbox_"; } - '~' { result += "_ubox_"; } - '*' { result += "_ptr_"; } - '&' { result += "_ref_"; } - ',' { result += "_"; } + '@' { result += ~"_sbox_"; } + '~' { result += ~"_ubox_"; } + '*' { result += ~"_ptr_"; } + '&' { result += ~"_ref_"; } + ',' { result += ~"_"; } - '{' | '(' { result += "_of_"; } + '{' | '(' { result += ~"_of_"; } 'a' to 'z' | 'A' to 'Z' | '0' to '9' @@ -469,16 +470,16 @@ fn sanitize(s: str) -> str { if result.len() > 0u && result[0] != '_' as u8 && ! char::is_XID_start(result[0] as char) { - ret "_" + result; + ret ~"_" + result; } ret result; } -fn mangle(ss: path) -> str { +fn mangle(ss: path) -> ~str { // Follow C++ namespace-mangling style - let mut n = "_ZN"; // Begin name-sequence. + let mut n = ~"_ZN"; // Begin name-sequence. for ss.each |s| { alt s { path_name(s) | path_mod(s) { @@ -486,52 +487,52 @@ fn mangle(ss: path) -> str { n += #fmt["%u%s", str::len(sani), sani]; } } } - n += "E"; // End name-sequence. + n += ~"E"; // End name-sequence. n } -fn exported_name(path: path, hash: @str/~, vers: @str/~) -> str { +fn exported_name(path: path, hash: @~str, vers: @~str) -> ~str { ret mangle( vec::append_one(vec::append_one(path, path_name(hash)), path_name(vers))); } -fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str { +fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str { let hash = get_symbol_hash(ccx, t); ret exported_name(path, @hash, ccx.link_meta.vers); } fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, - t: ty::t, name: @str/~) -> - str { + t: ty::t, name: @~str) -> + ~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)]); } fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, - flav: @str/~) -> str { + flav: @~str) -> ~str { ret mangle(vec::append_one(path, path_name(@ccx.names(*flav)))); } -fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str { +fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> ~str { ret mangle(path); } -fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @str/~) -> str { +fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @~str) -> ~str { ret ccx.names(*flav); } // If the user wants an exe generated we need to invoke // cc to link the object file with some libs fn link_binary(sess: session, - obj_filename: str, - out_filename: str, + obj_filename: ~str, + out_filename: ~str, lm: link_meta) { // Converts a library file name into a cc -l argument - fn unlib(config: @session::config, filename: str) -> str unsafe { - let rmlib = fn@(filename: str) -> str { - let found = str::find_str(filename, "lib"); + fn unlib(config: @session::config, filename: ~str) -> ~str unsafe { + let rmlib = fn@(filename: ~str) -> ~str { + let found = str::find_str(filename, ~"lib"); if config.os == session::os_macos || (config.os == session::os_linux || config.os == session::os_freebsd) && @@ -539,10 +540,10 @@ fn link_binary(sess: session, ret str::slice(filename, 3u, str::len(filename)); } else { ret filename; } }; - fn rmext(filename: str) -> str { + fn rmext(filename: ~str) -> ~str { let mut parts = str::split_char(filename, '.'); vec::pop(parts); - ret str::connect(parts, "."); + ret str::connect(parts, ~"."); } ret alt config.os { session::os_macos { rmext(rmlib(filename)) } @@ -564,46 +565,46 @@ fn link_binary(sess: session, path::connect(path::dirname(out_filename), long_libname) } else { out_filename }; - log(debug, "output: " + output); + log(debug, ~"output: " + output); // The default library location, we need this to find the runtime. // The location of crates will be determined as needed. - let stage: str = "-L" + sess.filesearch.get_target_lib_path(); + let stage: ~str = ~"-L" + sess.filesearch.get_target_lib_path(); // In the future, FreeBSD will use clang as default compiler. // It would be flexible to use cc (system's default C compiler) // instead of hard-coded gcc. // For win32, there is no cc command, // so we add a condition to make it use gcc. - let cc_prog: str = - if sess.targ_cfg.os == session::os_win32 { "gcc" } else { "cc" }; + let cc_prog: ~str = + if sess.targ_cfg.os == session::os_win32 { ~"gcc" } else { ~"cc" }; // The invocations of cc share some flags across platforms let mut cc_args = vec::append(~[stage], sess.targ_cfg.target_strs.cc_args); - vec::push(cc_args, "-o"); + vec::push(cc_args, ~"-o"); vec::push(cc_args, output); vec::push(cc_args, obj_filename); let mut lib_cmd; let os = sess.targ_cfg.os; if os == session::os_macos { - lib_cmd = "-dynamiclib"; - } else { lib_cmd = "-shared"; } + lib_cmd = ~"-dynamiclib"; + } else { lib_cmd = ~"-shared"; } // # Crate linking let cstore = sess.cstore; for cstore::get_used_crate_files(cstore).each |cratepath| { - if str::ends_with(cratepath, ".rlib") { + if str::ends_with(cratepath, ~".rlib") { vec::push(cc_args, cratepath); again; } let cratepath = cratepath; let dir = path::dirname(cratepath); - if dir != "" { vec::push(cc_args, "-L" + dir); } + if dir != ~"" { vec::push(cc_args, ~"-L" + dir); } let libarg = unlib(sess.targ_cfg, path::basename(cratepath)); - vec::push(cc_args, "-l" + libarg); + vec::push(cc_args, ~"-l" + libarg); } let ula = cstore::get_used_link_args(cstore); @@ -618,11 +619,11 @@ 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| { vec::push(cc_args, "-L" + path); } + for addl_paths.each |path| { vec::push(cc_args, ~"-L" + path); } // The names of the extern libraries let used_libs = cstore::get_used_libraries(cstore); - for used_libs.each |l| { vec::push(cc_args, "-l" + l); } + for used_libs.each |l| { vec::push(cc_args, ~"-l" + l); } if sess.building_library { vec::push(cc_args, lib_cmd); @@ -630,35 +631,35 @@ fn link_binary(sess: session, // On mac we need to tell the linker to let this library // be rpathed if sess.targ_cfg.os == session::os_macos { - vec::push(cc_args, "-Wl,-install_name,@rpath/" + vec::push(cc_args, ~"-Wl,-install_name,@rpath/" + path::basename(output)); } } if !sess.debugging_opt(session::no_rt) { // Always want the runtime linked in - vec::push(cc_args, "-lrustrt"); + vec::push(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 { - vec::push_all(cc_args, ~["-lrt", "-ldl"]); + vec::push_all(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 - vec::push(cc_args, "-lm"); + vec::push(cc_args, ~"-lm"); } if sess.targ_cfg.os == session::os_freebsd { - vec::push_all(cc_args, ~["-pthread", "-lrt", - "-L/usr/local/lib", "-lexecinfo", - "-L/usr/local/lib/gcc46", - "-L/usr/local/lib/gcc44", "-lstdc++", - "-Wl,-z,origin", - "-Wl,-rpath,/usr/local/lib/gcc46", - "-Wl,-rpath,/usr/local/lib/gcc44"]); + vec::push_all(cc_args, ~[~"-pthread", ~"-lrt", + ~"-L/usr/local/lib", ~"-lexecinfo", + ~"-L/usr/local/lib/gcc46", + ~"-L/usr/local/lib/gcc44", ~"-lstdc++", + ~"-Wl,-z,origin", + ~"-Wl,-rpath,/usr/local/lib/gcc46", + ~"-Wl,-rpath,/usr/local/lib/gcc44"]); } // OS X 10.6 introduced 'compact unwind info', which is produced by the @@ -666,31 +667,31 @@ 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 { - vec::push(cc_args, "-Wl,-no_compact_unwind"); + vec::push(cc_args, ~"-Wl,-no_compact_unwind"); } // Stack growth requires statically linking a __morestack function - vec::push(cc_args, "-lmorestack"); + vec::push(cc_args, ~"-lmorestack"); // FIXME (#2397): At some point we want to rpath our guesses as to where // extern libraries might live, based on the addl_lib_search_paths vec::push_all(cc_args, rpath::get_rpath_flags(sess, output)); - #debug("%s link args: %s", cc_prog, str::connect(cc_args, " ")); + #debug("%s link args: %s", cc_prog, str::connect(cc_args, ~" ")); // We run 'cc' here let prog = run::program_output(cc_prog, cc_args); if 0 != prog.status { sess.err(#fmt["linking with `%s` failed with code %d", cc_prog, prog.status]); sess.note(#fmt["%s arguments: %s", - cc_prog, str::connect(cc_args, " ")]); + cc_prog, str::connect(cc_args, ~" ")]); sess.note(prog.err + prog.out); sess.abort_if_errors(); } // 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 f29dc26ed39..2e16d92cec8 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -13,7 +13,7 @@ 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 @@ -40,17 +40,17 @@ fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path { let mut path = vec::append(~[sess.filesearch.sysroot()], filesearch::relative_target_lib_path( sess.opts.target_triple)); - vec::push(path, os::dll_filename("rustrt")); + vec::push(path, 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] { + target_triple: ~str) -> ~[~str] { #debug("cwd: %s", cwd); #debug("sysroot: %s", sysroot); #debug("output: %s", output); @@ -72,16 +72,16 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, // And a final backup rpath to the global library location. 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); } } - log_rpaths("relative", rel_rpaths); - log_rpaths("absolute", abs_rpaths); - log_rpaths("fallback", fallback_rpaths); + log_rpaths(~"relative", rel_rpaths); + log_rpaths(~"absolute", abs_rpaths); + log_rpaths(~"fallback", fallback_rpaths); let mut rpaths = rel_rpaths; vec::push_all(rpaths, abs_rpaths); @@ -95,7 +95,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) @@ -105,12 +105,12 @@ fn get_rpaths_relative_to_output(os: session::os, fn get_rpath_relative_to_output(os: session::os, cwd: path::path, output: path::path, - &&lib: path::path) : not_win32(os) -> str { + &&lib: path::path) : not_win32(os) -> ~str { // Mac doesn't appear to support $ORIGIN let prefix = alt os { - session::os_linux { "$ORIGIN" + path::path_sep() } - session::os_freebsd { "$ORIGIN" + path::path_sep() } - session::os_macos { "@executable_path" + path::path_sep() } + session::os_linux { ~"$ORIGIN" + path::path_sep() } + session::os_freebsd { ~"$ORIGIN" + path::path_sep() } + session::os_macos { ~"@executable_path" + path::path_sep() } session::os_win32 { core::unreachable(); } }; @@ -142,7 +142,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { } let mut path = ~[]; - for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ".."); }; + for uint::range(start_idx, len1 - 1u) |_i| { vec::push(path, ~".."); }; // FIXME (#2880): use view here. vec::push_all(path, vec::slice(split2, start_idx, len2 - 1u)); @@ -150,15 +150,15 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { if check vec::is_not_empty(path) { ret path::connect_many(path); } else { - ret "."; + ret ~"."; } } -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) ) } -fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> str { +fn get_absolute_rpath(cwd: path::path, &&lib: path::path) -> ~str { path::dirname(get_absolute(cwd, lib)) } @@ -170,11 +170,11 @@ fn get_absolute(cwd: path::path, lib: path::path) -> path::path { } } -fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str { +fn get_install_prefix_rpath(cwd: path::path, target_triple: ~str) -> ~str { let install_prefix = #env("CFG_PREFIX"); - if install_prefix == "" { - fail "rustc compiled without CFG_PREFIX environment variable"; + if install_prefix == ~"" { + fail ~"rustc compiled without CFG_PREFIX environment variable"; } let path = vec::append( @@ -183,7 +183,7 @@ fn get_install_prefix_rpath(cwd: path::path, target_triple: str) -> str { 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 = ~[]; for rpaths.each |rpath| { @@ -199,116 +199,116 @@ 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] fn test_get_absolute1() { - let cwd = "/dir"; - let lib = "some/path/lib"; + let cwd = ~"/dir"; + let lib = ~"some/path/lib"; let res = get_absolute(cwd, lib); - assert res == "/dir/some/path/lib"; + assert res == ~"/dir/some/path/lib"; } #[test] fn test_get_absolute2() { - let cwd = "/dir"; - let lib = "/some/path/lib"; + let cwd = ~"/dir"; + let lib = ~"/some/path/lib"; let res = get_absolute(cwd, lib); - assert res == "/some/path/lib"; + assert res == ~"/some/path/lib"; } #[test] fn test_prefix_rpath() { - let res = get_install_prefix_rpath("/usr/lib", "triple"); - let d = path::connect(#env("CFG_PREFIX"), "/lib/rustc/triple/lib"); + let res = get_install_prefix_rpath(~"/usr/lib", ~"triple"); + let d = path::connect(#env("CFG_PREFIX"), ~"/lib/rustc/triple/lib"); assert str::ends_with(res, d); } #[test] fn test_prefix_rpath_abs() { - let res = get_install_prefix_rpath("/usr/lib", "triple"); + let res = get_install_prefix_rpath(~"/usr/lib", ~"triple"); assert path::path_is_absolute(res); } #[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"]; + let res = minimize_rpaths(~[~"1a", ~"2", ~"2", ~"1a", ~"4a", + ~"1a", ~"2", ~"3", ~"4a", ~"3"]); + assert res == ~[~"1a", ~"2", ~"4a", ~"3"]; } #[test] fn test_relative_to1() { - let p1 = "/usr/bin/rustc"; - let p2 = "/usr/lib/mylib"; + let p1 = ~"/usr/bin/rustc"; + let p2 = ~"/usr/lib/mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib"; + assert res == ~"../lib"; } #[test] fn test_relative_to2() { - let p1 = "/usr/bin/rustc"; - let p2 = "/usr/bin/../lib/mylib"; + let p1 = ~"/usr/bin/rustc"; + let p2 = ~"/usr/bin/../lib/mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib"; + assert res == ~"../lib"; } #[test] fn test_relative_to3() { - let p1 = "/usr/bin/whatever/rustc"; - let p2 = "/usr/lib/whatever/mylib"; + let p1 = ~"/usr/bin/whatever/rustc"; + let p2 = ~"/usr/lib/whatever/mylib"; let res = get_relative_to(p1, p2); - assert res == "../../lib/whatever"; + assert res == ~"../../lib/whatever"; } #[test] fn test_relative_to4() { - let p1 = "/usr/bin/whatever/../rustc"; - let p2 = "/usr/lib/whatever/mylib"; + let p1 = ~"/usr/bin/whatever/../rustc"; + let p2 = ~"/usr/lib/whatever/mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib/whatever"; + assert res == ~"../lib/whatever"; } #[test] fn test_relative_to5() { - let p1 = "/usr/bin/whatever/../rustc"; - let p2 = "/usr/lib/whatever/../mylib"; + let p1 = ~"/usr/bin/whatever/../rustc"; + let p2 = ~"/usr/lib/whatever/../mylib"; let res = get_relative_to(p1, p2); - assert res == "../lib"; + assert res == ~"../lib"; } #[test] fn test_relative_to6() { - let p1 = "/1"; - let p2 = "/2/3"; + let p1 = ~"/1"; + let p2 = ~"/2/3"; let res = get_relative_to(p1, p2); - assert res == "2"; + assert res == ~"2"; } #[test] fn test_relative_to7() { - let p1 = "/1/2"; - let p2 = "/3"; + let p1 = ~"/1/2"; + let p2 = ~"/3"; let res = get_relative_to(p1, p2); - assert res == ".."; + assert res == ~".."; } #[test] fn test_relative_to8() { - let p1 = "/home/brian/Dev/rust/build/" - + "stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so"; - let p2 = "/home/brian/Dev/rust/build/stage2/bin/.." - + "/lib/rustc/i686-unknown-linux-gnu/lib/libstd.so"; + let p1 = ~"/home/brian/Dev/rust/build/" + + ~"stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so"; + let p2 = ~"/home/brian/Dev/rust/build/stage2/bin/.." + + ~"/lib/rustc/i686-unknown-linux-gnu/lib/libstd.so"; let res = get_relative_to(p1, p2); - assert res == "."; + assert res == ~"."; } #[test] @@ -317,8 +317,8 @@ mod test { let o = session::os_linux; check not_win32(o); let res = get_rpath_relative_to_output(o, - "/usr", "bin/rustc", "lib/libstd.so"); - assert res == "$ORIGIN/../lib"; + ~"/usr", ~"bin/rustc", ~"lib/libstd.so"); + assert res == ~"$ORIGIN/../lib"; } #[test] @@ -344,7 +344,7 @@ mod test { #[test] fn test_get_absolute_rpath() { - let res = get_absolute_rpath("/usr", "lib/libstd.so"); - assert res == "/usr/lib"; + let res = get_absolute_rpath(~"/usr", ~"lib/libstd.so"); + assert res == ~"/usr/lib"; } } diff --git a/src/rustc/back/target_strs.rs b/src/rustc/back/target_strs.rs index ca11e4c6d69..798c4868a7c 100644 --- a/src/rustc/back/target_strs.rs +++ b/src/rustc/back/target_strs.rs @@ -1,7 +1,7 @@ type t = { - module_asm: str, - meta_sect_name: str, - data_layout: str, - target_triple: str, - cc_args: ~[str] + module_asm: ~str, + meta_sect_name: ~str, + data_layout: ~str, + target_triple: ~str, + cc_args: ~[~str] }; diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index e95f7e39af4..94c69976c8c 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -30,7 +30,7 @@ fn declare_upcalls(targ_cfg: @session::config, _tn: type_names, tydesc_type: TypeRef, llmod: ModuleRef) -> @upcalls { - fn decl(llmod: ModuleRef, prefix: str, name: str, + fn decl(llmod: ModuleRef, prefix: ~str, name: ~str, tys: ~[TypeRef], rv: TypeRef) -> ValueRef { let mut arg_tys: ~[TypeRef] = ~[]; @@ -41,63 +41,63 @@ fn declare_upcalls(targ_cfg: @session::config, fn nothrow(f: ValueRef) -> ValueRef { base::set_no_unwind(f); f } - let d = |a,b,c| decl(llmod, "upcall_", a, b, c); - let dv = |a,b| decl(llmod, "upcall_", a, b, T_void()); + let d = |a,b,c| decl(llmod, ~"upcall_", a, b, c); + let dv = |a,b| decl(llmod, ~"upcall_", a, b, T_void()); let int_t = T_int(targ_cfg); let size_t = T_size_t(targ_cfg); - ret @{_fail: dv("fail", ~[T_ptr(T_i8()), + ret @{_fail: dv(~"fail", ~[T_ptr(T_i8()), T_ptr(T_i8()), size_t]), - trace: dv("trace", ~[T_ptr(T_i8()), + trace: dv(~"trace", ~[T_ptr(T_i8()), T_ptr(T_i8()), int_t]), malloc: - nothrow(d("malloc", + nothrow(d(~"malloc", ~[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", + nothrow(d(~"exchange_malloc", ~[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), 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()))), cmp_type: - dv("cmp_type", + dv(~"cmp_type", ~[T_ptr(T_i1()), T_ptr(tydesc_type), T_ptr(T_i8()), T_ptr(T_i8()), T_i8()]), log_type: - dv("log_type", ~[T_ptr(tydesc_type), + dv(~"log_type", ~[T_ptr(tydesc_type), 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", + d(~"call_shim_on_c_stack", // arguments: void *args, void *fn_ptr ~[T_ptr(T_i8()), T_ptr(T_i8())], int_t), call_shim_on_rust_stack: - d("call_shim_on_rust_stack", + d(~"call_shim_on_rust_stack", ~[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 63ca5b60e65..a7cd20e875b 100644 --- a/src/rustc/back/x86.rs +++ b/src/rustc/back/x86.rs @@ -4,38 +4,39 @@ import metadata::loader::meta_section_name; fn get_target_strs(target_os: session::os) -> target_strs::t { ret { - module_asm: "", + module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), data_layout: alt target_os { session::os_macos { - "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" + - "-f32:32:32-f64:32:64-v64:64:64" + - "-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32" + ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + + ~"-i32:32:32-i64:32:64" + + ~"-f32:32:32-f64:32:64-v64:64:64" + + ~"-v128:128:128-a0:0:64-f80:128:128" + ~"-n8:16:32" } session::os_win32 { - "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" + ~"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32" } session::os_linux { - "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" + ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } session::os_freebsd { - "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" + ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32" } }, target_triple: alt target_os { - session::os_macos { "i686-apple-darwin" } - session::os_win32 { "i686-pc-mingw32" } - session::os_linux { "i686-unknown-linux-gnu" } - session::os_freebsd { "i686-unknown-freebsd" } + session::os_macos { ~"i686-apple-darwin" } + session::os_win32 { ~"i686-pc-mingw32" } + session::os_linux { ~"i686-unknown-linux-gnu" } + 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 b3e6c518dd4..63399cd2b41 100644 --- a/src/rustc/back/x86_64.rs +++ b/src/rustc/back/x86_64.rs @@ -4,45 +4,45 @@ import metadata::loader::meta_section_name; fn get_target_strs(target_os: session::os) -> target_strs::t { ret { - module_asm: "", + module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), data_layout: alt target_os { session::os_macos { - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64" } session::os_win32 { // FIXME: Test this. Copied from linux (#2398) - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64-S128" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_linux { - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64-S128" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_freebsd { - "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - "s0:64:64-f80:128:128-n8:16:32:64-S128" + ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ + ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + ~"s0:64:64-f80:128:128-n8:16:32:64-S128" } }, target_triple: alt target_os { - session::os_macos { "x86_64-apple-darwin" } - session::os_win32 { "x86_64-pc-mingw32" } - session::os_linux { "x86_64-unknown-linux-gnu" } - session::os_freebsd { "x86_64-unknown-freebsd" } + session::os_macos { ~"x86_64-apple-darwin" } + session::os_win32 { ~"x86_64-pc-mingw32" } + session::os_linux { ~"x86_64-unknown-linux-gnu" } + 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 eda52e0dcf4..47b126df332 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -22,45 +22,45 @@ enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified, * The name used for source code that doesn't originate in a file * (e.g. source from stdin or a string) */ -fn anon_src() -> str { "<anon>" } +fn anon_src() -> ~str { ~"<anon>" } -fn source_name(input: input) -> str { +fn source_name(input: input) -> ~str { alt input { file_input(ifile) { ifile } str_input(_) { anon_src() } } } -fn default_configuration(sess: session, argv0: str, input: input) -> +fn default_configuration(sess: session, argv0: ~str, input: input) -> ast::crate_cfg { let libc = alt sess.targ_cfg.os { - session::os_win32 { "msvcrt.dll" } - session::os_macos { "libc.dylib" } - session::os_linux { "libc.so.6" } - session::os_freebsd { "libc.so.7" } + session::os_win32 { ~"msvcrt.dll" } + session::os_macos { ~"libc.dylib" } + session::os_linux { ~"libc.so.6" } + session::os_freebsd { ~"libc.so.7" } // _ { "libc.so" } }; let mk = attr::mk_name_value_item_str; let arch = alt sess.targ_cfg.arch { - session::arch_x86 { "x86" } - session::arch_x86_64 { "x86_64" } - session::arch_arm { "arm" } + session::arch_x86 { ~"x86" } + session::arch_x86_64 { ~"x86_64" } + session::arch_arm { ~"arm" } }; ret ~[ // Target bindings. attr::mk_word_item(@os::family()), - mk(@"target_os"/~, os::sysname()), - mk(@"target_family"/~, os::family()), - mk(@"target_arch"/~, arch), - mk(@"target_libc"/~, libc), + mk(@~"target_os", os::sysname()), + mk(@~"target_family", os::family()), + mk(@~"target_arch", arch), + mk(@~"target_libc", libc), // Build bindings. - mk(@"build_compiler"/~, argv0), - mk(@"build_input"/~, source_name(input))]; + mk(@~"build_compiler", argv0), + mk(@~"build_input", source_name(input))]; } -fn build_configuration(sess: session, argv0: str, input: input) -> +fn build_configuration(sess: session, argv0: ~str, input: input) -> ast::crate_cfg { // Combine the configuration requested by the session (command line) with // some default and generated configuration items @@ -69,16 +69,16 @@ fn build_configuration(sess: session, argv0: str, input: input) -> // If the user wants a test runner, then add the test cfg let gen_cfg = { - if sess.opts.test && !attr::contains_name(user_cfg, "test") + if sess.opts.test && !attr::contains_name(user_cfg, ~"test") { - ~[attr::mk_word_item(@"test"/~)] + ~[attr::mk_word_item(@~"test")] } else { ~[] } }; ret vec::append(vec::append(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. @@ -89,9 +89,9 @@ fn parse_cfgspecs(cfgspecs: ~[str]) -> ast::crate_cfg { enum input { /// Load source from file - file_input(str), + file_input(~str), /// The string is the source - str_input(str) + str_input(~str) } fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) @@ -108,7 +108,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) } } -fn time<T>(do_it: bool, what: str, thunk: fn() -> T) -> T { +fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T { if !do_it { ret thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); @@ -131,93 +131,93 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, outputs: option<output_filenames>) -> {crate: @ast::crate, tcx: option<ty::ctxt>} { let time_passes = sess.time_passes(); - let mut crate = time(time_passes, "parsing", + let mut crate = time(time_passes, ~"parsing", ||parse_input(sess, cfg, input) ); if upto == cu_parse { ret {crate: crate, tcx: none}; } sess.building_library = session::building_library( sess.opts.crate_type, crate, sess.opts.test); - crate = time(time_passes, "configuration", || + crate = time(time_passes, ~"configuration", || front::config::strip_unconfigured_items(crate)); - crate = time(time_passes, "maybe building test harness", || + crate = time(time_passes, ~"maybe building test harness", || front::test::modify_for_testing(sess, crate)); - crate = time(time_passes, "expansion", || + crate = time(time_passes, ~"expansion", || syntax::ext::expand::expand_crate(sess.parse_sess, sess.opts.cfg, crate)); if upto == cu_expand { ret {crate: crate, tcx: none}; } - crate = time(time_passes, "intrinsic injection", || + crate = time(time_passes, ~"intrinsic injection", || front::intrinsic_inject::inject_intrinsic(sess, crate)); - crate = time(time_passes, "core injection", || + crate = time(time_passes, ~"core injection", || front::core_inject::maybe_inject_libcore_ref(sess, crate)); - time(time_passes, "building warning settings table", || + time(time_passes, ~"building warning settings table", || lint::build_settings_crate(sess, crate)); - let ast_map = time(time_passes, "ast indexing", || + let ast_map = time(time_passes, ~"ast indexing", || syntax::ast_map::map_crate(sess.diagnostic(), *crate)); - time(time_passes, "external crate/lib resolution", || + time(time_passes, ~"external crate/lib resolution", || creader::read_crates(sess.diagnostic(), *crate, sess.cstore, sess.filesearch, session::sess_os_to_meta_os(sess.targ_cfg.os), sess.opts.static)); let { def_map: def_map, exp_map: exp_map, impl_map: impl_map } = - time(time_passes, "resolution", || + time(time_passes, ~"resolution", || middle::resolve3::resolve_crate(sess, ast_map, crate)); - let freevars = time(time_passes, "freevar finding", || + let freevars = time(time_passes, ~"freevar finding", || freevars::annotate_freevars(def_map, crate)); - let region_map = time(time_passes, "region resolution", || + let region_map = time(time_passes, ~"region resolution", || middle::region::resolve_crate(sess, def_map, crate)); - let rp_set = time(time_passes, "region paramerization inference", || + let rp_set = time(time_passes, ~"region paramerization inference", || middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate)); let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars, region_map, rp_set); - let (method_map, vtable_map) = time(time_passes, "typechecking", || + let (method_map, vtable_map) = time(time_passes, ~"typechecking", || typeck::check_crate(ty_cx, impl_map, crate)); - time(time_passes, "const checking", || + time(time_passes, ~"const checking", || middle::check_const::check_crate(sess, crate, ast_map, def_map, method_map, ty_cx)); if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; } - time(time_passes, "block-use checking", || + time(time_passes, ~"block-use checking", || middle::block_use::check_crate(ty_cx, crate)); - time(time_passes, "loop checking", || + time(time_passes, ~"loop checking", || middle::check_loop::check_crate(ty_cx, crate)); - time(time_passes, "alt checking", || + time(time_passes, ~"alt checking", || middle::check_alt::check_crate(ty_cx, crate)); - let last_use_map = time(time_passes, "liveness checking", || + let last_use_map = time(time_passes, ~"liveness checking", || middle::liveness::check_crate(ty_cx, method_map, crate)); - time(time_passes, "typestate checking", || + time(time_passes, ~"typestate checking", || middle::tstate::ck::check_crate(ty_cx, crate)); - let (root_map, mutbl_map) = time(time_passes, "borrow checking", || + let (root_map, mutbl_map) = time(time_passes, ~"borrow checking", || middle::borrowck::check_crate(ty_cx, method_map, last_use_map, crate)); - time(time_passes, "kind checking", || + time(time_passes, ~"kind checking", || kind::check_crate(ty_cx, method_map, last_use_map, crate)); - time(time_passes, "lint checking", || lint::check_crate(ty_cx, crate)); + time(time_passes, ~"lint checking", || lint::check_crate(ty_cx, crate)); if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; } let outputs = option::get(outputs); @@ -227,11 +227,11 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, impl_map: impl_map, method_map: method_map, vtable_map: vtable_map}; - let (llmod, link_meta) = time(time_passes, "translation", || + let (llmod, link_meta) = time(time_passes, ~"translation", || trans::base::trans_crate(sess, crate, ty_cx, outputs.obj_filename, exp_map, maps)); - time(time_passes, "LLVM passes", || + time(time_passes, ~"LLVM passes", || link::write::run_passes(sess, llmod, outputs.obj_filename)); let stop_after_codegen = @@ -240,7 +240,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; } - time(time_passes, "linking", || + time(time_passes, ~"linking", || link::link_binary(sess, outputs.obj_filename, outputs.out_filename, link_meta)); @@ -248,7 +248,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, } fn compile_input(sess: session, cfg: ast::crate_cfg, input: input, - outdir: option<str>, output: option<str>) { + outdir: option<~str>, output: option<~str>) { let upto = if sess.opts.parse_only { cu_parse } else if sess.opts.no_trans { cu_no_trans } @@ -266,7 +266,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, alt node { pprust::node_expr(s, expr) { pp::space(s.s); - pp::word(s.s, "as"); + pp::word(s.s, ~"as"); pp::space(s.s); pp::word(s.s, ppaux::ty_to_str(tcx, ty::expr_ty(tcx, expr))); pprust::pclose(s); @@ -283,7 +283,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, pprust::node_block(s, blk) { pp::space(s.s); pprust::synth_comment(s, - "block " + int::to_str(blk.node.id, 10u)); + ~"block " + int::to_str(blk.node.id, 10u)); } pprust::node_expr(s, expr) { pp::space(s.s); @@ -292,7 +292,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, } pprust::node_pat(s, pat) { pp::space(s.s); - pprust::synth_comment(s, "pat " + int::to_str(pat.id, 10u)); + pprust::synth_comment(s, ~"pat " + int::to_str(pat.id, 10u)); } } } @@ -327,29 +327,29 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, } } -fn get_os(triple: str) -> option<session::os> { - ret if str::contains(triple, "win32") || - str::contains(triple, "mingw32") { +fn get_os(triple: ~str) -> option<session::os> { + ret if str::contains(triple, ~"win32") || + str::contains(triple, ~"mingw32") { some(session::os_win32) - } else if str::contains(triple, "darwin") { + } else if str::contains(triple, ~"darwin") { some(session::os_macos) - } else if str::contains(triple, "linux") { + } else if str::contains(triple, ~"linux") { some(session::os_linux) - } else if str::contains(triple, "freebsd") { + } else if str::contains(triple, ~"freebsd") { some(session::os_freebsd) } else { none }; } -fn get_arch(triple: str) -> option<session::arch> { - ret if str::contains(triple, "i386") || str::contains(triple, "i486") || - str::contains(triple, "i586") || - str::contains(triple, "i686") || - str::contains(triple, "i786") { +fn get_arch(triple: ~str) -> option<session::arch> { + ret if str::contains(triple, ~"i386") || str::contains(triple, ~"i486") || + str::contains(triple, ~"i586") || + str::contains(triple, ~"i686") || + str::contains(triple, ~"i786") { some(session::arch_x86) - } else if str::contains(triple, "x86_64") { + } else if str::contains(triple, ~"x86_64") { some(session::arch_x86_64) - } else if str::contains(triple, "arm") || - str::contains(triple, "xscale") { + } else if str::contains(triple, ~"arm") || + str::contains(triple, ~"xscale") { some(session::arch_arm) } else { none }; } @@ -358,12 +358,12 @@ fn build_target_config(sopts: @session::options, demitter: diagnostic::emitter) -> @session::config { let os = alt get_os(sopts.target_triple) { some(os) { os } - none { early_error(demitter, "unknown operating system") } + none { early_error(demitter, ~"unknown operating system") } }; let arch = alt get_arch(sopts.target_triple) { some(arch) { arch } none { early_error(demitter, - "unknown architecture: " + sopts.target_triple) } + ~"unknown architecture: " + sopts.target_triple) } }; let (int_type, uint_type, float_type) = alt arch { session::arch_x86 {(ast::ty_i32, ast::ty_u32, ast::ty_f64)} @@ -381,7 +381,7 @@ fn build_target_config(sopts: @session::options, ret target_cfg; } -fn host_triple() -> str { +fn host_triple() -> ~str { // Get the host triple out of the build environment. This ensures that our // idea of the host triple is the same as for the set of libraries we've // actually built. We can't just take LLVM's host triple because they @@ -391,29 +391,29 @@ fn host_triple() -> str { // be grabbing (at compile time) the target triple that this rustc is // built with and calling that (at runtime) the host triple. let ht = #env("CFG_HOST_TRIPLE"); - ret if ht != "" { + ret if ht != ~"" { ht } else { - fail "rustc built without CFG_HOST_TRIPLE" + fail ~"rustc built without CFG_HOST_TRIPLE" }; } fn build_session_options(match: getopts::match, demitter: diagnostic::emitter) -> @session::options { - let crate_type = if opt_present(match, "lib") { + let crate_type = if opt_present(match, ~"lib") { session::lib_crate - } else if opt_present(match, "bin") { + } else if opt_present(match, ~"bin") { session::bin_crate } else { session::unknown_crate }; - let static = opt_present(match, "static"); + let static = opt_present(match, ~"static"); - let parse_only = opt_present(match, "parse-only"); - let no_trans = opt_present(match, "no-trans"); + let parse_only = opt_present(match, ~"parse-only"); + let no_trans = opt_present(match, ~"no-trans"); - let lint_flags = vec::append(getopts::opt_strs(match, "W"), - getopts::opt_strs(match, "warn")); + let lint_flags = vec::append(getopts::opt_strs(match, ~"W"), + getopts::opt_strs(match, ~"warn")); let lint_dict = lint::get_lint_dict(); let lint_opts = do vec::map(lint_flags) |flag| { alt lint::lookup_lint(lint_dict, flag) { @@ -425,7 +425,7 @@ fn build_session_options(match: getopts::match, }; let mut debugging_opts = 0u; - let debug_flags = getopts::opt_strs(match, "Z"); + let debug_flags = getopts::opt_strs(match, ~"Z"); let debug_map = session::debugging_opts_map(); for debug_flags.each |debug_flag| { let mut this_bit = 0u; @@ -442,40 +442,41 @@ fn build_session_options(match: getopts::match, let output_type = if parse_only || no_trans { link::output_type_none - } else if opt_present(match, "S") && opt_present(match, "emit-llvm") { + } else if opt_present(match, ~"S") && + opt_present(match, ~"emit-llvm") { link::output_type_llvm_assembly - } else if opt_present(match, "S") { + } else if opt_present(match, ~"S") { link::output_type_assembly - } else if opt_present(match, "c") { + } else if opt_present(match, ~"c") { link::output_type_object - } else if opt_present(match, "emit-llvm") { + } else if opt_present(match, ~"emit-llvm") { link::output_type_bitcode } else { link::output_type_exe }; - let extra_debuginfo = opt_present(match, "xg"); - let debuginfo = opt_present(match, "g") || extra_debuginfo; - let sysroot_opt = getopts::opt_maybe_str(match, "sysroot"); - let target_opt = getopts::opt_maybe_str(match, "target"); - let save_temps = getopts::opt_present(match, "save-temps"); + let extra_debuginfo = opt_present(match, ~"xg"); + let debuginfo = opt_present(match, ~"g") || extra_debuginfo; + let sysroot_opt = getopts::opt_maybe_str(match, ~"sysroot"); + let target_opt = getopts::opt_maybe_str(match, ~"target"); + let save_temps = getopts::opt_present(match, ~"save-temps"); alt output_type { // unless we're emitting huamn-readable assembly, omit comments. link::output_type_llvm_assembly | link::output_type_assembly {} _ { debugging_opts |= session::no_asm_comments; } } let opt_level: uint = - if opt_present(match, "O") { - if opt_present(match, "opt-level") { - early_error(demitter, "-O and --opt-level both provided"); + if opt_present(match, ~"O") { + if opt_present(match, ~"opt-level") { + early_error(demitter, ~"-O and --opt-level both provided"); } 2u - } else if opt_present(match, "opt-level") { - alt getopts::opt_str(match, "opt-level") { - "0" { 0u } - "1" { 1u } - "2" { 2u } - "3" { 3u } + } else if opt_present(match, ~"opt-level") { + alt getopts::opt_str(match, ~"opt-level") { + ~"0" { 0u } + ~"1" { 1u } + ~"2" { 2u } + ~"3" { 3u } _ { - early_error(demitter, "optimization level needs " + - "to be between 0-3") + early_error(demitter, ~"optimization level needs " + + ~"to be between 0-3") } } } else { 0u }; @@ -485,9 +486,9 @@ fn build_session_options(match: getopts::match, some(s) { s } }; - let addl_lib_search_paths = getopts::opt_strs(match, "L"); - let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg")); - let test = opt_present(match, "test"); + let addl_lib_search_paths = getopts::opt_strs(match, ~"L"); + let cfg = parse_cfgspecs(getopts::opt_strs(match, ~"cfg")); + let test = opt_present(match, ~"test"); let sopts: @session::options = @{crate_type: crate_type, static: static, @@ -545,44 +546,45 @@ fn build_session_( warning_settings: warning_settings} } -fn parse_pretty(sess: session, &&name: str) -> pp_mode { - if str::eq(name, "normal") { +fn parse_pretty(sess: session, &&name: ~str) -> pp_mode { + if str::eq(name, ~"normal") { ret ppm_normal; - } else if str::eq(name, "expanded") { + } else if str::eq(name, ~"expanded") { ret ppm_expanded; - } else if str::eq(name, "typed") { + } else if str::eq(name, ~"typed") { ret ppm_typed; - } else if str::eq(name, "expanded,identified") { + } else if str::eq(name, ~"expanded,identified") { ret ppm_expanded_identified; - } else if str::eq(name, "identified") { + } else if str::eq(name, ~"identified") { ret ppm_identified; } - sess.fatal("argument to `pretty` must be one of `normal`, `typed`, or " + - "`identified`"); + sess.fatal(~"argument to `pretty` must be one of `normal`, `typed`, or " + + ~"`identified`"); } 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"), - optflag("O"), optopt("opt-level"), optmulti("L"), optflag("S"), - optopt("o"), optopt("out-dir"), optflag("xg"), - optflag("c"), optflag("g"), optflag("save-temps"), - optopt("sysroot"), optopt("target"), + ret ~[optflag(~"h"), optflag(~"help"), optflag(~"v"), optflag(~"version"), + optflag(~"emit-llvm"), optflagopt(~"pretty"), + optflag(~"ls"), optflag(~"parse-only"), optflag(~"no-trans"), + optflag(~"O"), optopt(~"opt-level"), optmulti(~"L"), optflag(~"S"), + optopt(~"o"), optopt(~"out-dir"), optflag(~"xg"), + optflag(~"c"), optflag(~"g"), optflag(~"save-temps"), + optopt(~"sysroot"), optopt(~"target"), - optmulti("W"), optmulti("warn"), + optmulti(~"W"), optmulti(~"warn"), - optmulti("Z"), + optmulti(~"Z"), - optmulti("cfg"), optflag("test"), - optflag("lib"), optflag("bin"), optflag("static"), optflag("gc")]; + optmulti(~"cfg"), optflag(~"test"), + optflag(~"lib"), optflag(~"bin"), + optflag(~"static"), optflag(~"gc")]; } -type output_filenames = @{out_filename: str, obj_filename:str}; +type output_filenames = @{out_filename: ~str, obj_filename:~str}; fn build_output_filenames(input: input, - odir: option<str>, - ofile: option<str>, + odir: option<~str>, + ofile: option<~str>, sess: session) -> output_filenames { let obj_path; @@ -595,13 +597,13 @@ fn build_output_filenames(input: input, let obj_suffix = alt sopts.output_type { - link::output_type_none { "none" } - link::output_type_bitcode { "bc" } - link::output_type_assembly { "s" } - link::output_type_llvm_assembly { "ll" } + link::output_type_none { ~"none" } + link::output_type_bitcode { ~"bc" } + link::output_type_assembly { ~"s" } + link::output_type_llvm_assembly { ~"ll" } // Object and exe output both use the '.o' extension here link::output_type_object | link::output_type_exe { - "o" + ~"o" } }; @@ -630,7 +632,7 @@ fn build_output_filenames(input: input, path::basename(path) } str_input(_) { - "rust_out" + ~"rust_out" } }; let base_path = path::connect(dirname, base_filename); @@ -640,10 +642,10 @@ fn build_output_filenames(input: input, let basename = path::basename(base_path); let dylibname = os::dll_filename(basename); out_path = path::connect(dirname, dylibname); - obj_path = path::connect(dirname, basename + "." + obj_suffix); + obj_path = path::connect(dirname, basename + ~"." + obj_suffix); } else { out_path = base_path; - obj_path = base_path + "." + obj_suffix; + obj_path = base_path + ~"." + obj_suffix; } } @@ -653,7 +655,7 @@ fn build_output_filenames(input: input, out_file } else { let (base, _) = path::splitext(out_file); - let modified = base + "." + obj_suffix; + let modified = base + ~"." + obj_suffix; modified }; @@ -665,7 +667,7 @@ fn build_output_filenames(input: input, } if odir != none { - sess.warn("ignoring --out-dir flag due to -o flag."); + sess.warn(~"ignoring --out-dir flag due to -o flag."); } } } @@ -673,12 +675,12 @@ fn build_output_filenames(input: input, obj_filename: obj_path}; } -fn early_error(emitter: diagnostic::emitter, msg: str) -> ! { +fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! { emitter(none, msg, diagnostic::fatal); fail; } -fn list_metadata(sess: session, path: str, out: io::writer) { +fn list_metadata(sess: session, path: ~str, out: io::writer) { metadata::loader::list_file_metadata( session::sess_os_to_meta_os(sess.targ_cfg.os), path, out); } @@ -690,15 +692,15 @@ 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: " + + err(f) { fail ~"test_switch_implies_cfg_test: " + getopts::fail_str(f); } }; let sessopts = build_session_options(match, diagnostic::emit); let sess = build_session(sessopts, diagnostic::emit); - let cfg = build_configuration(sess, "whatever", str_input("")); - assert (attr::contains_name(cfg, "test")); + let cfg = build_configuration(sess, ~"whatever", str_input(~"")); + assert (attr::contains_name(cfg, ~"test")); } // When the user supplies --test and --cfg test, don't implicitly add @@ -706,15 +708,17 @@ 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); } + err(f) { + fail ~"test_switch_implies_cfg_test_unless_cfg_test: " + + getopts::fail_str(f); + } }; let sessopts = build_session_options(match, diagnostic::emit); let sess = build_session(sessopts, diagnostic::emit); - let cfg = build_configuration(sess, "whatever", str_input("")); - let test_items = attr::find_meta_items_by_name(cfg, "test"); + let cfg = build_configuration(sess, ~"whatever", str_input(~"")); + let test_items = attr::find_meta_items_by_name(cfg, ~"test"); assert (vec::len(test_items) == 1u); } } diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 5a9c6774db5..e54ca83ebdc 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -20,17 +20,17 @@ import rustc::driver::session; import rustc::middle::lint; import io::reader_util; -fn version(argv0: str) { - let mut vers = "unknown version"; +fn version(argv0: ~str) { + let mut vers = ~"unknown version"; let env_vers = #env["CFG_VERSION"]; if str::len(env_vers) != 0u { vers = env_vers; } io::println(#fmt("%s %s", argv0, vers)); io::println(#fmt("host: %s", host_triple())); } -fn usage(argv0: str) { +fn usage(argv0: ~str) { io::println(#fmt("Usage: %s [options] <input>\n", argv0) + - " + ~" Options: --bin Compile an executable crate (default) @@ -81,24 +81,24 @@ fn describe_warnings() { let lint_dict = lint::get_lint_dict(); let mut max_key = 0u; for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); } - fn padded(max: uint, s: str) -> str { + fn padded(max: uint, s: ~str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } io::println(#fmt("\nAvailable warnings:\n")); io::println(#fmt(" %s %7.7s %s", - padded(max_key, "name"), "default", "meaning")); + padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(#fmt(" %s %7.7s %s\n", - padded(max_key, "----"), "-------", "-------")); + padded(max_key, ~"----"), ~"-------", ~"-------")); for lint_dict.each |k, v| { - let k = str::replace(k, "_", "-"); + let k = str::replace(k, ~"_", ~"-"); io::println(#fmt(" %s %7.7s %s", padded(max_key, k), - alt v.default { lint::warn { "warn" } - lint::error { "error" } - lint::ignore { "ignore" } }, + alt v.default { lint::warn { ~"warn" } + lint::error { ~"error" } + lint::ignore { ~"ignore" } }, v.desc)); } - io::println(""); + io::println(~""); } fn describe_debug_flags() { @@ -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(); @@ -126,62 +126,62 @@ fn run_compiler(args: ~[str], demitter: diagnostic::emitter) { } }; - if opt_present(match, "h") || opt_present(match, "help") { + if opt_present(match, ~"h") || opt_present(match, ~"help") { usage(binary); ret; } - let lint_flags = vec::append(getopts::opt_strs(match, "W"), - getopts::opt_strs(match, "warn")); - if lint_flags.contains("help") { + let lint_flags = vec::append(getopts::opt_strs(match, ~"W"), + getopts::opt_strs(match, ~"warn")); + if lint_flags.contains(~"help") { describe_warnings(); ret; } - if getopts::opt_strs(match, "Z").contains("help") { + if getopts::opt_strs(match, ~"Z").contains(~"help") { describe_debug_flags(); ret; } - if opt_present(match, "v") || opt_present(match, "version") { + if opt_present(match, ~"v") || opt_present(match, ~"version") { version(binary); ret; } let input = alt vec::len(match.free) { - 0u { early_error(demitter, "no input filename given") } + 0u { early_error(demitter, ~"no input filename given") } 1u { let ifile = match.free[0]; - if ifile == "-" { + if ifile == ~"-" { let src = str::from_bytes(io::stdin().read_whole_stream()); str_input(src) } else { file_input(ifile) } } - _ { early_error(demitter, "multiple input filenames provided") } + _ { early_error(demitter, ~"multiple input filenames provided") } }; let sopts = build_session_options(match, demitter); let sess = build_session(sopts, demitter); - let odir = getopts::opt_maybe_str(match, "out-dir"); - let ofile = getopts::opt_maybe_str(match, "o"); + let odir = getopts::opt_maybe_str(match, ~"out-dir"); + let ofile = getopts::opt_maybe_str(match, ~"o"); let cfg = build_configuration(sess, binary, input); let pretty = - option::map(getopts::opt_default(match, "pretty", - "normal"), + option::map(getopts::opt_default(match, ~"pretty", + ~"normal"), |a| parse_pretty(sess, a) ); alt pretty { some::<pp_mode>(ppm) { pretty_print_input(sess, cfg, input, ppm); ret; } none::<pp_mode> {/* continue */ } } - let ls = opt_present(match, "ls"); + let ls = opt_present(match, ~"ls"); if ls { alt input { file_input(ifile) { list_metadata(sess, ifile, io::stdout()); } str_input(_) { - early_error(demitter, "can not list metadata for stdin"); + early_error(demitter, ~"can not list metadata for stdin"); } } ret; @@ -216,7 +216,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { // The 'diagnostics emitter'. Every error, warning, etc. should // go through this function. let demitter = fn@(cmsp: option<(codemap::codemap, codemap::span)>, - msg: str, lvl: diagnostic::level) { + msg: ~str, lvl: diagnostic::level) { if lvl == diagnostic::fatal { comm::send(ch, fatal); } @@ -239,13 +239,13 @@ fn monitor(+f: fn~(diagnostic::emitter)) { if comm::recv(p) == done { diagnostic::emit( none, - diagnostic::ice_msg("unexpected failure"), + diagnostic::ice_msg(~"unexpected failure"), diagnostic::error); for [ - "the compiler hit an unexpected failure path. \ + ~"the compiler hit an unexpected failure path. \ this is a bug", - "try running with RUST_LOG=rustc=0,::rt::backtrace \ + ~"try running with RUST_LOG=rustc=0,::rt::backtrace \ to get further details and report the results \ to github.com/mozilla/rust/issues" ]/_.each |note| { @@ -258,7 +258,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { } } -fn main(args: ~[str]) { +fn main(args: ~[~str]) { do monitor |demitter| { run_compiler(args, demitter); } diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 8daa4ec8e8a..3697934dbc0 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -40,23 +40,24 @@ const borrowck_stats: uint = 1024u; const borrowck_note_pure: uint = 2048; const borrowck_note_loan: uint = 4096; -fn debugging_opts_map() -> ~[(str, str, uint)] { - ~[("ppregions", "prettyprint regions with \ +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), - ("count-llvm-insns", "count where LLVM \ + (~"time-passes", ~"measure time of each rustc pass", time_passes), + (~"count-llvm-insns", ~"count where LLVM \ instrs originate", count_llvm_insns), - ("time-llvm-passes", "measure time of each LLVM pass", time_llvm_passes), - ("trans-stats", "gather trans statistics", trans_stats), - ("no-asm-comments", "omit comments when using -S", no_asm_comments), - ("no-verify", "skip LLVM verification", no_verify), - ("trace", "emit trace logs", trace), - ("no-rt", "do not link to the runtime", no_rt), - ("coherence", "perform coherence checking", coherence), - ("borrowck-stats", "gather borrowck statistics", borrowck_stats), - ("borrowck-note-pure", "note where purity is req'd", + (~"time-llvm-passes", ~"measure time of each LLVM pass", + time_llvm_passes), + (~"trans-stats", ~"gather trans statistics", trans_stats), + (~"no-asm-comments", ~"omit comments when using -S", no_asm_comments), + (~"no-verify", ~"skip LLVM verification", no_verify), + (~"trace", ~"emit trace logs", trace), + (~"no-rt", ~"do not link to the runtime", no_rt), + (~"coherence", ~"perform coherence checking", coherence), + (~"borrowck-stats", ~"gather borrowck statistics", borrowck_stats), + (~"borrowck-note-pure", ~"note where purity is req'd", borrowck_note_pure), - ("borrowck-note-loan", "note where loans are req'd", + (~"borrowck-note-loan", ~"note where loans are req'd", borrowck_note_loan) ] } @@ -72,9 +73,9 @@ type options = lint_opts: ~[(lint::lint, lint::level)], save_temps: bool, output_type: back::link::output_type, - addl_lib_search_paths: ~[str], - maybe_sysroot: option<str>, - target_triple: str, + addl_lib_search_paths: ~[~str], + maybe_sysroot: option<~str>, + target_triple: ~str, cfg: ast::crate_cfg, test: bool, parse_only: bool, @@ -82,7 +83,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, @@ -94,20 +95,20 @@ type session = @{targ_cfg: @config, span_diagnostic: diagnostic::span_handler, filesearch: filesearch::filesearch, mut building_library: bool, - working_dir: str, + working_dir: ~str, warning_settings: lint::warning_settings}; impl session for session { - fn span_fatal(sp: span, msg: str) -> ! { + fn span_fatal(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_fatal(sp, msg) } - fn fatal(msg: str) -> ! { + fn fatal(msg: ~str) -> ! { self.span_diagnostic.handler().fatal(msg) } - fn span_err(sp: span, msg: str) { + fn span_err(sp: span, msg: ~str) { self.span_diagnostic.span_err(sp, msg) } - fn err(msg: str) { + fn err(msg: ~str) { self.span_diagnostic.handler().err(msg) } fn has_errors() -> bool { @@ -116,32 +117,32 @@ impl session for session { fn abort_if_errors() { self.span_diagnostic.handler().abort_if_errors() } - fn span_warn(sp: span, msg: str) { + fn span_warn(sp: span, msg: ~str) { self.span_diagnostic.span_warn(sp, msg) } - fn warn(msg: str) { + fn warn(msg: ~str) { self.span_diagnostic.handler().warn(msg) } - fn span_note(sp: span, msg: str) { + fn span_note(sp: span, msg: ~str) { self.span_diagnostic.span_note(sp, msg) } - fn note(msg: str) { + fn note(msg: ~str) { self.span_diagnostic.handler().note(msg) } - fn span_bug(sp: span, msg: str) -> ! { + fn span_bug(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_bug(sp, msg) } - fn bug(msg: str) -> ! { + fn bug(msg: ~str) -> ! { self.span_diagnostic.handler().bug(msg) } - fn span_unimpl(sp: span, msg: str) -> ! { + fn span_unimpl(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_unimpl(sp, msg) } - fn unimpl(msg: str) -> ! { + fn unimpl(msg: ~str) -> ! { self.span_diagnostic.handler().unimpl(msg) } fn span_lint_level(level: lint::level, - sp: span, msg: str) { + sp: span, msg: ~str) { alt level { lint::ignore { } lint::warn { self.span_warn(sp, msg); } @@ -150,7 +151,7 @@ impl session for session { } fn span_lint(lint_mode: lint::lint, expr_id: ast::node_id, item_id: ast::node_id, - span: span, msg: str) { + span: span, msg: ~str) { let level = lint::get_warning_settings_level( self.warning_settings, lint_mode, expr_id, item_id); self.span_lint_level(level, span, msg); @@ -201,7 +202,7 @@ fn basic_options() -> @options { } // Seems out of place, but it uses session, so I'm putting it here -fn expect<T: copy>(sess: session, opt: option<T>, msg: fn() -> str) -> T { +fn expect<T: copy>(sess: session, opt: option<T>, msg: fn() -> ~str) -> T { diagnostic::expect(sess.diagnostic(), opt, msg) } @@ -216,8 +217,8 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate, } else { alt syntax::attr::first_attr_value_str_by_name( crate.node.attrs, - "crate_type") { - option::some(@"lib"/~) { true } + ~"crate_type") { + option::some(@~"lib") { true } _ { false } } } @@ -240,12 +241,12 @@ fn sess_os_to_meta_os(os: os) -> metadata::loader::os { mod test { import syntax::ast_util; - fn make_crate_type_attr(t: str) -> ast::attribute { + fn make_crate_type_attr(t: ~str) -> ast::attribute { ast_util::respan(ast_util::dummy_sp(), { style: ast::attr_outer, value: ast_util::respan(ast_util::dummy_sp(), ast::meta_name_value( - @"crate_type"/~, + @~"crate_type", ast_util::respan(ast_util::dummy_sp(), ast::lit_str(@t)))), is_sugared_doc: false @@ -254,8 +255,8 @@ 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")]; } + 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: ~[]}, diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index a044b45b3ae..c633cf5d2af 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -125,7 +125,7 @@ fn in_cfg(cfg: ast::crate_cfg, attrs: ~[ast::attribute]) -> 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"); + let cfg_metas = attr::find_meta_items_by_name(metas, ~"cfg"); // Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes, // so we can match against them. This is the list of configurations for diff --git a/src/rustc/front/core_inject.rs b/src/rustc/front/core_inject.rs index c16fbabdcce..24b1a8094e3 100644 --- a/src/rustc/front/core_inject.rs +++ b/src/rustc/front/core_inject.rs @@ -16,7 +16,7 @@ fn maybe_inject_libcore_ref(sess: session, } fn use_core(crate: @ast::crate) -> bool { - !attr::attrs_contains_name(crate.node.attrs, "no_core") + !attr::attrs_contains_name(crate.node.attrs, ~"no_core") } fn inject_libcore_ref(sess: session, @@ -30,11 +30,11 @@ 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), + 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"/~), + let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), @~"core"), n2)); let vi2 = @{node: ast::view_item_import(~[vp]), attrs: ~[], diff --git a/src/rustc/front/intrinsic.rs b/src/rustc/front/intrinsic.rs index 21d8777e22d..7f2e11ecccd 100644 --- a/src/rustc/front/intrinsic.rs +++ b/src/rustc/front/intrinsic.rs @@ -64,14 +64,14 @@ mod intrinsic { fn visit_enter_rec(n_fields: uint, sz: uint, align: uint) -> bool; - fn visit_rec_field(i: uint, name: str/&, + fn visit_rec_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool; fn visit_leave_rec(n_fields: uint, sz: uint, align: uint) -> bool; fn visit_enter_class(n_fields: uint, sz: uint, align: uint) -> bool; - fn visit_class_field(i: uint, name: str/&, + fn visit_class_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool; fn visit_leave_class(n_fields: uint, sz: uint, align: uint) -> bool; @@ -87,12 +87,12 @@ mod intrinsic { fn visit_enter_enum_variant(variant: uint, disr_val: int, n_fields: uint, - name: str/&) -> bool; + name: &str) -> bool; fn visit_enum_variant_field(i: uint, inner: *tydesc) -> bool; fn visit_leave_enum_variant(variant: uint, disr_val: int, n_fields: uint, - name: str/&) -> bool; + name: &str) -> bool; fn visit_leave_enum(n_variants: uint, sz: uint, align: uint) -> bool; diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index 9f2741804bf..ea841c0700c 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -9,7 +9,7 @@ fn inject_intrinsic(sess: session, let intrinsic_module = @#include_str("intrinsic.rs"); - let item = parse::parse_item_from_source_str("<intrinsic>", + let item = parse::parse_item_from_source_str(~"<intrinsic>", intrinsic_module, sess.opts.cfg, ~[], ast::public, @@ -18,7 +18,7 @@ fn inject_intrinsic(sess: session, alt item { some(i) { i } none { - sess.fatal("no item found in intrinsic module"); + sess.fatal(~"no item found in intrinsic module"); } }; diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index f533c922531..17b92f6925e 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -58,7 +58,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate { // When not compiling with --test we should not compile the // #[test] functions do config::strip_items(crate) |attrs| { - !attr::contains_name(attr::attr_metas(attrs), "test") + !attr::contains_name(attr::attr_metas(attrs), ~"test") } } @@ -72,7 +72,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { fn nomain(&&item: @ast::item) -> option<@ast::item> { alt item.node { ast::item_fn(_, _, _) { - if *item.ident == "main" { + if *item.ident == ~"main" { option::none } else { option::some(item) } } @@ -106,7 +106,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> ast::item_fn(decl, _, _) if decl.purity == ast::unsafe_fn { cx.sess.span_fatal( i.span, - "unsafe functions cannot be used for tests"); + ~"unsafe functions cannot be used for tests"); } _ { #debug("this is a test function"); @@ -126,7 +126,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> fn is_test_fn(i: @ast::item) -> bool { let has_test_attr = - vec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u; + vec::len(attr::find_attrs_by_name(i.attrs, ~"test")) > 0u; fn has_test_signature(i: @ast::item) -> bool { alt i.node { @@ -144,7 +144,7 @@ fn is_test_fn(i: @ast::item) -> bool { } fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool { - let ignoreattrs = attr::find_attrs_by_name(i.attrs, "ignore"); + let ignoreattrs = attr::find_attrs_by_name(i.attrs, ~"ignore"); let ignoreitems = attr::attr_metas(ignoreattrs); let cfg_metas = vec::concat(vec::filter_map(ignoreitems, |&&i| attr::get_meta_item_list(i) )); @@ -156,7 +156,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool { } fn should_fail(i: @ast::item) -> bool { - vec::len(attr::find_attrs_by_name(i.attrs, "should_fail")) > 0u + vec::len(attr::find_attrs_by_name(i.attrs, ~"should_fail")) > 0u } fn add_test_module(cx: test_ctxt, m: ast::_mod) -> ast::_mod { @@ -192,9 +192,9 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { 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"/~)); + attr::mk_attr(attr::mk_word_item(@~"!resolve_unexported")); let item: ast::item = - {ident: @"__test"/~, + {ident: @~"__test", attrs: ~[resolve_unexported_attr], id: cx.sess.next_node_id(), node: item_, @@ -233,7 +233,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item { let item_ = ast::item_fn(decl, ~[], body); let item: ast::item = - {ident: @"tests"/~, + {ident: @~"tests", attrs: ~[], id: cx.sess.next_node_id(), node: item_, @@ -247,19 +247,19 @@ fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] { // the paths with std:: let is_std = { let items = attr::find_linkage_metas(cx.crate.node.attrs); - alt attr::last_meta_item_value_str_by_name(items, "name") { - some(@"std"/~) { true } + alt attr::last_meta_item_value_str_by_name(items, ~"name") { + some(@~"std") { true } _ { false } } }; if is_std { path } - else { vec::append(~[@"std"/~], path) } + else { vec::append(~[@~"std"], path) } } // 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"/~])); + path_node(mk_path(cx, ~[@~"test", @~"test_desc"])); let test_desc_ty: ast::ty = {id: cx.sess.next_node_id(), @@ -314,7 +314,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let name_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"name"/~, expr: @name_expr}); + nospan({mutbl: ast::m_imm, ident: @~"name", expr: @name_expr}); let fn_path = path_node(path); @@ -327,7 +327,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span); let fn_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"fn"/~, expr: fn_wrapper_expr}); + nospan({mutbl: ast::m_imm, ident: @~"fn", expr: fn_wrapper_expr}); let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore)); @@ -338,7 +338,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { span: span}; let ignore_field: ast::field = - nospan({mutbl: ast::m_imm, ident: @"ignore"/~, expr: @ignore_expr}); + nospan({mutbl: ast::m_imm, ident: @~"ignore", expr: @ignore_expr}); let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail)); @@ -350,7 +350,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let fail_field: ast::field = nospan({mutbl: ast::m_imm, - ident: @"should_fail"/~, + ident: @~"should_fail", expr: @fail_expr}); let desc_rec_: ast::expr_ = @@ -406,7 +406,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_inner = @{id: cx.sess.next_node_id(), node: ast::ty_path(str_pt, cx.sess.next_node_id()), span: dummy_sp()}; @@ -425,7 +425,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { let args_arg: ast::arg = {mode: ast::expl(ast::by_val), ty: @args_ty, - ident: @"args"/~, + ident: @~"args", id: cx.sess.next_node_id()}; let ret_ty = {id: cx.sess.next_node_id(), @@ -448,7 +448,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { let item_ = ast::item_fn(decl, ~[], body); let item: ast::item = - {ident: @"main"/~, + {ident: @~"main", attrs: ~[], id: cx.sess.next_node_id(), node: item_, @@ -460,7 +460,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); @@ -469,7 +469,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { 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); @@ -484,7 +484,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { 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); diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 1df423cdbb2..0c00a8674a5 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -987,19 +987,19 @@ fn SetLinkage(Global: ValueRef, Link: Linkage) { /* Memory-managed object interface to type handles. */ -type type_names = @{type_names: std::map::hashmap<TypeRef, str>, - named_types: std::map::hashmap<str, TypeRef>}; +type type_names = @{type_names: std::map::hashmap<TypeRef, ~str>, + named_types: std::map::hashmap<~str, TypeRef>}; -fn associate_type(tn: type_names, s: str, t: TypeRef) { +fn associate_type(tn: type_names, s: ~str, t: TypeRef) { assert tn.type_names.insert(t, s); assert tn.named_types.insert(s, t); } -fn type_has_name(tn: type_names, t: TypeRef) -> option<str> { +fn type_has_name(tn: type_names, t: TypeRef) -> option<~str> { ret tn.type_names.find(t); } -fn name_has_type(tn: type_names, s: str) -> option<TypeRef> { +fn name_has_type(tn: type_names, s: ~str) -> option<TypeRef> { ret tn.named_types.find(s); } @@ -1010,12 +1010,12 @@ fn mk_type_names() -> type_names { named_types: std::map::str_hash()} } -fn type_to_str(names: type_names, ty: TypeRef) -> str { +fn type_to_str(names: type_names, ty: TypeRef) -> ~str { ret type_to_str_inner(names, ~[], ty); } fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> - str { + ~str { alt type_has_name(names, ty) { option::some(n) { ret n; } _ {} @@ -1026,30 +1026,30 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> let kind = llvm::LLVMGetTypeKind(ty); fn tys_str(names: type_names, outer: ~[TypeRef], - tys: ~[TypeRef]) -> str { - let mut s: str = ""; + tys: ~[TypeRef]) -> ~str { + let mut s: ~str = ~""; let mut first: bool = true; for tys.each |t| { - if first { first = false; } else { s += ", "; } + if first { first = false; } else { s += ~", "; } s += type_to_str_inner(names, outer, t); } ret s; } alt kind { - Void { ret "Void"; } - Half { ret "Half"; } - Float { ret "Float"; } - Double { ret "Double"; } - X86_FP80 { ret "X86_FP80"; } - FP128 { ret "FP128"; } - PPC_FP128 { ret "PPC_FP128"; } - Label { ret "Label"; } + Void { ret ~"Void"; } + Half { ret ~"Half"; } + Float { ret ~"Float"; } + Double { ret ~"Double"; } + X86_FP80 { ret ~"X86_FP80"; } + FP128 { ret ~"FP128"; } + PPC_FP128 { ret ~"PPC_FP128"; } + Label { ret ~"Label"; } Integer { - ret "i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int); + ret ~"i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int); } Function { - let mut s = "fn("; + let mut s = ~"fn("; let out_ty: TypeRef = llvm::LLVMGetReturnType(ty); let n_args = llvm::LLVMCountParamTypes(ty) as uint; let args = vec::from_elem(n_args, 0 as TypeRef); @@ -1057,25 +1057,25 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> llvm::LLVMGetParamTypes(ty, vec::unsafe::to_ptr(args)); } s += tys_str(names, outer, args); - s += ") -> "; + s += ~") -> "; s += type_to_str_inner(names, outer, out_ty); ret s; } Struct { - let mut s: str = "{"; + let mut s: ~str = ~"{"; let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint; let elts = vec::from_elem(n_elts, 0 as TypeRef); unsafe { llvm::LLVMGetStructElementTypes(ty, vec::unsafe::to_ptr(elts)); } s += tys_str(names, outer, elts); - s += "}"; + s += ~"}"; ret s; } Array { let el_ty = llvm::LLVMGetElementType(ty); - ret "[" + type_to_str_inner(names, outer, el_ty) + " x " + - uint::str(llvm::LLVMGetArrayLength(ty) as uint) + "]"; + ret ~"[" + type_to_str_inner(names, outer, el_ty) + ~" x " + + uint::str(llvm::LLVMGetArrayLength(ty) as uint) + ~"]"; } Pointer { let mut i: uint = 0u; @@ -1083,23 +1083,23 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> i += 1u; if tout as int == ty as int { let n: uint = vec::len::<TypeRef>(outer0) - i; - ret "*\\" + int::str(n as int); + ret ~"*\\" + int::str(n as int); } } let addrstr = { let addrspace = llvm::LLVMGetPointerAddressSpace(ty) as uint; if addrspace == 0u { - "" + ~"" } else { #fmt("addrspace(%u)", addrspace) } }; - ret addrstr + "*" + + ret addrstr + ~"*" + type_to_str_inner(names, outer, llvm::LLVMGetElementType(ty)); } - Vector { ret "Vector"; } - Metadata { ret "Metadata"; } - X86_MMX { ret "X86_MMAX"; } + Vector { ret ~"Vector"; } + Metadata { ret ~"Metadata"; } + X86_MMX { ret ~"X86_MMAX"; } } } @@ -1109,7 +1109,7 @@ fn float_width(llt: TypeRef) -> uint { 2 { 64u } 3 { 80u } 4 | 5 { 128u } - _ { fail "llvm_float_width called on a non-float type" } + _ { fail ~"llvm_float_width called on a non-float type" } }; } @@ -1131,7 +1131,7 @@ class target_data_res { type target_data = {lltd: TargetDataRef, dtor: @target_data_res}; -fn mk_target_data(string_rep: str) -> target_data { +fn mk_target_data(string_rep: ~str) -> target_data { let lltd = str::as_c_str(string_rep, |buf| llvm::LLVMCreateTargetData(buf) ); ret {lltd: lltd, dtor: @target_data_res(lltd)}; diff --git a/src/rustc/metadata/common.rs b/src/rustc/metadata/common.rs index b6883097a5b..e7ef25a04d5 100644 --- a/src/rustc/metadata/common.rs +++ b/src/rustc/metadata/common.rs @@ -127,11 +127,11 @@ enum astencode_tag { // Reserves 0x50 -- 0x6f // djb's cdb hashes. fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); } -fn hash_path(&&s: str) -> uint { +fn hash_path(&&s: ~str) -> uint { let mut h = 5381u; for str::each(s) |ch| { h = (h << 5u) + h ^ (ch as uint); } ret h; } -type link_meta = {name: @str/~, vers: @str/~, extras_hash: str}; +type link_meta = {name: @~str, vers: @~str, extras_hash: ~str}; diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 09713da9c74..28022a37320 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -38,7 +38,7 @@ fn read_crates(diag: span_handler, crate: ast::crate, type cache_entry = { cnum: int, span: span, - hash: @str/~, + hash: @~str, metas: @~[@ast::meta_item] }; @@ -49,7 +49,7 @@ fn dump_crates(crate_cache: dvec<cache_entry>) { #debug("span: %?", entry.span); #debug("hash: %?", entry.hash); let attrs = ~[ - attr::mk_attr(attr::mk_list_item(@"link"/~, *entry.metas)) + 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)); @@ -79,9 +79,9 @@ fn warn_if_multiple_versions(diag: span_handler, diag.handler().warn( #fmt("using multiple versions of crate `%s`", *name)); for matches.each |match| { - diag.span_note(match.span, "used here"); + diag.span_note(match.span, ~"used here"); let attrs = ~[ - attr::mk_attr(attr::mk_list_item(@"link"/~, *match.metas)) + attr::mk_attr(attr::mk_list_item(@~"link", *match.metas)) ]; loader::note_linkage_attrs(diag, attrs); } @@ -103,7 +103,7 @@ fn visit_view_item(e: env, i: @ast::view_item) { alt i.node { ast::view_item_use(ident, meta_items, id) { #debug("resolving use stmt. ident: %?, meta: %?", ident, meta_items); - let cnum = resolve_crate(e, ident, meta_items, "", i.span); + let cnum = resolve_crate(e, ident, meta_items, ~"", i.span); cstore::add_use_stmt_cnum(e.cstore, id, cnum); } _ { } @@ -123,25 +123,25 @@ fn visit_item(e: env, i: @ast::item) { let cstore = e.cstore; let foreign_name = - alt attr::first_attr_value_str_by_name(i.attrs, "link_name") { + alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { some(nn) { - if *nn == "" { + if *nn == ~"" { e.diag.span_fatal( i.span, - "empty #[link_name] not allowed; use #[nolink]."); + ~"empty #[link_name] not allowed; use #[nolink]."); } nn } none { i.ident } }; let mut already_added = false; - if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u { + if vec::len(attr::find_attrs_by_name(i.attrs, ~"nolink")) == 0u { already_added = !cstore::add_used_library(cstore, *foreign_name); } - let link_args = attr::find_attrs_by_name(i.attrs, "link_args"); + let link_args = attr::find_attrs_by_name(i.attrs, ~"link_args"); if vec::len(link_args) > 0u && already_added { - e.diag.span_fatal(i.span, "library '" + *foreign_name + - "' already added: can't specify link_args."); + e.diag.span_fatal(i.span, ~"library '" + *foreign_name + + ~"' already added: can't specify link_args."); } for link_args.each |a| { alt attr::get_meta_item_value_str(attr::attr_meta(a)) { @@ -168,10 +168,10 @@ fn metas_with(ident: ast::ident, key: ast::ident, fn metas_with_ident(ident: ast::ident, metas: ~[@ast::meta_item]) -> ~[@ast::meta_item] { - metas_with(ident, @"name"/~, metas) + 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| { @@ -184,7 +184,7 @@ fn existing_match(e: env, metas: ~[@ast::meta_item], hash: str) -> } fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], - hash: str, span: span) -> ast::crate_num { + hash: ~str, span: span) -> ast::crate_num { let metas = metas_with_ident(ident, metas); alt existing_match(e, metas, hash) { @@ -218,7 +218,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], let cnum_map = resolve_crate_deps(e, cdata); let cname = - alt attr::last_meta_item_value_str_by_name(metas, "name") { + alt attr::last_meta_item_value_str_by_name(metas, ~"name") { option::some(v) { v } option::none { ident } }; @@ -245,7 +245,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 16b2481edd9..22d70f86eb8 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -30,7 +30,7 @@ export get_impl_method; export get_item_path; export maybe_get_item_ast, found_ast, found, found_parent, not_found; -fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> str { +fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> ~str { let cdata = cstore::get_crate_data(cstore, def.crate).data; ret decoder::get_symbol(cdata, def.node); } diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index f805d8d16cd..af9b6d57e57 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -37,9 +37,9 @@ type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>; // Multiple items may have the same def_id in crate metadata. They may be // renamed imports or reexports. This map keeps the "real" module path // and def_id. -type mod_path_map = map::hashmap<ast::def_id, @str/~>; +type mod_path_map = map::hashmap<ast::def_id, @~str>; -type crate_metadata = @{name: str, +type crate_metadata = @{name: ~str, 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>; @@ -83,12 +83,12 @@ fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata { ret p(cstore).metas.get(cnum); } -fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @str/~ { +fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @~str { let cdata = get_crate_data(cstore, cnum); ret decoder::get_crate_hash(cdata.data); } -fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @str/~ { +fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @~str { let cdata = get_crate_data(cstore, cnum); ret decoder::get_crate_vers(cdata.data); } @@ -111,33 +111,33 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) { for p(cstore).metas.each |k,v| { i(k, v);}; } -fn add_used_crate_file(cstore: cstore, lib: str) { +fn add_used_crate_file(cstore: cstore, lib: ~str) { if !vec::contains(p(cstore).used_crate_files, lib) { vec::push(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; } -fn add_used_library(cstore: cstore, lib: str) -> bool { - assert lib != ""; +fn add_used_library(cstore: cstore, lib: ~str) -> bool { + assert lib != ~""; if vec::contains(p(cstore).used_libraries, lib) { ret false; } vec::push(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; } -fn add_used_link_args(cstore: cstore, args: str) { +fn add_used_link_args(cstore: cstore, args: ~str) { vec::push_all(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,8 +153,8 @@ 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/~] { - type crate_hash = {name: @str/~, hash: @str/~}; +fn get_dep_hashes(cstore: cstore) -> ~[@~str] { + type crate_hash = {name: @~str, hash: @~str}; let mut result = ~[]; for p(cstore).use_crate_map.each_value |cnum| { @@ -171,14 +171,14 @@ fn get_dep_hashes(cstore: cstore) -> ~[@str/~] { for sorted.each |x| { #debug(" hash[%s]: %s", *x.name, *x.hash); } - fn mapper(ch: crate_hash) -> @str/~ { ret ch.hash; } + fn mapper(ch: crate_hash) -> @~str { ret ch.hash; } ret vec::map(sorted, mapper); } 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), ~[], - |ds| str::split_str(*ds, "::").map(|x| @x ) ) + |ds| str::split_str(*ds, ~"::").map(|x| @x ) ) } // Local Variables: // mode: rust diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index bd3697a23b2..45bdee06070 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -112,7 +112,7 @@ fn item_family(item: ebml::doc) -> char { ebml::doc_as_u8(fam) as char } -fn item_symbol(item: ebml::doc) -> str { +fn item_symbol(item: ebml::doc) -> ~str { let sym = ebml::get_doc(item, tag_items_data_item_symbol); ret str::from_bytes(ebml::doc_data(sym)); } @@ -214,7 +214,7 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] { // 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 eq_item(data: &[u8], s: ~str) -> bool { // XXX: Use string equality. let data_len = data.len(); let s_len = s.len(); @@ -385,7 +385,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)); } @@ -399,19 +399,19 @@ enum def_like { fn def_like_to_def(def_like: def_like) -> ast::def { alt def_like { dl_def(def) { ret def; } - dl_impl(*) { fail "found impl in def_like_to_def"; } - dl_field { fail "found field in def_like_to_def"; } + dl_impl(*) { fail ~"found impl in def_like_to_def"; } + dl_field { fail ~"found field in def_like_to_def"; } } } // A path. class path_entry { // The full path, separated by '::'. - let path_string: str; + let path_string: ~str; // The definition, implementation, or field that this path corresponds to. let def_like: def_like; - new(path_string: str, def_like: def_like) { + new(path_string: ~str, def_like: def_like) { self.path_string = path_string; self.def_like = def_like; } @@ -429,8 +429,8 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { do ebml::tagged_docs(items_data, tag_items_data_item) |item_doc| { if !broken { let name = ast_map::path_to_str_with_sep(item_path(item_doc), - "::"); - if name != "" { + ~"::"); + if name != ~"" { // Extract the def ID. let def_id = class_member_id(item_doc, cdata); @@ -628,7 +628,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let fty = alt ty::get(ty).struct { ty::ty_fn(f) { f } _ { tcx.diag.handler().bug( - "get_trait_methods: id has non-function type"); + ~"get_trait_methods: id has non-function type"); } }; vec::push(result, {ident: name, tps: bounds, fty: fty, purity: alt check item_family(mth) { @@ -684,7 +684,7 @@ fn family_names_type(fam_ch: char) -> bool { alt fam_ch { 'y' | 't' | 'I' { true } _ { false } } } -fn read_path(d: ebml::doc) -> {path: str, pos: uint} { +fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { let desc = ebml::doc_data(d); let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint; let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc)); @@ -692,8 +692,8 @@ fn read_path(d: ebml::doc) -> {path: str, pos: uint} { ret {path: path, pos: pos}; } -fn describe_def(items: ebml::doc, id: ast::def_id) -> str { - if id.crate != ast::local_crate { ret "external"; } +fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { + if id.crate != ast::local_crate { ret ~"external"; } let it = alt maybe_find_item(id.node, items) { some(it) { it } none { fail (#fmt("describe_def: item not found %?", id)); } @@ -701,26 +701,26 @@ fn describe_def(items: ebml::doc, id: ast::def_id) -> str { ret item_family_to_str(item_family(it)); } -fn item_family_to_str(fam: char) -> str { +fn item_family_to_str(fam: char) -> ~str { alt check fam { - 'c' { ret "const"; } - 'f' { ret "fn"; } - 'u' { ret "unsafe fn"; } - 'p' { ret "pure fn"; } - 'F' { ret "foreign fn"; } - 'U' { ret "unsafe foreign fn"; } - 'P' { ret "pure foreign fn"; } - 'y' { ret "type"; } - 'T' { ret "foreign type"; } - 't' { ret "type"; } - 'm' { ret "mod"; } - 'n' { ret "foreign mod"; } - 'v' { ret "enum"; } - 'i' { ret "impl"; } - 'I' { ret "trait"; } - 'C' { ret "class"; } - 'g' { ret "public field"; } - 'j' { ret "private field"; } + 'c' { ret ~"const"; } + 'f' { ret ~"fn"; } + 'u' { ret ~"unsafe fn"; } + 'p' { ret ~"pure fn"; } + 'F' { ret ~"foreign fn"; } + 'U' { ret ~"unsafe foreign fn"; } + 'P' { ret ~"pure foreign fn"; } + 'y' { ret ~"type"; } + 'T' { ret ~"foreign type"; } + 't' { ret ~"type"; } + 'm' { ret ~"mod"; } + 'n' { ret ~"foreign mod"; } + 'v' { ret ~"enum"; } + 'i' { ret ~"impl"; } + 'I' { ret ~"trait"; } + 'C' { ret ~"class"; } + 'g' { ret ~"public field"; } + 'j' { ret ~"private field"; } } } @@ -776,14 +776,14 @@ fn list_meta_items(meta_items: ebml::doc, out: io::writer) { } } -fn list_crate_attributes(md: ebml::doc, hash: @str/~, out: io::writer) { +fn list_crate_attributes(md: ebml::doc, hash: @~str, out: io::writer) { out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash)); for get_attributes(md).each |attr| { out.write_str(#fmt["%s\n", pprust::attribute_to_str(attr)]); } - out.write_str("\n\n"); + out.write_str(~"\n\n"); } fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { @@ -791,14 +791,14 @@ fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { } type crate_dep = {cnum: ast::crate_num, name: ast::ident, - vers: @str/~, hash: @str/~}; + vers: @~str, hash: @~str}; 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; - fn docstr(doc: ebml::doc, tag_: uint) -> str { + fn docstr(doc: ebml::doc, tag_: uint) -> ~str { str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_))) } do ebml::tagged_docs(depsdoc, tag_crate_dep) |depdoc| { @@ -812,33 +812,33 @@ fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] { } fn list_crate_deps(data: @~[u8], out: io::writer) { - out.write_str("=External Dependencies=\n"); + out.write_str(~"=External Dependencies=\n"); for get_crate_deps(data).each |dep| { out.write_str(#fmt["%d %s-%s-%s\n", dep.cnum, *dep.name, *dep.hash, *dep.vers]); } - out.write_str("\n"); + 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") { + attr::find_linkage_metas(attrs), ~"vers") { some(ver) { ver } - none { @"0.0"/~ } + none { @~"0.0" } }; } fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) { - out.write_str("=Items=\n"); + out.write_str(~"=Items=\n"); let items = ebml::get_doc(md, tag_items); do iter_crate_items(bytes) |tag, path, did| { // Don't print out any metadata info about intrinsics @@ -847,10 +847,10 @@ fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) { describe_def(items, did)]); } } - out.write_str("\n"); + out.write_str(~"\n"); } -fn iter_crate_items(bytes: @~[u8], proc: fn(uint, str, ast::def_id)) { +fn iter_crate_items(bytes: @~[u8], proc: fn(uint, ~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); @@ -867,9 +867,9 @@ fn iter_crate_items(bytes: @~[u8], proc: fn(uint, str, ast::def_id)) { }; } -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, "::")), "::") +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 @@ -913,7 +913,7 @@ fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { alt cdata.cnum_map.find(did.crate) { option::some(n) { ret {crate: n, node: did.node}; } - option::none { fail "didn't find a crate in the cnum_map"; } + option::none { fail ~"didn't find a crate in the cnum_map"; } } } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 8b8df41ab43..d1ecf88b3fe 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -43,10 +43,10 @@ type encode_parms = { diag: span_handler, tcx: ty::ctxt, reachable: hashmap<ast::node_id, ()>, - reexports: ~[(str, 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>, + item_symbols: hashmap<ast::node_id, ~str>, + discrim_symbols: hashmap<ast::node_id, ~str>, link_meta: link_meta, cstore: cstore::cstore, encode_inlined_item: encode_inlined_item @@ -56,10 +56,10 @@ enum encode_ctxt = { diag: span_handler, tcx: ty::ctxt, reachable: hashmap<ast::node_id, ()>, - reexports: ~[(str, 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>, + item_symbols: hashmap<ast::node_id, ~str>, + discrim_symbols: hashmap<ast::node_id, ~str>, link_meta: link_meta, cstore: cstore::cstore, encode_inlined_item: encode_inlined_item, @@ -109,7 +109,7 @@ 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>]) { + path: ~[ident], &index: ~[entry<~str>]) { for variants.each |variant| { add_to_index(ebml_w, path, index, variant.node.name); do ebml_w.wr_tag(tag_paths_data_item) { @@ -119,7 +119,7 @@ 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 mut full_path = ~[]; vec::push_all(full_path, path); @@ -129,7 +129,7 @@ fn add_to_index(ebml_w: ebml::writer, path: &[ident], &index: ~[entry<str>], } fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_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); do ebml_w.wr_tag(tag_paths_foreign_path) { @@ -140,7 +140,7 @@ fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_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 { again; } @@ -158,7 +158,7 @@ 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>]) { + &index: ~[entry<~str>]) { for module.items.each |it| { if !reachable(ecx, it.id) || !ast_util::is_exported(it.ident, module) { again; } @@ -220,7 +220,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, } } item_impl(*) {} - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } } @@ -232,8 +232,8 @@ fn encode_trait_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @trait_ref) { } fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate) - -> ~[entry<str>] { - let mut index: ~[entry<str>] = ~[]; + -> ~[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); @@ -243,7 +243,7 @@ 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; vec::push(index, {val: path, pos: ebml_w.writer.tell()}); @@ -264,7 +264,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) { ebml_w.end_tag(); } -fn def_to_str(did: def_id) -> str { ret #fmt["%d:%d", did.crate, did.node]; } +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]) { @@ -641,7 +641,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, do option::iter(m_dtor) |dtor| { vec::push(*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 { + + ~"_dtor"), path, if tps.len() > 0u { some(ii_dtor(dtor, item.ident, tps, local_def(item.id))) } else { none }, tps, ast_util::dtor_dec()); @@ -766,7 +766,7 @@ 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(); } - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } @@ -802,7 +802,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, ebml_w.start_tag(tag_items_data); vec::push(*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| { @@ -886,7 +886,7 @@ fn encode_index<T>(ebml_w: ebml::writer, buckets: ~[@~[entry<T>]], ebml_w.end_tag(); } -fn write_str(writer: io::writer, &&s: str) { writer.write_str(s); } +fn write_str(writer: io::writer, &&s: ~str) { writer.write_str(s); } fn write_int(writer: io::writer, &&n: int) { writer.write_be_uint(n as uint, 4u); @@ -948,22 +948,22 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { fn synthesize_link_attr(ecx: @encode_ctxt, items: ~[@meta_item]) -> attribute { - assert (*ecx.link_meta.name != ""); - assert (*ecx.link_meta.vers != ""); + assert (*ecx.link_meta.name != ~""); + assert (*ecx.link_meta.vers != ~""); let name_item = - attr::mk_name_value_item_str(@"name"/~, *ecx.link_meta.name); + attr::mk_name_value_item_str(@~"name", *ecx.link_meta.name); let vers_item = - attr::mk_name_value_item_str(@"vers"/~, *ecx.link_meta.vers); + attr::mk_name_value_item_str(@~"vers", *ecx.link_meta.vers); let other_items = { - let tmp = attr::remove_meta_items_by_name(items, @"name"/~); - attr::remove_meta_items_by_name(tmp, @"vers"/~) + let tmp = attr::remove_meta_items_by_name(items, @~"name"); + attr::remove_meta_items_by_name(tmp, @~"vers") }; let meta_items = vec::append(~[name_item, vers_item], other_items); - let link_item = attr::mk_list_item(@"link"/~, meta_items); + let link_item = attr::mk_list_item(@~"link", meta_items); ret attr::mk_attr(link_item); } @@ -973,7 +973,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { for crate.node.attrs.each |attr| { vec::push( attrs, - if *attr::get_attr_name(attr) != "link" { + if *attr::get_attr_name(attr) != ~"link" { attr } else { alt attr.node.value.node { @@ -1046,7 +1046,7 @@ fn encode_crate_dep(ebml_w: ebml::writer, dep: decoder::crate_dep) { ebml_w.end_tag(); } -fn encode_hash(ebml_w: ebml::writer, hash: str) { +fn encode_hash(ebml_w: ebml::writer, hash: ~str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::bytes(hash)); ebml_w.end_tag(); @@ -1099,7 +1099,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] { } // Get the encoded string for a type -fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> str { +fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { let cx = @{diag: tcx.diag, ds: def_to_str, tcx: tcx, diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index ab42afb1edd..cb773589dcc 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -31,11 +31,11 @@ iface filesearch { } fn mk_filesearch(maybe_sysroot: option<path>, - target_triple: str, + target_triple: ~str, addl_lib_search_paths: ~[path]) -> filesearch { type filesearch_impl = {sysroot: path, addl_lib_search_paths: ~[path], - target_triple: str}; + target_triple: ~str}; impl of filesearch for filesearch_impl { fn sysroot() -> path { self.sysroot } fn lib_search_paths() -> ~[path] { @@ -88,12 +88,12 @@ 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 { + target_triple: ~str) -> path { let path = vec::append(~[sysroot], relative_target_lib_path(target_triple)); let path = path::connect_many(path); @@ -102,9 +102,9 @@ fn make_target_lib_path(sysroot: path, fn get_default_sysroot() -> path { alt os::self_exe_path() { - option::some(p) { path::normalize(path::connect(p, "..")) } + option::some(p) { path::normalize(path::connect(p, ~"..")) } option::none { - fail "can't determine value for sysroot"; + fail ~"can't determine value for sysroot"; } } } @@ -116,30 +116,30 @@ fn get_sysroot(maybe_sysroot: option<path>) -> path { } } -fn get_cargo_sysroot() -> result<path, str> { - let path = ~[get_default_sysroot(), libdir(), "cargo"]; +fn get_cargo_sysroot() -> result<path, ~str> { + let path = ~[get_default_sysroot(), libdir(), ~"cargo"]; result::ok(path::connect_many(path)) } -fn get_cargo_root() -> result<path, str> { - alt os::getenv("CARGO_ROOT") { +fn get_cargo_root() -> result<path, ~str> { + alt os::getenv(~"CARGO_ROOT") { some(_p) { result::ok(_p) } none { alt os::homedir() { - some(_q) { result::ok(path::connect(_q, ".cargo")) } - none { result::err("no CARGO_ROOT or home directory") } + some(_q) { result::ok(path::connect(_q, ~".cargo")) } + none { result::err(~"no CARGO_ROOT or home directory") } } } } } -fn get_cargo_root_nearest() -> result<path, str> { +fn get_cargo_root_nearest() -> result<path, ~str> { do result::chain(get_cargo_root()) |p| { let cwd = os::getcwd(); let mut dirname = path::dirname(cwd); let mut dirpath = path::split(dirname); - let cwd_cargo = path::connect(cwd, ".cargo"); - let mut par_cargo = path::connect(dirname, ".cargo"); + let cwd_cargo = path::connect(cwd, ~".cargo"); + let mut par_cargo = path::connect(dirname, ~".cargo"); let mut rslt = result::ok(cwd_cargo); if !os::path_is_dir(cwd_cargo) && cwd_cargo != p { @@ -150,20 +150,20 @@ fn get_cargo_root_nearest() -> result<path, str> { } vec::pop(dirpath); dirname = path::dirname(dirname); - par_cargo = path::connect(dirname, ".cargo"); + par_cargo = path::connect(dirname, ~".cargo"); } } rslt } } -fn get_cargo_lib_path() -> result<path, str> { +fn get_cargo_lib_path() -> result<path, ~str> { do result::chain(get_cargo_root()) |p| { result::ok(path::connect(p, libdir())) } } -fn get_cargo_lib_path_nearest() -> result<path, str> { +fn get_cargo_lib_path_nearest() -> result<path, ~str> { do result::chain(get_cargo_root_nearest()) |p| { result::ok(path::connect(p, libdir())) } @@ -171,10 +171,10 @@ fn get_cargo_lib_path_nearest() -> result<path, str> { // The name of the directory rustc expects libraries to be located. // On Unix should be "lib", on windows "bin" -fn libdir() -> str { +fn libdir() -> ~str { let libdir = #env("CFG_LIBDIR"); if str::is_empty(libdir) { - fail "rustc compiled without CFG_LIBDIR environment variable"; + fail ~"rustc compiled without CFG_LIBDIR environment variable"; } libdir } diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index 32ed2c527bb..862e6b90e7d 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -31,12 +31,12 @@ type ctxt = { span: span, ident: ast::ident, metas: ~[@ast::meta_item], - hash: str, + 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 { @@ -46,33 +46,33 @@ 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) } -fn libname(cx: ctxt) -> {prefix: str, suffix: str} { - if cx.static { ret {prefix: "lib", suffix: ".rlib"}; } +fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} { + if cx.static { ret {prefix: ~"lib", suffix: ~".rlib"}; } alt cx.os { - os_win32 { ret {prefix: "", suffix: ".dll"}; } - os_macos { ret {prefix: "lib", suffix: ".dylib"}; } - os_linux { ret {prefix: "lib", suffix: ".so"}; } - os_freebsd { ret {prefix: "lib", suffix: ".so"}; } + os_win32 { ret {prefix: ~"", suffix: ~".dll"}; } + os_macos { ret {prefix: ~"lib", suffix: ~".dylib"}; } + os_linux { ret {prefix: ~"lib", suffix: ~".so"}; } + os_freebsd { ret {prefix: ~"lib", suffix: ~".so"}; } } } fn find_library_crate_aux(cx: ctxt, - nn: {prefix: str, suffix: str}, + 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 prefix: ~str = nn.prefix + *crate_name + ~"-"; + let suffix: ~str = nn.suffix; let mut matches = ~[]; filesearch::search(filesearch, |path| { #debug("inspecting file %s", path); - let f: str = path::basename(path); + let f: ~str = path::basename(path); if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) { #debug("skipping %s, doesn't look like %s*%s", path, prefix, suffix); @@ -105,7 +105,7 @@ fn find_library_crate_aux(cx: ctxt, } else { cx.diag.span_err( cx.span, #fmt("multiple matching crates for `%s`", *crate_name)); - cx.diag.handler().note("candidates:"); + cx.diag.handler().note(~"candidates:"); for matches.each |match| { cx.diag.handler().note(#fmt("path: %s", match.ident)); let attrs = decoder::get_crate_attributes(match.data); @@ -116,8 +116,8 @@ fn find_library_crate_aux(cx: ctxt, } } -fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @str/~ { - let name_items = attr::find_meta_items_by_name(metas, "name"); +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) { alt attr::get_meta_item_value_str(i) { @@ -127,7 +127,7 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @str/~ { _ { fail } } } - none { fail "expected to find the crate name" } + none { fail ~"expected to find the crate name" } } } @@ -138,7 +138,7 @@ fn note_linkage_attrs(diag: span_handler, attrs: ~[ast::attribute]) { } fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item], - hash: str) -> bool { + hash: ~str) -> bool { let attrs = decoder::get_crate_attributes(crate_data); let linkage_metas = attr::find_linkage_metas(attrs); if hash.is_not_empty() { @@ -170,7 +170,7 @@ 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) }); @@ -196,21 +196,21 @@ fn get_metadata_section(os: os, ret option::none::<@~[u8]>; } -fn meta_section_name(os: os) -> str { +fn meta_section_name(os: os) -> ~str { alt os { - os_macos { "__DATA,__note.rustc" } - os_win32 { ".note.rustc" } - os_linux { ".note.rustc" } - os_freebsd { ".note.rustc" } + os_macos { ~"__DATA,__note.rustc" } + os_win32 { ~".note.rustc" } + os_linux { ~".note.rustc" } + os_freebsd { ~".note.rustc" } } } // A diagnostic function for dumping crate metadata to an output stream -fn list_file_metadata(os: os, path: str, out: io::writer) { +fn list_file_metadata(os: os, path: ~str, out: io::writer) { alt get_metadata_section(os, path) { option::some(bytes) { decoder::list_crate_metadata(bytes, out); } option::none { - out.write_str("could not find metadata in " + path + ".\n"); + out.write_str(~"could not find metadata in " + path + ~".\n"); } } } diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 31a92b72f97..c0420f49a09 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -42,7 +42,7 @@ fn parse_ident(st: @pstate, last: char) -> ast::ident { fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) -> ast::ident { - let mut rslt = ""; + let mut rslt = ~""; while !is_last(peek(st)) { rslt += str::from_byte(next_byte(st)); } @@ -170,7 +170,7 @@ fn parse_proto(c: char) -> ast::proto { '*' { ast::proto_any } '&' { ast::proto_block } 'n' { ast::proto_bare } - _ { fail "illegal fn type kind " + str::from_char(c); } + _ { fail ~"illegal fn type kind " + str::from_char(c); } } } @@ -197,7 +197,7 @@ 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]/~ = []/~; + let mut params: ~[ty::t] = ~[]; while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } st.pos = st.pos + 1u; @@ -245,8 +245,8 @@ fn parse_opt<T>(st: @pstate, f: fn() -> T) -> option<T> { } } -fn parse_str(st: @pstate, term: char) -> str { - let mut result = ""; +fn parse_str(st: @pstate, term: char) -> ~str { + let mut result = ~""; while peek(st) != term { result += str::from_byte(next_byte(st)); } @@ -320,7 +320,7 @@ 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, '='); vec::push(fields, {ident: name, mt: parse_mt(st, conv)}); @@ -330,7 +330,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'T' { assert (next(st) == '['); - let mut params = []/~; + let mut params = ~[]; while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } st.pos = st.pos + 1u; ret ty::mk_tup(st.tcx, params); @@ -403,7 +403,7 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { } fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id { - let mut def = []/~; + let mut def = ~[]; while peek(st) != '|' { vec::push(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 } diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 026f06bc8b0..6cb430c519f 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -19,7 +19,7 @@ export enc_mode; type ctxt = { diag: span_handler, // Def -> str Callback: - ds: fn@(def_id) -> str, + ds: fn@(def_id) -> ~str, // The type context. tcx: ty::ctxt, reachable: fn@(node_id) -> bool, @@ -29,7 +29,7 @@ type ctxt = { // Compact string representation for ty.t values. API ty_str & parse_from_str. // Extra parameters are for converting to/from def_ids in the string rep. // Whatever format you choose should not contain pipe characters. -type ty_abbrev = {pos: uint, len: uint, s: @str/~}; +type ty_abbrev = {pos: uint, len: uint, s: @~str}; enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap<ty::t, ty_abbrev>), } @@ -84,8 +84,8 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len); if abbrev_len < len { // I.e. it's actually an abbreviation. - let s = "#" + uint::to_str(pos, 16u) + ":" + - uint::to_str(len, 16u) + "#"; + let s = ~"#" + uint::to_str(pos, 16u) + ~":" + + uint::to_str(len, 16u) + ~"#"; let a = {pos: pos, len: len, s: @s}; abbrevs.insert(t, a); } @@ -146,7 +146,7 @@ fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) { } ty::re_var(_) { // these should not crop up after typeck - cx.diag.handler().bug("Cannot encode region variables"); + cx.diag.handler().bug(~"Cannot encode region variables"); } } } @@ -192,45 +192,45 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { alt t { ty_i { w.write_char('i'); } ty_char { w.write_char('c'); } - ty_i8 { w.write_str("MB"/&); } - ty_i16 { w.write_str("MW"/&); } - ty_i32 { w.write_str("ML"/&); } - ty_i64 { w.write_str("MD"/&); } + ty_i8 { w.write_str(&"MB"); } + ty_i16 { w.write_str(&"MW"); } + ty_i32 { w.write_str(&"ML"); } + ty_i64 { w.write_str(&"MD"); } } } ty::ty_uint(t) { alt t { ty_u { w.write_char('u'); } - ty_u8 { w.write_str("Mb"/&); } - ty_u16 { w.write_str("Mw"/&); } - ty_u32 { w.write_str("Ml"/&); } - ty_u64 { w.write_str("Md"/&); } + ty_u8 { w.write_str(&"Mb"); } + ty_u16 { w.write_str(&"Mw"); } + ty_u32 { w.write_str(&"Ml"); } + ty_u64 { w.write_str(&"Md"); } } } ty::ty_float(t) { alt t { ty_f { w.write_char('l'); } - ty_f32 { w.write_str("Mf"/&); } - ty_f64 { w.write_str("MF"/&); } + ty_f32 { w.write_str(&"Mf"); } + ty_f64 { w.write_str(&"MF"); } } } ty::ty_str { w.write_char('S'); } ty::ty_enum(def, substs) { - w.write_str("t["/&); + w.write_str(&"t["); w.write_str(cx.ds(def)); w.write_char('|'); enc_substs(w, cx, substs); w.write_char(']'); } ty::ty_trait(def, substs) { - w.write_str("x["/&); + w.write_str(&"x["); w.write_str(cx.ds(def)); w.write_char('|'); enc_substs(w, cx, substs); w.write_char(']'); } ty::ty_tup(ts) { - w.write_str("T["/&); + w.write_str(&"T["); for ts.each |t| { enc_ty(w, cx, t); } w.write_char(']'); } @@ -254,7 +254,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); } ty::ty_unboxed_vec(mt) { w.write_char('U'); enc_mt(w, cx, mt); } ty::ty_rec(fields) { - w.write_str("R["/&); + w.write_str(&"R["); for fields.each |field| { w.write_str(*field.ident); w.write_char('='); @@ -284,37 +284,37 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { w.write_char('s'); } ty::ty_type { w.write_char('Y'); } - ty::ty_opaque_closure_ptr(ty::ck_block) { w.write_str("C&"/&); } - ty::ty_opaque_closure_ptr(ty::ck_box) { w.write_str("C@"/&); } - ty::ty_opaque_closure_ptr(ty::ck_uniq) { w.write_str("C~"/&); } + ty::ty_opaque_closure_ptr(ty::ck_block) { w.write_str(&"C&"); } + ty::ty_opaque_closure_ptr(ty::ck_box) { w.write_str(&"C@"); } + ty::ty_opaque_closure_ptr(ty::ck_uniq) { w.write_str(&"C~"); } ty::ty_constr(ty, cs) { - w.write_str("A["/&); + w.write_str(&"A["); enc_ty(w, cx, ty); for cs.each |tc| { enc_ty_constr(w, cx, tc); } w.write_char(']'); } ty::ty_opaque_box { w.write_char('B'); } ty::ty_class(def, substs) { - #debug("~~~~ %s", "a["); - w.write_str("a["/&); + #debug("~~~~ %s", ~"a["); + w.write_str(&"a["); let s = cx.ds(def); #debug("~~~~ %s", s); w.write_str(s); - #debug("~~~~ %s", "|"); + #debug("~~~~ %s", ~"|"); w.write_char('|'); enc_substs(w, cx, substs); - #debug("~~~~ %s", "]"); + #debug("~~~~ %s", ~"]"); w.write_char(']'); } } } fn enc_proto(w: io::writer, proto: proto) { alt proto { - proto_uniq { w.write_str("f~"/&); } - proto_box { w.write_str("f@"/&); } - proto_block { w.write_str("f&"); } - proto_any { w.write_str("f*"/&); } - proto_bare { w.write_str("fn"/&); } + proto_uniq { w.write_str(&"f~"); } + proto_box { w.write_str(&"f@"); } + proto_block { w.write_str(~"f&"); } + proto_any { w.write_str(&"f*"); } + proto_bare { w.write_str(&"fn"); } } } diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index a4810e77b56..2211f62f235 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -433,10 +433,10 @@ fn encode_vtable_res(ecx: @e::encode_ctxt, fn encode_vtable_origin(ecx: @e::encode_ctxt, ebml_w: ebml::writer, vtable_origin: typeck::vtable_origin) { - do ebml_w.emit_enum("vtable_origin") { + do ebml_w.emit_enum(~"vtable_origin") { alt vtable_origin { typeck::vtable_static(def_id, tys, vtable_res) { - do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) { + do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_def_id(def_id) } @@ -449,7 +449,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } } typeck::vtable_param(pn, bn) { - do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) { + do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_uint(pn); } @@ -459,7 +459,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } } typeck::vtable_trait(def_id, tys) { - do ebml_w.emit_enum_variant("vtable_trait", 1u, 3u) { + do ebml_w.emit_enum_variant(~"vtable_trait", 1u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_def_id(def_id) } @@ -480,7 +480,7 @@ impl helpers for ebml::ebml_deserializer { fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin { - do self.read_enum("vtable_origin") { + do self.read_enum(~"vtable_origin") { do self.read_enum_variant |i| { alt check i { 0u { @@ -552,15 +552,15 @@ impl helpers for ebml::writer { fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) { do self.emit_rec { - do self.emit_rec_field("bounds", 0u) { + do self.emit_rec_field(~"bounds", 0u) { do self.emit_from_vec(*tpbt.bounds) |bs| { self.emit_bounds(ecx, bs); } } - do self.emit_rec_field("rp", 1u) { + do self.emit_rec_field(~"rp", 1u) { self.emit_bool(tpbt.rp); } - do self.emit_rec_field("ty", 2u) { + do self.emit_rec_field(~"ty", 2u) { self.emit_ty(ecx, tpbt.ty); } } @@ -755,13 +755,13 @@ impl decoder for ebml::ebml_deserializer { -> ty::ty_param_bounds_and_ty { do self.read_rec { { - bounds: self.read_rec_field("bounds", 0u, || { + bounds: self.read_rec_field(~"bounds", 0u, || { @self.read_to_vec(|| self.read_bounds(xcx) ) }), - rp: self.read_rec_field("rp", 1u, || { + rp: self.read_rec_field(~"rp", 1u, || { self.read_bool() }), - ty: self.read_rec_field("ty", 2u, || { + ty: self.read_rec_field(~"ty", 2u, || { self.read_ty(xcx) }) } diff --git a/src/rustc/middle/block_use.rs b/src/rustc/middle/block_use.rs index e6bafb4c48a..6c103915aaf 100644 --- a/src/rustc/middle/block_use.rs +++ b/src/rustc/middle/block_use.rs @@ -16,7 +16,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) { alt ty::get(ty::expr_ty(cx.tcx, ex)).struct { ty::ty_fn({proto: p, _}) if is_blockish(p) { cx.tcx.sess.span_err(ex.span, - "expressions with stack closure type \ + ~"expressions with stack closure type \ can only appear in callee or (by-ref) argument position"); } _ {} diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 01d04fa167a..4db8ae6705d 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -185,7 +185,7 @@ fn check_crate(tcx: ty::ctxt, check_loans::check_loans(bccx, req_maps, crate); if tcx.sess.borrowck_stats() { - io::println("--- borrowck stats ---"); + io::println(~"--- borrowck stats ---"); io::println(#fmt["paths requiring guarantees: %u", bccx.guaranteed_paths]); io::println(#fmt["paths requiring loans : %s", @@ -200,7 +200,7 @@ fn check_crate(tcx: ty::ctxt, ret (bccx.root_map, bccx.mutbl_map); - fn make_stat(bccx: borrowck_ctxt, stat: uint) -> str { + fn make_stat(bccx: borrowck_ctxt, stat: uint) -> ~str { let stat_f = stat as float; let total = bccx.guaranteed_paths as float; #fmt["%u (%.0f%%)", stat , stat_f * 100f / total] @@ -386,11 +386,11 @@ impl error_methods for borrowck_ctxt { self.bckerr_code_to_str(err.code)]); } - fn span_err(s: span, m: str) { + fn span_err(s: span, m: ~str) { self.tcx.sess.span_err(s, m); } - fn span_note(s: span, m: str) { + fn span_note(s: span, m: ~str) { self.tcx.sess.span_note(s, m); } @@ -408,14 +408,14 @@ impl error_methods for borrowck_ctxt { } impl to_str_methods for borrowck_ctxt { - fn cat_to_repr(cat: categorization) -> str { + fn cat_to_repr(cat: categorization) -> ~str { alt cat { - cat_special(sk_method) { "method" } - cat_special(sk_static_item) { "static_item" } - cat_special(sk_self) { "self" } - cat_special(sk_heap_upvar) { "heap-upvar" } - cat_stack_upvar(_) { "stack-upvar" } - cat_rvalue { "rvalue" } + cat_special(sk_method) { ~"method" } + cat_special(sk_static_item) { ~"static_item" } + cat_special(sk_self) { ~"self" } + cat_special(sk_heap_upvar) { ~"heap-upvar" } + cat_stack_upvar(_) { ~"stack-upvar" } + cat_rvalue { ~"rvalue" } cat_local(node_id) { #fmt["local(%d)", node_id] } cat_binding(node_id) { #fmt["binding(%d)", node_id] } cat_arg(node_id) { #fmt["arg(%d)", node_id] } @@ -430,33 +430,33 @@ impl to_str_methods for borrowck_ctxt { } } - fn mut_to_str(mutbl: ast::mutability) -> str { + fn mut_to_str(mutbl: ast::mutability) -> ~str { alt mutbl { - m_mutbl { "mutable" } - m_const { "const" } - m_imm { "immutable" } + m_mutbl { ~"mutable" } + m_const { ~"const" } + m_imm { ~"immutable" } } } - fn ptr_sigil(ptr: ptr_kind) -> str { + fn ptr_sigil(ptr: ptr_kind) -> ~str { alt ptr { - uniq_ptr { "~" } - gc_ptr { "@" } - region_ptr { "&" } - unsafe_ptr { "*" } + uniq_ptr { ~"~" } + gc_ptr { ~"@" } + region_ptr { ~"&" } + unsafe_ptr { ~"*" } } } - fn comp_to_repr(comp: comp_kind) -> str { + fn comp_to_repr(comp: comp_kind) -> ~str { alt comp { comp_field(fld, _) { *fld } - comp_index(*) { "[]" } - comp_tuple { "()" } - comp_variant(_) { "<enum>" } + comp_index(*) { ~"[]" } + comp_tuple { ~"()" } + comp_variant(_) { ~"<enum>" } } } - fn lp_to_str(lp: @loan_path) -> str { + fn lp_to_str(lp: @loan_path) -> ~str { alt *lp { lp_local(node_id) { #fmt["local(%d)", node_id] @@ -475,56 +475,56 @@ impl to_str_methods for borrowck_ctxt { } } - fn cmt_to_repr(cmt: cmt) -> str { + fn cmt_to_repr(cmt: cmt) -> ~str { #fmt["{%s id:%d m:%s lp:%s ty:%s}", self.cat_to_repr(cmt.cat), cmt.id, self.mut_to_str(cmt.mutbl), - cmt.lp.map_default("none", |p| self.lp_to_str(p) ), + cmt.lp.map_default(~"none", |p| self.lp_to_str(p) ), ty_to_str(self.tcx, cmt.ty)] } - fn pk_to_sigil(pk: ptr_kind) -> str { + fn pk_to_sigil(pk: ptr_kind) -> ~str { alt pk { - uniq_ptr {"~"} - gc_ptr {"@"} - region_ptr {"&"} - unsafe_ptr {"*"} + uniq_ptr {~"~"} + gc_ptr {~"@"} + region_ptr {~"&"} + unsafe_ptr {~"*"} } } - fn cmt_to_str(cmt: cmt) -> str { + fn cmt_to_str(cmt: cmt) -> ~str { let mut_str = self.mut_to_str(cmt.mutbl); alt cmt.cat { - cat_special(sk_method) { "method" } - cat_special(sk_static_item) { "static item" } - cat_special(sk_self) { "self reference" } + cat_special(sk_method) { ~"method" } + cat_special(sk_static_item) { ~"static item" } + cat_special(sk_self) { ~"self reference" } cat_special(sk_heap_upvar) { - "captured outer variable in a heap closure" + ~"captured outer variable in a heap closure" } - cat_rvalue { "non-lvalue" } - cat_local(_) { mut_str + " local variable" } - cat_binding(_) { "pattern binding" } - cat_arg(_) { "argument" } + cat_rvalue { ~"non-lvalue" } + cat_local(_) { mut_str + ~" local variable" } + cat_binding(_) { ~"pattern binding" } + cat_arg(_) { ~"argument" } cat_deref(_, _, pk) { #fmt["dereference of %s %s pointer", mut_str, self.pk_to_sigil(pk)] } cat_stack_upvar(_) { - "captured outer " + mut_str + " variable in a stack closure" + ~"captured outer " + mut_str + ~" variable in a stack closure" } - cat_comp(_, comp_field(*)) { mut_str + " field" } - cat_comp(_, comp_tuple) { "tuple content" } - cat_comp(_, comp_variant(_)) { "enum content" } + cat_comp(_, comp_field(*)) { mut_str + ~" field" } + cat_comp(_, comp_tuple) { ~"tuple content" } + cat_comp(_, comp_variant(_)) { ~"enum content" } cat_comp(_, comp_index(t, _)) { alt ty::get(t).struct { ty::ty_vec(*) | ty::ty_evec(*) { - mut_str + " vec content" + mut_str + ~" vec content" } ty::ty_str | ty::ty_estr(*) { - mut_str + " str content" + mut_str + ~" str content" } - _ { mut_str + " indexed content" } + _ { mut_str + ~" indexed content" } } } cat_discr(cmt, _) { @@ -533,20 +533,20 @@ impl to_str_methods for borrowck_ctxt { } } - fn bckerr_code_to_str(code: bckerr_code) -> str { + fn bckerr_code_to_str(code: bckerr_code) -> ~str { alt code { err_mutbl(req, act) { #fmt["creating %s alias to aliasable, %s memory", self.mut_to_str(req), self.mut_to_str(act)] } err_mut_uniq { - "unique value in aliasable, mutable location" + ~"unique value in aliasable, mutable location" } err_mut_variant { - "enum variant in aliasable, mutable location" + ~"enum variant in aliasable, mutable location" } err_preserve_gc { - "GC'd value would have to be preserved for longer \ + ~"GC'd value would have to be preserved for longer \ than the scope of the function" } } diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index 4977af45b7e..d32d5dfd4a9 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -70,11 +70,11 @@ impl methods for assignment_type { at_mutbl_ref {false} } } - fn ing_form(desc: str) -> str { + fn ing_form(desc: ~str) -> ~str { alt self { - at_straight_up { "assigning to " + desc } - at_swap { "swapping to and from " + desc } - at_mutbl_ref { "taking mut reference to " + desc } + at_straight_up { ~"assigning to " + desc } + at_swap { ~"swapping to and from " + desc } + at_mutbl_ref { ~"taking mut reference to " + desc } } } } @@ -381,7 +381,7 @@ impl methods for check_loan_ctxt { } } - fn report_purity_error(pc: purity_cause, sp: span, msg: str) { + fn report_purity_error(pc: purity_cause, sp: span, msg: ~str) { alt pc { pc_pure_fn { self.tcx().sess.span_err( diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index ddbd78b631c..3c21c6d0c0f 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -426,7 +426,7 @@ impl methods for gather_loan_ctxt { self.gather_pat(subcmt, subpat, arm_id, alt_id); } none { - tcx.sess.span_bug(pat.span, "Non derefable type"); + tcx.sess.span_bug(pat.span, ~"Non derefable type"); } } } diff --git a/src/rustc/middle/borrowck/loan.rs b/src/rustc/middle/borrowck/loan.rs index 84f7f5a9d15..5549ca53eb2 100644 --- a/src/rustc/middle/borrowck/loan.rs +++ b/src/rustc/middle/borrowck/loan.rs @@ -39,7 +39,7 @@ impl loan_methods for loan_ctxt { if cmt.lp.is_none() { self.bccx.tcx.sess.span_bug( cmt.span, - "loan() called with non-lendable value"); + ~"loan() called with non-lendable value"); } alt cmt.cat { @@ -47,7 +47,7 @@ impl loan_methods for loan_ctxt { // should never be loanable self.bccx.tcx.sess.span_bug( cmt.span, - "rvalue with a non-none lp"); + ~"rvalue with a non-none lp"); } cat_local(_) | cat_arg(_) | cat_stack_upvar(_) { self.ok_with_loan_of(cmt, req_mutbl) @@ -88,7 +88,7 @@ impl loan_methods for loan_ctxt { // Aliased data is simply not lendable. self.bccx.tcx.sess.span_bug( cmt.span, - "aliased ptr with a non-none lp"); + ~"aliased ptr with a non-none lp"); } } } diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index 7ec2520cd59..08d7227557b 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -25,7 +25,8 @@ impl public_methods for borrowck_ctxt { if opt_scope_id.is_some() { self.tcx.sess.span_bug( cmt.span, - "preserve() called with local and non-none opt_scope_id"); + ~"preserve() called with local and \ + non-none opt_scope_id"); } ok(()) } diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index ed7c76d39ad..9b2bcc31572 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -43,7 +43,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { let v = ~[pat]; alt is_useful(tcx, seen, v) { not_useful { - tcx.sess.span_err(pat.span, "unreachable pattern"); + tcx.sess.span_err(pat.span, ~"unreachable pattern"); } _ {} } @@ -67,8 +67,8 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { alt ty::get(ty).struct { ty::ty_bool { alt check ctor { - val(const_int(1i64)) { some(@"true"/~) } - val(const_int(0i64)) { some(@"false"/~) } + val(const_int(1i64)) { some(@~"true") } + val(const_int(0i64)) { some(@~"false") } } } ty::ty_enum(id, _) { @@ -82,9 +82,9 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { } } }; - let msg = "non-exhaustive patterns" + alt ext { - some(s) { ": " + *s + " not covered" } - none { "" } + let msg = ~"non-exhaustive patterns" + alt ext { + some(s) { ~": " + *s + ~" not covered" } + none { ~"" } }; tcx.sess.span_err(sp, msg); } @@ -344,7 +344,7 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) { visit::visit_local(loc, s, v); if is_refutable(tcx, loc.node.pat) { tcx.sess.span_err(loc.node.pat.span, - "refutable pattern in local binding"); + ~"refutable pattern in local binding"); } } diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 5ac7834c348..287c701d7d0 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -63,16 +63,16 @@ fn check_expr(sess: session, def_map: resolve::def_map, expr_unary(box(_), _) | expr_unary(uniq(_), _) | expr_unary(deref, _){ sess.span_err(e.span, - "disallowed operator in constant expression"); + ~"disallowed operator in constant expression"); ret; } expr_lit(@{node: lit_str(_), _}) { sess.span_err(e.span, - "string constants are not supported"); + ~"string constants are not supported"); } expr_binary(_, _, _) | expr_unary(_, _) { if method_map.contains_key(e.id) { - sess.span_err(e.span, "user-defined operators are not \ + sess.span_err(e.span, ~"user-defined operators are not \ allowed in constant expressions"); } } @@ -80,9 +80,9 @@ fn check_expr(sess: session, def_map: resolve::def_map, expr_cast(_, _) { let ety = ty::expr_ty(tcx, e); if !ty::type_is_numeric(ety) { - sess.span_err(e.span, "can not cast to `" + + sess.span_err(e.span, ~"can not cast to `" + util::ppaux::ty_to_str(tcx, ety) + - "` in a constant expression"); + ~"` in a constant expression"); } } expr_path(_) { @@ -90,19 +90,20 @@ fn check_expr(sess: session, def_map: resolve::def_map, some(def_const(def_id)) { if !ast_util::is_local(def_id) { sess.span_err( - e.span, "paths in constants may only refer to \ + e.span, ~"paths in constants may only refer to \ crate-local constants"); } } _ { sess.span_err( - e.span, "paths in constants may only refer to constants"); + e.span, + ~"paths in constants may only refer to constants"); } } } _ { sess.span_err(e.span, - "constant contains unimplemented expression type"); + ~"constant contains unimplemented expression type"); ret; } } @@ -112,14 +113,14 @@ fn check_expr(sess: session, def_map: resolve::def_map, if t != ty_char { if (v as u64) > ast_util::int_ty_max( if t == ty_i { sess.targ_cfg.int_type } else { t }) { - sess.span_err(e.span, "literal out of range for its type"); + sess.span_err(e.span, ~"literal out of range for its type"); } } } expr_lit(@{node: lit_uint(v, t), _}) { if v > ast_util::uint_ty_max( if t == ty_u { sess.targ_cfg.uint_type } else { t }) { - sess.span_err(e.span, "literal out of range for its type"); + sess.span_err(e.span, ~"literal out of range for its type"); } } _ {} @@ -157,7 +158,7 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map, fn visit_item(it: @item, &&env: env, v: visit::vt<env>) { if (*env.idstack).contains(it.id) { - env.sess.span_fatal(env.root_it.span, "recursive constant"); + env.sess.span_fatal(env.root_it.span, ~"recursive constant"); } (*env.idstack).push(it.id); visit::visit_item(it, env, v); diff --git a/src/rustc/middle/check_loop.rs b/src/rustc/middle/check_loop.rs index 524e88fc49e..69bb7220a4c 100644 --- a/src/rustc/middle/check_loop.rs +++ b/src/rustc/middle/check_loop.rs @@ -30,17 +30,17 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { } expr_break { if !cx.in_loop { - tcx.sess.span_err(e.span, "`break` outside of loop"); + tcx.sess.span_err(e.span, ~"`break` outside of loop"); } } expr_again { if !cx.in_loop { - tcx.sess.span_err(e.span, "`again` outside of loop"); + tcx.sess.span_err(e.span, ~"`again` outside of loop"); } } expr_ret(oe) { if !cx.can_ret { - tcx.sess.span_err(e.span, "`ret` in block function"); + tcx.sess.span_err(e.span, ~"`ret` in block function"); } visit::visit_expr_opt(oe, cx, v); } diff --git a/src/rustc/middle/const_eval.rs b/src/rustc/middle/const_eval.rs index cc36455da06..cdb1a3b10d0 100644 --- a/src/rustc/middle/const_eval.rs +++ b/src/rustc/middle/const_eval.rs @@ -6,7 +6,7 @@ enum const_val { const_float(f64), const_int(i64), const_uint(u64), - const_str(str), + const_str(~str), } // FIXME: issue #1417 @@ -159,7 +159,7 @@ fn compare_const_vals(a: const_val, b: const_val) -> int { } } _ { - fail "compare_const_vals: ill-typed comparison"; + fail ~"compare_const_vals: ill-typed comparison"; } } } diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index ae581290ab4..7bbc2db0665 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -51,7 +51,7 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk) ast::expr_path(path) { let mut i = 0; alt def_map.find(expr.id) { - none { fail ("Not found: " + path_to_str(path)) } + none { fail (~"Not found: " + path_to_str(path)) } some(df) { let mut def = df; while i < depth { @@ -106,7 +106,7 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) -> fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { alt tcx.freevars.find(fid) { - none { fail "get_freevars: " + int::str(fid) + " has no freevars"; } + none { fail ~"get_freevars: " + int::str(fid) + ~" has no freevars"; } some(d) { ret d; } } } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index b4709820276..7d89b4c701a 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -39,18 +39,18 @@ import lint::{non_implicitly_copyable_typarams,implicit_copies}; // primitives in the stdlib are explicitly annotated to only take sendable // types. -fn kind_to_str(k: kind) -> str { +fn kind_to_str(k: kind) -> ~str { let mut kinds = ~[]; if ty::kind_lteq(kind_const(), k) { - vec::push(kinds, "const"); + vec::push(kinds, ~"const"); } if ty::kind_can_be_copied(k) { - vec::push(kinds, "copy"); + vec::push(kinds, ~"copy"); } if ty::kind_can_be_sent(k) { - vec::push(kinds, "send"); + vec::push(kinds, ~"send"); } - str::connect(kinds, " ") + str::connect(kinds, ~" ") } type rval_map = std::map::hashmap<node_id, ()>; @@ -125,13 +125,13 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { if fv.is_none() { cx.tcx.sess.span_err( sp, - "cannot capture values explicitly with a block closure"); + ~"cannot capture values explicitly with a block closure"); } } fn check_for_bare(cx: ctx, _id: node_id, _fv: option<@freevar_entry>, _is_move: bool,_var_t: ty::t, sp: span) { - cx.tcx.sess.span_err(sp, "attempted dynamic environment capture"); + cx.tcx.sess.span_err(sp, ~"attempted dynamic environment capture"); } let fty = ty::node_id_to_type(cx.tcx, id); @@ -224,13 +224,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { let t = ty::expr_ty(cx.tcx, ex); let ty_fields = alt ty::get(t).struct { ty::ty_rec(f) { f } - _ { cx.tcx.sess.span_bug(ex.span, "bad expr type in record"); } + _ { cx.tcx.sess.span_bug(ex.span, ~"bad expr type in record"); } }; for ty_fields.each |tf| { if !vec::any(fields, |f| f.node.ident == tf.ident ) && !ty::kind_can_be_copied(ty::type_kind(cx.tcx, tf.mt.ty)) { cx.tcx.sess.span_err(ex.span, - "copying a noncopyable value"); + ~"copying a noncopyable value"); } } } @@ -340,15 +340,15 @@ fn check_bounds(cx: ctx, id: node_id, sp: span, cx.tcx.sess.span_lint( non_implicitly_copyable_typarams, id, cx.current_item, sp, - "instantiating copy type parameter with a \ + ~"instantiating copy type parameter with a \ not implicitly copyable type"); } else { cx.tcx.sess.span_err( sp, - "instantiating a type parameter with an incompatible type " + - "(needs `" + kind_to_str(p_kind) + - "`, got `" + kind_to_str(kind) + - "`, missing `" + kind_to_str(p_kind - kind) + "`)"); + ~"instantiating a type parameter with an incompatible type " + + ~"(needs `" + kind_to_str(p_kind) + + ~"`, got `" + kind_to_str(kind) + + ~"`, missing `" + kind_to_str(p_kind - kind) + ~"`)"); } } } @@ -381,7 +381,7 @@ fn check_copy_ex(cx: ctx, ex: @expr, implicit_copy: bool) { } fn check_imm_free_var(cx: ctx, def: def, sp: span) { - let msg = "mutable variables cannot be implicitly captured; \ + let msg = ~"mutable variables cannot be implicitly captured; \ use a capture clause"; alt def { def_local(_, is_mutbl) { @@ -413,18 +413,18 @@ fn check_copy(cx: ctx, id: node_id, ty: ty::t, sp: span, implicit_copy: bool) { let k = ty::type_kind(cx.tcx, ty); if !ty::kind_can_be_copied(k) { - cx.tcx.sess.span_err(sp, "copying a noncopyable value"); + cx.tcx.sess.span_err(sp, ~"copying a noncopyable value"); } else if implicit_copy && !ty::kind_can_be_implicitly_copied(k) { cx.tcx.sess.span_lint( implicit_copies, id, cx.current_item, sp, - "implicitly copying a non-implicitly-copyable value"); + ~"implicitly copying a non-implicitly-copyable value"); } } fn check_send(cx: ctx, ty: ty::t, sp: span) { if !ty::kind_can_be_sent(ty::type_kind(cx.tcx, ty)) { - cx.tcx.sess.span_err(sp, "not a sendable value"); + cx.tcx.sess.span_err(sp, ~"not a sendable value"); } } diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index ce91f5ce27e..adb333def8d 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -73,10 +73,10 @@ enum level { } type lint_spec = @{lint: lint, - desc: str, + desc: ~str, default: level}; -type lint_dict = hashmap<str,lint_spec>; +type lint_dict = hashmap<~str,lint_spec>; /* Pass names should not contain a '-', as the compiler normalizes @@ -84,55 +84,55 @@ type lint_dict = hashmap<str,lint_spec>; */ fn get_lint_dict() -> lint_dict { let v = ~[ - ("ctypes", + (~"ctypes", @{lint: ctypes, - desc: "proper use of core::libc types in foreign modules", + desc: ~"proper use of core::libc types in foreign modules", default: warn}), - ("unused_imports", + (~"unused_imports", @{lint: unused_imports, - desc: "imports that are never used", + desc: ~"imports that are never used", default: ignore}), - ("while_true", + (~"while_true", @{lint: while_true, - desc: "suggest using loop { } instead of while(true) { }", + desc: ~"suggest using loop { } instead of while(true) { }", default: warn}), - ("path_statement", + (~"path_statement", @{lint: path_statement, - desc: "path statements with no effect", + desc: ~"path statements with no effect", default: warn}), - ("old_vecs", + (~"old_vecs", @{lint: old_vecs, - desc: "old (deprecated) vectors", + desc: ~"old (deprecated) vectors", default: error}), - ("old_strs", + (~"old_strs", @{lint: old_strs, - desc: "old (deprecated) strings", + desc: ~"old (deprecated) strings", default: warn}), - ("unrecognized_warning", + (~"unrecognized_warning", @{lint: unrecognized_warning, - desc: "unrecognized warning attribute", + desc: ~"unrecognized warning attribute", default: warn}), - ("non_implicitly_copyable_typarams", + (~"non_implicitly_copyable_typarams", @{lint: non_implicitly_copyable_typarams, - desc: "passing non implicitly copyable types as copy type params", + desc: ~"passing non implicitly copyable types as copy type params", default: warn}), - ("vecs_not_implicitly_copyable", + (~"vecs_not_implicitly_copyable", @{lint: vecs_not_implicitly_copyable, - desc: "make vecs and strs not implicitly copyable\ + desc: ~"make vecs and strs not implicitly copyable\ (`err` is ignored; only checked at top level", default: warn}), - ("implicit_copies", + (~"implicit_copies", @{lint: implicit_copies, - desc: "implicit copies of non implicitly copyable data", + desc: ~"implicit copies of non implicitly copyable data", default: warn}) ]; @@ -198,7 +198,7 @@ impl methods for ctxt { } } - fn span_lint(level: level, span: span, msg: str) { + fn span_lint(level: level, span: span, msg: ~str) { self.sess.span_lint_level(level, span, msg); } @@ -211,7 +211,8 @@ impl methods for ctxt { let mut new_ctxt = self; - let metas = attr::attr_metas(attr::find_attrs_by_name(attrs, "warn")); + let metas = attr::attr_metas( + attr::find_attrs_by_name(attrs, ~"warn")); for metas.each |meta| { alt meta.node { ast::meta_list(_, metas) { @@ -239,14 +240,14 @@ impl methods for ctxt { _ { self.sess.span_err( meta.span, - "malformed warning attribute"); + ~"malformed warning attribute"); } } } } _ { self.sess.span_err(meta.span, - "malformed warning attribute"); + ~"malformed warning attribute"); } } } @@ -256,12 +257,12 @@ impl methods for ctxt { } -fn lookup_lint(dict: lint_dict, s: str) - -> (str, option<(lint, level)>) { - let s = str::replace(s, "-", "_"); - let (name, level) = if s.starts_with("no_") { +fn lookup_lint(dict: lint_dict, s: ~str) + -> (~str, option<(lint, level)>) { + let s = str::replace(s, ~"-", ~"_"); + let (name, level) = if s.starts_with(~"no_") { (s.substr(3u, s.len() - 3u), ignore) - } else if s.starts_with("err_") { + } else if s.starts_with(~"err_") { (s.substr(4u, s.len() - 4u), error) } else { (s, warn) @@ -341,7 +342,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) { cx.sess.span_lint( while_true, e.id, it.id, e.span, - "denote infinite loops with loop { ... }"); + ~"denote infinite loops with loop { ... }"); } _ {} } @@ -367,14 +368,14 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { cx.sess.span_lint( ctypes, id, fn_id, ty.span, - "found rust type `int` in foreign module, while \ + ~"found rust type `int` in foreign module, while \ libc::c_int or libc::c_long should be used"); } ast::def_prim_ty(ast::ty_uint(ast::ty_u)) { cx.sess.span_lint( ctypes, id, fn_id, ty.span, - "found rust type `uint` in foreign module, while \ + ~"found rust type `uint` in foreign module, while \ libc::c_uint or libc::c_ulong should be used"); } _ { } @@ -411,7 +412,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { cx.sess.span_lint( path_statement, id, it.id, s.span, - "path statement with no effect"); + ~"path statement with no effect"); } _ {} } @@ -432,13 +433,13 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) { if ! uses_vstore.contains_key(e.id) { cx.sess.span_lint( old_vecs, e.id, it.id, - e.span, "deprecated vec expr"); + e.span, ~"deprecated vec expr"); } ast::expr_lit(@{node: ast::lit_str(_), span:_}) if ! uses_vstore.contains_key(e.id) { cx.sess.span_lint( old_strs, e.id, it.id, - e.span, "deprecated str expr"); + e.span, ~"deprecated str expr"); } ast::expr_vstore(@inner, _) { @@ -454,14 +455,14 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) { if ! uses_vstore.contains_key(t.id) { cx.sess.span_lint( old_vecs, t.id, it.id, - t.span, "deprecated vec type"); + t.span, ~"deprecated vec type"); } 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"); + t.span, ~"deprecated str type"); } ast::ty_vstore(inner, _) | ast::ty_box({ty: inner, _}) | diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 1987dcc0f63..6bce1ab88d1 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -153,11 +153,11 @@ fn check_crate(tcx: ty::ctxt, } impl of to_str::to_str for live_node { - fn to_str() -> str { #fmt["ln(%u)", *self] } + fn to_str() -> ~str { #fmt["ln(%u)", *self] } } impl of to_str::to_str for variable { - fn to_str() -> str { #fmt["v(%u)", *self] } + fn to_str() -> ~str { #fmt["v(%u)", *self] } } // ______________________________________________________________________ @@ -289,9 +289,9 @@ class ir_maps { fn variable_name(var: variable) -> ident { alt self.var_kinds[*var] { vk_local(_, name) | vk_arg(_, name, _) {name} - vk_field(name) {@("self." + *name)} - vk_self {@"self"/~} - vk_implicit_ret {@"<implicit-ret>"/~} + vk_field(name) {@(~"self." + *name)} + vk_self {@~"self"} + vk_implicit_ret {@~"<implicit-ret>"} } } @@ -303,7 +303,7 @@ class ir_maps { alt self.capture_map.find(expr.id) { some(caps) {caps} none { - self.tcx.sess.span_bug(expr.span, "no registered caps"); + self.tcx.sess.span_bug(expr.span, ~"no registered caps"); } } } @@ -580,7 +580,7 @@ class liveness { } none { self.tcx.sess.span_bug( - span, "Not present in def map") + span, ~"Not present in def map") } } } @@ -654,26 +654,26 @@ class liveness { for uint::range(0u, self.ir.num_vars) |var_idx| { let idx = node_base_idx + var_idx; if test(idx).is_valid() { - wr.write_str(" "); + wr.write_str(~" "); wr.write_str(variable(var_idx).to_str()); } } } - fn ln_str(ln: live_node) -> str { + fn ln_str(ln: live_node) -> ~str { do io::with_str_writer |wr| { - wr.write_str("[ln("); + wr.write_str(~"[ln("); wr.write_uint(*ln); - wr.write_str(") of kind "); + wr.write_str(~") of kind "); wr.write_str(#fmt["%?", copy self.ir.lnks[*ln]]); - wr.write_str(" reads"); + wr.write_str(~" reads"); self.write_vars(wr, ln, |idx| self.users[idx].reader ); - wr.write_str(" writes"); + wr.write_str(~" writes"); self.write_vars(wr, ln, |idx| self.users[idx].writer ); - wr.write_str(" "); - wr.write_str(" precedes "); + wr.write_str(~" "); + wr.write_str(~" precedes "); wr.write_str((copy self.successors[*ln]).to_str()); - wr.write_str("]"); + wr.write_str(~"]"); } } @@ -1003,7 +1003,7 @@ class liveness { expr_break { if !self.break_ln.is_valid() { self.tcx.sess.span_bug( - expr.span, "break with invalid break_ln"); + expr.span, ~"break with invalid break_ln"); } self.break_ln @@ -1012,7 +1012,7 @@ class liveness { expr_again { if !self.cont_ln.is_valid() { self.tcx.sess.span_bug( - expr.span, "cont with invalid cont_ln"); + expr.span, ~"cont with invalid cont_ln"); } self.cont_ln @@ -1117,7 +1117,7 @@ class liveness { } expr_mac(*) { - self.tcx.sess.span_bug(expr.span, "unexpanded macro"); + self.tcx.sess.span_bug(expr.span, ~"unexpanded macro"); } } } @@ -1505,7 +1505,7 @@ impl check_methods for @liveness { } else if ty::type_is_bot(t_ret) { // for bot return types, not ok. Function should fail. self.tcx.sess.span_err( - sp, "some control paths may return"); + sp, ~"some control paths may return"); } else { alt fk { visit::fk_ctor(*) { @@ -1513,7 +1513,7 @@ impl check_methods for @liveness { } _ { self.tcx.sess.span_err( - sp, "not all control paths return a value"); + sp, ~"not all control paths return a value"); } } } @@ -1630,11 +1630,11 @@ impl check_methods for @liveness { some(lnk_expr(span)) { self.tcx.sess.span_err( span, - "re-assignment of immutable variable"); + ~"re-assignment of immutable variable"); self.tcx.sess.span_note( orig_span, - "prior assignment occurs here"); + ~"prior assignment occurs here"); } some(lnk) { self.tcx.sess.span_bug( @@ -1671,7 +1671,7 @@ impl check_methods for @liveness { vk_self { self.tcx.sess.span_err( move_span, - "illegal move from self (cannot move out of a field of \ + ~"illegal move from self (cannot move out of a field of \ self)"); ret; } @@ -1686,7 +1686,7 @@ impl check_methods for @liveness { self.report_illegal_read(move_span, lnk, var, moved_variable); self.tcx.sess.span_note( - move_span, "move of variable occurred here"); + move_span, ~"move of variable occurred here"); } @@ -1695,9 +1695,9 @@ impl check_methods for @liveness { var: variable, rk: read_kind) { let msg = alt rk { - possibly_uninitialized_variable {"possibly uninitialized variable"} - possibly_uninitialized_field {"possibly uninitialized field"} - moved_variable {"moved variable"} + possibly_uninitialized_variable {~"possibly uninitialized variable"} + possibly_uninitialized_field {~"possibly uninitialized field"} + moved_variable {~"moved variable"} }; let name = (*self.ir).variable_name(var); alt lnk { diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 532d85645df..76851e4f778 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -150,7 +150,7 @@ type parent = option<ast::node_id>; /* Records the parameter ID of a region name. */ type binding = {node_id: ast::node_id, - name: str, + name: ~str, br: ty::bound_region}; // Mapping from a block/expr/binding to the innermost scope that @@ -265,7 +265,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, fn parent_id(cx: ctxt, span: span) -> ast::node_id { alt cx.parent { none { - cx.sess.span_bug(span, "crate should not be parent here"); + cx.sess.span_bug(span, ~"crate should not be parent here"); } some(parent_id) { parent_id @@ -505,7 +505,7 @@ impl methods for determine_rp_ctxt { fn region_is_relevant(r: @ast::region) -> bool { alt r.node { ast::re_anon {self.anon_implies_rp} - ast::re_named(@"self"/~) {true} + ast::re_named(@~"self") {true} ast::re_named(_) {false} } } diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index fb5c81caeb1..9d026b1cc20 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -104,7 +104,7 @@ type indexed_mod = { glob_imports: dvec<glob_imp_def>, mut globbed_exports: ~[ident], glob_imported_names: hashmap<ident, glob_import_state>, - path: str + path: ~str }; /* foreign modules can't contain enums, and we don't store their ASTs because @@ -254,11 +254,11 @@ fn map_crate(e: @env, c: @ast::crate) { } } - fn path_from_scope(sc: scopes, n: str) -> str { - let mut path = n + "::"; + fn path_from_scope(sc: scopes, n: ~str) -> ~str { + let mut path = n + ~"::"; do list::iter(sc) |s| { alt s { - scope_item(i) { path = *i.ident + "::" + path; } + scope_item(i) { path = *i.ident + ~"::" + path; } _ {} } } @@ -316,7 +316,7 @@ fn map_crate(e: @env, c: @ast::crate) { e.mod_map.get(ast::crate_node_id). glob_imports.push(glob); } - _ { e.sess.span_bug(vi.span, "unexpected scope in a \ + _ { e.sess.span_bug(vi.span, ~"unexpected scope in a \ glob import"); } } } @@ -343,7 +343,7 @@ fn map_crate(e: @env, c: @ast::crate) { glob_imports: dvec(), mut globbed_exports: ~[], glob_imported_names: box_str_hash(), - path: ""}); + path: ~""}); // Next, assemble the links for globbed imports and exports. let v_link_glob = @@ -379,10 +379,10 @@ fn check_unused_imports(e: @env, level: lint::level) { if !vec::contains(e.used_imports.data, k) { alt level { lint::warn { - e.sess.span_warn(sp, "unused import " + *name); + e.sess.span_warn(sp, ~"unused import " + *name); } lint::error { - e.sess.span_err(sp, "unused import " + *name); + e.sess.span_err(sp, ~"unused import " + *name); } lint::ignore { } @@ -511,7 +511,7 @@ fn resolve_names(e: @env, c: @ast::crate) { } _ { e.sess.span_err(p.span, - "not an enum variant: " + + ~"not an enum variant: " + ast_util::path_name(p)); } } @@ -525,8 +525,8 @@ fn resolve_names(e: @env, c: @ast::crate) { e.def_map.insert(pat.id, fnd); } some(fnd@ast::def_const(_)) { - e.sess.span_err(p.span, "pattern variable conflicts \ - with constant '" + *path_to_ident(p) + "'"); + e.sess.span_err(p.span, ~"pattern variable conflicts \ + with constant '" + *path_to_ident(p) + ~"'"); } // Binds a var -- nothing needs to be done _ {} @@ -552,7 +552,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item, let old_resolve_unexported = e.resolve_unexported; e.resolve_unexported |= attr::contains_name(attr::attr_metas(i.attrs), - "!resolve_unexported"); + ~"!resolve_unexported"); let sc = @cons(scope_item(i), sc); alt i.node { @@ -759,8 +759,8 @@ fn follow_import(e: env, &&sc: scopes, path: ~[ident], sp: span) -> alt dcur { some(ast::def_mod(_)) | some(ast::def_foreign_mod(_)) { ret dcur; } _ { - e.sess.span_err(sp, str::connect(path.map(|x|*x), "::") + - " does not name a module."); + e.sess.span_err(sp, str::connect(path.map(|x|*x), ~"::") + + ~" does not name a module."); ret none; } } @@ -790,7 +790,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, md = lookup(ns_module); if is_none(val) && is_none(typ) && is_none(md) && vec::len(impls) == 0u { - unresolved_err(e, cx, sp, name, "import"); + unresolved_err(e, cx, sp, name, ~"import"); } else { e.imports.insert(id, resolved(val, typ, md, @impls, name, sp)); } @@ -834,7 +834,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, option::get(e.mod_map.get(ast::crate_node_id).m).view_items) } _ { - e.sess.bug("find_imports_after: nil or unexpected scope"); + e.sess.bug(~"find_imports_after: nil or unexpected scope"); } } } @@ -885,7 +885,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)); } _ { } } @@ -893,17 +893,17 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident, // Utilities -fn ns_name(ns: namespace) -> str { +fn ns_name(ns: namespace) -> ~str { alt ns { - ns_type { "typename" } - ns_val { "name" } - ns_module { "modulename" } + ns_type { ~"typename" } + ns_val { ~"name" } + ns_module { ~"modulename" } } } enum ctxt { in_mod(def), in_scope(scopes), } -fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) { +fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: ~str) { fn find_fn_or_mod_scope(sc: scopes) -> option<scope> { for list::each(sc) |cur| { alt cur { @@ -936,18 +936,18 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) { } else if did.node != ast::crate_node_id { let paths = e.ext_map.get(did); path = @str::connect(vec::append_one(paths, path).map(|x|*x), - "::"); + ~"::"); } } } e.sess.span_err(sp, mk_unresolved_msg(path, kind)); } -fn unresolved_fatal(e: env, sp: span, id: ident, kind: str) -> ! { +fn unresolved_fatal(e: env, sp: span, id: ident, kind: ~str) -> ! { e.sess.span_fatal(sp, mk_unresolved_msg(id, kind)); } -fn mk_unresolved_msg(id: ident, kind: str) -> str { +fn mk_unresolved_msg(id: ident, kind: ~str) -> ~str { ret #fmt["unresolved %s: %s", kind, *id]; } @@ -1037,22 +1037,22 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, scope_toplevel { if ns == ns_type { ret some(ast::def_prim_ty(alt *name { - "bool" { ast::ty_bool } - "int" { ast::ty_int(ast::ty_i) } - "uint" { ast::ty_uint(ast::ty_u) } - "float" { ast::ty_float(ast::ty_f) } - "str" { ast::ty_str } - "char" { ast::ty_int(ast::ty_char) } - "i8" { ast::ty_int(ast::ty_i8) } - "i16" { ast::ty_int(ast::ty_i16) } - "i32" { ast::ty_int(ast::ty_i32) } - "i64" { ast::ty_int(ast::ty_i64) } - "u8" { ast::ty_uint(ast::ty_u8) } - "u16" { ast::ty_uint(ast::ty_u16) } - "u32" { ast::ty_uint(ast::ty_u32) } - "u64" { ast::ty_uint(ast::ty_u64) } - "f32" { ast::ty_float(ast::ty_f32) } - "f64" { ast::ty_float(ast::ty_f64) } + ~"bool" { ast::ty_bool } + ~"int" { ast::ty_int(ast::ty_i) } + ~"uint" { ast::ty_uint(ast::ty_u) } + ~"float" { ast::ty_float(ast::ty_f) } + ~"str" { ast::ty_str } + ~"char" { ast::ty_int(ast::ty_char) } + ~"i8" { ast::ty_int(ast::ty_i8) } + ~"i16" { ast::ty_int(ast::ty_i16) } + ~"i32" { ast::ty_int(ast::ty_i32) } + ~"i64" { ast::ty_int(ast::ty_i64) } + ~"u8" { ast::ty_uint(ast::ty_u8) } + ~"u16" { ast::ty_uint(ast::ty_u16) } + ~"u32" { ast::ty_uint(ast::ty_u32) } + ~"u64" { ast::ty_uint(ast::ty_u64) } + ~"f32" { ast::ty_float(ast::ty_f32) } + ~"f64" { ast::ty_float(ast::ty_f64) } _ { ret none; } })); } @@ -1071,7 +1071,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, } ast::item_trait(tps, _) { if ns == ns_type { - if *name == "self" { + if *name == ~"self" { ret some(def_self(it.id)); } ret lookup_in_ty_params(e, name, tps); @@ -1096,7 +1096,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, } } scope_method(id, tps) { - if (*name == "self" && ns == ns_val) { + if (*name == ~"self" && ns == ns_val) { ret some(ast::def_self(id)); } else if ns == ns_type { ret lookup_in_ty_params(e, name, tps); @@ -1152,9 +1152,9 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, (left_fn && local || left_fn_level2 && self_scope || scope_is_fn(hd) && left_fn && def_is_ty_arg(df)) { let msg = if ns == ns_type { - "attempt to use a type argument out of scope" + ~"attempt to use a type argument out of scope" } else { - "attempted dynamic environment-capture" + ~"attempted dynamic environment-capture" }; e.sess.span_fatal(sp, msg); } else if local || self_scope { @@ -1331,7 +1331,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint, } } } - _ { e.sess.span_bug(vi.span, "unexpected view_item in block"); } + _ { e.sess.span_bug(vi.span, ~"unexpected view_item in block"); } } } ret none; @@ -1417,7 +1417,7 @@ fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace, } _ { // Precondition - e.sess.span_bug(sp, "lookup_in_mod was passed a non-mod def"); + e.sess.span_bug(sp, ~"lookup_in_mod was passed a non-mod def"); } } } @@ -1444,7 +1444,7 @@ fn lookup_import(e: env, n_id: node_id, ns: namespace) -> option<def> { ret lookup_import(e, n_id, ns); } resolving(sp) { - e.sess.span_err(sp, "cyclic import"); + e.sess.span_err(sp, ~"cyclic import"); ret none; } resolved(val, typ, md, _, _, _) { @@ -1454,7 +1454,7 @@ fn lookup_import(e: env, n_id: node_id, ns: namespace) -> option<def> { ret alt ns { ns_val { val } ns_type { typ } ns_module { md } }; } is_glob(_,_,_) { - e.sess.bug("lookup_import: can't handle is_glob"); + e.sess.bug(~"lookup_import: can't handle is_glob"); } } } @@ -1530,7 +1530,7 @@ fn lookup_in_globs(e: env, globs: ~[glob_imp_def], sp: span, id: ident, } _ { - e.sess.span_bug(sp, "lookup_in_globs: not a glob"); + e.sess.span_bug(sp, ~"lookup_in_globs: not a glob"); } } alt lookup_in_mod(e, def.def, sp, name, ns, dr) { @@ -1551,8 +1551,8 @@ fn lookup_in_globs(e: env, globs: ~[glob_imp_def], sp: span, id: ident, let sp = match.path.span; e.sess.span_note(sp, #fmt["'%s' is imported here", *id]); } - e.sess.span_fatal(sp, "'" + *id + "' is glob-imported from" + - " multiple different modules."); + e.sess.span_fatal(sp, ~"'" + *id + ~"' is glob-imported from" + + ~" multiple different modules."); } } @@ -1712,7 +1712,7 @@ fn ns_for_def(d: def) -> namespace { ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) | ast::def_ty_param(_, _) | ast::def_prim_ty(_) | ast::def_class(_) { ns_type } - ast::def_region(_) { fail "regions are not handled by this pass" } + ast::def_region(_) { fail ~"regions are not handled by this pass" } } } @@ -1750,25 +1750,25 @@ fn check_mod_name(e: env, name: ident, entries: @list<mod_index_entry>) { let mut saw_type = false; let mut saw_value = false; let mut entries = entries; - fn dup(e: env, sp: span, word: str, name: ident) { - e.sess.span_fatal(sp, "duplicate definition of " + word + *name); + fn dup(e: env, sp: span, word: ~str, name: ident) { + e.sess.span_fatal(sp, ~"duplicate definition of " + word + *name); } loop { alt *entries { cons(entry, rest) { if !is_none(lookup_in_mie(e, entry, ns_val)) { if saw_value { - dup(e, mie_span(entry), "", name); + dup(e, mie_span(entry), ~"", name); } else { saw_value = true; } } if !is_none(lookup_in_mie(e, entry, ns_type)) { if saw_type { - dup(e, mie_span(entry), "type ", name); + dup(e, mie_span(entry), ~"type ", name); } else { saw_type = true; } } if !is_none(lookup_in_mie(e, entry, ns_module)) { if saw_mod { - dup(e, mie_span(entry), "module ", name); + dup(e, mie_span(entry), ~"module ", name); } else { saw_mod = true; } } entries = rest; @@ -1799,11 +1799,11 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) { ast::item_fn(decl, ty_params, _) { check_fn(*e, i.span, decl); ensure_unique(*e, i.span, ty_params, |tp| tp.ident, - "type parameter"); + ~"type parameter"); } ast::item_enum(_, ty_params) { ensure_unique(*e, i.span, ty_params, |tp| tp.ident, - "type parameter"); + ~"type parameter"); } ast::item_trait(_, methods) { ensure_unique(*e, i.span, methods, |m| { @@ -1816,11 +1816,11 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) { } } }, - "method"); + ~"method"); } ast::item_impl(_, _, _, methods) { ensure_unique(*e, i.span, methods, |m| m.ident, - "method"); + ~"method"); } _ { } } @@ -1834,28 +1834,28 @@ fn check_pat(e: @env, ch: checker, p: @ast::pat) { fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) { visit::visit_arm(a, x, v); - let ch0 = checker(*e, "binding"); + let ch0 = checker(*e, ~"binding"); check_pat(e, ch0, a.pats[0]); let seen0 = ch0.seen.get(); let mut i = vec::len(a.pats); while i > 1u { i -= 1u; - let ch = checker(*e, "binding"); + let ch = checker(*e, ~"binding"); check_pat(e, ch, a.pats[i]); // Ensure the bindings introduced in this pattern are the same as in // the first pattern. if ch.seen.len() != seen0.len() { e.sess.span_err(a.pats[i].span, - "inconsistent number of bindings"); + ~"inconsistent number of bindings"); } else { for ch.seen.each |name| { if is_none(vec::find(seen0, |x| str::eq(*name, *x))) { // Fight the alias checker let name_ = name; e.sess.span_err(a.pats[i].span, - "binding " + *name_ + - " does not occur in first pattern"); + ~"binding " + *name_ + + ~" does not occur in first pattern"); } } } @@ -1864,15 +1864,15 @@ fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) { fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) { visit::visit_block(b, x, v); - let values = checker(*e, "value"); - let types = checker(*e, "type"); - let mods = checker(*e, "module"); + let values = checker(*e, ~"value"); + let types = checker(*e, ~"type"); + let mods = checker(*e, ~"module"); for b.node.stmts.each |st| { alt st.node { ast::stmt_decl(d, _) { alt d.node { ast::decl_local(locs) { - let local_values = checker(*e, "value"); + let local_values = checker(*e, ~"value"); for locs.each |loc| { do pat_util::pat_bindings(e.def_map, loc.node.pat) |_i, p_sp, n| { @@ -1911,14 +1911,14 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) { fn check_fn(e: env, sp: span, decl: ast::fn_decl) { fn arg_name(a: ast::arg) -> ident { ret a.ident; } - ensure_unique(e, sp, decl.inputs, arg_name, "argument"); + ensure_unique(e, sp, decl.inputs, arg_name, ~"argument"); } fn check_expr(e: @env, ex: @ast::expr, &&x: (), v: vt<()>) { alt ex.node { ast::expr_rec(fields, _) { fn field_name(f: ast::field) -> ident { ret f.node.ident; } - ensure_unique(*e, ex.span, fields, field_name, "field"); + ensure_unique(*e, ex.span, fields, field_name, ~"field"); } _ { } } @@ -1929,16 +1929,16 @@ fn check_ty(e: @env, ty: @ast::ty, &&x: (), v: vt<()>) { alt ty.node { ast::ty_rec(fields) { fn field_name(f: ast::ty_field) -> ident { ret f.node.ident; } - ensure_unique(*e, ty.span, fields, field_name, "field"); + ensure_unique(*e, ty.span, fields, field_name, ~"field"); } _ { } } visit::visit_ty(ty, x, v); } -type checker = @{seen: dvec<ident>, kind: str, sess: session}; +type checker = @{seen: dvec<ident>, kind: ~str, sess: session}; -fn checker(e: env, kind: str) -> checker { +fn checker(e: env, kind: ~str) -> checker { ret @{seen: dvec(), kind: kind, sess: e.sess}; } @@ -1946,7 +1946,7 @@ fn check_name(ch: checker, sp: span, name: ident) { for ch.seen.each |s| { if str::eq(*s, *name) { ch.sess.span_fatal( - sp, "duplicate " + ch.kind + " name: " + *name); + sp, ~"duplicate " + ch.kind + ~" name: " + *name); } } } @@ -1956,7 +1956,7 @@ fn add_name(ch: checker, sp: span, name: ident) { } fn ensure_unique<T>(e: env, sp: span, elts: ~[T], id: fn(T) -> ident, - kind: str) { + kind: ~str) { let ch = checker(e, kind); for elts.each |elt| { add_name(ch, sp, id(elt)); } } @@ -1969,7 +1969,7 @@ fn check_exports(e: @env) { if defid.crate != ast::local_crate { // FIXME: ought to support external export-globs eventually. #2527 - e.sess.span_unimpl(sp, "glob-export of items in external crate"); + e.sess.span_unimpl(sp, ~"glob-export of items in external crate"); } else { let mid = def_id_of_def(m); @@ -1994,7 +1994,7 @@ fn check_exports(e: @env) { } } _ { - let s = "glob-export from mod with non-items"; + let s = ~"glob-export from mod with non-items"; e.sess.span_unimpl(sp, s); } } @@ -2047,7 +2047,7 @@ fn check_exports(e: @env) { maybe_add_reexport(e, export_id, t); maybe_add_reexport(e, export_id, m); } - _ { e.sess.span_bug(vi.span, "unresolved export"); } + _ { e.sess.span_bug(vi.span, ~"unresolved export"); } } } mie_item(@{id, _}) | mie_foreign_item(@{id, _}) | @@ -2142,7 +2142,8 @@ fn check_exports(e: @env) { let id = if vec::len(path.idents) == 1u { path.idents[0] } else { - e.sess.span_fatal(vp.span, "bad export name-list") + e.sess.span_fatal(vp.span, + ~"bad export name-list") }; check_export_enum_list(e, node_id, _mod, vp.span, id, ids); diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index c2f97907319..07af1e5538a 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -203,18 +203,18 @@ fn Atom(n: uint) -> Atom { } class AtomTable { - let atoms: hashmap<@str/~,Atom>; - let strings: dvec<@str/~>; + let atoms: hashmap<@~str,Atom>; + let strings: dvec<@~str>; let mut atom_count: uint; new() { - self.atoms = hashmap::<@str/~,Atom>(|x| str::hash(*x), + self.atoms = hashmap::<@~str,Atom>(|x| str::hash(*x), |x, y| str::eq(*x, *y)); self.strings = dvec(); self.atom_count = 0u; } - fn intern(string: @str/~) -> Atom { + fn intern(string: @~str) -> Atom { alt self.atoms.find(string) { none { /* fall through */ } some(atom) { ret atom; } @@ -228,11 +228,11 @@ class AtomTable { ret atom; } - fn atom_to_str(atom: Atom) -> @str/~ { + fn atom_to_str(atom: Atom) -> @~str { ret self.strings.get_elt(atom); } - fn atoms_to_strs(atoms: ~[Atom], f: fn(@str/~) -> bool) { + fn atoms_to_strs(atoms: ~[Atom], f: fn(@~str) -> bool) { for atoms.each |atom| { if !f(self.atom_to_str(atom)) { ret; @@ -240,15 +240,15 @@ class AtomTable { } } - fn atoms_to_str(atoms: ~[Atom]) -> @str/~ { + fn atoms_to_str(atoms: ~[Atom]) -> @~str { // XXX: str::connect should do this. - let mut result = ""; + let mut result = ~""; let mut first = true; for self.atoms_to_strs(atoms) |string| { if first { first = false; } else { - result += "::"; + result += ~"::"; } result += *string; @@ -498,7 +498,8 @@ class NameBindings { fn get_module() -> @Module { alt self.module_def { NoModuleDef { - fail "get_module called on a node with no module definition!"; + fail + ~"get_module called on a node with no module definition!"; } ModuleDef(module) { ret module; @@ -560,25 +561,25 @@ class PrimitiveTypeTable { new(atom_table: @AtomTable) { self.primitive_types = atom_hashmap(); - self.intern(atom_table, @"bool"/~, ty_bool); - self.intern(atom_table, @"char"/~, ty_int(ty_char)); - self.intern(atom_table, @"float"/~, ty_float(ty_f)); - self.intern(atom_table, @"f32"/~, ty_float(ty_f32)); - self.intern(atom_table, @"f64"/~, ty_float(ty_f64)); - self.intern(atom_table, @"int"/~, ty_int(ty_i)); - self.intern(atom_table, @"i8"/~, ty_int(ty_i8)); - self.intern(atom_table, @"i16"/~, ty_int(ty_i16)); - self.intern(atom_table, @"i32"/~, ty_int(ty_i32)); - self.intern(atom_table, @"i64"/~, ty_int(ty_i64)); - self.intern(atom_table, @"str"/~, ty_str); - self.intern(atom_table, @"uint"/~, ty_uint(ty_u)); - self.intern(atom_table, @"u8"/~, ty_uint(ty_u8)); - self.intern(atom_table, @"u16"/~, ty_uint(ty_u16)); - self.intern(atom_table, @"u32"/~, ty_uint(ty_u32)); - self.intern(atom_table, @"u64"/~, ty_uint(ty_u64)); + self.intern(atom_table, @~"bool", ty_bool); + self.intern(atom_table, @~"char", ty_int(ty_char)); + self.intern(atom_table, @~"float", ty_float(ty_f)); + self.intern(atom_table, @~"f32", ty_float(ty_f32)); + self.intern(atom_table, @~"f64", ty_float(ty_f64)); + self.intern(atom_table, @~"int", ty_int(ty_i)); + self.intern(atom_table, @~"i8", ty_int(ty_i8)); + self.intern(atom_table, @~"i16", ty_int(ty_i16)); + self.intern(atom_table, @~"i32", ty_int(ty_i32)); + self.intern(atom_table, @~"i64", ty_int(ty_i64)); + self.intern(atom_table, @~"str", ty_str); + self.intern(atom_table, @~"uint", ty_uint(ty_u)); + self.intern(atom_table, @~"u8", ty_uint(ty_u8)); + self.intern(atom_table, @~"u16", ty_uint(ty_u16)); + self.intern(atom_table, @~"u32", ty_uint(ty_u32)); + self.intern(atom_table, @~"u64", ty_uint(ty_u64)); } - fn intern(atom_table: @AtomTable, string: @str/~, + fn intern(atom_table: @AtomTable, string: @~str, primitive_type: prim_ty) { let atom = (*atom_table).intern(string); self.primitive_types.insert(atom, primitive_type); @@ -651,7 +652,7 @@ class Resolver { self.type_ribs = @dvec(); self.xray_context = NoXray; - self.self_atom = (*self.atom_table).intern(@"self"/~); + self.self_atom = (*self.atom_table).intern(@~"self"); self.primitive_type_table = @PrimitiveTypeTable(self.atom_table); self.namespaces = ~[ ModuleNS, TypeNS, ValueNS, ImplNS ]; @@ -934,7 +935,7 @@ class Resolver { } item_mac(*) { - fail "item macros unimplemented" + fail ~"item macros unimplemented" } } } @@ -1038,14 +1039,15 @@ class Resolver { let last_ident = full_path.idents.last(); if last_ident != ident { self.session.span_err(view_item.span, - "cannot export under \ + ~"cannot export under \ a new name"); } if full_path.idents.len() != 1u { - self.session.span_err(view_item.span, - "cannot export an item \ - that is not in this \ - module"); + self.session.span_err( + view_item.span, + ~"cannot export an item \ + that is not in this \ + module"); } let atom = (*self.atom_table).intern(ident); @@ -1054,7 +1056,7 @@ class Resolver { view_path_glob(*) { self.session.span_err(view_item.span, - "export globs are \ + ~"export globs are \ unsupported"); } @@ -1063,7 +1065,7 @@ class Resolver { path_list_idents.len() == 0u { self.session.span_warn(view_item.span, - "this syntax for \ + ~"this syntax for \ exporting no \ variants is \ unsupported; export \ @@ -1072,7 +1074,7 @@ class Resolver { } else { if path.idents.len() != 0u { self.session.span_err(view_item.span, - "cannot export an \ + ~"cannot export an \ item that is not \ in this module"); } @@ -1180,7 +1182,7 @@ class Resolver { path_entry.path_string, path_entry.def_like); - let mut pieces = split_str(path_entry.path_string, "::"); + let mut pieces = split_str(path_entry.path_string, ~"::"); let final_ident = pop(pieces); // Find the module we need, creating modules along the way if we @@ -1251,7 +1253,7 @@ class Resolver { alt existing_module.parent_link { NoParentLink | BlockParentLink(*) { - fail "can't happen"; + fail ~"can't happen"; } ModuleParentLink (parent_module, @@ -1468,7 +1470,7 @@ class Resolver { } if self.unresolved_imports == prev_unresolved_imports { - self.session.err("failed to resolve imports"); + self.session.err(~"failed to resolve imports"); self.report_unresolved_imports(module_root); break; } @@ -1520,7 +1522,7 @@ class Resolver { Failed { // We presumably emitted an error. Continue. self.session.span_err(import_directive.span, - "failed to resolve import"); + ~"failed to resolve import"); } Indeterminate { // Bail out. We'll come around next time. @@ -1803,7 +1805,7 @@ class Resolver { binding"); } UnknownResult { - fail "module result should be known at this point"; + fail ~"module result should be known at this point"; } } alt value_result { @@ -1813,7 +1815,7 @@ class Resolver { } UnboundResult { /* Continue. */ } UnknownResult { - fail "value result should be known at this point"; + fail ~"value result should be known at this point"; } } alt type_result { @@ -1823,7 +1825,7 @@ class Resolver { } UnboundResult { /* Continue. */ } UnknownResult { - fail "type result should be known at this point"; + fail ~"type result should be known at this point"; } } alt impl_result { @@ -1834,7 +1836,7 @@ class Resolver { } UnboundImplResult { /* Continue. */ } UnknownImplResult { - fail "impl result should be known at this point"; + fail ~"impl result should be known at this point"; } } @@ -2025,7 +2027,7 @@ class Resolver { xray) { Failed { - self.session.span_err(span, "unresolved name"); + self.session.span_err(span, ~"unresolved name"); ret Failed; } Indeterminate { @@ -2082,7 +2084,7 @@ class Resolver { let mut search_module; alt self.resolve_module_in_lexical_scope(module, first_element) { Failed { - self.session.span_err(span, "unresolved name"); + self.session.span_err(span, ~"unresolved name"); ret Failed; } Indeterminate { @@ -2316,7 +2318,7 @@ class Resolver { source_name = source; } GlobImport { - fail "found `import *`, which is invalid"; + fail ~"found `import *`, which is invalid"; } } @@ -2443,14 +2445,15 @@ class Resolver { if is_none(module_result) && is_none(value_result) && is_none(type_result) && is_none(impl_result) { - self.session.span_err(import_directive.span, "unresolved import"); + self.session.span_err(import_directive.span, + ~"unresolved import"); ret Failed; } // Otherwise, proceed and write in the bindings. alt module.import_resolutions.find(target_name) { none { - fail "(resolving one-level renaming import) reduced graph \ + fail ~"(resolving one-level renaming import) reduced graph \ construction or glob importing should have created the \ import resolution name by now"; } @@ -2488,7 +2491,7 @@ class Resolver { let import_count = module.imports.len(); if index != import_count { self.session.span_err(module.imports.get_elt(index).span, - "unresolved import"); + ~"unresolved import"); } // Descend into children and anonymous children. @@ -2800,15 +2803,15 @@ class Resolver { // named function item. This is not allowed, so we // report an error. - self.session.span_err(span, - "attempted dynamic environment-\ - capture"); + self.session.span_err( + span, + ~"attempted dynamic environment-capture"); } else { // This was an attempt to use a type parameter outside // its scope. self.session.span_err(span, - "attempt to use a type \ + ~"attempt to use a type \ argument out of scope"); } @@ -2881,7 +2884,7 @@ class Resolver { // Items with the !resolve_unexported attribute are X-ray contexts. // This is used to allow the test runner to run unexported tests. let orig_xray_flag = self.xray_context; - if contains_name(attr_metas(item.attrs), "!resolve_unexported") { + if contains_name(attr_metas(item.attrs), ~"!resolve_unexported") { self.xray_context = Xray; } @@ -3014,7 +3017,7 @@ class Resolver { if !self.session.building_library && is_none(self.session.main_fn) && - str::eq(*item.ident, "main") { + str::eq(*item.ident, ~"main") { self.session.main_fn = some((item.id, item.span)); } @@ -3037,7 +3040,7 @@ class Resolver { } item_mac(*) { - fail "item macros unimplemented" + fail ~"item macros unimplemented" } } @@ -3102,7 +3105,7 @@ class Resolver { capture_item.span) { none { self.session.span_err(capture_item.span, - "unresolved name in \ + ~"unresolved name in \ capture clause"); } some(def) { @@ -3231,7 +3234,7 @@ class Resolver { alt self.resolve_path(interface.path, TypeNS, true, visitor) { none { self.session.span_err(interface.path.span, - "attempt to implement a \ + ~"attempt to implement a \ nonexistent interface"); } some(def) { @@ -3345,7 +3348,7 @@ class Resolver { true, visitor) { none { self.session.span_err(span, - "attempt to implement an \ + ~"attempt to implement an \ unknown interface"); } some(def) { @@ -3441,7 +3444,7 @@ class Resolver { for arm.pats.each() |p: @pat| { if self.num_bindings(p) != good { self.session.span_err(p.span, - "inconsistent number of bindings"); + ~"inconsistent number of bindings"); self.warn_var_patterns(arm); break; }; @@ -3544,7 +3547,7 @@ class Resolver { // Write the result into the def map. #debug("(resolving type) writing resolution for `%s` \ (id %d)", - connect(path.idents.map(|x| *x), "::"), + connect(path.idents.map(|x| *x), ~"::"), path_id); self.record_def(path_id, def); } @@ -3552,7 +3555,7 @@ class Resolver { self.session.span_err (ty.span, #fmt("use of undeclared type name `%s`", connect(path.idents.map(|x| *x), - "::"))); + ~"::"))); } } } @@ -3565,7 +3568,7 @@ class Resolver { false, visitor) { none { self.session.span_err(constraint.span, - "(resolving function) \ + ~"(resolving function) \ use of undeclared \ constraint"); } @@ -3623,7 +3626,7 @@ class Resolver { } FoundConst { self.session.span_err(pattern.span, - "pattern variable \ + ~"pattern variable \ conflicts with a constant \ in scope"); } @@ -3699,7 +3702,7 @@ class Resolver { } none { self.session.span_err(path.span, - "unresolved enum variant"); + ~"unresolved enum variant"); } } @@ -3735,7 +3738,7 @@ class Resolver { Success(target) { alt target.bindings.value_def { none { - fail "resolved name in the value namespace to a set \ + fail ~"resolved name in the value namespace to a set \ of name bindings with no def?!"; } some(def @ def_variant(*)) { @@ -3751,7 +3754,7 @@ class Resolver { } Indeterminate { - fail "unexpected indeterminate result"; + fail ~"unexpected indeterminate result"; } Failed { @@ -3858,7 +3861,7 @@ class Resolver { ret ImportNameDefinition(def); } none { - fail "target for namespace doesn't refer to \ + fail ~"target for namespace doesn't refer to \ bindings that contain a definition for \ that namespace!"; } @@ -3910,7 +3913,7 @@ class Resolver { } Indeterminate { - fail "indeterminate unexpected"; + fail ~"indeterminate unexpected"; } Success(resulting_module) { @@ -3964,7 +3967,7 @@ class Resolver { } Indeterminate { - fail "indeterminate unexpected"; + fail ~"indeterminate unexpected"; } Success(resulting_module) { @@ -4012,7 +4015,7 @@ class Resolver { AllowCapturingSelf); } ModuleNS | ImplNS { - fail "module or impl namespaces do not have local ribs"; + fail ~"module or impl namespaces do not have local ribs"; } } @@ -4044,7 +4047,7 @@ class Resolver { Success(target) { alt (*target.bindings).def_for_namespace(namespace) { none { - fail "resolved name in a namespace to a set of name \ + fail ~"resolved name in a namespace to a set of name \ bindings with no def for that namespace?!"; } some(def) { @@ -4056,7 +4059,7 @@ class Resolver { } } Indeterminate { - fail "unexpected indeterminate result"; + fail ~"unexpected indeterminate result"; } Failed { ret none; @@ -4083,14 +4086,14 @@ class Resolver { some(def) { // Write the result into the def map. #debug("(resolving expr) resolved `%s`", - connect(path.idents.map(|x| *x), "::")); + connect(path.idents.map(|x| *x), ~"::")); self.record_def(expr.id, def); } none { self.session.span_err(expr.span, #fmt("unresolved name: %s", connect(path.idents.map(|x| *x), - "::"))); + ~"::"))); } } @@ -4197,15 +4200,15 @@ class Resolver { alt self.unused_import_lint_level { warn { self.session.span_warn(import_resolution.span, - "unused import"); + ~"unused import"); } error { self.session.span_err(import_resolution.span, - "unused import"); + ~"unused import"); } ignore { self.session.span_bug(import_resolution.span, - "shouldn't be here if lint \ + ~"shouldn't be here if lint \ pass is ignored"); } } @@ -4221,7 +4224,7 @@ class Resolver { // /// A somewhat inefficient routine to print out the name of a module. - fn module_to_str(module: @Module) -> str { + fn module_to_str(module: @Module) -> ~str { let atoms = dvec(); let mut current_module = module; loop { @@ -4234,21 +4237,21 @@ class Resolver { current_module = module; } BlockParentLink(module, node_id) { - atoms.push((*self.atom_table).intern(@"<opaque>"/~)); + atoms.push((*self.atom_table).intern(@~"<opaque>")); current_module = module; } } } if atoms.len() == 0u { - ret "???"; + ret ~"???"; } - let mut string = ""; + let mut string = ~""; let mut i = atoms.len() - 1u; loop { if i < atoms.len() - 1u { - string += "::"; + string += ~"::"; } string += *(*self.atom_table).atom_to_str(atoms.get_elt(i)); @@ -4273,36 +4276,36 @@ class Resolver { for module.import_resolutions.each |name, import_resolution| { let mut module_repr; alt (*import_resolution).target_for_namespace(ModuleNS) { - none { module_repr = ""; } + none { module_repr = ~""; } some(target) { - module_repr = " module:?"; + module_repr = ~" module:?"; // XXX } } let mut value_repr; alt (*import_resolution).target_for_namespace(ValueNS) { - none { value_repr = ""; } + none { value_repr = ~""; } some(target) { - value_repr = " value:?"; + value_repr = ~" value:?"; // XXX } } let mut type_repr; alt (*import_resolution).target_for_namespace(TypeNS) { - none { type_repr = ""; } + none { type_repr = ~""; } some(target) { - type_repr = " type:?"; + type_repr = ~" type:?"; // XXX } } let mut impl_repr; alt (*import_resolution).target_for_namespace(ImplNS) { - none { impl_repr = ""; } + none { impl_repr = ~""; } some(target) { - impl_repr = " impl:?"; + impl_repr = ~" impl:?"; // XXX } } diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 2fdf8c3ff7f..0b7053a2c2b 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -41,7 +41,7 @@ enum opt_result { range_result(result, result), } fn trans_opt(bcx: block, o: opt) -> opt_result { - let _icx = bcx.insn_ctxt("alt::trans_opt"); + let _icx = bcx.insn_ctxt(~"alt::trans_opt"); let ccx = bcx.ccx(); let mut bcx = bcx; alt o { @@ -275,7 +275,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} { - let _icx = bcx.insn_ctxt("alt::extract_variant_args"); + 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 { ty::ty_enum(id, substs) { assert id == vdefs.enm; substs.tps } @@ -389,7 +389,7 @@ fn pick_col(m: match) -> uint { 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 _icx = bcx.insn_ctxt(~"alt::compile_submatch"); let mut bcx = bcx; let tcx = bcx.tcx(), dm = tcx.def_map; if m.len() == 0u { Br(bcx, option::get(chk)()); ret; } @@ -404,7 +404,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], bcx.fcx.lllocals.insert(val, loc); }; let {bcx: guard_cx, val} = { - do with_scope_result(bcx, e.info(), "guard") |bcx| { + do with_scope_result(bcx, e.info(), ~"guard") |bcx| { trans_temp_expr(bcx, e) } }; @@ -460,7 +460,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], let tup_ty = node_id_type(bcx, pat_id); let n_tup_elts = alt ty::get(tup_ty).struct { ty::ty_tup(elts) { elts.len() } - _ { ccx.sess.bug("non-tuple type in tuple pattern"); } + _ { ccx.sess.bug(~"non-tuple type in tuple pattern"); } }; let mut tup_vals = ~[], i = 0u; while i < n_tup_elts { @@ -531,7 +531,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], } let else_cx = alt kind { no_branch | single { bcx } - _ { sub_block(bcx, "match_else") } + _ { sub_block(bcx, ~"match_else") } }; let sw = if kind == switch { Switch(bcx, test_val, else_cx.llbb, opts.len()) @@ -546,7 +546,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], i += 1u; let mut opt_cx = else_cx; if !exhaustive || i < len { - opt_cx = sub_block(bcx, "match_case"); + opt_cx = sub_block(bcx, ~"match_case"); alt kind { single { Br(bcx, opt_cx.llbb); } switch { @@ -560,7 +560,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], compare { let t = node_id_type(bcx, pat_id); let {bcx: after_cx, val: matches} = { - do with_scope_result(bcx, none, "compare_scope") |bcx| { + do with_scope_result(bcx, none, ~"compare_scope") |bcx| { alt trans_opt(bcx, opt) { single_result({bcx, val}) { trans_compare(bcx, ast::eq, test_val, t, val, t) @@ -575,7 +575,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], } } }; - bcx = sub_block(after_cx, "compare_next"); + bcx = sub_block(after_cx, ~"compare_next"); CondBr(after_cx, matches, opt_cx.llbb, bcx.llbb); } _ { } @@ -608,7 +608,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef], // Returns false for unreachable blocks 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 _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| { @@ -642,15 +642,15 @@ fn trans_alt(bcx: block, arms: ~[ast::arm], mode: ast::alt_mode, dest: dest) -> block { - let _icx = bcx.insn_ctxt("alt::trans_alt"); - do with_scope(bcx, alt_expr.info(), "alt") |bcx| { + let _icx = bcx.insn_ctxt(~"alt::trans_alt"); + do with_scope(bcx, alt_expr.info(), ~"alt") |bcx| { trans_alt_inner(bcx, expr, arms, mode, dest) } } 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 _icx = scope_cx.insn_ctxt(~"alt::trans_alt_inner"); let bcx = scope_cx, tcx = bcx.tcx(); let mut bodies = ~[], match = ~[]; @@ -658,7 +658,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], if bcx.unreachable { ret bcx; } for vec::each(arms) |a| { - let body = scope_block(bcx, a.body.info(), "case_body"); + let body = scope_block(bcx, a.body.info(), ~"case_body"); let id_map = pat_util::pat_id_map(tcx.def_map, a.pats[0]); vec::push(bodies, body); for vec::each(a.pats) |p| { @@ -676,8 +676,8 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], fn mk_fail(bcx: block, sp: span, done: @mut option<BasicBlockRef>) -> BasicBlockRef { alt *done { some(bb) { ret bb; } _ { } } - let fail_cx = sub_block(bcx, "case_fallthrough"); - trans_fail(fail_cx, some(sp), "non-exhaustive match failure");; + let fail_cx = sub_block(bcx, ~"case_fallthrough"); + trans_fail(fail_cx, some(sp), ~"non-exhaustive match failure");; *done = some(fail_cx.llbb); ret fail_cx.llbb; } @@ -709,7 +709,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], // Not alt-related, but similar to the pattern-munging code above fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, make_copy: bool) -> block { - let _icx = bcx.insn_ctxt("alt::bind_irrefutable_pat"); + let _icx = bcx.insn_ctxt(~"alt::bind_irrefutable_pat"); let ccx = bcx.fcx.ccx; let mut bcx = bcx; diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 17d00eb2ed9..9273170c65c 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -65,11 +65,11 @@ enum dest { ignore, } -fn dest_str(ccx: @crate_ctxt, d: dest) -> str { +fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str { alt d { by_val(v) { #fmt["by_val(%s)", val_str(ccx.tn, *v)] } save_in(v) { #fmt["save_in(%s)", val_str(ccx.tn, v)] } - ignore { "ignore" } + ignore { ~"ignore" } } } @@ -95,7 +95,7 @@ class icx_popper { } impl ccx_icx for @crate_ctxt { - fn insn_ctxt(s: str) -> icx_popper { + fn insn_ctxt(s: ~str) -> icx_popper { #debug("new insn_ctxt: %s", s); if self.sess.count_llvm_insns() { vec::push(*self.stats.llvm_insn_ctxt, s); @@ -105,20 +105,20 @@ impl ccx_icx for @crate_ctxt { } impl bcx_icx for block { - fn insn_ctxt(s: str) -> icx_popper { + fn insn_ctxt(s: ~str) -> icx_popper { self.ccx().insn_ctxt(s) } } impl fcx_icx for fn_ctxt { - fn insn_ctxt(s: str) -> icx_popper { + fn insn_ctxt(s: ~str) -> icx_popper { self.ccx.insn_ctxt(s) } } fn join_returns(parent_cx: block, in_cxs: ~[block], in_ds: ~[dest], out_dest: dest) -> block { - let out = sub_block(parent_cx, "join"); + let out = sub_block(parent_cx, ~"join"); let mut reachable = false, i = 0u, phi = none; for vec::each(in_cxs) |cx| { if !cx.unreachable { @@ -160,11 +160,11 @@ fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { fn get_dest_addr(dest: dest) -> ValueRef { alt dest { save_in(a) { a } - _ { fail "get_dest_addr: not a save_in"; } + _ { fail ~"get_dest_addr: not a save_in"; } } } -fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timespec, +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; @@ -172,7 +172,7 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timespec, } -fn decl_fn(llmod: ModuleRef, name: str, cc: lib::llvm::CallConv, +fn decl_fn(llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, llty: TypeRef) -> ValueRef { let llfn: ValueRef = str::as_c_str(name, |buf| { llvm::LLVMGetOrInsertFunction(llmod, buf, llty) @@ -181,21 +181,22 @@ fn decl_fn(llmod: ModuleRef, name: str, cc: lib::llvm::CallConv, ret llfn; } -fn decl_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) -> ValueRef { +fn decl_cdecl_fn(llmod: ModuleRef, name: ~str, llty: TypeRef) -> ValueRef { ret decl_fn(llmod, name, lib::llvm::CCallConv, llty); } // Only use this if you are going to actually define the function. It's // not valid to simply declare a function as internal. -fn decl_internal_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) -> +fn decl_internal_cdecl_fn(llmod: ModuleRef, name: ~str, llty: TypeRef) -> ValueRef { let llfn = decl_cdecl_fn(llmod, name, llty); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); ret llfn; } -fn get_extern_fn(externs: hashmap<str, ValueRef>, llmod: ModuleRef, name: str, +fn get_extern_fn(externs: hashmap<~str, ValueRef>, + llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { if externs.contains_key(name) { ret externs.get(name); } let f = decl_fn(llmod, name, cc, ty); @@ -203,8 +204,8 @@ fn get_extern_fn(externs: hashmap<str, ValueRef>, llmod: ModuleRef, name: str, ret f; } -fn get_extern_const(externs: hashmap<str, ValueRef>, llmod: ModuleRef, - name: str, ty: TypeRef) -> ValueRef { +fn get_extern_const(externs: hashmap<~str, ValueRef>, llmod: ModuleRef, + name: ~str, ty: TypeRef) -> ValueRef { if externs.contains_key(name) { ret externs.get(name); } let c = str::as_c_str(name, |buf| llvm::LLVMAddGlobal(llmod, ty, buf)); externs.insert(name, c); @@ -212,10 +213,10 @@ fn get_extern_const(externs: hashmap<str, ValueRef>, llmod: ModuleRef, } fn get_simple_extern_fn(cx: block, - externs: hashmap<str, ValueRef>, + externs: hashmap<~str, ValueRef>, llmod: ModuleRef, - name: str, n_args: int) -> ValueRef { - let _icx = cx.insn_ctxt("get_simple_extern_fn"); + name: ~str, n_args: int) -> ValueRef { + let _icx = cx.insn_ctxt(~"get_simple_extern_fn"); let ccx = cx.fcx.ccx; let inputs = vec::from_elem(n_args as uint, ccx.int_type); let output = ccx.int_type; @@ -223,10 +224,10 @@ fn get_simple_extern_fn(cx: block, ret get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t); } -fn trans_foreign_call(cx: block, externs: hashmap<str, ValueRef>, - llmod: ModuleRef, name: str, args: ~[ValueRef]) -> +fn trans_foreign_call(cx: block, externs: hashmap<~str, ValueRef>, + llmod: ModuleRef, name: ~str, args: ~[ValueRef]) -> ValueRef { - let _icx = cx.insn_ctxt("trans_foreign_call"); + let _icx = cx.insn_ctxt(~"trans_foreign_call"); let n = args.len() as int; let llforeign: ValueRef = get_simple_extern_fn(cx, externs, llmod, name, n); @@ -238,26 +239,26 @@ fn trans_foreign_call(cx: block, externs: hashmap<str, ValueRef>, } fn trans_free(cx: block, v: ValueRef) -> block { - let _icx = cx.insn_ctxt("trans_free"); + let _icx = cx.insn_ctxt(~"trans_free"); 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_unique_free"); + let _icx = cx.insn_ctxt(~"trans_unique_free"); Call(cx, cx.ccx().upcalls.exchange_free, ~[PointerCast(cx, v, T_ptr(T_i8()))]); ret cx; } fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { - let _icx = cx.insn_ctxt("umax"); + let _icx = cx.insn_ctxt(~"umax"); let cond = ICmp(cx, lib::llvm::IntULT, a, b); ret Select(cx, cond, b, a); } fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { - let _icx = cx.insn_ctxt("umin"); + let _icx = cx.insn_ctxt(~"umin"); let cond = ICmp(cx, lib::llvm::IntULT, a, b); ret Select(cx, cond, a, b); } @@ -271,7 +272,7 @@ fn alloca_zeroed(cx: block, t: TypeRef) -> ValueRef { } fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef { - let _icx = cx.insn_ctxt("alloca"); + let _icx = cx.insn_ctxt(~"alloca"); if cx.unreachable { ret llvm::LLVMGetUndef(t); } let initcx = raw_block(cx.fcx, cx.fcx.llstaticallocas); let p = Alloca(initcx, t); @@ -280,7 +281,7 @@ fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef { } fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("zero_mem"); + let _icx = cx.insn_ctxt(~"zero_mem"); let bcx = cx; let ccx = cx.ccx(); let llty = type_of(ccx, t); @@ -289,7 +290,7 @@ fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) -> block { } fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef { - let _icx = cx.insn_ctxt("arrayalloca"); + let _icx = cx.insn_ctxt(~"arrayalloca"); if cx.unreachable { ret llvm::LLVMGetUndef(t); } ret ArrayAlloca(raw_block(cx.fcx, cx.fcx.llstaticallocas), t, v); } @@ -298,7 +299,7 @@ fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef { // The type of the returned pointer is always i8*. If you care about the // return type, use bump_ptr(). fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("ptr_offs"); + let _icx = bcx.insn_ctxt(~"ptr_offs"); let raw = PointerCast(bcx, base, T_ptr(T_i8())); InBoundsGEP(bcx, raw, ~[sz]) } @@ -307,7 +308,7 @@ fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef { // to a given type. fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("bump_ptr"); + let _icx = bcx.insn_ctxt(~"bump_ptr"); let ccx = bcx.ccx(); let bumped = ptr_offs(bcx, base, sz); let typ = T_ptr(type_of(ccx, t)); @@ -320,7 +321,7 @@ fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) -> fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, variant_id: ast::def_id, ty_substs: ~[ty::t], ix: uint) -> ValueRef { - let _icx = bcx.insn_ctxt("GEP_enum"); + let _icx = bcx.insn_ctxt(~"GEP_enum"); let ccx = bcx.ccx(); let variant = ty::enum_variant_with_id(ccx.tcx, enum_id, variant_id); assert ix < variant.args.len(); @@ -341,7 +342,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, fn opaque_box_body(bcx: block, body_t: ty::t, boxptr: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("opaque_box_body"); + 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]); @@ -352,7 +353,7 @@ fn opaque_box_body(bcx: block, // potentially dynamic size. fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("malloc_raw"); + let _icx = bcx.insn_ctxt(~"malloc_raw"); let ccx = bcx.ccx(); let (mk_fn, upcall) = alt heap { @@ -386,7 +387,7 @@ fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> ValueRef { // and pulls out the body fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) -> {box: ValueRef, body: ValueRef} { - let _icx = bcx.insn_ctxt("malloc_general"); + let _icx = bcx.insn_ctxt(~"malloc_general"); let llbox = malloc_raw_dyn(bcx, t, heap, size); let non_gc_box = non_gc_box_cast(bcx, llbox); let body = GEPi(bcx, non_gc_box, ~[0u, abi::box_field_body]); @@ -471,23 +472,23 @@ fn set_glue_inlining(f: ValueRef, t: ty::t) { // Double-check that we never ask LLVM to declare the same symbol twice. It // silently mangles such symbols, breaking our linkage model. -fn note_unique_llvm_symbol(ccx: @crate_ctxt, sym: str) { +fn note_unique_llvm_symbol(ccx: @crate_ctxt, sym: ~str) { if ccx.all_llvm_symbols.contains_key(sym) { - ccx.sess.bug("duplicate LLVM symbol: " + sym); + ccx.sess.bug(~"duplicate LLVM symbol: " + sym); } ccx.all_llvm_symbols.insert(sym, ()); } // Generates the declaration for (but doesn't emit) a type descriptor. fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { - let _icx = ccx.insn_ctxt("declare_tydesc"); + let _icx = ccx.insn_ctxt(~"declare_tydesc"); let llty = type_of(ccx, t); let llsize = llsize_of(ccx, llty); let llalign = llalign_of(ccx, llty); //XXX this triggers duplicate LLVM symbols let name = if false /*ccx.sess.opts.debuginfo*/ { - mangle_internal_name_by_type_only(ccx, t, @"tydesc"/~) - } else { mangle_internal_name_by_seq(ccx, @"tydesc"/~) }; + mangle_internal_name_by_type_only(ccx, t, @~"tydesc") + } else { mangle_internal_name_by_seq(ccx, @~"tydesc") }; note_unique_llvm_symbol(ccx, name); log(debug, #fmt("+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name)); let gvar = str::as_c_str(name, |buf| { @@ -502,22 +503,22 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { mut drop_glue: none, mut free_glue: none, mut visit_glue: none}; - log(debug, "--- declare_tydesc " + ppaux::ty_to_str(ccx.tcx, t)); + log(debug, ~"--- declare_tydesc " + ppaux::ty_to_str(ccx.tcx, t)); ret inf; } type glue_helper = fn@(block, ValueRef, ty::t); fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, - name: str) -> ValueRef { - let _icx = ccx.insn_ctxt("declare_generic_glue"); + name: ~str) -> ValueRef { + let _icx = ccx.insn_ctxt(~"declare_generic_glue"); let name = name; let mut fn_nm; //XXX this triggers duplicate LLVM symbols if false /*ccx.sess.opts.debuginfo*/ { - fn_nm = mangle_internal_name_by_type_only(ccx, t, @("glue_" + name)); + fn_nm = mangle_internal_name_by_type_only(ccx, t, @(~"glue_" + name)); } else { - fn_nm = mangle_internal_name_by_seq(ccx, @("glue_" + name)); + fn_nm = mangle_internal_name_by_seq(ccx, @(~"glue_" + name)); } note_unique_llvm_symbol(ccx, fn_nm); let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty); @@ -527,7 +528,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 _icx = ccx.insn_ctxt(~"make_generic_glue_inner"); let fcx = new_fn_ctxt(ccx, ~[], llfn, none); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); ccx.stats.n_glues_created += 1u; @@ -548,9 +549,9 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, } fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, - helper: glue_helper, name: str) + helper: glue_helper, name: ~str) -> ValueRef { - let _icx = ccx.insn_ctxt("make_generic_glue"); + let _icx = ccx.insn_ctxt(~"make_generic_glue"); if !ccx.sess.trans_stats() { ret make_generic_glue_inner(ccx, t, llfn, helper); } @@ -558,13 +559,13 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, let start = time::get_time(); let llval = make_generic_glue_inner(ccx, t, llfn, helper); let end = time::get_time(); - log_fn_time(ccx, "glue " + name + " " + ty_to_short_str(ccx.tcx, t), + log_fn_time(ccx, ~"glue " + name + ~" " + ty_to_short_str(ccx.tcx, t), start, end); ret llval; } fn emit_tydescs(ccx: @crate_ctxt) { - let _icx = ccx.insn_ctxt("emit_tydescs"); + let _icx = ccx.insn_ctxt(~"emit_tydescs"); for ccx.tydescs.each |key, val| { let glue_fn_ty = T_ptr(T_glue_fn(ccx)); let ti = val; @@ -613,7 +614,7 @@ fn emit_tydescs(ccx: @crate_ctxt) { } fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { - let _icx = bcx.insn_ctxt("make_take_glue"); + let _icx = bcx.insn_ctxt(~"make_take_glue"); // NB: v is a *pointer* to type t here, not a direct value. let bcx = alt ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | @@ -655,7 +656,7 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { } fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { - let _icx = cx.insn_ctxt("incr_refcnt_of_boxed"); + 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]); @@ -665,10 +666,10 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { } fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { - let _icx = bcx.insn_ctxt("make_visit_glue"); + let _icx = bcx.insn_ctxt(~"make_visit_glue"); let mut bcx = bcx; - assert bcx.ccx().tcx.intrinsic_defs.contains_key(@"ty_visitor"/~); - let (iid, ty) = bcx.ccx().tcx.intrinsic_defs.get(@"ty_visitor"/~); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(@~"ty_visitor"); + let (iid, ty) = bcx.ccx().tcx.intrinsic_defs.get(@~"ty_visitor"); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, iid); build_return(bcx); @@ -679,7 +680,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { // v is a pointer to the actual box component of the type here. The // ValueRef will have the wrong type here (make_generic_glue is casting // everything to a pointer to the type that the glue acts on). - let _icx = bcx.insn_ctxt("make_free_glue"); + let _icx = bcx.insn_ctxt(~"make_free_glue"); let ccx = bcx.ccx(); let bcx = alt ty::get(t).struct { ty::ty_box(body_mt) { @@ -761,7 +762,7 @@ fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id, fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { // NB: v0 is an *alias* of type t here, not a direct value. - let _icx = bcx.insn_ctxt("make_drop_glue"); + let _icx = bcx.insn_ctxt(~"make_drop_glue"); let ccx = bcx.ccx(); let bcx = alt ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | @@ -810,7 +811,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]) -> ValueRef { - let _icx = ccx.insn_ctxt("trans_res_dtor"); + let _icx = ccx.insn_ctxt(~"trans_res_dtor"); if (substs.len() > 0u) { let did = if did.crate != ast::local_crate { maybe_instantiate_inline(ccx, did) @@ -842,7 +843,7 @@ fn maybe_validate_box(_cx: block, _box_ptr: ValueRef) { } fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("decr_refcnt_maybe_free"); + let _icx = bcx.insn_ctxt(~"decr_refcnt_maybe_free"); let ccx = bcx.ccx(); maybe_validate_box(bcx, box_ptr); @@ -858,7 +859,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { } // Structural comparison: a rather involved form of glue. -fn maybe_name_value(cx: @crate_ctxt, v: ValueRef, s: str) { +fn maybe_name_value(cx: @crate_ctxt, v: ValueRef, s: ~str) { if cx.sess.opts.save_temps { let _: () = str::as_c_str(s, |buf| llvm::LLVMSetValueName(v, buf)); } @@ -881,12 +882,12 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, ty::ty_float(_) { ret rslt(cx, f(floating_point)); } ty::ty_type { ret rslt(trans_fail(cx, none, - "attempt to compare values of type type"), + ~"attempt to compare values of type type"), C_nil()); } _ { // Should never get here, because t is scalar. - cx.sess().bug("non-scalar type passed to \ + cx.sess().bug(~"non-scalar type passed to \ compare_scalar_types"); } } @@ -896,9 +897,9 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, // A helper function to do the actual comparison of scalar values. fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, nt: scalar_type, op: ast::binop) -> ValueRef { - let _icx = cx.insn_ctxt("compare_scalar_values"); + let _icx = cx.insn_ctxt(~"compare_scalar_values"); fn die_(cx: block) -> ! { - cx.tcx().sess.bug("compare_scalar_values: must be a\ + cx.tcx().sess.bug(~"compare_scalar_values: must be a\ comparison operator"); } let die = fn@() -> ! { die_(cx) }; @@ -967,13 +968,13 @@ fn store_inbounds(cx: block, v: ValueRef, p: ValueRef, // Iterates through the elements of a structural type. fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, f: val_and_ty_fn) -> block { - let _icx = cx.insn_ctxt("iter_structural_ty"); + 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, f: val_and_ty_fn) -> block { - let _icx = cx.insn_ctxt("iter_variant"); + let _icx = cx.insn_ctxt(~"iter_variant"); if variant.args.len() == 0u { ret cx; } let fn_ty = variant.ctor_ty; let ccx = cx.ccx(); @@ -989,7 +990,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, j += 1u; } } - _ { cx.tcx().sess.bug("iter_variant: not a function type"); } + _ { cx.tcx().sess.bug(~"iter_variant: not a function type"); } } ret cx; } @@ -1036,14 +1037,14 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, // NB: we must hit the discriminant first so that structural // comparison know not to proceed when the discriminants differ. cx = f(cx, lldiscrim_a_ptr, ty::mk_int(cx.tcx())); - let unr_cx = sub_block(cx, "enum-iter-unr"); + let unr_cx = sub_block(cx, ~"enum-iter-unr"); Unreachable(unr_cx); let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants); - let next_cx = sub_block(cx, "enum-iter-next"); + let next_cx = sub_block(cx, ~"enum-iter-next"); for vec::each(*variants) |variant| { let variant_cx = sub_block(cx, - "enum-iter-variant-" + + ~"enum-iter-variant-" + int::to_str(variant.disr_val, 10u)); AddCase(llswitch, C_int(ccx, variant.disr_val), variant_cx.llbb); let variant_cx = @@ -1066,7 +1067,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, cx = f(cx, llfld_a, fld.mt.ty); } } - _ { cx.sess().unimpl("type in iter_structural_ty"); } + _ { cx.sess().unimpl(~"type in iter_structural_ty"); } } ret cx; } @@ -1081,7 +1082,7 @@ fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt, fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, ti: @tydesc_info) { - let _icx = ccx.insn_ctxt("lazily_emit_tydesc_glue"); + let _icx = ccx.insn_ctxt(~"lazily_emit_tydesc_glue"); if field == abi::tydesc_field_take_glue { alt ti.take_glue { some(_) { } @@ -1089,10 +1090,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue TAKE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = declare_generic_glue - (ccx, ti.ty, T_glue_fn(ccx), "take"); + (ccx, ti.ty, T_glue_fn(ccx), ~"take"); ti.take_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_take_glue, "take"); + make_take_glue, ~"take"); #debug("--- lazily_emit_tydesc_glue TAKE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1104,10 +1105,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue DROP %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = - declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "drop"); + declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"drop"); ti.drop_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_drop_glue, "drop"); + make_drop_glue, ~"drop"); #debug("--- lazily_emit_tydesc_glue DROP %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1119,10 +1120,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue FREE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = - declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "free"); + declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"free"); ti.free_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_free_glue, "free"); + make_free_glue, ~"free"); #debug("--- lazily_emit_tydesc_glue FREE %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1134,10 +1135,10 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, #debug("+++ lazily_emit_tydesc_glue VISIT %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = - declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), "visit"); + declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"visit"); ti.visit_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, - make_visit_glue, "visit"); + make_visit_glue, ~"visit"); #debug("--- lazily_emit_tydesc_glue VISIT %s", ppaux::ty_to_str(ccx.tcx, ti.ty)); } @@ -1148,7 +1149,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, // See [Note-arg-mode] fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, field: uint, static_ti: option<@tydesc_info>) { - let _icx = cx.insn_ctxt("call_tydesc_glue_full"); + let _icx = cx.insn_ctxt(~"call_tydesc_glue_full"); if cx.unreachable { ret; } let mut static_glue_fn = none; @@ -1188,7 +1189,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, // See [Note-arg-mode] fn call_tydesc_glue(++cx: block, v: ValueRef, t: ty::t, field: uint) -> block { - let _icx = cx.insn_ctxt("call_tydesc_glue"); + let _icx = cx.insn_ctxt(~"call_tydesc_glue"); let ti = get_tydesc(cx.ccx(), t); call_tydesc_glue_full(cx, v, ti.tydesc, field, some(ti)); ret cx; @@ -1198,7 +1199,7 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, llop: ValueRef) -> ValueRef { // We can't use call_tydesc_glue_full() and friends here because compare // glue has a special signature. - let _icx = bcx.insn_ctxt("call_cmp_glue"); + let _icx = bcx.insn_ctxt(~"call_cmp_glue"); let lllhs = spill_if_immediate(bcx, lhs, t); let llrhs = spill_if_immediate(bcx, rhs, t); @@ -1216,7 +1217,7 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, } fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("take_ty"); + let _icx = cx.insn_ctxt(~"take_ty"); if ty::type_needs_drop(cx.tcx(), t) { ret call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue); } @@ -1224,7 +1225,7 @@ fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block { } fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("drop_ty"); + let _icx = cx.insn_ctxt(~"drop_ty"); if ty::type_needs_drop(cx.tcx(), t) { ret call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue); } @@ -1232,7 +1233,7 @@ fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { } fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("drop_ty_immediate"); + let _icx = bcx.insn_ctxt(~"drop_ty_immediate"); alt ty::get(t).struct { ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str | ty::ty_evec(_, ty::vstore_uniq) | @@ -1244,12 +1245,12 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { ty::ty_estr(ty::vstore_box) { decr_refcnt_maybe_free(bcx, v, t) } - _ { bcx.tcx().sess.bug("drop_ty_immediate: non-box ty"); } + _ { bcx.tcx().sess.bug(~"drop_ty_immediate: non-box ty"); } } } fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { - let _icx = bcx.insn_ctxt("take_ty_immediate"); + let _icx = bcx.insn_ctxt(~"take_ty_immediate"); alt ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_evec(_, ty::vstore_box) | @@ -1270,7 +1271,7 @@ fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { } fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("free_ty"); + let _icx = cx.insn_ctxt(~"free_ty"); if ty::type_needs_drop(cx.tcx(), t) { ret call_tydesc_glue(cx, v, t, abi::tydesc_field_free_glue); } @@ -1283,11 +1284,11 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, // alignment information when the alignment is statically known (it must // be nothing more than a constant int, or LLVM complains -- not even a // constant element of a tydesc works). - let _icx = cx.insn_ctxt("call_memmove"); + let _icx = cx.insn_ctxt(~"call_memmove"); let ccx = cx.ccx(); let key = alt ccx.sess.targ_cfg.arch { - session::arch_x86 | session::arch_arm { "llvm.memmove.p0i8.p0i8.i32" } - session::arch_x86_64 { "llvm.memmove.p0i8.p0i8.i64" } + session::arch_x86 | session::arch_arm { ~"llvm.memmove.p0i8.p0i8.i32" } + session::arch_x86_64 { ~"llvm.memmove.p0i8.p0i8.i64" } }; let memmove = ccx.intrinsics.get(key); let src_ptr = PointerCast(cx, src, T_ptr(T_i8())); @@ -1299,7 +1300,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, } fn memmove_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) { - let _icx = bcx.insn_ctxt("memmove_ty"); + let _icx = bcx.insn_ctxt(~"memmove_ty"); let ccx = bcx.ccx(); if ty::type_is_structural(t) { let llsz = llsize_of(ccx, type_of(ccx, t)); @@ -1322,7 +1323,7 @@ fn type_is_structural_or_param(t: ty::t) -> bool { fn copy_val(cx: block, action: copy_action, dst: ValueRef, src: ValueRef, t: ty::t) -> block { - let _icx = cx.insn_ctxt("copy_val"); + let _icx = cx.insn_ctxt(~"copy_val"); if action == DROP_EXISTING && (type_is_structural_or_param(t) || ty::type_is_unique(t)) { @@ -1339,7 +1340,7 @@ fn copy_val(cx: block, action: copy_action, dst: ValueRef, fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, src: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("copy_val_no_check"); + let _icx = bcx.insn_ctxt(~"copy_val_no_check"); let ccx = bcx.ccx(); let mut bcx = bcx; if ty::type_is_scalar(t) { @@ -1357,7 +1358,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, memmove_ty(bcx, dst, src, t); ret take_ty(bcx, dst, t); } - ccx.sess.bug("unexpected type in trans::copy_val_no_check: " + + ccx.sess.bug(~"unexpected type in trans::copy_val_no_check: " + ppaux::ty_to_str(ccx.tcx, t)); } @@ -1370,7 +1371,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, fn move_val(cx: block, action: copy_action, dst: ValueRef, src: lval_result, t: ty::t) -> block { - let _icx = cx.insn_ctxt("move_val"); + let _icx = cx.insn_ctxt(~"move_val"); let mut src_val = src.val; let tcx = cx.tcx(); let mut cx = cx; @@ -1396,14 +1397,14 @@ fn move_val(cx: block, action: copy_action, dst: ValueRef, revoke_clean(cx, src_val); ret cx; } - cx.sess().bug("unexpected type in trans::move_val: " + + cx.sess().bug(~"unexpected type in trans::move_val: " + ppaux::ty_to_str(tcx, t)); } fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef, src: lval_result, t: ty::t, last_use: bool) -> block { - let _icx = cx.insn_ctxt("trans_temp_expr"); + let _icx = cx.insn_ctxt(~"trans_temp_expr"); // Lvals in memory are not temporaries. Copy them. if src.kind != temporary && !last_use { let v = if src.kind == owned { @@ -1418,7 +1419,7 @@ fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef, fn trans_crate_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) -> ValueRef { - let _icx = cx.insn_ctxt("trans_crate_lit"); + let _icx = cx.insn_ctxt(~"trans_crate_lit"); alt lit.node { ast::lit_int(i, t) { C_integral(T_int_ty(cx, t), i as u64, True) } ast::lit_uint(u, t) { C_integral(T_uint_ty(cx, t), u, False) } @@ -1432,7 +1433,7 @@ fn trans_crate_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) C_integral(T_uint_ty(cx, t), i as u64, False) } _ { cx.sess.span_bug(lit.span, - "integer literal doesn't have a type"); + ~"integer literal doesn't have a type"); } } } @@ -1440,13 +1441,13 @@ fn trans_crate_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) ast::lit_bool(b) { C_bool(b) } ast::lit_nil { C_nil() } ast::lit_str(s) { - cx.sess.span_unimpl(lit.span, "unique string in this context"); + cx.sess.span_unimpl(lit.span, ~"unique string in this context"); } } } fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_lit"); + let _icx = cx.insn_ctxt(~"trans_lit"); if dest == ignore { ret cx; } alt lit.node { ast::lit_str(s) { tvec::trans_estr(cx, s, ast::vstore_uniq, dest) } @@ -1460,7 +1461,7 @@ fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block { fn trans_boxed_expr(bcx: block, contents: @ast::expr, t: ty::t, heap: heap, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_boxed_expr"); + let _icx = bcx.insn_ctxt(~"trans_boxed_expr"); let {box, body} = malloc_general(bcx, t, heap); add_clean_free(bcx, box, heap); let bcx = trans_expr_save_in(bcx, contents, body); @@ -1471,7 +1472,7 @@ fn trans_boxed_expr(bcx: block, contents: @ast::expr, fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, un_expr: @ast::expr, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_unary"); + let _icx = bcx.insn_ctxt(~"trans_unary"); // Check for user-defined method call alt bcx.ccx().maps.method_map.find(un_expr.id) { some(mentry) { @@ -1507,7 +1508,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, trans_boxed_expr(bcx, e, e_ty, heap_exchange, dest) } ast::deref { - bcx.sess().bug("deref expressions should have been \ + bcx.sess().bug(~"deref expressions should have been \ translated using trans_lval(), not \ trans_unary()") } @@ -1515,7 +1516,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, } fn trans_addr_of(cx: block, e: @ast::expr, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_addr_of"); + let _icx = cx.insn_ctxt(~"trans_addr_of"); let mut {bcx, val, kind} = trans_temp_lval(cx, e); let ety = expr_ty(cx, e); let is_immediate = ty::type_is_immediate(ety); @@ -1527,7 +1528,7 @@ fn trans_addr_of(cx: block, e: @ast::expr, dest: dest) -> block { fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, _lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> result { - let _icx = cx.insn_ctxt("trans_compare"); + let _icx = cx.insn_ctxt(~"trans_compare"); if ty::type_is_scalar(rhs_t) { let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op); ret rslt(rs.bcx, rs.val); @@ -1539,7 +1540,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, ast::eq | ast::ne { C_u8(abi::cmp_glue_op_eq) } ast::lt | ast::ge { C_u8(abi::cmp_glue_op_lt) } ast::le | ast::gt { C_u8(abi::cmp_glue_op_le) } - _ { cx.tcx().sess.bug("trans_compare got non-comparison-op"); } + _ { cx.tcx().sess.bug(~"trans_compare got non-comparison-op"); } } }; @@ -1549,7 +1550,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, alt op { ast::eq | ast::lt | ast::le { rslt(cx, cmpval) } ast::ne | ast::ge | ast::gt { rslt(cx, Not(cx, cmpval)) } - _ { cx.tcx().sess.bug("trans_compare got non-comparison-op"); } + _ { cx.tcx().sess.bug(~"trans_compare got non-comparison-op"); } } } @@ -1594,9 +1595,9 @@ fn cast_shift_rhs(op: ast::binop, fn fail_if_zero(cx: block, span: span, divmod: ast::binop, rhs: ValueRef, rhs_t: ty::t) -> block { let text = if divmod == ast::div { - "divide by zero" + ~"divide by zero" } else { - "modulo zero" + ~"modulo zero" }; let is_zero = alt ty::get(rhs_t).struct { ty::ty_int(t) { @@ -1608,7 +1609,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop, ICmp(cx, lib::llvm::IntEQ, rhs, zero) } _ { - cx.tcx().sess.bug("fail-if-zero on unexpected type: " + + cx.tcx().sess.bug(~"fail-if-zero on unexpected type: " + ty_to_str(cx.ccx().tcx, rhs_t)); } }; @@ -1623,7 +1624,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t, dest: dest) -> block { let mut cx = cx; - let _icx = cx.insn_ctxt("trans_eager_binop"); + let _icx = cx.insn_ctxt(~"trans_eager_binop"); if dest == ignore { ret cx; } let intype = { if ty::type_is_bot(lhs_t) { rhs_t } @@ -1694,7 +1695,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, dst: @ast::expr, src: @ast::expr) -> block { #debug["%s", expr_to_str(ex)]; - let _icx = bcx.insn_ctxt("trans_assign_op"); + let _icx = bcx.insn_ctxt(~"trans_assign_op"); let t = expr_ty(bcx, src); let lhs_res = trans_lval(bcx, dst); assert (lhs_res.kind == owned); @@ -1735,7 +1736,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, fn root_value(bcx: block, val: ValueRef, ty: ty::t, scope_id: ast::node_id) { - let _icx = bcx.insn_ctxt("root_value"); + let _icx = bcx.insn_ctxt(~"root_value"); if bcx.sess().trace() { trans_trace( @@ -1753,7 +1754,7 @@ fn root_value(bcx: block, val: ValueRef, ty: ty::t, fn autoderef(cx: block, e_id: ast::node_id, v: ValueRef, t: ty::t, max: uint) -> result_t { - let _icx = cx.insn_ctxt("autoderef"); + let _icx = cx.insn_ctxt(~"autoderef"); let mut v1: ValueRef = v; let mut t1: ty::t = t; let ccx = cx.ccx(); @@ -1818,21 +1819,21 @@ enum lazy_binop_ty { lazy_and, lazy_or } fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, b: @ast::expr, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_lazy_binop"); + let _icx = bcx.insn_ctxt(~"trans_lazy_binop"); let {bcx: past_lhs, val: lhs} = { - do with_scope_result(bcx, a.info(), "lhs") |bcx| { + do with_scope_result(bcx, a.info(), ~"lhs") |bcx| { trans_temp_expr(bcx, a) } }; if past_lhs.unreachable { ret past_lhs; } - let join = sub_block(bcx, "join"), before_rhs = sub_block(bcx, "rhs"); + let join = sub_block(bcx, ~"join"), before_rhs = sub_block(bcx, ~"rhs"); alt op { lazy_and { CondBr(past_lhs, lhs, before_rhs.llbb, join.llbb); } lazy_or { CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb); } } let {bcx: past_rhs, val: rhs} = { - do with_scope_result(before_rhs, b.info(), "rhs") |bcx| { + do with_scope_result(before_rhs, b.info(), ~"rhs") |bcx| { trans_temp_expr(bcx, b) } }; @@ -1846,7 +1847,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr, dest: dest, ex: @ast::expr) -> block { - let _icx = bcx.insn_ctxt("trans_binary"); + let _icx = bcx.insn_ctxt(~"trans_binary"); // User-defined operators alt bcx.ccx().maps.method_map.find(ex.id) { some(origin) { @@ -1885,13 +1886,13 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, els: option<@ast::expr>, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_if"); + let _icx = cx.insn_ctxt(~"trans_if"); let {bcx, val: cond_val} = trans_temp_expr(cx, cond); let then_dest = dup_for_join(dest); let else_dest = dup_for_join(dest); - let then_cx = scope_block(bcx, thn.info(), "then"); - let else_cx = scope_block(bcx, els.info(), "else"); + let then_cx = scope_block(bcx, thn.info(), ~"then"); + let else_cx = scope_block(bcx, els.info(), ~"else"); CondBr(bcx, cond_val, then_cx.llbb, else_cx.llbb); let then_bcx = trans_block(then_cx, thn, then_dest); let then_bcx = trans_block_cleanups(then_bcx, then_cx); @@ -1910,7 +1911,7 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, trans_block(else_cx, blk, else_dest) } // would be nice to have a constraint on ifs - _ { cx.tcx().sess.bug("strange alternative in if"); } + _ { cx.tcx().sess.bug(~"strange alternative in if"); } } } _ { else_cx } @@ -1922,11 +1923,11 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, fn trans_while(cx: block, cond: @ast::expr, body: ast::blk) -> block { - let _icx = cx.insn_ctxt("trans_while"); - let next_cx = sub_block(cx, "while next"); - let loop_cx = loop_scope_block(cx, next_cx, "`while`", body.info()); - let cond_cx = scope_block(loop_cx, cond.info(), "while loop cond"); - let body_cx = scope_block(loop_cx, body.info(), "while loop body"); + let _icx = cx.insn_ctxt(~"trans_while"); + let next_cx = sub_block(cx, ~"while next"); + let loop_cx = loop_scope_block(cx, next_cx, ~"`while`", body.info()); + let cond_cx = scope_block(loop_cx, cond.info(), ~"while loop cond"); + let body_cx = scope_block(loop_cx, body.info(), ~"while loop body"); Br(cx, loop_cx.llbb); Br(loop_cx, cond_cx.llbb); let cond_res = trans_temp_expr(cond_cx, cond); @@ -1938,9 +1939,9 @@ fn trans_while(cx: block, cond: @ast::expr, body: ast::blk) } fn trans_loop(cx:block, body: ast::blk) -> block { - let _icx = cx.insn_ctxt("trans_loop"); - let next_cx = sub_block(cx, "next"); - let body_cx = loop_scope_block(cx, next_cx, "`loop`", body.info()); + let _icx = cx.insn_ctxt(~"trans_loop"); + let next_cx = sub_block(cx, ~"next"); + let body_cx = loop_scope_block(cx, next_cx, ~"`loop`", body.info()); let body_end = trans_block(body_cx, body, ignore); cleanup_and_Br(body_end, body_cx, body_cx.llbb); Br(cx, body_cx.llbb); @@ -2078,7 +2079,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, vtables: option<typeck::vtable_res>, ref_id: option<ast::node_id>) -> {val: ValueRef, must_cast: bool} { - let _icx = ccx.insn_ctxt("monomorphic_fn"); + let _icx = ccx.insn_ctxt(~"monomorphic_fn"); let mut must_cast = false; let substs = vec::map(real_substs, |t| { alt normalize_for_monomorphization(ccx.tcx, t) { @@ -2131,17 +2132,19 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, must_cast: true}; } ast_map::node_ctor(nm, _, ct, _, pt) { (pt, nm, ct.span) } - ast_map::node_dtor(_, dtor, _, pt) {(pt, @"drop"/~, dtor.span)} - ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") } + ast_map::node_dtor(_, dtor, _, pt) {(pt, @~"drop", dtor.span)} + ast_map::node_expr(*) { + ccx.tcx.sess.bug(~"Can't monomorphize an expr") + } ast_map::node_export(*) { - ccx.tcx.sess.bug("Can't monomorphize an export") + ccx.tcx.sess.bug(~"Can't monomorphize an export") } - ast_map::node_arg(*) { ccx.tcx.sess.bug("Can't monomorphize an arg") } + ast_map::node_arg(*) { ccx.tcx.sess.bug(~"Can't monomorphize an arg") } ast_map::node_block(*) { - ccx.tcx.sess.bug("Can't monomorphize a block") + ccx.tcx.sess.bug(~"Can't monomorphize a block") } ast_map::node_local(*) { - ccx.tcx.sess.bug("Can't monomorphize a local") + ccx.tcx.sess.bug(~"Can't monomorphize a local") } }; let mono_ty = ty::subst_tps(ccx.tcx, substs, llitem_ty); @@ -2153,7 +2156,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, // causing an infinite expansion. if depth > 10u { ccx.sess.span_fatal( - span, "overly deep expansion of inlined function"); + span, ~"overly deep expansion of inlined function"); } ccx.monomorphizing.insert(fn_id, depth + 1u); @@ -2175,7 +2178,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, d } ast_map::node_item(*) { - ccx.tcx.sess.bug("Can't monomorphize this kind of item") + ccx.tcx.sess.bug(~"Can't monomorphize this kind of item") } ast_map::node_foreign_item(i, _, _) { let d = mk_lldecl(); @@ -2216,23 +2219,25 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let parent_id = alt ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, dtor.node.self_id)) { some(did) { did } - none { ccx.sess.span_bug(dtor.span, "Bad self ty in \ + none { ccx.sess.span_bug(dtor.span, ~"Bad self ty in \ dtor"); } }; trans_class_dtor(ccx, *pt, dtor.node.body, dtor.node.id, psubsts, some(hash_id), parent_id) } // Ugh -- but this ensures any new variants won't be forgotten - ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") } + ast_map::node_expr(*) { + ccx.tcx.sess.bug(~"Can't monomorphize an expr") + } ast_map::node_export(*) { - ccx.tcx.sess.bug("Can't monomorphize an export") + ccx.tcx.sess.bug(~"Can't monomorphize an export") } - ast_map::node_arg(*) { ccx.tcx.sess.bug("Can't monomorphize an arg") } + ast_map::node_arg(*) { ccx.tcx.sess.bug(~"Can't monomorphize an arg") } ast_map::node_block(*) { - ccx.tcx.sess.bug("Can't monomorphize a block") + ccx.tcx.sess.bug(~"Can't monomorphize a block") } ast_map::node_local(*) { - ccx.tcx.sess.bug("Can't monomorphize a local") + ccx.tcx.sess.bug(~"Can't monomorphize a local") } }; ccx.monomorphizing.insert(fn_id, depth); @@ -2243,7 +2248,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) -> ast::def_id { - let _icx = ccx.insn_ctxt("maybe_instantiate_inline"); + let _icx = ccx.insn_ctxt(~"maybe_instantiate_inline"); alt ccx.external.find(fn_id) { some(some(node_id)) { // Already inline @@ -2293,7 +2298,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) local_def(my_id) } csearch::found_parent(_, _) { - ccx.sess.bug("maybe_get_item_ast returned a found_parent \ + ccx.sess.bug(~"maybe_get_item_ast returned a found_parent \ with a non-item parent"); } csearch::found(ast::ii_method(impl_did, mth)) { @@ -2321,7 +2326,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("lval_static_fn"); + let _icx = bcx.insn_ctxt(~"lval_static_fn"); let vts = option::map(bcx.ccx().maps.vtable_map.find(id), |vts| { impl::resolve_vtables_in_fn_ctxt(bcx.fcx, vts) }); @@ -2331,7 +2336,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>) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("lval_static_fn_inner"); + let _icx = bcx.insn_ctxt(~"lval_static_fn_inner"); let ccx = bcx.ccx(), tcx = ccx.tcx; let tpt = ty::lookup_item_type(tcx, fn_id); @@ -2381,7 +2386,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, } fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { - let _icx = ccx.insn_ctxt("lookup_discriminant"); + let _icx = ccx.insn_ctxt(~"lookup_discriminant"); alt ccx.discrims.find(vid) { none { // It's an external discriminant that we haven't seen yet. @@ -2404,13 +2409,13 @@ fn cast_self(cx: block, slf: val_self_pair) -> ValueRef { } fn trans_local_var(cx: block, def: ast::def) -> local_var_result { - let _icx = cx.insn_ctxt("trans_local_var"); + let _icx = cx.insn_ctxt(~"trans_local_var"); fn take_local(table: hashmap<ast::node_id, local_val>, id: ast::node_id) -> local_var_result { alt table.find(id) { some(local_mem(v)) { {val: v, kind: owned} } some(local_imm(v)) { {val: v, kind: owned_imm} } - r { fail("take_local: internal error"); } + r { fail(~"take_local: internal error"); } } } alt def { @@ -2429,7 +2434,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { ast::def_self(sid) { let slf = alt copy cx.fcx.llself { some(s) { cast_self(cx, s) } - none { cx.sess().bug("trans_local_var: reference to self \ + none { cx.sess().bug(~"trans_local_var: reference to self \ out of context"); } }; ret {val: slf, kind: owned}; @@ -2443,9 +2448,9 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { fn trans_path(cx: block, id: ast::node_id) -> lval_maybe_callee { - let _icx = cx.insn_ctxt("trans_path"); + let _icx = cx.insn_ctxt(~"trans_path"); alt cx.tcx().def_map.find(id) { - none { cx.sess().bug("trans_path: unbound node ID"); } + none { cx.sess().bug(~"trans_path: unbound node ID"); } some(df) { ret trans_var(cx, df, id); } @@ -2453,7 +2458,7 @@ fn trans_path(cx: block, id: ast::node_id) } fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { - let _icx = cx.insn_ctxt("trans_var"); + let _icx = cx.insn_ctxt(~"trans_var"); let ccx = cx.ccx(); alt def { ast::def_fn(did, _) { @@ -2492,7 +2497,7 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { fn trans_rec_field(bcx: block, base: @ast::expr, field: ast::ident) -> lval_result { - let _icx = bcx.insn_ctxt("trans_rec_field"); + let _icx = bcx.insn_ctxt(~"trans_rec_field"); let {bcx, val} = trans_temp_expr(bcx, base); let {bcx, val, ty} = autoderef(bcx, base.id, val, expr_ty(bcx, base), @@ -2512,7 +2517,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, ty::class_items_as_mutable_fields(bcx.tcx(), did, substs) } // Constraint? - _ { bcx.tcx().sess.span_bug(sp, "trans_rec_field:\ + _ { bcx.tcx().sess.span_bug(sp, ~"trans_rec_field:\ base expr has non-record type"); } }; // seems wrong? Doesn't take into account the field @@ -2537,7 +2542,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, idx: @ast::expr) -> lval_result { - let _icx = cx.insn_ctxt("trans_index"); + let _icx = cx.insn_ctxt(~"trans_index"); let base_ty = expr_ty(cx, base); let exp = trans_temp_expr(cx, base); let lv = autoderef(exp.bcx, base.id, exp.val, base_ty, uint::max_value); @@ -2562,9 +2567,9 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, let unit_ty = node_id_type(cx, ex.id); let llunitty = type_of(ccx, unit_ty); let unit_sz = llsize_of(ccx, llunitty); - maybe_name_value(cx.ccx(), unit_sz, "unit_sz"); + maybe_name_value(cx.ccx(), unit_sz, ~"unit_sz"); let scaled_ix = Mul(bcx, ix_val, unit_sz); - maybe_name_value(cx.ccx(), scaled_ix, "scaled_ix"); + maybe_name_value(cx.ccx(), scaled_ix, ~"scaled_ix"); let mut (base, len) = tvec::get_base_and_len(bcx, v, base_ty); @@ -2578,7 +2583,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len); let bcx = do with_cond(bcx, bounds_check) |bcx| { // fail: bad bounds check. - trans_fail(bcx, some(ex.span), "bounds check") + trans_fail(bcx, some(ex.span), ~"bounds check") }; let elt = InBoundsGEP(bcx, base, ~[ix_val]); ret lval_owned(bcx, PointerCast(bcx, elt, T_ptr(llunitty))); @@ -2594,7 +2599,7 @@ fn expr_is_lval(bcx: block, e: @ast::expr) -> bool { } fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("trans_callee"); + let _icx = bcx.insn_ctxt(~"trans_callee"); alt e.node { ast::expr_path(path) { ret trans_path(bcx, e.id); } ast::expr_field(base, _, _) { @@ -2605,7 +2610,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { ret impl::trans_method_callee(bcx, e.id, base, origin); } _ { - bcx.ccx().sess.span_bug(e.span, "trans_callee: weird expr"); + bcx.ccx().sess.span_bug(e.span, ~"trans_callee: weird expr"); } } } @@ -2635,7 +2640,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { scope_id]); } - let _icx = lv.bcx.insn_ctxt("root_value_lval"); + let _icx = lv.bcx.insn_ctxt(~"root_value_lval"); let ty = expr_ty(lv.bcx, e); let root_loc = alloca_zeroed(lv.bcx, type_of(cx.ccx(), ty)); let bcx = store_temp_expr(lv.bcx, INIT, root_loc, lv, ty, false); @@ -2645,7 +2650,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { }; fn unrooted(cx: block, e: @ast::expr) -> lval_result { - let _icx = cx.insn_ctxt("trans_lval"); + let _icx = cx.insn_ctxt(~"trans_lval"); alt e.node { ast::expr_path(_) { let v = trans_path(cx, e.id); @@ -2679,7 +2684,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { }; ret lval_owned(sub.bcx, val); } - _ { cx.sess().span_bug(e.span, "non-lval in trans_lval"); } + _ { cx.sess().span_bug(e.span, ~"non-lval in trans_lval"); } } } } @@ -2694,7 +2699,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { */ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { #debug("non_gc_box_cast"); - add_comment(cx, "non_gc_box_cast"); + add_comment(cx, ~"non_gc_box_cast"); assert(llvm::LLVMGetPointerAddressSpace(val_ty(val)) as uint == 1u); let non_gc_t = T_ptr(llvm::LLVMGetElementType(val_ty(val))); PointerCast(cx, val, non_gc_t) @@ -2703,7 +2708,7 @@ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { fn lval_maybe_callee_to_lval(c: lval_maybe_callee, sp: span) -> lval_result { alt c.env { self_env(*) { - c.bcx.sess().span_bug(sp, "implicitly binding method call"); + c.bcx.sess().span_bug(sp, ~"implicitly binding method call"); } is_closure { {bcx: c.bcx, val: c.val, kind: c.kind} } null_env { @@ -2717,7 +2722,7 @@ fn lval_maybe_callee_to_lval(c: lval_maybe_callee, sp: span) -> lval_result { fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, llsrc: ValueRef, signed: bool) -> ValueRef { - let _icx = bcx.insn_ctxt("int_cast"); + let _icx = bcx.insn_ctxt(~"int_cast"); let srcsz = llvm::LLVMGetIntTypeWidth(llsrctype); let dstsz = llvm::LLVMGetIntTypeWidth(lldsttype); ret if dstsz == srcsz { @@ -2731,7 +2736,7 @@ fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, llsrc: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("float_cast"); + let _icx = bcx.insn_ctxt(~"float_cast"); let srcsz = lib::llvm::float_width(llsrctype); let dstsz = lib::llvm::float_width(lldsttype); ret if dstsz > srcsz { @@ -2759,7 +2764,7 @@ fn cast_type_kind(t: ty::t) -> cast_kind { fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, dest: dest) -> block { - let _icx = cx.insn_ctxt("trans_cast"); + let _icx = cx.insn_ctxt(~"trans_cast"); let ccx = cx.ccx(); let t_out = node_id_type(cx, id); alt ty::get(t_out).struct { @@ -2813,10 +2818,10 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, cast_integral {int_cast(e_res.bcx, ll_t_out, val_ty(lldiscrim_a), lldiscrim_a, true)} cast_float {SIToFP(e_res.bcx, lldiscrim_a, ll_t_out)} - _ { ccx.sess.bug("translating unsupported cast.") } + _ { ccx.sess.bug(~"translating unsupported cast.") } } } - _ { ccx.sess.bug("translating unsupported cast.") } + _ { ccx.sess.bug(~"translating unsupported cast.") } }; ret store_in_dest(e_res.bcx, newval, dest); } @@ -2843,7 +2848,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, derefs: uint) -> result { #debug("+++ trans_arg_expr on %s", expr_to_str(e)); - let _icx = cx.insn_ctxt("trans_arg_expr"); + let _icx = cx.insn_ctxt(~"trans_arg_expr"); let ccx = cx.ccx(); let e_ty = expr_ty(cx, e); let is_bot = ty::type_is_bot(e_ty); @@ -3021,7 +3026,7 @@ enum call_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} { - let _icx = cx.insn_ctxt("trans_args"); + let _icx = cx.insn_ctxt(~"trans_args"); let mut temp_cleanups = ~[]; let arg_tys = ty::ty_fn_args(fn_ty); let mut llargs: ~[ValueRef] = ~[]; @@ -3083,7 +3088,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, fn trans_call(in_cx: block, call_ex: @ast::expr, f: @ast::expr, args: call_args, id: ast::node_id, dest: dest) -> block { - let _icx = in_cx.insn_ctxt("trans_call"); + let _icx = in_cx.insn_ctxt(~"trans_call"); trans_call_inner( in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id), |cx| trans_callee(cx, f), args, dest) @@ -3115,7 +3120,7 @@ fn trans_call_inner( args: call_args, dest: dest) -> block { - do with_scope(in_cx, call_info, "call") |cx| { + do with_scope(in_cx, call_info, ~"call") |cx| { let ret_in_loop = alt args { arg_exprs(args) { args.len() > 0u && alt vec::last(args).node { ast::expr_loop_body(@{node: ast::expr_fn_block(_, body, _), _}) { @@ -3198,15 +3203,15 @@ fn trans_call_inner( } fn invoke(bcx: block, llfn: ValueRef, llargs: ~[ValueRef]) -> block { - let _icx = bcx.insn_ctxt("invoke_"); + let _icx = bcx.insn_ctxt(~"invoke_"); if bcx.unreachable { ret bcx; } if need_invoke(bcx) { - log(debug, "invoking"); - let normal_bcx = sub_block(bcx, "normal return"); + log(debug, ~"invoking"); + let normal_bcx = sub_block(bcx, ~"normal return"); Invoke(bcx, llfn, llargs, normal_bcx.llbb, get_landing_pad(bcx)); ret normal_bcx; } else { - log(debug, "calling"); + log(debug, ~"calling"); Call(bcx, llfn, llargs); ret bcx; } @@ -3268,7 +3273,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) { } fn get_landing_pad(bcx: block) -> BasicBlockRef { - let _icx = bcx.insn_ctxt("get_landing_pad"); + let _icx = bcx.insn_ctxt(~"get_landing_pad"); let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below do in_lpad_scope_cx(bcx) |inf| { @@ -3276,7 +3281,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { alt copy inf.landing_pad { some(target) { cached = some(target); } none { - pad_bcx = sub_block(bcx, "unwind"); + pad_bcx = sub_block(bcx, ~"unwind"); inf.landing_pad = some(pad_bcx.llbb); } } @@ -3317,7 +3322,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { } fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_tup"); + let _icx = bcx.insn_ctxt(~"trans_tup"); let mut bcx = bcx; let addr = alt dest { ignore { @@ -3325,7 +3330,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { ret bcx; } save_in(pos) { pos } - _ { bcx.tcx().sess.bug("trans_tup: weird dest"); } + _ { bcx.tcx().sess.bug(~"trans_tup: weird dest"); } }; let mut temp_cleanups = ~[]; for vec::eachi(elts) |i, e| { @@ -3342,7 +3347,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { 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"); + let _icx = bcx.insn_ctxt(~"trans_rec"); let t = node_id_type(bcx, id); let mut bcx = bcx; let addr = alt check dest { @@ -3405,7 +3410,7 @@ fn trans_expr_save_in(bcx: block, e: @ast::expr, dest: ValueRef) // trans_expr_save_in. For intermediates where you don't care about lval-ness, // use trans_temp_expr. fn trans_temp_lval(bcx: block, e: @ast::expr) -> lval_result { - let _icx = bcx.insn_ctxt("trans_temp_lval"); + let _icx = bcx.insn_ctxt(~"trans_temp_lval"); let mut bcx = bcx; if expr_is_lval(bcx, e) { ret trans_lval(bcx, e); @@ -3431,7 +3436,7 @@ fn trans_temp_lval(bcx: block, e: @ast::expr) -> lval_result { // Use only for intermediate values. See trans_expr and trans_expr_save_in for // expressions that must 'end up somewhere' (or get ignored). fn trans_temp_expr(bcx: block, e: @ast::expr) -> result { - let _icx = bcx.insn_ctxt("trans_temp_expr"); + let _icx = bcx.insn_ctxt(~"trans_temp_expr"); lval_result_to_result(trans_temp_lval(bcx, e), expr_ty(bcx, e)) } @@ -3492,7 +3497,7 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id, // - exprs returning nil or bot always get dest=ignore // - exprs with non-immediate type never get dest=by_val fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_expr"); + let _icx = bcx.insn_ctxt(~"trans_expr"); debuginfo::update_source_pos(bcx, e.span); if expr_is_lval(bcx, e) { @@ -3514,7 +3519,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { scope_id]); } - let _icx = bcx.insn_ctxt("root_value_expr"); + let _icx = bcx.insn_ctxt(~"root_value_expr"); add_root_cleanup(bcx, scope_id, root_loc, ty); let lv = {bcx: bcx, val: root_loc, kind: owned}; lval_result_to_dps(lv, ty, false, dest) @@ -3531,7 +3536,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { ret alt::trans_alt(bcx, e, expr, arms, mode, dest); } ast::expr_block(blk) { - ret do with_scope(bcx, blk.info(), "block-expr body") |bcx| { + ret do with_scope(bcx, blk.info(), ~"block-expr body") |bcx| { trans_block(bcx, blk, dest) }; } @@ -3627,11 +3632,11 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { } ast::expr_assert(a) { assert dest == ignore; - ret trans_check_expr(bcx, e, a, "Assertion"); + ret trans_check_expr(bcx, e, a, ~"Assertion"); } ast::expr_check(ast::checked_expr, a) { assert dest == ignore; - ret trans_check_expr(bcx, e, a, "Predicate"); + ret trans_check_expr(bcx, e, a, ~"Predicate"); } ast::expr_check(ast::claimed_expr, a) { assert dest == ignore; @@ -3641,9 +3646,9 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { if it's set to false and acting like a check otherwise. */ let c = get_extern_const(bcx.ccx().externs, bcx.ccx().llmod, - "check_claims", T_bool()); + ~"check_claims", T_bool()); ret do with_cond(bcx, Load(bcx, c)) |bcx| { - trans_check_expr(bcx, e, a, "Claim") + trans_check_expr(bcx, e, a, ~"Claim") }; } ast::expr_while(cond, body) { @@ -3728,7 +3733,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { store_in_dest(bcx, ptr_val, dest) } _ { - bcx.tcx().sess.span_bug(e.span, "trans_expr reached \ + bcx.tcx().sess.span_bug(e.span, ~"trans_expr reached \ fall-through case"); } } @@ -3795,20 +3800,20 @@ fn do_spill_noroot(++cx: block, v: ValueRef) -> ValueRef { } fn spill_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef { - let _icx = cx.insn_ctxt("spill_if_immediate"); + let _icx = cx.insn_ctxt(~"spill_if_immediate"); if ty::type_is_immediate(t) { ret do_spill(cx, v, t); } ret v; } fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef { - let _icx = cx.insn_ctxt("load_if_immediate"); + let _icx = cx.insn_ctxt(~"load_if_immediate"); if ty::type_is_immediate(t) { ret Load(cx, v); } ret v; } fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, bcx: block, e: @ast::expr) -> block { - let _icx = bcx.insn_ctxt("trans_log"); + let _icx = bcx.insn_ctxt(~"trans_log"); let ccx = bcx.ccx(); if ty::type_is_bot(expr_ty(bcx, lvl)) { ret trans_expr(bcx, lvl, ignore); @@ -3825,7 +3830,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, ccx.module_data.get(modname) } else { let s = link::mangle_internal_name_by_path_and_seq( - ccx, modpath, @"loglevel"/~); + ccx, modpath, @~"loglevel"); let global = str::as_c_str(s, |buf| { llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf) }); @@ -3837,14 +3842,14 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, }; let current_level = Load(bcx, global); let {bcx, val: level} = { - do with_scope_result(bcx, lvl.info(), "level") |bcx| { + do with_scope_result(bcx, lvl.info(), ~"level") |bcx| { trans_temp_expr(bcx, lvl) } }; do with_cond(bcx, ICmp(bcx, lib::llvm::IntUGE, current_level, level)) |bcx| { - do with_scope(bcx, log_ex.info(), "log") |bcx| { + do with_scope(bcx, log_ex.info(), ~"log") |bcx| { let {bcx, val, _} = trans_temp_expr(bcx, e); let e_ty = expr_ty(bcx, e); let tydesc = get_tydesc_simple(ccx, e_ty); @@ -3858,11 +3863,11 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, } fn trans_check_expr(bcx: block, chk_expr: @ast::expr, - pred_expr: @ast::expr, s: str) -> block { - let _icx = bcx.insn_ctxt("trans_check_expr"); - let expr_str = s + " " + expr_to_str(pred_expr) + " failed"; + pred_expr: @ast::expr, s: ~str) -> block { + let _icx = bcx.insn_ctxt(~"trans_check_expr"); + let expr_str = s + ~" " + expr_to_str(pred_expr) + ~" failed"; let {bcx, val} = { - do with_scope_result(bcx, chk_expr.info(), "check") |bcx| { + do with_scope_result(bcx, chk_expr.info(), ~"check") |bcx| { trans_temp_expr(bcx, pred_expr) } }; @@ -3873,7 +3878,7 @@ fn trans_check_expr(bcx: block, chk_expr: @ast::expr, fn trans_fail_expr(bcx: block, sp_opt: option<span>, fail_expr: option<@ast::expr>) -> block { - let _icx = bcx.insn_ctxt("trans_fail_expr"); + let _icx = bcx.insn_ctxt(~"trans_fail_expr"); let mut bcx = bcx; alt fail_expr { some(expr) { @@ -3890,17 +3895,17 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>, ret bcx; } else { bcx.sess().span_bug( - expr.span, "fail called with unsupported type " + + expr.span, ~"fail called with unsupported type " + ppaux::ty_to_str(tcx, e_ty)); } } - _ { ret trans_fail(bcx, sp_opt, "explicit failure"); } + _ { ret trans_fail(bcx, sp_opt, ~"explicit failure"); } } } -fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: str) { +fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: ~str) { if !bcx.sess().trace() { ret; } - let _icx = bcx.insn_ctxt("trans_trace"); + let _icx = bcx.insn_ctxt(~"trans_trace"); add_comment(bcx, trace_str); let V_trace_str = C_cstr(bcx.ccx(), trace_str); let {V_filename, V_line} = alt sp_opt { @@ -3911,7 +3916,7 @@ fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: str) { V_line: loc.line as int} } none { - {V_filename: C_cstr(bcx.ccx(), "<runtime>"), + {V_filename: C_cstr(bcx.ccx(), ~"<runtime>"), V_line: 0} } }; @@ -3922,16 +3927,16 @@ fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: str) { Call(bcx, ccx.upcalls.trace, args); } -fn trans_fail(bcx: block, sp_opt: option<span>, fail_str: str) -> +fn trans_fail(bcx: block, sp_opt: option<span>, fail_str: ~str) -> block { - let _icx = bcx.insn_ctxt("trans_fail"); + let _icx = bcx.insn_ctxt(~"trans_fail"); let V_fail_str = C_cstr(bcx.ccx(), fail_str); ret trans_fail_value(bcx, sp_opt, V_fail_str); } fn trans_fail_value(bcx: block, sp_opt: option<span>, V_fail_str: ValueRef) -> block { - let _icx = bcx.insn_ctxt("trans_fail_value"); + let _icx = bcx.insn_ctxt(~"trans_fail_value"); let ccx = bcx.ccx(); let {V_filename, V_line} = alt sp_opt { some(sp) { @@ -3941,7 +3946,7 @@ fn trans_fail_value(bcx: block, sp_opt: option<span>, V_line: loc.line as int} } none { - {V_filename: C_cstr(bcx.ccx(), "<runtime>"), + {V_filename: C_cstr(bcx.ccx(), ~"<runtime>"), V_line: 0} } }; @@ -3955,7 +3960,7 @@ fn trans_fail_value(bcx: block, sp_opt: option<span>, fn trans_break_cont(bcx: block, to_end: bool) -> block { - let _icx = bcx.insn_ctxt("trans_break_cont"); + let _icx = bcx.insn_ctxt(~"trans_break_cont"); // Locate closest loop block, outputting cleanup as we go. let mut unwind = bcx; let mut target; @@ -3996,7 +4001,7 @@ fn trans_cont(cx: block) -> block { } fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { - let _icx = bcx.insn_ctxt("trans_ret"); + let _icx = bcx.insn_ctxt(~"trans_ret"); let mut bcx = bcx; let retptr = alt copy bcx.fcx.loop_ret { some({flagptr, retptr}) { @@ -4025,17 +4030,17 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { } fn build_return(bcx: block) { - let _icx = bcx.insn_ctxt("build_return"); + let _icx = bcx.insn_ctxt(~"build_return"); Br(bcx, bcx.fcx.llreturn); } fn init_local(bcx: block, local: @ast::local) -> block { - let _icx = bcx.insn_ctxt("init_local"); + let _icx = bcx.insn_ctxt(~"init_local"); let ty = node_id_type(bcx, local.node.id); let llptr = alt bcx.fcx.lllocals.find(local.node.id) { some(local_mem(v)) { v } _ { bcx.tcx().sess.span_bug(local.span, - "init_local: Someone forgot to document why it's\ + ~"init_local: Someone forgot to document why it's\ safe to assume local.node.init must be local_mem!"); } }; @@ -4058,7 +4063,7 @@ fn init_local(bcx: block, local: @ast::local) -> block { } fn trans_stmt(cx: block, s: ast::stmt) -> block { - let _icx = cx.insn_ctxt("trans_stmt"); + let _icx = cx.insn_ctxt(~"trans_stmt"); #debug["trans_stmt(%s)", stmt_to_str(s)]; if !cx.sess().no_asm_comments() { @@ -4093,11 +4098,11 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { // You probably don't want to use this one. See the // next three functions instead. fn new_block(cx: fn_ctxt, parent: option<block>, +kind: block_kind, - name: str, opt_node_info: option<node_info>) -> block { + name: ~str, opt_node_info: option<node_info>) -> block { let s = if cx.ccx.sess.opts.save_temps || cx.ccx.sess.opts.debuginfo { cx.ccx.names(name) - } else { "" }; + } else { ~"" }; let llbb: BasicBlockRef = str::as_c_str(s, |buf| { llvm::LLVMAppendBasicBlock(cx.llfn, buf) }); @@ -4116,17 +4121,17 @@ fn simple_block_scope() -> block_kind { // Use this when you're at the top block of a function or the like. fn top_scope_block(fcx: fn_ctxt, opt_node_info: option<node_info>) -> block { ret new_block(fcx, none, simple_block_scope(), - "function top level", opt_node_info); + ~"function top level", opt_node_info); } fn scope_block(bcx: block, opt_node_info: option<node_info>, - n: str) -> block { + n: ~str) -> block { ret new_block(bcx.fcx, some(bcx), simple_block_scope(), n, opt_node_info); } -fn loop_scope_block(bcx: block, loop_break: block, n: str, +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), @@ -4138,7 +4143,7 @@ fn loop_scope_block(bcx: block, loop_break: block, n: str, // Use this when you're making a general CFG BB within a scope. -fn sub_block(bcx: block, n: str) -> block { +fn sub_block(bcx: block, n: ~str) -> block { new_block(bcx.fcx, some(bcx), block_non_scope, n, none) } @@ -4160,7 +4165,7 @@ fn trans_block_cleanups(bcx: block, cleanup_cx: block) -> block { fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> block { - let _icx = bcx.insn_ctxt("trans_block_cleanups"); + let _icx = bcx.insn_ctxt(~"trans_block_cleanups"); if bcx.unreachable { ret bcx; } let mut bcx = bcx; alt check cleanup_cx.kind { @@ -4187,7 +4192,7 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> // instruction. fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, leave: option<BasicBlockRef>) { - let _icx = bcx.insn_ctxt("cleanup_and_leave"); + let _icx = bcx.insn_ctxt(~"cleanup_and_leave"); let mut cur = bcx, bcx = bcx; let is_lpad = leave == none; loop { @@ -4206,7 +4211,7 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, Br(bcx, cp.dest); ret; } - let sub_cx = sub_block(bcx, "cleanup"); + let sub_cx = sub_block(bcx, ~"cleanup"); Br(bcx, sub_cx.llbb); vec::push(inf.cleanup_paths, {target: leave, dest: sub_cx.llbb}); bcx = trans_block_cleanups_(sub_cx, cur, is_lpad); @@ -4230,30 +4235,30 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, fn cleanup_and_Br(bcx: block, upto: block, target: BasicBlockRef) { - let _icx = bcx.insn_ctxt("cleanup_and_Br"); + let _icx = bcx.insn_ctxt(~"cleanup_and_Br"); cleanup_and_leave(bcx, some(upto.llbb), some(target)); } fn leave_block(bcx: block, out_of: block) -> block { - let _icx = bcx.insn_ctxt("leave_block"); - let next_cx = sub_block(block_parent(out_of), "next"); + let _icx = bcx.insn_ctxt(~"leave_block"); + let next_cx = sub_block(block_parent(out_of), ~"next"); if bcx.unreachable { Unreachable(next_cx); } cleanup_and_Br(bcx, out_of, next_cx.llbb); next_cx } fn with_scope(bcx: block, opt_node_info: option<node_info>, - name: str, f: fn(block) -> block) -> block { - let _icx = bcx.insn_ctxt("with_scope"); + name: ~str, f: fn(block) -> block) -> block { + let _icx = bcx.insn_ctxt(~"with_scope"); let scope_cx = scope_block(bcx, opt_node_info, name); Br(bcx, scope_cx.llbb); leave_block(f(scope_cx), scope_cx) } fn with_scope_result(bcx: block, opt_node_info: option<node_info>, - name: str, f: fn(block) -> result) + name: ~str, f: fn(block) -> result) -> result { - let _icx = bcx.insn_ctxt("with_scope_result"); + let _icx = bcx.insn_ctxt(~"with_scope_result"); let scope_cx = scope_block(bcx, opt_node_info, name); Br(bcx, scope_cx.llbb); let {bcx, val} = f(scope_cx); @@ -4261,8 +4266,8 @@ fn with_scope_result(bcx: block, opt_node_info: option<node_info>, } fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block { - let _icx = bcx.insn_ctxt("with_cond"); - let next_cx = sub_block(bcx, "next"), cond_cx = sub_block(bcx, "cond"); + let _icx = bcx.insn_ctxt(~"with_cond"); + let next_cx = sub_block(bcx, ~"next"), cond_cx = sub_block(bcx, ~"cond"); CondBr(bcx, val, cond_cx.llbb, next_cx.llbb); let after_cx = f(cond_cx); if !after_cx.terminated { Br(after_cx, next_cx.llbb); } @@ -4286,7 +4291,7 @@ fn block_locals(b: ast::blk, it: fn(@ast::local)) { } fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { - let _icx = bcx.insn_ctxt("alloc_ty"); + let _icx = bcx.insn_ctxt(~"alloc_ty"); let ccx = bcx.ccx(); let llty = type_of(ccx, t); if ty::type_has_params(t) { log(error, ppaux::ty_to_str(ccx.tcx, t)); } @@ -4296,7 +4301,7 @@ fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { } fn alloc_local(cx: block, local: @ast::local) -> block { - let _icx = cx.insn_ctxt("alloc_local"); + let _icx = cx.insn_ctxt(~"alloc_local"); let t = node_id_type(cx, local.node.id); let simple_name = alt local.node.pat.node { ast::pat_ident(pth, none) { some(path_to_ident(pth)) } @@ -4316,7 +4321,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block { fn trans_block(bcx: block, b: ast::blk, dest: dest) -> block { - let _icx = bcx.insn_ctxt("trans_block"); + let _icx = bcx.insn_ctxt(~"trans_block"); let mut bcx = bcx; do block_locals(b) |local| { bcx = alloc_local(bcx, local); }; for vec::each(b.node.stmts) |s| { @@ -4337,11 +4342,11 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest) // Creates the standard set of basic blocks for a function fn mk_standard_basic_blocks(llfn: ValueRef) -> {sa: BasicBlockRef, ca: BasicBlockRef, rt: BasicBlockRef} { - {sa: str::as_c_str("static_allocas", + {sa: str::as_c_str(~"static_allocas", |buf| llvm::LLVMAppendBasicBlock(llfn, buf)), - ca: str::as_c_str("load_env", + ca: str::as_c_str(~"load_env", |buf| llvm::LLVMAppendBasicBlock(llfn, buf)), - rt: str::as_c_str("return", + rt: str::as_c_str(~"return", |buf| llvm::LLVMAppendBasicBlock(llfn, buf))} } @@ -4398,7 +4403,7 @@ fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef, fn create_llargs_for_fn_args(cx: fn_ctxt, ty_self: self_arg, args: ~[ast::arg]) { - let _icx = cx.insn_ctxt("create_llargs_for_fn_args"); + let _icx = cx.insn_ctxt(~"create_llargs_for_fn_args"); // Skip the implicit arguments 0, and 1. let mut arg_n = first_real_arg; alt ty_self { @@ -4423,11 +4428,11 @@ 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 { - let _icx = fcx.insn_ctxt("copy_args_to_allocas"); + let _icx = fcx.insn_ctxt(~"copy_args_to_allocas"); let tcx = bcx.tcx(); let mut arg_n: uint = 0u, bcx = bcx; let epic_fail = fn@() -> ! { - tcx.sess.bug("someone forgot\ + tcx.sess.bug(~"someone forgot\ to document an invariant in copy_args_to_allocas!"); }; for vec::each(arg_tys) |arg| { @@ -4459,14 +4464,14 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], // Ties up the llstaticallocas -> llloadenv -> lltop edges, // and builds the return block. fn finish_fn(fcx: fn_ctxt, lltop: BasicBlockRef) { - let _icx = fcx.insn_ctxt("finish_fn"); + let _icx = fcx.insn_ctxt(~"finish_fn"); tie_up_header_blocks(fcx, lltop); let ret_cx = raw_block(fcx, fcx.llreturn); RetVoid(ret_cx); } fn tie_up_header_blocks(fcx: fn_ctxt, lltop: BasicBlockRef) { - let _icx = fcx.insn_ctxt("tie_up_header_blocks"); + let _icx = fcx.insn_ctxt(~"tie_up_header_blocks"); Br(raw_block(fcx, fcx.llstaticallocas), fcx.llloadenv); Br(raw_block(fcx, fcx.llloadenv), lltop); } @@ -4483,7 +4488,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl, id: ast::node_id, maybe_load_env: fn(fn_ctxt), finish: fn(block)) { - let _icx = ccx.insn_ctxt("trans_closure"); + let _icx = ccx.insn_ctxt(~"trans_closure"); set_uwtable(llfndecl); // Set up arguments to the function. @@ -4539,7 +4544,7 @@ fn trans_fn(ccx: @crate_ctxt, let do_time = ccx.sess.trans_stats(); let start = if do_time { time::get_time() } else { {sec: 0i64, nsec: 0i32} }; - let _icx = ccx.insn_ctxt("trans_fn"); + let _icx = ccx.insn_ctxt(~"trans_fn"); trans_closure(ccx, path, decl, body, llfndecl, ty_self, param_substs, id, |fcx| { @@ -4558,12 +4563,12 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, variant: ast::variant, disr: int, is_degen: bool, param_substs: option<param_substs>, llfndecl: ValueRef) { - let _icx = ccx.insn_ctxt("trans_enum_variant"); + let _icx = ccx.insn_ctxt(~"trans_enum_variant"); // Translate variant arguments to function arguments. let fn_args = vec::map(variant.node.args, |varg| {mode: ast::expl(ast::by_copy), ty: varg.ty, - ident: @"arg"/~, + ident: @~"arg", id: varg.id}); let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, param_substs, none); @@ -4609,7 +4614,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, // duplicate constants. I think. Maybe LLVM has a magical mode that does so // later on? fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { - let _icx = cx.insn_ctxt("trans_const_expr"); + let _icx = cx.insn_ctxt(~"trans_const_expr"); alt e.node { ast::expr_lit(lit) { trans_crate_lit(cx, e, *lit) } // If we have a vstore, just keep going; it has to be a string @@ -4649,7 +4654,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { else { llvm::LLVMConstURem(te1, te2) } } ast::and | - ast::or { cx.sess.span_unimpl(e.span, "binop logic"); } + ast::or { cx.sess.span_unimpl(e.span, ~"binop logic"); } ast::bitxor { llvm::LLVMConstXor(te1, te2) } ast::bitand { llvm::LLVMConstAnd(te1, te2) } ast::bitor { llvm::LLVMConstOr(te1, te2) } @@ -4663,7 +4668,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { ast::le | ast::ne | ast::ge | - ast::gt { cx.sess.span_unimpl(e.span, "binop comparator"); } + ast::gt { cx.sess.span_unimpl(e.span, ~"binop comparator"); } } } ast::expr_unary(u, e) { @@ -4674,7 +4679,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { ast::box(_) | ast::uniq(_) | ast::deref { cx.sess.span_bug(e.span, - "bad unop type in trans_const_expr"); } + ~"bad unop type in trans_const_expr"); } ast::not { llvm::LLVMConstNot(te) } ast::neg { if is_float { llvm::LLVMConstFNeg(te) } @@ -4717,20 +4722,20 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { trans_const_expr(cx, subexpr) } _ { - cx.sess.span_bug(e.span, "expected item"); + cx.sess.span_bug(e.span, ~"expected item"); } } } - _ { cx.sess.span_bug(e.span, "expected to find a const def") } + _ { cx.sess.span_bug(e.span, ~"expected to find a const def") } } } _ { cx.sess.span_bug(e.span, - "bad constant expression type in trans_const_expr"); } + ~"bad constant expression type in trans_const_expr"); } } } fn trans_const(ccx: @crate_ctxt, e: @ast::expr, id: ast::node_id) { - let _icx = ccx.insn_ctxt("trans_const"); + let _icx = ccx.insn_ctxt(~"trans_const"); let v = trans_const_expr(ccx, e); // The scalars come back as 1st class LLVM vals @@ -4845,7 +4850,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path, } fn trans_item(ccx: @crate_ctxt, item: ast::item) { - let _icx = ccx.insn_ctxt("trans_item"); + let _icx = ccx.insn_ctxt(~"trans_item"); let path = alt check ccx.tcx.items.get(item.id) { ast_map::node_item(_, p) { p } }; @@ -4933,7 +4938,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { // only as a convenience for humans working with the code, to organize names // and control visibility. fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) { - let _icx = ccx.insn_ctxt("trans_mod"); + let _icx = ccx.insn_ctxt(~"trans_mod"); for vec::each(m.items) |item| { trans_item(ccx, *item); } } @@ -4958,7 +4963,7 @@ fn register_fn_full(ccx: @crate_ctxt, sp: span, path: path, fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path, node_id: ast::node_id, node_type: ty::t, cc: lib::llvm::CallConv, llfty: TypeRef) -> ValueRef { - let ps: str = mangle_exported_name(ccx, path, node_type); + let ps: ~str = mangle_exported_name(ccx, path, node_type); let llfn: ValueRef = decl_fn(ccx.llmod, ps, cc, llfty); ccx.item_symbols.insert(node_id, ps); @@ -4976,14 +4981,14 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, main_node_type: ty::t) { if ccx.main_fn != none::<ValueRef> { - ccx.sess.span_fatal(sp, "multiple 'main' functions"); + ccx.sess.span_fatal(sp, ~"multiple 'main' functions"); } let main_takes_argv = // invariant! alt ty::get(main_node_type).struct { ty::ty_fn({inputs, _}) { inputs.len() != 0u } - _ { ccx.sess.span_fatal(sp, "main has a non-function type"); } + _ { ccx.sess.span_fatal(sp, ~"main has a non-function type"); } }; let llfn = create_main(ccx, main_llfn, main_takes_argv); @@ -4998,7 +5003,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, 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 llfdecl = decl_fn(ccx.llmod, "_rust_main", + let llfdecl = decl_fn(ccx.llmod, ~"_rust_main", lib::llvm::CCallConv, llfty); let fcx = new_fn_ctxt(ccx, ~[], llfdecl, none); @@ -5024,10 +5029,10 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, #[cfg(windows)] fn main_name() -> str { ret "WinMain@16"; } #[cfg(unix)] - fn main_name() -> str { ret "main"; } + fn main_name() -> ~str { ret ~"main"; } 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| { + let llbb = str::as_c_str(~"top", |buf| { llvm::LLVMAppendBasicBlock(llfn, buf) }); let bld = ccx.builder.B; @@ -5035,7 +5040,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, 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); - let start = decl_cdecl_fn(ccx.llmod, "rust_start", start_ty); + 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]; @@ -5078,14 +5083,14 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { /* If there's already a symbol for the dtor with <id> and substs <substs>, return it; otherwise, create one and register it, returning it as well */ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, - substs: option<param_substs>) -> str { + substs: option<param_substs>) -> ~str { let t = ty::node_id_to_type(ccx.tcx, id); alt ccx.item_symbols.find(id) { some(s) { s } none if is_none(substs) { let s = mangle_exported_name( ccx, - vec::append(path, ~[path_name(@ccx.names("dtor"))]), + vec::append(path, ~[path_name(@ccx.names(~"dtor"))]), t); ccx.item_symbols.insert(id, s); s @@ -5099,7 +5104,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, mangle_exported_name( ccx, vec::append(path, - ~[path_name(@ccx.names("dtor"))]), + ~[path_name(@ccx.names(~"dtor"))]), mono_ty) } none { @@ -5144,7 +5149,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ast_map::node_method(m, impl_id, pth) { exprt = true; let mty = ty::node_id_to_type(ccx.tcx, id); - let pth = vec::append(*pth, ~[path_name(@ccx.names("meth")), + let pth = vec::append(*pth, ~[path_name(@ccx.names(~"meth")), path_name(m.ident)]); let llfn = register_fn_full(ccx, m.span, pth, id, mty); set_inline_hint_if_appr(m.attrs, llfn); @@ -5206,7 +5211,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { // The constant translation pass. fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { - let _icx = ccx.insn_ctxt("trans_constant"); + let _icx = ccx.insn_ctxt(~"trans_constant"); alt it.node { ast::item_enum(variants, _) { let vi = ty::enum_variants(ccx.tcx, {crate: ast::local_crate, @@ -5215,7 +5220,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { let path = item_path(ccx, it); for vec::each(variants) |variant| { let p = vec::append(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); @@ -5250,7 +5255,7 @@ fn p2i(ccx: @crate_ctxt, v: ValueRef) -> ValueRef { ret llvm::LLVMConstPtrToInt(v, ccx.int_type); } -fn declare_intrinsics(llmod: ModuleRef) -> hashmap<str, 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] = @@ -5262,67 +5267,67 @@ fn declare_intrinsics(llmod: ModuleRef) -> hashmap<str, ValueRef> { let T_trap_args: ~[TypeRef] = ~[]; let T_frameaddress_args: ~[TypeRef] = ~[T_i32()]; let gcroot = - decl_cdecl_fn(llmod, "llvm.gcroot", + decl_cdecl_fn(llmod, ~"llvm.gcroot", T_fn(~[T_ptr(T_ptr(T_i8())), T_ptr(T_i8())], T_void())); let gcread = - decl_cdecl_fn(llmod, "llvm.gcread", + decl_cdecl_fn(llmod, ~"llvm.gcread", 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", + decl_cdecl_fn(llmod, ~"llvm.memmove.p0i8.p0i8.i32", T_fn(T_memmove32_args, T_void())); let memmove64 = - decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i64", + decl_cdecl_fn(llmod, ~"llvm.memmove.p0i8.p0i8.i64", T_fn(T_memmove64_args, T_void())); let memset32 = - decl_cdecl_fn(llmod, "llvm.memset.p0i8.i32", + decl_cdecl_fn(llmod, ~"llvm.memset.p0i8.i32", T_fn(T_memset32_args, T_void())); let memset64 = - decl_cdecl_fn(llmod, "llvm.memset.p0i8.i64", + 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, + let trap = decl_cdecl_fn(llmod, ~"llvm.trap", T_fn(T_trap_args, T_void())); - let frameaddress = decl_cdecl_fn(llmod, "llvm.frameaddress", + let frameaddress = decl_cdecl_fn(llmod, ~"llvm.frameaddress", T_fn(T_frameaddress_args, T_ptr(T_i8()))); let intrinsics = str_hash::<ValueRef>(); - intrinsics.insert("llvm.gcroot", gcroot); - intrinsics.insert("llvm.gcread", gcread); - intrinsics.insert("llvm.memmove.p0i8.p0i8.i32", memmove32); - intrinsics.insert("llvm.memmove.p0i8.p0i8.i64", memmove64); - intrinsics.insert("llvm.memset.p0i8.i32", memset32); - intrinsics.insert("llvm.memset.p0i8.i64", memset64); - intrinsics.insert("llvm.trap", trap); - intrinsics.insert("llvm.frameaddress", frameaddress); + intrinsics.insert(~"llvm.gcroot", gcroot); + intrinsics.insert(~"llvm.gcread", gcread); + intrinsics.insert(~"llvm.memmove.p0i8.p0i8.i32", memmove32); + intrinsics.insert(~"llvm.memmove.p0i8.p0i8.i64", memmove64); + intrinsics.insert(~"llvm.memset.p0i8.i32", memset32); + intrinsics.insert(~"llvm.memset.p0i8.i64", memset64); + intrinsics.insert(~"llvm.trap", trap); + intrinsics.insert(~"llvm.frameaddress", frameaddress); ret intrinsics; } fn declare_dbg_intrinsics(llmod: ModuleRef, - intrinsics: hashmap<str, ValueRef>) { + intrinsics: hashmap<~str, ValueRef>) { let declare = - decl_cdecl_fn(llmod, "llvm.dbg.declare", + decl_cdecl_fn(llmod, ~"llvm.dbg.declare", T_fn(~[T_metadata(), T_metadata()], T_void())); let value = - decl_cdecl_fn(llmod, "llvm.dbg.value", + decl_cdecl_fn(llmod, ~"llvm.dbg.value", T_fn(~[T_metadata(), T_i64(), T_metadata()], T_void())); - intrinsics.insert("llvm.dbg.declare", declare); - intrinsics.insert("llvm.dbg.value", value); + intrinsics.insert(~"llvm.dbg.declare", declare); + intrinsics.insert(~"llvm.dbg.value", value); } fn trap(bcx: block) { let v: ~[ValueRef] = ~[]; - alt bcx.ccx().intrinsics.find("llvm.trap") { + alt bcx.ccx().intrinsics.find(~"llvm.trap") { some(x) { Call(bcx, x, v); } - _ { bcx.sess().bug("unbound llvm.trap in trap"); } + _ { bcx.sess().bug(~"unbound llvm.trap in trap"); } } } fn create_module_map(ccx: @crate_ctxt) -> ValueRef { 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| { + let map = str::as_c_str(~"_rust_mod_map", |buf| { llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) }); lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); @@ -5347,9 +5352,9 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta, let cstore = sess.cstore; while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; } let mapname = if sess.building_library { - *mapmeta.name + "_" + *mapmeta.vers + "_" + mapmeta.extras_hash - } else { "toplevel" }; - let sym_name = "_rust_crate_map_" + mapname; + *mapmeta.name + ~"_" + *mapmeta.vers + ~"_" + mapmeta.extras_hash + } 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 map = str::as_c_str(sym_name, |buf| { @@ -5365,9 +5370,9 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { let cstore = ccx.sess.cstore; while cstore::have_crate_data(cstore, i) { let cdata = cstore::get_crate_data(cstore, i); - let nm = "_rust_crate_map_" + cdata.name + - "_" + *cstore::get_crate_vers(cstore, i) + - "_" + *cstore::get_crate_hash(cstore, i); + let nm = ~"_rust_crate_map_" + cdata.name + + ~"_" + *cstore::get_crate_vers(cstore, i) + + ~"_" + *cstore::get_crate_hash(cstore, i); let cr = str::as_c_str(nm, |buf| { llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf) }); @@ -5399,7 +5404,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) encode_inlined_item: encode_inlined_item }; - fn reexports(cx: @crate_ctxt) -> ~[(str, ast::def_id)] { + fn reexports(cx: @crate_ctxt) -> ~[(~str, ast::def_id)] { let mut reexports = ~[]; for cx.exp_map.each |exp_id, defs| { for defs.each |def| { @@ -5430,7 +5435,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { 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 mut llglobal = str::as_c_str("rust_metadata", |buf| { + let mut llglobal = str::as_c_str(~"rust_metadata", |buf| { llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf) }); llvm::LLVMSetInitializer(llglobal, llconst); @@ -5441,7 +5446,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { let t_ptr_i8 = T_ptr(T_i8()); llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8); - let llvm_used = str::as_c_str("llvm.used", |buf| { + let llvm_used = str::as_c_str(~"llvm.used", |buf| { llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf) }); lib::llvm::SetLinkage(llvm_used, lib::llvm::AppendingLinkage); @@ -5450,12 +5455,12 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { // Writes the current ABI version into the crate. fn write_abi_version(ccx: @crate_ctxt) { - mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version), + mk_global(ccx, ~"rust_abi_version", C_uint(ccx, abi::abi_version), false); } fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, - output: str, emap: resolve::exp_map, + output: ~str, emap: resolve::exp_map, maps: astencode::maps) -> (ModuleRef, link_meta) { let sha = std::sha1::sha1(); @@ -5471,7 +5476,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, // crashes if the module identifer is same as other symbols // such as a function name in the module. // 1. http://llvm.org/bugs/show_bug.cgi?id=11479 - let llmod_id = *link_meta.name + ".rc"; + let llmod_id = *link_meta.name + ~".rc"; let llmod = str::as_c_str(llmod_id, |buf| { llvm::LLVMModuleCreateWithNameInContext @@ -5496,9 +5501,9 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, let float_type = T_float(targ_cfg); let task_type = T_task(targ_cfg); let taskptr_type = T_ptr(task_type); - lib::llvm::associate_type(tn, "taskptr", taskptr_type); + lib::llvm::associate_type(tn, ~"taskptr", taskptr_type); let tydesc_type = T_tydesc(targ_cfg); - lib::llvm::associate_type(tn, "tydesc", tydesc_type); + lib::llvm::associate_type(tn, ~"tydesc", tydesc_type); let crate_map = decl_crate_map(sess, link_meta, llmod); let dbg_cx = if sess.opts.debuginfo { option::some(debuginfo::mk_ctxt(llmod_id)) @@ -5516,12 +5521,12 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, item_vals: int_hash::<ValueRef>(), exp_map: emap, reachable: reachable, - item_symbols: int_hash::<str>(), + item_symbols: int_hash::<~str>(), mut main_fn: none::<ValueRef>, link_meta: link_meta, enum_sizes: ty::new_ty_hash(), discrims: ast_util::new_def_hash::<ValueRef>(), - discrim_symbols: int_hash::<str>(), + discrim_symbols: int_hash::<~str>(), tydescs: ty::new_ty_hash(), external: ast_util::new_def_hash(), monomorphized: map::hashmap(hash_mono_id, |a, b| a == b), @@ -5563,12 +5568,12 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, { - let _icx = ccx.insn_ctxt("data"); + let _icx = ccx.insn_ctxt(~"data"); trans_constants(ccx, crate); } { - let _icx = ccx.insn_ctxt("text"); + let _icx = ccx.insn_ctxt(~"text"); trans_mod(ccx, crate.node.module); } @@ -5580,7 +5585,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, // Translate the metadata. write_metadata(ccx, crate); if ccx.sess.trans_stats() { - io::println("--- trans stats ---"); + io::println(~"--- trans stats ---"); io::println(#fmt("n_static_tydescs: %u", ccx.stats.n_static_tydescs)); io::println(#fmt("n_glues_created: %u", diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 8c261a402b4..3d6746aa2ea 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -15,7 +15,7 @@ fn B(cx: block) -> BuilderRef { ret b; } -fn count_insn(cx: block, category: str) { +fn count_insn(cx: block, category: ~str) { if cx.ccx().sess.count_llvm_insns() { let h = cx.ccx().stats.llvm_insns; @@ -36,17 +36,17 @@ fn count_insn(cx: block, category: str) { // Pass 2: concat strings for each elt, skipping // forwards over any cycles by advancing to rightmost // occurrence of each element in path. - let mut s = "."; + let mut s = ~"."; i = 0u; while i < len { let e = v[i]; i = mm.get(e); - s += "/"; + s += ~"/"; s += e; i += 1u; } - s += "/"; + s += ~"/"; s += category; let n = alt h.find(s) { some(n) { n } _ { 0u } }; @@ -67,7 +67,7 @@ fn RetVoid(cx: block) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "retvoid"); + count_insn(cx, ~"retvoid"); llvm::LLVMBuildRetVoid(B(cx)); } @@ -75,7 +75,7 @@ fn Ret(cx: block, V: ValueRef) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "ret"); + count_insn(cx, ~"ret"); llvm::LLVMBuildRet(B(cx), V); } @@ -93,7 +93,7 @@ fn Br(cx: block, Dest: BasicBlockRef) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "br"); + count_insn(cx, ~"br"); llvm::LLVMBuildBr(B(cx), Dest); } @@ -102,7 +102,7 @@ fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef, if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "condbr"); + count_insn(cx, ~"condbr"); llvm::LLVMBuildCondBr(B(cx), If, Then, Else); } @@ -123,7 +123,7 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "indirectbr"); + count_insn(cx, ~"indirectbr"); llvm::LLVMBuildIndirectBr(B(cx), Addr, NumDests as c_uint); } @@ -142,9 +142,9 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], #debug["Invoke(%s with arguments (%s))", val_str(cx.ccx().tn, Fn), str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)), - ", ")]; + ~", ")]; unsafe { - count_insn(cx, "invoke"); + count_insn(cx, ~"invoke"); llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, Then, Catch, noname()); @@ -157,7 +157,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], assert (!cx.terminated); cx.terminated = true; unsafe { - count_insn(cx, "fastinvoke"); + count_insn(cx, ~"fastinvoke"); let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, Then, Catch, noname()); @@ -169,7 +169,7 @@ fn Unreachable(cx: block) { if cx.unreachable { ret; } cx.unreachable = true; if !cx.terminated { - count_insn(cx, "unreachable"); + count_insn(cx, ~"unreachable"); llvm::LLVMBuildUnreachable(B(cx)); } } @@ -181,218 +181,218 @@ fn _Undef(val: ValueRef) -> ValueRef { /* Arithmetic */ fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "add"); + count_insn(cx, ~"add"); ret llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname()); } fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nswadd"); + count_insn(cx, ~"nswadd"); ret llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname()); } fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nuwadd"); + count_insn(cx, ~"nuwadd"); ret llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname()); } fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "fadd"); + count_insn(cx, ~"fadd"); ret llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname()); } fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "sub"); + count_insn(cx, ~"sub"); ret llvm::LLVMBuildSub(B(cx), LHS, RHS, noname()); } fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nwsub"); + count_insn(cx, ~"nwsub"); ret llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname()); } fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nuwsub"); + count_insn(cx, ~"nuwsub"); ret llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname()); } fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "sub"); + count_insn(cx, ~"sub"); ret llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname()); } fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "mul"); + count_insn(cx, ~"mul"); ret llvm::LLVMBuildMul(B(cx), LHS, RHS, noname()); } fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nswmul"); + count_insn(cx, ~"nswmul"); ret llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname()); } fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "nuwmul"); + count_insn(cx, ~"nuwmul"); ret llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname()); } fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "fmul"); + count_insn(cx, ~"fmul"); ret llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname()); } fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "udiv"); + count_insn(cx, ~"udiv"); ret llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname()); } fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "sdiv"); + count_insn(cx, ~"sdiv"); ret llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname()); } fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "extractsdiv"); + count_insn(cx, ~"extractsdiv"); ret llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname()); } fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "fdiv"); + count_insn(cx, ~"fdiv"); ret llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname()); } fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "urem"); + count_insn(cx, ~"urem"); ret llvm::LLVMBuildURem(B(cx), LHS, RHS, noname()); } fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "srem"); + count_insn(cx, ~"srem"); ret llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname()); } fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "frem"); + count_insn(cx, ~"frem"); ret llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname()); } fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "shl"); + count_insn(cx, ~"shl"); ret llvm::LLVMBuildShl(B(cx), LHS, RHS, noname()); } fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "lshr"); + count_insn(cx, ~"lshr"); ret llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname()); } fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "ashr"); + count_insn(cx, ~"ashr"); ret llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname()); } fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "and"); + count_insn(cx, ~"and"); ret llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname()); } fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "or"); + count_insn(cx, ~"or"); ret llvm::LLVMBuildOr(B(cx), LHS, RHS, noname()); } fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "xor"); + count_insn(cx, ~"xor"); ret llvm::LLVMBuildXor(B(cx), LHS, RHS, noname()); } fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(LHS); } - count_insn(cx, "binop"); + count_insn(cx, ~"binop"); ret llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname()); } fn Neg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "neg"); + count_insn(cx, ~"neg"); ret llvm::LLVMBuildNeg(B(cx), V, noname()); } fn NSWNeg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "nswneg"); + count_insn(cx, ~"nswneg"); ret llvm::LLVMBuildNSWNeg(B(cx), V, noname()); } fn NUWNeg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "nuwneg"); + count_insn(cx, ~"nuwneg"); ret llvm::LLVMBuildNUWNeg(B(cx), V, noname()); } fn FNeg(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "fneg"); + count_insn(cx, ~"fneg"); ret llvm::LLVMBuildFNeg(B(cx), V, noname()); } fn Not(cx: block, V: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(V); } - count_insn(cx, "not"); + count_insn(cx, ~"not"); ret llvm::LLVMBuildNot(B(cx), V, noname()); } /* Memory */ fn Malloc(cx: block, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "malloc"); + count_insn(cx, ~"malloc"); ret llvm::LLVMBuildMalloc(B(cx), Ty, noname()); } fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "arraymalloc"); + count_insn(cx, ~"arraymalloc"); ret llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname()); } fn Alloca(cx: block, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); } - count_insn(cx, "alloca"); + count_insn(cx, ~"alloca"); ret llvm::LLVMBuildAlloca(B(cx), Ty, noname()); } fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); } - count_insn(cx, "arrayalloca"); + count_insn(cx, ~"arrayalloca"); ret llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname()); } fn Free(cx: block, PointerVal: ValueRef) { if cx.unreachable { ret; } - count_insn(cx, "free"); + count_insn(cx, ~"free"); llvm::LLVMBuildFree(B(cx), PointerVal); } @@ -404,7 +404,7 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef { llvm::LLVMGetElementType(ty) } else { ccx.int_type }; ret llvm::LLVMGetUndef(eltty); } - count_insn(cx, "load"); + count_insn(cx, ~"load"); ret llvm::LLVMBuildLoad(B(cx), PointerVal, noname()); } @@ -413,14 +413,14 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) { #debug["Store %s -> %s", val_str(cx.ccx().tn, Val), val_str(cx.ccx().tn, Ptr)]; - count_insn(cx, "store"); + count_insn(cx, ~"store"); llvm::LLVMBuildStore(B(cx), Val, Ptr); } fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { - count_insn(cx, "gep"); + count_insn(cx, ~"gep"); ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), Indices.len() as c_uint, noname()); } @@ -431,7 +431,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef { let mut v: ~[ValueRef] = ~[]; for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); } - count_insn(cx, "gepi"); + count_insn(cx, ~"gepi"); ret InBoundsGEP(cx, base, v); } @@ -439,7 +439,7 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { - count_insn(cx, "inboundsgep"); + count_insn(cx, ~"inboundsgep"); ret llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), Indices.len() as c_uint, @@ -449,138 +449,138 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } - count_insn(cx, "structgep"); + count_insn(cx, ~"structgep"); ret llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname()); } fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "globalstring"); + count_insn(cx, ~"globalstring"); ret llvm::LLVMBuildGlobalString(B(cx), _Str, noname()); } fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } - count_insn(cx, "globalstringptr"); + count_insn(cx, ~"globalstringptr"); ret llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname()); } /* Casts */ fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "trunc"); + count_insn(cx, ~"trunc"); ret llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname()); } fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "zext"); + count_insn(cx, ~"zext"); ret llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname()); } fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "sext"); + count_insn(cx, ~"sext"); ret llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname()); } fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fptoui"); + count_insn(cx, ~"fptoui"); ret llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname()); } fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fptosi"); + count_insn(cx, ~"fptosi"); ret llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname()); } fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "uitofp"); + count_insn(cx, ~"uitofp"); ret llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname()); } fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "sitofp"); + count_insn(cx, ~"sitofp"); ret llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname()); } fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fptrunc"); + count_insn(cx, ~"fptrunc"); ret llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname()); } fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fpext"); + count_insn(cx, ~"fpext"); ret llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname()); } fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "ptrtoint"); + count_insn(cx, ~"ptrtoint"); ret llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname()); } fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "inttoptr"); + count_insn(cx, ~"inttoptr"); ret llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname()); } fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "bitcast"); + count_insn(cx, ~"bitcast"); ret llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname()); } fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "zextorbitcast"); + count_insn(cx, ~"zextorbitcast"); ret llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname()); } fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "sextorbitcast"); + count_insn(cx, ~"sextorbitcast"); ret llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname()); } fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "truncorbitcast"); + count_insn(cx, ~"truncorbitcast"); ret llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname()); } fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, _Name: *u8) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "cast"); + count_insn(cx, ~"cast"); ret llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname()); } fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "pointercast"); + count_insn(cx, ~"pointercast"); ret llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname()); } fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "intcast"); + count_insn(cx, ~"intcast"); ret llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname()); } fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } - count_insn(cx, "fpcast"); + count_insn(cx, ~"fpcast"); ret llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname()); } @@ -589,21 +589,21 @@ fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "icmp"); + count_insn(cx, ~"icmp"); ret llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname()); } fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "fcmp"); + count_insn(cx, ~"fcmp"); ret llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname()); } /* Miscellaneous instructions */ fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } - count_insn(cx, "emptyphi"); + count_insn(cx, ~"emptyphi"); ret llvm::LLVMBuildPhi(B(cx), Ty, noname()); } @@ -613,7 +613,7 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef]) assert vals.len() == bbs.len(); let phi = EmptyPhi(cx, Ty); unsafe { - count_insn(cx, "addincoming"); + count_insn(cx, ~"addincoming"); llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals), vec::unsafe::to_ptr(bbs), vals.len() as c_uint); @@ -635,28 +635,28 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef { let ty = val_ty(Fn); let retty = if llvm::LLVMGetTypeKind(ty) == lib::llvm::Integer { llvm::LLVMGetReturnType(ty) } else { ccx.int_type }; - count_insn(cx, ""); + count_insn(cx, ~""); ret llvm::LLVMGetUndef(retty); } -fn add_span_comment(bcx: block, sp: span, text: str) { +fn add_span_comment(bcx: block, sp: span, text: ~str) { let ccx = bcx.ccx(); if !ccx.sess.no_asm_comments() { - let s = text + " (" + codemap::span_to_str(sp, ccx.sess.codemap) - + ")"; + let s = text + ~" (" + codemap::span_to_str(sp, ccx.sess.codemap) + + ~")"; log(debug, s); add_comment(bcx, s); } } -fn add_comment(bcx: block, text: str) { +fn add_comment(bcx: block, text: ~str) { let ccx = bcx.ccx(); if !ccx.sess.no_asm_comments() { - let sanitized = str::replace(text, "$", ""); - let comment_text = "# " + sanitized; + let sanitized = str::replace(text, ~"$", ~""); + let comment_text = ~"# " + sanitized; let asm = str::as_c_str(comment_text, |c| { - str::as_c_str("", |e| { - count_insn(bcx, "inlineasm"); + str::as_c_str(~"", |e| { + count_insn(bcx, ~"inlineasm"); llvm::LLVMConstInlineAsm(T_fn(~[], T_void()), c, e, False, False) }) @@ -668,7 +668,7 @@ fn add_comment(bcx: block, text: str) { fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { - count_insn(cx, "call"); + count_insn(cx, ~"call"); #debug["Call(Fn=%s, Args=%?)", val_str(cx.ccx().tn, Fn), @@ -682,7 +682,7 @@ fn Call(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"); + count_insn(cx, ~"fastcall"); let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv); @@ -694,7 +694,7 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef], Conv: CallConv) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { - count_insn(cx, "callwithconv"); + count_insn(cx, ~"callwithconv"); let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); lib::llvm::SetInstructionCallConv(v, Conv); @@ -705,67 +705,67 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef], fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef { if cx.unreachable { ret _Undef(Then); } - count_insn(cx, "select"); + count_insn(cx, ~"select"); ret llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname()); } fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } - count_insn(cx, "vaarg"); + count_insn(cx, ~"vaarg"); ret llvm::LLVMBuildVAArg(B(cx), list, Ty, noname()); } fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } - count_insn(cx, "extractelement"); + count_insn(cx, ~"extractelement"); ret llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname()); } fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef, Index: ValueRef) { if cx.unreachable { ret; } - count_insn(cx, "insertelement"); + count_insn(cx, ~"insertelement"); llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, noname()); } fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef, Mask: ValueRef) { if cx.unreachable { ret; } - count_insn(cx, "shufflevector"); + count_insn(cx, ~"shufflevector"); llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, noname()); } fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } - count_insn(cx, "extractvalue"); + count_insn(cx, ~"extractvalue"); ret llvm::LLVMBuildExtractValue(B(cx), AggVal, Index as c_uint, noname()); } fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) { if cx.unreachable { ret; } - count_insn(cx, "insertvalue"); + count_insn(cx, ~"insertvalue"); llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint, noname()); } fn IsNull(cx: block, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "isnull"); + count_insn(cx, ~"isnull"); ret llvm::LLVMBuildIsNull(B(cx), Val, noname()); } fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - count_insn(cx, "isnotnull"); + count_insn(cx, ~"isnotnull"); ret llvm::LLVMBuildIsNotNull(B(cx), Val, noname()); } fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { let ccx = cx.fcx.ccx; if cx.unreachable { ret llvm::LLVMGetUndef(ccx.int_type); } - count_insn(cx, "ptrdiff"); + count_insn(cx, ~"ptrdiff"); ret llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname()); } @@ -775,13 +775,13 @@ fn Trap(cx: block) { let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b); let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB); let M: ModuleRef = llvm::LLVMGetGlobalParent(FN); - let T: ValueRef = str::as_c_str("llvm.trap", |buf| { + let T: ValueRef = str::as_c_str(~"llvm.trap", |buf| { llvm::LLVMGetNamedFunction(M, buf) }); assert (T as int != 0); let Args: ~[ValueRef] = ~[]; unsafe { - count_insn(cx, "trap"); + count_insn(cx, ~"trap"); llvm::LLVMBuildCall(b, T, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); } @@ -790,20 +790,20 @@ fn Trap(cx: block) { fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef, NumClauses: uint) -> ValueRef { assert !cx.terminated && !cx.unreachable; - count_insn(cx, "landingpad"); + count_insn(cx, ~"landingpad"); ret llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, NumClauses as c_uint, noname()); } fn SetCleanup(cx: block, LandingPad: ValueRef) { - count_insn(cx, "setcleanup"); + count_insn(cx, ~"setcleanup"); llvm::LLVMSetCleanup(LandingPad, lib::llvm::True); } fn Resume(cx: block, Exn: ValueRef) -> ValueRef { assert (!cx.terminated); cx.terminated = true; - count_insn(cx, "resume"); + count_insn(cx, ~"resume"); ret llvm::LLVMBuildResume(B(cx), Exn); } diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 6b90ec30ab3..22d16efbae5 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -100,7 +100,7 @@ enum environment_value { env_ref(ValueRef, ty::t, lval_kind), } -fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str { +fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str { alt ev { env_copy(v, t, lk) { #fmt("copy(%s,%s)", val_str(ccx.tn, v), ty_to_str(ccx.tcx, t)) } @@ -139,11 +139,11 @@ fn allocate_cbox(bcx: block, ck: ty::closure_kind, cdata_ty: ty::t) -> ValueRef { - let _icx = bcx.insn_ctxt("closure::allocate_cbox"); + let _icx = bcx.insn_ctxt(~"closure::allocate_cbox"); let ccx = bcx.ccx(), tcx = ccx.tcx; fn nuke_ref_count(bcx: block, llbox: ValueRef) { - let _icx = bcx.insn_ctxt("closure::nuke_ref_count"); + let _icx = bcx.insn_ctxt(~"closure::nuke_ref_count"); // Initialize ref count to arbitrary value for debugging: let ccx = bcx.ccx(); let llbox = PointerCast(bcx, llbox, T_opaque_box_ptr(ccx)); @@ -184,7 +184,7 @@ type closure_result = { fn store_environment(bcx: block, bound_values: ~[environment_value], ck: ty::closure_kind) -> closure_result { - let _icx = bcx.insn_ctxt("closure::store_environment"); + let _icx = bcx.insn_ctxt(~"closure::store_environment"); let ccx = bcx.ccx(), tcx = ccx.tcx; // compute the shape of the closure @@ -224,7 +224,7 @@ fn store_environment(bcx: block, bcx = base::copy_val(bcx, INIT, bound_data, val, ty); } env_copy(_, _, temporary) { - fail "cannot capture temporary upvar"; + fail ~"cannot capture temporary upvar"; } env_move(val, ty, kind) { let src = {bcx:bcx, val:val, kind:kind}; @@ -241,7 +241,7 @@ fn store_environment(bcx: block, Store(bcx, addr, bound_data); } env_ref(_, _, temporary) { - fail "cannot capture temporary upvar"; + fail ~"cannot capture temporary upvar"; } } } @@ -257,7 +257,7 @@ fn build_closure(bcx0: block, ck: ty::closure_kind, id: ast::node_id, include_ret_handle: option<ValueRef>) -> closure_result { - let _icx = bcx0.insn_ctxt("closure::build_closure"); + 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 bcx = bcx0; @@ -318,7 +318,7 @@ fn load_environment(fcx: fn_ctxt, cap_vars: ~[capture::capture_var], load_ret_handle: bool, ck: ty::closure_kind) { - let _icx = fcx.insn_ctxt("closure::load_environment"); + let _icx = fcx.insn_ctxt(~"closure::load_environment"); let bcx = raw_block(fcx, fcx.llloadenv); // Load a pointer to the closure data, skipping over the box header: @@ -360,12 +360,12 @@ fn trans_expr_fn(bcx: block, cap_clause: ast::capture_clause, is_loop_body: option<option<ValueRef>>, dest: dest) -> block { - let _icx = bcx.insn_ctxt("closure::trans_expr_fn"); + let _icx = bcx.insn_ctxt(~"closure::trans_expr_fn"); if dest == ignore { ret bcx; } 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 = vec::append_one(bcx.fcx.path, path_name(@"anon"/~)); + let sub_path = vec::append_one(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); @@ -407,7 +407,7 @@ fn make_fn_glue( t: ty::t, glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block) -> block { - let _icx = cx.insn_ctxt("closure::make_fn_glue"); + let _icx = cx.insn_ctxt(~"closure::make_fn_glue"); let bcx = cx; let tcx = cx.tcx(); @@ -426,7 +426,7 @@ fn make_fn_glue( ty::ty_fn({proto: ast::proto_any, _}) { bcx } ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) } ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) } - _ { fail "make_fn_glue invoked on non-function type" } + _ { fail ~"make_fn_glue invoked on non-function type" } }; } @@ -436,7 +436,7 @@ fn make_opaque_cbox_take_glue( cboxptr: ValueRef) // ptr to ptr to the opaque closure -> block { // Easy cases: - let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_take_glue"); + let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue"); alt ck { ty::ck_block { ret bcx; } ty::ck_box { incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); ret bcx; } @@ -482,7 +482,7 @@ fn make_opaque_cbox_drop_glue( ck: ty::closure_kind, cboxptr: ValueRef) // ptr to the opaque closure -> block { - let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_drop_glue"); + let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_drop_glue"); alt ck { ty::ck_block { bcx } ty::ck_box { @@ -501,7 +501,7 @@ fn make_opaque_cbox_free_glue( ck: ty::closure_kind, cbox: ValueRef) // ptr to the opaque closure -> block { - let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_free_glue"); + let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue"); alt ck { ty::ck_block { ret bcx; } ty::ck_box | ty::ck_uniq { /* hard cases: */ } @@ -523,7 +523,7 @@ fn make_opaque_cbox_free_glue( // Free the ty descr (if necc) and the box itself alt ck { - ty::ck_block { fail "Impossible"; } + ty::ck_block { fail ~"Impossible"; } ty::ck_box { trans_free(bcx, cbox) } diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 4995713fbdb..13f5b2f8470 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -21,10 +21,10 @@ import metadata::common::link_meta; import syntax::ast_map::path; import util::ppaux::ty_to_str; -type namegen = fn@(str) -> str; +type namegen = fn@(~str) -> ~str; fn new_namegen() -> namegen { let i = @mut 0; - ret fn@(prefix: str) -> str { *i += 1; prefix + int::str(*i) }; + ret fn@(prefix: ~str) -> ~str { *i += 1; prefix + int::str(*i) }; } type tydesc_info = @@ -68,9 +68,9 @@ type stats = mut n_glues_created: uint, mut n_null_glues: uint, mut n_real_glues: uint, - llvm_insn_ctxt: @mut ~[str], - llvm_insns: hashmap<str, uint>, - fn_times: @mut ~[{ident: str, time: int}]}; + llvm_insn_ctxt: @mut ~[~str], + llvm_insns: hashmap<~str, uint>, + fn_times: @mut ~[{ident: ~str, time: int}]}; class BuilderRef_res { let B: BuilderRef; @@ -84,17 +84,17 @@ type crate_ctxt = { llmod: ModuleRef, td: target_data, tn: type_names, - externs: hashmap<str, ValueRef>, - intrinsics: hashmap<str, ValueRef>, + externs: hashmap<~str, ValueRef>, + intrinsics: hashmap<~str, ValueRef>, item_vals: hashmap<ast::node_id, ValueRef>, exp_map: resolve::exp_map, reachable: reachable::map, - item_symbols: hashmap<ast::node_id, str>, + item_symbols: hashmap<ast::node_id, ~str>, mut main_fn: option<ValueRef>, link_meta: link_meta, enum_sizes: hashmap<ty::t, uint>, discrims: hashmap<ast::def_id, ValueRef>, - discrim_symbols: hashmap<ast::node_id, str>, + discrim_symbols: hashmap<ast::node_id, ~str>, tydescs: hashmap<ty::t, @tydesc_info>, // Track mapping of external ids to local items imported for inlining external: hashmap<ast::def_id, option<ast::node_id>>, @@ -106,14 +106,14 @@ type crate_ctxt = { // Cache generated vtables vtables: hashmap<mono_id, ValueRef>, // Cache of constant strings, - const_cstr_cache: hashmap<str, ValueRef>, - module_data: hashmap<str, ValueRef>, + const_cstr_cache: hashmap<~str, ValueRef>, + module_data: hashmap<~str, ValueRef>, lltypes: hashmap<ty::t, TypeRef>, names: namegen, sha: std::sha1::sha1, - type_sha1s: hashmap<ty::t, str>, - type_short_names: hashmap<ty::t, str>, - all_llvm_symbols: set<str>, + type_sha1s: hashmap<ty::t, ~str>, + type_short_names: hashmap<ty::t, ~str>, + all_llvm_symbols: set<~str>, tcx: ty::ctxt, maps: astencode::maps, stats: stats, @@ -204,10 +204,10 @@ type fn_ctxt = @{ ccx: @crate_ctxt }; -fn warn_not_to_commit(ccx: @crate_ctxt, msg: str) { +fn warn_not_to_commit(ccx: @crate_ctxt, msg: ~str) { if !ccx.do_not_commit_warning_issued { ccx.do_not_commit_warning_issued = true; - ccx.sess.warn(msg + " -- do not commit like this!"); + ccx.sess.warn(msg + ~" -- do not commit like this!"); } } @@ -421,13 +421,13 @@ fn rslt(bcx: block, val: ValueRef) -> result { {bcx: bcx, val: val} } -fn ty_str(tn: type_names, t: TypeRef) -> str { +fn ty_str(tn: type_names, t: TypeRef) -> ~str { ret lib::llvm::type_to_str(tn, t); } fn val_ty(v: ValueRef) -> TypeRef { ret llvm::LLVMTypeOf(v); } -fn val_str(tn: type_names, v: ValueRef) -> str { ret ty_str(tn, val_ty(v)); } +fn val_str(tn: type_names, v: ValueRef) -> ~str { ret ty_str(tn, val_ty(v)); } // Returns the nth element of the given LLVM structure type. fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { @@ -464,13 +464,13 @@ impl bcx_cxs for block { pure fn tcx() -> ty::ctxt { self.fcx.ccx.tcx } pure fn sess() -> session { self.fcx.ccx.sess } - fn val_str(val: ValueRef) -> str { + fn val_str(val: ValueRef) -> ~str { val_str(self.ccx().tn, val) } - fn ty_to_str(t: ty::t) -> str { + fn ty_to_str(t: ty::t) -> ~str { ty_to_str(self.tcx(), t) } - fn to_str() -> str { + fn to_str() -> ~str { alt self.node_info { some(node_info) { #fmt["[block %d]", node_info.id] @@ -591,7 +591,7 @@ fn T_struct(elts: ~[TypeRef]) -> TypeRef unsafe { ret llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False); } -fn T_named_struct(name: str) -> TypeRef { +fn T_named_struct(name: ~str) -> TypeRef { let c = llvm::LLVMGetGlobalContext(); ret str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf)); } @@ -610,7 +610,7 @@ fn T_empty_struct() -> TypeRef { ret T_struct(~[]); } fn T_vtable() -> TypeRef { T_array(T_ptr(T_i8()), 1u) } fn T_task(targ_cfg: @session::config) -> TypeRef { - let t = T_named_struct("task"); + let t = T_named_struct(~"task"); // Refcount // Delegate pointer @@ -644,7 +644,7 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { } fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { - let s = "glue_fn"; + let s = ~"glue_fn"; alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} } let t = T_tydesc_field(cx, abi::tydesc_field_drop_glue); associate_type(cx.tn, s, t); @@ -652,7 +652,7 @@ fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { } fn T_tydesc(targ_cfg: @session::config) -> TypeRef { - let tydesc = T_named_struct("tydesc"); + let tydesc = T_named_struct(~"tydesc"); let tydescpp = T_ptr(T_ptr(tydesc)); let pvoid = T_ptr(T_i8()); let glue_fn_ty = @@ -748,7 +748,7 @@ fn T_taskptr(cx: @crate_ctxt) -> TypeRef { ret T_ptr(cx.task_type); } // This type must never be used directly; it must always be cast away. fn T_typaram(tn: type_names) -> TypeRef { - let s = "typaram"; + let s = ~"typaram"; alt name_has_type(tn, s) { some(t) { ret t; } _ {} } let t = T_i8(); associate_type(tn, s, t); @@ -768,7 +768,7 @@ fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef { } fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef { - let s = "opaque_enum"; + 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()]); associate_type(cx.tn, s, t); @@ -799,7 +799,7 @@ fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef { ret llvm::LLVMConstInt(t, u, sign_extend); } -fn C_floating(s: str, t: TypeRef) -> ValueRef { +fn C_floating(s: ~str, t: TypeRef) -> ValueRef { ret str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf)); } @@ -834,7 +834,7 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); } // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. -fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { +fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { alt cx.const_cstr_cache.find(s) { some(llval) { ret llval; } none { } @@ -844,7 +844,7 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; let g = - str::as_c_str(cx.names("str"), + str::as_c_str(cx.names(~"str"), |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)); llvm::LLVMSetInitializer(g, sc); llvm::LLVMSetGlobalConstant(g, True); @@ -855,13 +855,13 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { ret g; } -fn C_estr_slice(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 */)]) } // Returns a Plain Old LLVM String: -fn C_postr(s: str) -> ValueRef { +fn C_postr(s: ~str) -> ValueRef { ret do str::as_c_str(s) |buf| { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; @@ -898,7 +898,7 @@ fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe { fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef { let llshape = C_bytes(bytes); - let llglobal = str::as_c_str(ccx.names("shape"), |buf| { + let llglobal = str::as_c_str(ccx.names(~"shape"), |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) }); llvm::LLVMSetInitializer(llglobal, llshape); @@ -952,12 +952,12 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef { ret build::And(cx, bumped, build::Not(cx, mask)); } -fn path_str(p: path) -> str { - let mut r = "", first = true; +fn path_str(p: path) -> ~str { + let mut r = ~"", first = true; for vec::each(p) |e| { alt e { ast_map::path_name(s) | ast_map::path_mod(s) { if first { first = false; } - else { r += "::"; } + else { r += ~"::"; } r += *s; } } } diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index bbef68aaad6..b18569a093b 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -47,7 +47,7 @@ const DW_ATE_signed_char: int = 0x06; const DW_ATE_unsigned: int = 0x07; const DW_ATE_unsigned_char: int = 0x08; -fn llstr(s: str) -> ValueRef { +fn llstr(s: ~str) -> ValueRef { str::as_c_str(s, |sbuf| { llvm::LLVMMDString(sbuf, str::len(s) as libc::c_uint) }) @@ -75,7 +75,7 @@ fn llnull() -> ValueRef unsafe { unsafe::reinterpret_cast(ptr::null::<ValueRef>()) } -fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) { +fn add_named_metadata(cx: @crate_ctxt, name: ~str, val: ValueRef) { str::as_c_str(name, |sbuf| { llvm::LLVMAddNamedMetadataOperand(cx.llmod, sbuf, val) }) @@ -86,10 +86,10 @@ fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) { type debug_ctxt = { llmetadata: metadata_cache, names: namegen, - crate_file: str + crate_file: ~str }; -fn mk_ctxt(crate: str) -> debug_ctxt { +fn mk_ctxt(crate: ~str) -> debug_ctxt { {llmetadata: map::int_hash(), names: new_namegen(), crate_file: crate} @@ -106,8 +106,8 @@ fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { type metadata<T> = {node: ValueRef, data: T}; -type file_md = {path: str}; -type compile_unit_md = {name: str}; +type file_md = {path: ~str}; +type compile_unit_md = {name: ~str}; type subprogram_md = {id: ast::node_id}; type local_var_md = {id: ast::node_id}; type tydesc_md = {hash: uint}; @@ -181,11 +181,11 @@ fn create_compile_unit(cx: @crate_ctxt) llstr(#env["CFG_VERSION"]), lli1(true), // deprecated: main compile unit lli1(cx.sess.opts.optimize != 0u), - llstr(""), // flags (???) + llstr(~""), // flags (???) lli32(0) // runtime version (???) ]; let unit_node = llmdnode(unit_metadata); - add_named_metadata(cx, "llvm.dbg.cu", unit_node); + add_named_metadata(cx, ~"llvm.dbg.cu", unit_node); let mdval = @{node: unit_node, data: {name: crate_name}}; update_cache(cache, tg, compile_unit_metadata(mdval)); @@ -196,7 +196,7 @@ fn get_cache(cx: @crate_ctxt) -> metadata_cache { option::get(cx.dbg_cx).llmetadata } -fn get_file_path_and_dir(work_dir: str, full_path: str) -> (str, str) { +fn get_file_path_and_dir(work_dir: ~str, full_path: ~str) -> (~str, ~str) { (if str::starts_with(full_path, work_dir) { str::slice(full_path, str::len(work_dir) + 1u, str::len(full_path)) @@ -205,7 +205,7 @@ fn get_file_path_and_dir(work_dir: str, full_path: str) -> (str, str) { }, work_dir) } -fn create_file(cx: @crate_ctxt, full_path: str) -> @metadata<file_md> { +fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> { let cache = get_cache(cx);; let tg = FileDescriptorTag; alt cached_metadata::<@metadata<file_md>>( @@ -292,26 +292,26 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) } let (name, encoding) = alt check ty { - ast::ty_bool {("bool", DW_ATE_boolean)} + ast::ty_bool {(~"bool", DW_ATE_boolean)} ast::ty_int(m) { alt m { - ast::ty_char {("char", DW_ATE_unsigned)} - ast::ty_i {("int", DW_ATE_signed)} - ast::ty_i8 {("i8", DW_ATE_signed_char)} - ast::ty_i16 {("i16", DW_ATE_signed)} - ast::ty_i32 {("i32", DW_ATE_signed)} - ast::ty_i64 {("i64", DW_ATE_signed)} + ast::ty_char {(~"char", DW_ATE_unsigned)} + ast::ty_i {(~"int", DW_ATE_signed)} + ast::ty_i8 {(~"i8", DW_ATE_signed_char)} + ast::ty_i16 {(~"i16", DW_ATE_signed)} + ast::ty_i32 {(~"i32", DW_ATE_signed)} + ast::ty_i64 {(~"i64", DW_ATE_signed)} }} ast::ty_uint(m) { alt m { - ast::ty_u {("uint", DW_ATE_unsigned)} - ast::ty_u8 {("u8", DW_ATE_unsigned_char)} - ast::ty_u16 {("u16", DW_ATE_unsigned)} - ast::ty_u32 {("u32", DW_ATE_unsigned)} - ast::ty_u64 {("u64", DW_ATE_unsigned)} + ast::ty_u {(~"uint", DW_ATE_unsigned)} + ast::ty_u8 {(~"u8", DW_ATE_unsigned_char)} + ast::ty_u16 {(~"u16", DW_ATE_unsigned)} + ast::ty_u32 {(~"u32", DW_ATE_unsigned)} + ast::ty_u64 {(~"u64", DW_ATE_unsigned)} }} ast::ty_float(m) { alt m { - ast::ty_f {("float", DW_ATE_float)} - ast::ty_f32 {("f32", DW_ATE_float)} - ast::ty_f64 {("f64", DW_ATE_float)} + ast::ty_f {(~"float", DW_ATE_float)} + ast::ty_f32 {(~"f32", DW_ATE_float)} + ast::ty_f64 {(~"f64", DW_ATE_float)} }} }; @@ -332,7 +332,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) let llnode = llmdnode(lldata); let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; update_cache(cache, tg, tydesc_metadata(mdval)); - add_named_metadata(cx, "llvm.dbg.ty", llnode); + add_named_metadata(cx, ~"llvm.dbg.ty", llnode); ret mdval; } @@ -350,17 +350,17 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, let fname = filename_from_span(cx, span); let file_node = create_file(cx, fname); //let cu_node = create_compile_unit(cx, fname); - let llnode = create_derived_type(tg, file_node.node, "", 0, size * 8, + let llnode = create_derived_type(tg, file_node.node, ~"", 0, size * 8, align * 8, 0, pointee.node); let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; //update_cache(cache, tg, tydesc_metadata(mdval)); - add_named_metadata(cx, "llvm.dbg.ty", llnode); + add_named_metadata(cx, ~"llvm.dbg.ty", llnode); ret mdval; } type struct_ctxt = { file: ValueRef, - name: str, + name: ~str, line: int, mut members: ~[ValueRef], mut total_size: int, @@ -373,7 +373,7 @@ fn finish_structure(cx: @struct_ctxt) -> ValueRef { option::some(cx.members)); } -fn create_structure(file: @metadata<file_md>, name: str, line: int) +fn create_structure(file: @metadata<file_md>, name: ~str, line: int) -> @struct_ctxt { let cx = @{file: file.node, name: name, @@ -385,7 +385,7 @@ fn create_structure(file: @metadata<file_md>, name: str, line: int) ret cx; } -fn create_derived_type(type_tag: int, file: ValueRef, name: str, line: int, +fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int, size: int, align: int, offset: int, ty: ValueRef) -> ValueRef { let lldata = ~[lltag(type_tag), @@ -401,7 +401,7 @@ fn create_derived_type(type_tag: int, file: ValueRef, name: str, line: int, ret llmdnode(lldata); } -fn add_member(cx: @struct_ctxt, name: str, line: int, size: int, align: int, +fn add_member(cx: @struct_ctxt, name: ~str, line: int, size: int, align: int, ty: ValueRef) { vec::push(cx.members, create_derived_type(MemberTag, cx.file, name, line, size * 8, align * 8, cx.total_size, @@ -414,7 +414,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field], let fname = filename_from_span(cx, span); let file_node = create_file(cx, fname); let scx = create_structure(file_node, - option::get(cx.dbg_cx).names("rec"), + option::get(cx.dbg_cx).names(~"rec"), line_from_span(cx.sess.codemap, span) as int); for fields.each |field| { @@ -446,19 +446,19 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, let refcount_type = create_basic_type(cx, uint_t, ast::ty_uint(ast::ty_u), span); let scx = create_structure(file_node, ty_to_str(cx.tcx, outer), 0); - add_member(scx, "refcnt", 0, sys::size_of::<uint>() as int, + add_member(scx, ~"refcnt", 0, sys::size_of::<uint>() as int, sys::min_align_of::<uint>() as int, refcount_type.node); - add_member(scx, "boxed", 0, 8, //XXX member_size_and_align(??) + add_member(scx, ~"boxed", 0, 8, //XXX member_size_and_align(??) 8, //XXX just a guess boxed.node); let llnode = finish_structure(scx); let mdval = @{node: llnode, data: {hash: ty::type_id(outer)}}; //update_cache(cache, tg, tydesc_metadata(mdval)); - add_named_metadata(cx, "llvm.dbg.ty", llnode); + add_named_metadata(cx, ~"llvm.dbg.ty", llnode); ret mdval; } -fn create_composite_type(type_tag: int, name: str, file: ValueRef, line: int, +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]>) @@ -497,17 +497,17 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, let scx = create_structure(file_node, ty_to_str(cx.tcx, vec_t), 0); let size_t_type = create_basic_type(cx, ty::mk_uint(cx.tcx), ast::ty_uint(ast::ty_u), vec_ty_span); - add_member(scx, "fill", 0, sys::size_of::<libc::size_t>() as int, + add_member(scx, ~"fill", 0, sys::size_of::<libc::size_t>() as int, 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, + 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 (arr_size, arr_align) = size_and_align_of(cx, elem_t); - let data_ptr = create_composite_type(ArrayTypeTag, "", file_node.node, 0, + 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])); - add_member(scx, "data", 0, 0, // clang says the size should be 0 + 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); ret @{node: llnode, data: {hash: ty::type_id(vec_t)}}; @@ -617,11 +617,11 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) */ } -fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> str { +fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> ~str { codemap::lookup_char_pos(cx.sess.codemap, sp.lo).file.name } -fn create_var(type_tag: int, context: ValueRef, name: str, file: ValueRef, +fn create_var(type_tag: int, context: ValueRef, name: ~str, file: ValueRef, line: int, ret_ty: ValueRef) -> ValueRef { let lldata = ~[lltag(type_tag), context, @@ -648,7 +648,7 @@ fn create_local_var(bcx: block, local: @ast::local) let name = alt local.node.pat.node { ast::pat_ident(pth, _) { ast_util::path_to_ident(pth) } // FIXME this should be handled (#2533) - _ { fail "no single variable name for local"; } + _ { fail ~"no single variable name for local"; } }; let loc = codemap::lookup_char_pos(cx.sess.codemap, local.span.lo); @@ -667,19 +667,19 @@ fn create_local_var(bcx: block, local: @ast::local) let llptr = alt bcx.fcx.lllocals.find(local.node.id) { option::some(local_mem(v)) { v } option::some(_) { - bcx.tcx().sess.span_bug(local.span, "local is bound to \ + bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird"); } option::none { alt bcx.fcx.lllocals.get(local.node.pat.id) { local_imm(v) { v } - _ { bcx.tcx().sess.span_bug(local.span, "local is bound to \ + _ { bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird"); } } } }; let declargs = ~[llmdnode(~[llptr]), mdnode]; - trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"), + trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"), declargs); ret mdval; } @@ -710,7 +710,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) local_mem(v) | local_imm(v) { v } }; let declargs = ~[llmdnode(~[llptr]), mdnode]; - trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"), + trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"), declargs); ret mdval; } @@ -746,7 +746,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { ast::item_fn(decl, _, _) { (item.ident, decl.output, item.id) } - _ { fcx.ccx.sess.span_bug(item.span, "create_function: item \ + _ { fcx.ccx.sess.span_bug(item.span, ~"create_function: item \ bound to non-function"); } } } @@ -760,16 +760,16 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { ast_map::node_expr(expr) { alt expr.node { ast::expr_fn(_, decl, _, _) { - (@dbg_cx.names("fn"), decl.output, expr.id) + (@dbg_cx.names(~"fn"), decl.output, expr.id) } ast::expr_fn_block(decl, _, _) { - (@dbg_cx.names("fn"), decl.output, expr.id) + (@dbg_cx.names(~"fn"), decl.output, expr.id) } - _ { fcx.ccx.sess.span_bug(expr.span, "create_function: \ + _ { fcx.ccx.sess.span_bug(expr.span, ~"create_function: \ expected an expr_fn or fn_block here"); } } } - _ { fcx.ccx.sess.bug("create_function: unexpected \ + _ { fcx.ccx.sess.bug(~"create_function: unexpected \ sort of node"); } }; @@ -794,7 +794,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { } else { llnull() }; - let sub_node = create_composite_type(SubroutineTag, "", file_node, 0, 0, + let sub_node = create_composite_type(SubroutineTag, ~"", file_node, 0, 0, 0, 0, option::none, option::some(~[ty_node])); @@ -803,7 +803,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { file_node, llstr(*ident), llstr(*ident), //XXX fully-qualified C++ name - llstr(""), //XXX MIPS name????? + llstr(~""), //XXX MIPS name????? file_node, lli32(loc.line as int), sub_node, @@ -820,7 +820,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { //list of func vars ]; let val = llmdnode(fn_metadata); - add_named_metadata(cx, "llvm.dbg.sp", val); + add_named_metadata(cx, ~"llvm.dbg.sp", val); let mdval = @{node: val, data: {id: id}}; update_cache(cache, SubprogramTag, subprogram_metadata(mdval)); diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 2a054b9fe7b..847aca0db2c 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -90,7 +90,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { ty_align(elt) } _ { - fail "ty_size: unhandled type" + fail ~"ty_size: unhandled type" } }; } @@ -115,7 +115,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { len * eltsz } _ { - fail "ty_size: unhandled type" + fail ~"ty_size: unhandled type" } }; } @@ -212,7 +212,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } } _ { - fail "classify: unhandled type"; + fail ~"classify: unhandled type"; } } } @@ -310,7 +310,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { vec::push(tys, T_f64()); } _ { - fail "llregtype: unhandled class"; + fail ~"llregtype: unhandled class"; } } i += 1u; @@ -420,8 +420,8 @@ fn decl_x86_64_fn(tys: x86_64_tys, ret llfn; } -fn link_name(i: @ast::foreign_item) -> str { - alt attr::first_attr_value_str_by_name(i.attrs, "link_name") { +fn link_name(i: @ast::foreign_item) -> ~str { + alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { none { ret *i.ident; } option::some(ln) { ret *ln; } } @@ -444,7 +444,7 @@ fn c_arg_and_ret_lltys(ccx: @crate_ctxt, let llretty = type_of::type_of(ccx, ret_ty); (llargtys, llretty, ret_ty) } - _ { ccx.sess.bug("c_arg_and_ret_lltys called on non-function type"); } + _ { ccx.sess.bug(~"c_arg_and_ret_lltys called on non-function type"); } } } @@ -475,7 +475,7 @@ type shim_ret_builder = fn(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef, llretval: ValueRef); fn build_shim_fn_(ccx: @crate_ctxt, - shim_name: str, + shim_name: ~str, llbasefn: ValueRef, tys: @c_stack_tys, cc: lib::llvm::CallConv, @@ -519,7 +519,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt, arg_builder: wrap_arg_builder, ret_builder: wrap_ret_builder) { - let _icx = ccx.insn_ctxt("foreign::build_wrap_fn_"); + let _icx = ccx.insn_ctxt(~"foreign::build_wrap_fn_"); let fcx = new_fn_ctxt(ccx, ~[], llwrapfn, none); let bcx = top_scope_block(fcx, none); let lltop = bcx.llbb; @@ -579,18 +579,18 @@ fn build_wrap_fn_(ccx: @crate_ctxt, fn trans_foreign_mod(ccx: @crate_ctxt, foreign_mod: ast::foreign_mod, abi: ast::foreign_abi) { - let _icx = ccx.insn_ctxt("foreign::trans_foreign_mod"); + let _icx = ccx.insn_ctxt(~"foreign::trans_foreign_mod"); fn build_shim_fn(ccx: @crate_ctxt, foreign_item: @ast::foreign_item, tys: @c_stack_tys, cc: lib::llvm::CallConv) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::build_shim_fn"); + let _icx = ccx.insn_ctxt(~"foreign::build_shim_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) -> ~[ValueRef] { - let _icx = bcx.insn_ctxt("foreign::shim::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::shim::build_args"); let mut llargvals = ~[]; let mut i = 0u; let n = vec::len(tys.arg_tys); @@ -636,7 +636,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef, llretval: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::shim::build_ret"); + let _icx = bcx.insn_ctxt(~"foreign::shim::build_ret"); alt tys.x86_64_tys { some(x86_64) { do vec::iteri(x86_64.attrs) |i, a| { @@ -680,12 +680,12 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let lname = link_name(foreign_item); let llbasefn = base_fn(ccx, lname, tys, cc); // Name the shim function - let shim_name = lname + "__c_stack_shim"; + let shim_name = lname + ~"__c_stack_shim"; ret build_shim_fn_(ccx, shim_name, llbasefn, tys, cc, build_args, build_ret); } - fn base_fn(ccx: @crate_ctxt, lname: str, tys: @c_stack_tys, + fn base_fn(ccx: @crate_ctxt, lname: ~str, tys: @c_stack_tys, cc: lib::llvm::CallConv) -> ValueRef { // Declare the "prototype" for the base function F: alt tys.x86_64_tys { @@ -727,11 +727,11 @@ fn trans_foreign_mod(ccx: @crate_ctxt, llshimfn: ValueRef, llwrapfn: ValueRef) { - let _icx = ccx.insn_ctxt("foreign::build_wrap_fn"); + let _icx = ccx.insn_ctxt(~"foreign::build_wrap_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llwrapfn: ValueRef, llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::wrap::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::wrap::build_args"); let mut i = 0u; let n = vec::len(tys.arg_tys); let implicit_args = first_real_arg; // ret + env @@ -746,7 +746,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, fn build_ret(bcx: block, _tys: @c_stack_tys, _llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::wrap::build_ret"); + let _icx = bcx.insn_ctxt(~"foreign::wrap::build_ret"); RetVoid(bcx); } @@ -768,7 +768,8 @@ fn trans_foreign_mod(ccx: @crate_ctxt, if abi != ast::foreign_abi_rust_intrinsic { let llwrapfn = get_item_val(ccx, id); let tys = c_stack_tys(ccx, id); - if attr::attrs_contains_name(foreign_item.attrs, "rust_stack") { + if attr::attrs_contains_name(foreign_item.attrs, + ~"rust_stack") { build_direct_fn(ccx, llwrapfn, foreign_item, tys, cc); } else { let llshimfn = build_shim_fn(ccx, foreign_item, tys, cc); @@ -783,7 +784,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, some(ast_map::node_foreign_item(_, _, pt)) { pt } _ { ccx.sess.span_bug(foreign_item.span, - "can't find intrinsic path") + ~"can't find intrinsic path") } }; let psubsts = { @@ -807,76 +808,76 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, some(substs), some(item.span)); let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb; alt check *item.ident { - "atomic_xchng" { + ~"atomic_xchng" { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - "atomic_xchng_acq" { + ~"atomic_xchng_acq" { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - "atomic_xchng_rel" { + ~"atomic_xchng_rel" { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - "atomic_add" { + ~"atomic_add" { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - "atomic_add_acq" { + ~"atomic_add_acq" { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - "atomic_add_rel" { + ~"atomic_add_rel" { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - "atomic_sub" { + ~"atomic_sub" { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - "atomic_sub_acq" { + ~"atomic_sub_acq" { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - "atomic_sub_rel" { + ~"atomic_sub_rel" { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - "size_of" { + ~"size_of" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); Store(bcx, C_uint(ccx, shape::llsize_of_real(ccx, lltp_ty)), fcx.llretptr); } - "move_val" { + ~"move_val" { let tp_ty = substs.tys[0]; let src = {bcx: bcx, val: get_param(decl, first_real_arg + 1u), @@ -886,7 +887,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, src, tp_ty); } - "move_val_init" { + ~"move_val_init" { let tp_ty = substs.tys[0]; let src = {bcx: bcx, val: get_param(decl, first_real_arg + 1u), @@ -896,19 +897,19 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, src, tp_ty); } - "min_align_of" { + ~"min_align_of" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); Store(bcx, C_uint(ccx, shape::llalign_of_min(ccx, lltp_ty)), fcx.llretptr); } - "pref_align_of" { + ~"pref_align_of" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); Store(bcx, C_uint(ccx, shape::llalign_of_pref(ccx, lltp_ty)), fcx.llretptr); } - "get_tydesc" { + ~"get_tydesc" { let tp_ty = substs.tys[0]; let static_ti = get_tydesc(ccx, tp_ty); lazily_emit_all_tydesc_glue(ccx, static_ti); @@ -917,15 +918,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let td = PointerCast(bcx, static_ti.tydesc, T_ptr(T_nil())); Store(bcx, td, fcx.llretptr); } - "init" { + ~"init" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); if !ty::type_is_nil(tp_ty) { Store(bcx, C_null(lltp_ty), fcx.llretptr); } } - "forget" {} - "reinterpret_cast" { + ~"forget" {} + ~"reinterpret_cast" { let tp_ty = substs.tys[0]; let lltp_ty = type_of::type_of(ccx, tp_ty); let llout_ty = type_of::type_of(ccx, substs.tys[1]); @@ -947,23 +948,23 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, Store(bcx, Load(bcx, cast), fcx.llretptr); } } - "addr_of" { + ~"addr_of" { Store(bcx, get_param(decl, first_real_arg), fcx.llretptr); } - "needs_drop" { + ~"needs_drop" { let tp_ty = substs.tys[0]; Store(bcx, C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)), fcx.llretptr); } - "visit_tydesc" { + ~"visit_tydesc" { let td = get_param(decl, first_real_arg); let visitor = get_param(decl, first_real_arg + 1u); let td = PointerCast(bcx, td, T_ptr(ccx.tydesc_type)); call_tydesc_glue_full(bcx, visitor, td, abi::tydesc_field_visit_glue, none); } - "frame_address" { - let frameaddress = ccx.intrinsics.get("llvm.frameaddress"); + ~"frame_address" { + let frameaddress = ccx.intrinsics.get(~"llvm.frameaddress"); let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]); let fty = ty::mk_fn(bcx.tcx(), { purity: ast::impure_fn, @@ -993,15 +994,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) { - let _icx = ccx.insn_ctxt("foreign::build_foreign_fn"); + let _icx = ccx.insn_ctxt(~"foreign::build_foreign_fn"); fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, body: ast::blk, id: ast::node_id) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn"); + let _icx = ccx.insn_ctxt(~"foreign::foreign::build_rust_fn"); let t = ty::node_id_to_type(ccx.tcx, id); let ps = link::mangle_internal_name_by_path( - ccx, vec::append_one(path, ast_map::path_name(@"__rust_abi"/~))); + ccx, vec::append_one(path, ast_map::path_name(@~"__rust_abi"))); let llty = type_of_fn_from_ty(ccx, t); let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty); trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id); @@ -1011,11 +1012,11 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path, llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::foreign::build_shim_fn"); + let _icx = ccx.insn_ctxt(~"foreign::foreign::build_shim_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) -> ~[ValueRef] { - let _icx = bcx.insn_ctxt("foreign::extern::shim::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::extern::shim::build_args"); let mut llargvals = ~[]; let mut i = 0u; let n = vec::len(tys.arg_tys); @@ -1039,7 +1040,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let shim_name = link::mangle_internal_name_by_path( ccx, vec::append_one(path, - ast_map::path_name(@"__rust_stack_shim"/~))); + ast_map::path_name(@~"__rust_stack_shim"))); ret build_shim_fn_(ccx, shim_name, llrustfn, tys, lib::llvm::CCallConv, build_args, build_ret); @@ -1048,11 +1049,11 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef, llwrapfn: ValueRef, tys: @c_stack_tys) { - let _icx = ccx.insn_ctxt("foreign::foreign::build_wrap_fn"); + let _icx = ccx.insn_ctxt(~"foreign::foreign::build_wrap_fn"); fn build_args(bcx: block, tys: @c_stack_tys, llwrapfn: ValueRef, llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_args"); + let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_args"); alt tys.x86_64_tys { option::some(x86_64) { let mut atys = x86_64.arg_tys; @@ -1106,7 +1107,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) { - let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_ret"); + let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_ret"); alt tys.x86_64_tys { option::some(x86_64) { if x86_64.sret || !tys.ret_def { @@ -1150,7 +1151,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn register_foreign_fn(ccx: @crate_ctxt, sp: span, path: ast_map::path, node_id: ast::node_id) -> ValueRef { - let _icx = ccx.insn_ctxt("foreign::register_foreign_fn"); + let _icx = ccx.insn_ctxt(~"foreign::register_foreign_fn"); let t = ty::node_id_to_type(ccx.tcx, node_id); let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id); ret if ccx.sess.targ_cfg.arch == arch_x86_64 { @@ -1169,7 +1170,7 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span, fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item) -> ast::foreign_abi { - alt attr::first_attr_value_str_by_name(i.attrs, "abi") { + alt attr::first_attr_value_str_by_name(i.attrs, ~"abi") { none { alt check ccx.tcx.items.get(i.id) { ast_map::node_foreign_item(_, abi, _) { abi } diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index 2ebddb0038f..8ea0583b81b 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -17,7 +17,7 @@ import std::map::hashmap; fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, methods: ~[@ast::method], tps: ~[ast::ty_param]) { - let _icx = ccx.insn_ctxt("impl::trans_impl"); + let _icx = ccx.insn_ctxt(~"impl::trans_impl"); if tps.len() > 0u { ret; } let sub_path = vec::append_one(path, path_name(name)); for vec::each(methods) |m| { @@ -33,7 +33,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, } fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { - let _icx = bcx.insn_ctxt("impl::trans_self_arg"); + 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 = ~[]; @@ -51,7 +51,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { fn trans_method_callee(bcx: block, callee_id: ast::node_id, self: @ast::expr, mentry: typeck::method_map_entry) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_method_callee"); + let _icx = bcx.insn_ctxt(~"impl::trans_method_callee"); alt mentry.origin { typeck::method_static(did) { let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs); @@ -115,7 +115,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, trait_id: ast::def_id, n_method: uint, n_param: uint, n_bound: uint, substs: param_substs) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee"); + let _icx = bcx.insn_ctxt(~"impl::trans_monomorphized_callee"); alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) { typeck::vtable_static(impl_did, impl_substs, sub_origins) { let ccx = bcx.ccx(); @@ -141,7 +141,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, trans_trait_callee(bcx, val, fty, n_method) } typeck::vtable_param(n_param, n_bound) { - fail "vtable_param left in monomorphized function's vtable substs"; + fail ~"vtable_param left in monomorphized function's vtable substs"; } } } @@ -150,7 +150,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, fn trans_trait_callee(bcx: block, val: ValueRef, callee_ty: ty::t, n_method: uint) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_trait_callee"); + let _icx = bcx.insn_ctxt(~"impl::trans_trait_callee"); let ccx = bcx.ccx(); let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, ~[0u, 0u]), T_ptr(T_ptr(T_vtable())))); @@ -238,9 +238,9 @@ fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin) } fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef { - let _icx = ccx.insn_ctxt("impl::make_vtable"); + let _icx = ccx.insn_ctxt(~"impl::make_vtable"); let tbl = C_struct(ptrs); - let vt_gvar = str::as_c_str(ccx.names("vtable"), |buf| { + let vt_gvar = str::as_c_str(ccx.names(~"vtable"), |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf) }); llvm::LLVMSetInitializer(vt_gvar, tbl); @@ -251,12 +251,12 @@ fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef { 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 _icx = ccx.insn_ctxt(~"impl::make_impl_vtable"); let tcx = ccx.tcx; let ifce_id = expect(ccx.sess, ty::ty_to_def_id(option::get(ty::impl_trait(tcx, impl_id))), - || "make_impl_vtable: non-trait-type implemented"); + || ~"make_impl_vtable: non-trait-type implemented"); let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u; make_vtable(ccx, vec::map(*ty::trait_methods(tcx, ifce_id), |im| { let fty = ty::subst_tps(tcx, substs, ty::mk_fn(tcx, im.fty)); @@ -282,7 +282,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t], fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) -> block { - let _icx = bcx.insn_ctxt("impl::trans_cast"); + let _icx = bcx.insn_ctxt(~"impl::trans_cast"); if dest == ignore { ret trans_expr(bcx, val, ignore); } let ccx = bcx.ccx(); let v_ty = expr_ty(bcx, val); diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 39e0461dee6..7a371e7a5fd 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -136,7 +136,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } item_const(*) | item_enum(*) | item_trait(*) {} - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index ec9e68ae1c0..56ad6f13632 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -28,7 +28,7 @@ impl methods for reflector { C_int(self.bcx.ccx(), i) } - fn c_slice(s: str) -> ValueRef { + fn c_slice(s: ~str) -> ValueRef { let ss = C_estr_slice(self.bcx.ccx(), s); do_spill_noroot(self.bcx, ss) } @@ -53,9 +53,9 @@ impl methods for reflector { self.c_tydesc(mt.ty)] } - 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), + let mth_idx = option::get(ty::method_idx(@(~"visit_" + ty_name), *self.visitor_methods)); let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty); let v = self.visitor_val; @@ -76,34 +76,34 @@ impl methods for reflector { let bcx = trans_call_inner(self.bcx, none, mth_ty, ty::mk_bool(tcx), get_lval, arg_vals(args), by_val(d)); - let next_bcx = sub_block(bcx, "next"); + let next_bcx = sub_block(bcx, ~"next"); CondBr(bcx, *d, next_bcx.llbb, self.final_bcx.llbb); self.bcx = next_bcx } - fn bracketed(bracket_name: str, extra: ~[ValueRef], + fn bracketed(bracket_name: ~str, extra: ~[ValueRef], inner: fn()) { - self.visit("enter_" + bracket_name, extra); + self.visit(~"enter_" + bracket_name, extra); inner(); - self.visit("leave_" + bracket_name, extra); + self.visit(~"leave_" + bracket_name, 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 = vec::append(~[self.c_uint(n)], self.c_size_and_align(t)); - f("fixed", extra) + 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) { + fn leaf(name: ~str) { self.visit(name, ~[]); } @@ -115,49 +115,49 @@ impl methods for reflector { ty_to_str(bcx.ccx().tcx, t)); alt ty::get(t).struct { - ty::ty_bot { self.leaf("bot") } - ty::ty_nil { self.leaf("nil") } - ty::ty_bool { self.leaf("bool") } - ty::ty_int(ast::ty_i) { self.leaf("int") } - ty::ty_int(ast::ty_char) { self.leaf("char") } - ty::ty_int(ast::ty_i8) { self.leaf("i8") } - ty::ty_int(ast::ty_i16) { self.leaf("i16") } - ty::ty_int(ast::ty_i32) { self.leaf("i32") } - ty::ty_int(ast::ty_i64) { self.leaf("i64") } - ty::ty_uint(ast::ty_u) { self.leaf("uint") } - ty::ty_uint(ast::ty_u8) { self.leaf("u8") } - ty::ty_uint(ast::ty_u16) { self.leaf("u16") } - ty::ty_uint(ast::ty_u32) { self.leaf("u32") } - ty::ty_uint(ast::ty_u64) { self.leaf("u64") } - ty::ty_float(ast::ty_f) { self.leaf("float") } - ty::ty_float(ast::ty_f32) { self.leaf("f32") } - ty::ty_float(ast::ty_f64) { self.leaf("f64") } - ty::ty_str { self.leaf("str") } + ty::ty_bot { self.leaf(~"bot") } + ty::ty_nil { self.leaf(~"nil") } + ty::ty_bool { self.leaf(~"bool") } + ty::ty_int(ast::ty_i) { self.leaf(~"int") } + ty::ty_int(ast::ty_char) { self.leaf(~"char") } + ty::ty_int(ast::ty_i8) { self.leaf(~"i8") } + ty::ty_int(ast::ty_i16) { self.leaf(~"i16") } + ty::ty_int(ast::ty_i32) { self.leaf(~"i32") } + ty::ty_int(ast::ty_i64) { self.leaf(~"i64") } + ty::ty_uint(ast::ty_u) { self.leaf(~"uint") } + ty::ty_uint(ast::ty_u8) { self.leaf(~"u8") } + ty::ty_uint(ast::ty_u16) { self.leaf(~"u16") } + ty::ty_uint(ast::ty_u32) { self.leaf(~"u32") } + ty::ty_uint(ast::ty_u64) { self.leaf(~"u64") } + ty::ty_float(ast::ty_f) { self.leaf(~"float") } + ty::ty_float(ast::ty_f32) { self.leaf(~"f32") } + ty::ty_float(ast::ty_f64) { self.leaf(~"f64") } + ty::ty_str { self.leaf(~"str") } - ty::ty_vec(mt) { self.visit("vec", self.c_mt(mt)) } - ty::ty_unboxed_vec(mt) { self.visit("vec", self.c_mt(mt)) } + ty::ty_vec(mt) { self.visit(~"vec", self.c_mt(mt)) } + ty::ty_unboxed_vec(mt) { self.visit(~"vec", self.c_mt(mt)) } ty::ty_estr(vst) { do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit("estr_" + name, extra) + self.visit(~"estr_" + name, extra) } } ty::ty_evec(mt, vst) { do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit("evec_" + name, extra + + self.visit(~"evec_" + name, extra + self.c_mt(mt)) } } - ty::ty_box(mt) { self.visit("box", self.c_mt(mt)) } - ty::ty_uniq(mt) { self.visit("uniq", self.c_mt(mt)) } - ty::ty_ptr(mt) { self.visit("ptr", self.c_mt(mt)) } - ty::ty_rptr(_, mt) { self.visit("rptr", self.c_mt(mt)) } + ty::ty_box(mt) { self.visit(~"box", self.c_mt(mt)) } + ty::ty_uniq(mt) { self.visit(~"uniq", self.c_mt(mt)) } + ty::ty_ptr(mt) { self.visit(~"ptr", self.c_mt(mt)) } + ty::ty_rptr(_, mt) { self.visit(~"rptr", self.c_mt(mt)) } ty::ty_rec(fields) { - do self.bracketed("rec", + do self.bracketed(~"rec", ~[self.c_uint(vec::len(fields))] + self.c_size_and_align(t)) { for fields.eachi |i, field| { - self.visit("rec_field", + self.visit(~"rec_field", ~[self.c_uint(i), self.c_slice(*field.ident)] + self.c_mt(field.mt)); @@ -166,11 +166,11 @@ impl methods for reflector { } ty::ty_tup(tys) { - do self.bracketed("tup", + do self.bracketed(~"tup", ~[self.c_uint(vec::len(tys))] + self.c_size_and_align(t)) { for tys.eachi |i, t| { - self.visit("tup_field", + self.visit(~"tup_field", ~[self.c_uint(i), self.c_tydesc(t)]); } @@ -201,7 +201,7 @@ impl methods for reflector { self.c_uint(protoval), self.c_uint(vec::len(fty.inputs)), self.c_uint(retval)]; - self.visit("enter_fn", extra); + self.visit(~"enter_fn", extra); for fty.inputs.eachi |i, arg| { let modeval = alt arg.mode { ast::infer(_) { 0u } @@ -215,15 +215,15 @@ impl methods for reflector { } } }; - self.visit("fn_input", + self.visit(~"fn_input", ~[self.c_uint(i), self.c_uint(modeval), self.c_tydesc(arg.ty)]); } - self.visit("fn_output", + self.visit(~"fn_output", ~[self.c_uint(retval), self.c_tydesc(fty.output)]); - self.visit("leave_fn", extra); + self.visit(~"leave_fn", extra); } ty::ty_class(did, substs) { @@ -231,10 +231,10 @@ impl methods for reflector { let tcx = bcx.ccx().tcx; let fields = ty::class_items_as_fields(tcx, did, substs); - do self.bracketed("class", ~[self.c_uint(vec::len(fields))] + do self.bracketed(~"class", ~[self.c_uint(vec::len(fields))] + self.c_size_and_align(t)) { for fields.eachi |i, field| { - self.visit("class_field", + self.visit(~"class_field", ~[self.c_uint(i), self.c_slice(*field.ident)] + self.c_mt(field.mt)); @@ -251,17 +251,17 @@ impl methods for reflector { let tcx = bcx.ccx().tcx; let variants = ty::substd_enum_variants(tcx, did, substs); - do self.bracketed("enum", + do self.bracketed(~"enum", ~[self.c_uint(vec::len(variants))] + self.c_size_and_align(t)) { for variants.eachi |i, v| { - do self.bracketed("enum_variant", + do self.bracketed(~"enum_variant", ~[self.c_uint(i), self.c_int(v.disr_val), self.c_uint(vec::len(v.args)), self.c_slice(*v.name)]) { for v.args.eachi |j, a| { - self.visit("enum_variant_field", + self.visit(~"enum_variant_field", ~[self.c_uint(j), self.c_tydesc(a)]); } @@ -271,21 +271,21 @@ impl methods for reflector { } // Miscallaneous extra types - ty::ty_trait(_, _) { self.leaf("trait") } - 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_self { self.leaf("self") } - ty::ty_type { self.leaf("type") } - ty::ty_opaque_box { self.leaf("opaque_box") } - ty::ty_constr(t, _) { self.visit("constr", ~[self.c_tydesc(t)]) } + ty::ty_trait(_, _) { self.leaf(~"trait") } + 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_self { self.leaf(~"self") } + ty::ty_type { self.leaf(~"type") } + ty::ty_opaque_box { self.leaf(~"opaque_box") } + ty::ty_constr(t, _) { self.visit(~"constr", ~[self.c_tydesc(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)]) } } } @@ -296,9 +296,9 @@ fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t, visitor_val: ValueRef, visitor_iid: def_id) -> block { - let final = sub_block(bcx, "final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key(@"tydesc"/~); - let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(@"tydesc"/~); + let final = sub_block(bcx, ~"final"); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(@~"tydesc"); + let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(@~"tydesc"); let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); let r = reflector({ visitor_val: visitor_val, diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 607c20573ec..24a1591a6c8 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -97,7 +97,7 @@ const shape_fixedvec: u8 = 32u8; const shape_slice: u8 = 33u8; const shape_unboxed_vec: u8 = 34u8; -fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) -> +fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) -> ValueRef { let llglobal = str::as_c_str(name, @@ -184,8 +184,8 @@ fn s_send_tydesc(_tcx: ty_ctxt) -> u8 { } fn mk_ctxt(llmod: ModuleRef) -> ctxt { - let llshapetablesty = trans::common::T_named_struct("shapes"); - let llshapetables = str::as_c_str("shapes", |buf| { + let llshapetablesty = trans::common::T_named_struct(~"shapes"); + let llshapetables = str::as_c_str(~"shapes", |buf| { lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf) }); @@ -351,7 +351,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { s } ty::ty_param(*) { - ccx.tcx.sess.bug("non-monomorphized type parameter"); + 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] } @@ -361,7 +361,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { 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"); + ccx.sess.bug(~"shape_of: unexpected type struct found"); } } } @@ -458,7 +458,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { header += data; header += lv_table; - ret mk_global(ccx, "tag_shapes", C_bytes(header), true); + ret mk_global(ccx, ~"tag_shapes", C_bytes(header), true); /* tjc: Not annotating FIXMEs in this module because of #1498 */ fn largest_variants(ccx: @crate_ctxt, @@ -579,7 +579,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef { dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)]; } } - ret mk_global(ccx, "resource_shapes", C_struct(dtors), true); + ret mk_global(ccx, ~"resource_shapes", C_struct(dtors), true); } fn gen_shape_tables(ccx: @crate_ctxt) { @@ -699,7 +699,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { cx.enum_sizes.insert(t, max_size); ret max_size; } - _ { cx.sess.bug("static_size_of_enum called on non-enum"); } + _ { cx.sess.bug(~"static_size_of_enum called on non-enum"); } } } @@ -730,7 +730,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { ty::ty_class(did, substs) { let simpl_fields = (if is_some(ty::ty_dtor(tcx, did)) { // remember the drop flag - ~[{ident: @"drop"/~, mt: {ty: + ~[{ident: @~"drop", mt: {ty: ty::mk_u8(tcx), mutbl: ast::m_mutbl}}] } else { ~[] }) + diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index a6e317f9cc3..0c233d2c1bc 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -27,14 +27,14 @@ fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { ty::ty_estr(ty::vstore_box) | ty::ty_evec(_, ty::vstore_box) { ty::mk_imm_box(tcx, unboxed_vec_ty) } - _ { tcx.sess.bug("non boxed-vec type \ + _ { tcx.sess.bug(~"non boxed-vec type \ in tvec::expand_boxed_vec_ty"); } } } fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("tvec::get_fill"); + let _icx = bcx.insn_ctxt(~"tvec::get_fill"); Load(bcx, GEPi(bcx, vptr, ~[0u, abi::vec_elt_fill])) } fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) { @@ -50,12 +50,12 @@ fn get_bodyptr(bcx: block, vptr: ValueRef) -> ValueRef { fn get_dataptr(bcx: block, vptr: ValueRef) -> ValueRef { - let _icx = bcx.insn_ctxt("tvec::get_dataptr"); + let _icx = bcx.insn_ctxt(~"tvec::get_dataptr"); 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 _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); @@ -63,7 +63,7 @@ fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { fn alloc_raw(bcx: block, unit_ty: ty::t, fill: ValueRef, alloc: ValueRef, heap: heap) -> result { - let _icx = bcx.insn_ctxt("tvec::alloc_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::alloc_uniq"); let ccx = bcx.ccx(); let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty); @@ -80,7 +80,7 @@ fn alloc_uniq_raw(bcx: block, unit_ty: ty::t, } fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result { - let _icx = bcx.insn_ctxt("tvec::alloc_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::alloc_uniq"); let ccx = bcx.ccx(); let llunitty = type_of::type_of(ccx, unit_ty); let unit_sz = llsize_of(ccx, llunitty); @@ -93,7 +93,7 @@ fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result { } fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { - let _icx = bcx.insn_ctxt("tvec::duplicate_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::duplicate_uniq"); let fill = get_fill(bcx, get_bodyptr(bcx, vptr)); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); @@ -111,7 +111,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> block { - let _icx = bcx.insn_ctxt("tvec::make_drop_glue_unboxed"); + let _icx = bcx.insn_ctxt(~"tvec::make_drop_glue_unboxed"); let tcx = bcx.tcx(), unit_ty = ty::sequence_element_type(tcx, vec_ty); if ty::type_needs_drop(tcx, unit_ty) { iter_vec_unboxed(bcx, vptr, vec_ty, base::drop_ty) @@ -120,7 +120,7 @@ fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> 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 _icx = bcx.insn_ctxt(~"tvec::trans_evec"); let ccx = bcx.ccx(); let mut bcx = bcx; if dest == base::ignore { @@ -144,7 +144,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr], PointerCast(bcx, v, T_ptr(llunitty)) } _ { - bcx.ccx().sess.bug("bad dest for vstore_fixed \ + bcx.ccx().sess.bug(~"bad dest for vstore_fixed \ in tvec::trans_evec"); } }; @@ -226,7 +226,7 @@ fn trans_vstore(bcx: block, e: @ast::expr, ret trans_evec(bcx, es, v, e.id, dest); } _ { - bcx.sess().span_bug(e.span, "vstore on non-sequence type"); + bcx.sess().span_bug(e.span, ~"vstore on non-sequence type"); } } } @@ -266,9 +266,9 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) } } -fn trans_estr(bcx: block, s: @str/~, vstore: ast::vstore, +fn trans_estr(bcx: block, s: @~str, vstore: ast::vstore, dest: dest) -> block { - let _icx = bcx.insn_ctxt("tvec::trans_estr"); + let _icx = bcx.insn_ctxt(~"tvec::trans_estr"); if dest == base::ignore { ret bcx; } let ccx = bcx.ccx(); @@ -313,7 +313,7 @@ type iter_vec_block = fn(block, ValueRef, ty::t) -> block; fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> block { - let _icx = bcx.insn_ctxt("tvec::iter_vec_raw"); + let _icx = bcx.insn_ctxt(~"tvec::iter_vec_raw"); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); @@ -324,14 +324,14 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, let data_end_ptr = pointer_add(bcx, data_ptr, fill); // Now perform the iteration. - let header_cx = sub_block(bcx, "iter_vec_loop_header"); + 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 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"); - let next_cx = sub_block(header_cx, "iter_vec_next"); + let body_cx = sub_block(header_cx, ~"iter_vec_loop_body"); + let next_cx = sub_block(header_cx, ~"iter_vec_next"); 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, @@ -344,14 +344,14 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> block { - let _icx = bcx.insn_ctxt("tvec::iter_vec_uniq"); + let _icx = bcx.insn_ctxt(~"tvec::iter_vec_uniq"); let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr)); iter_vec_raw(bcx, data_ptr, vec_ty, fill, f) } fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t, f: iter_vec_block) -> block { - let _icx = bcx.insn_ctxt("tvec::iter_vec_unboxed"); + let _icx = bcx.insn_ctxt(~"tvec::iter_vec_unboxed"); let fill = get_fill(bcx, body_ptr); let dataptr = get_dataptr(bcx, body_ptr); ret iter_vec_raw(bcx, dataptr, vec_ty, fill, f); diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index cfc1f621efd..aac6f2d97ba 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -59,7 +59,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef { T_ptr(T_unique(cx, type_of(cx, mt.ty))) } _ { - cx.sess.bug("non-box in type_of_non_gc_box"); + cx.sess.bug(~"non-box in type_of_non_gc_box"); } } } @@ -158,11 +158,11 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { common::T_named_struct(llvm_type_name(cx, t)) } - ty::ty_self { cx.tcx.sess.unimpl("type_of: ty_self"); } - ty::ty_var(_) { cx.tcx.sess.bug("type_of shouldn't see a ty_var"); } - ty::ty_param(*) { cx.tcx.sess.bug("type_of with ty_param"); } + ty::ty_self { cx.tcx.sess.unimpl(~"type_of: ty_self"); } + ty::ty_var(_) { cx.tcx.sess.bug(~"type_of with ty_var"); } + ty::ty_param(*) { cx.tcx.sess.bug(~"type_of with ty_param"); } ty::ty_var_integral(_) { - cx.tcx.sess.bug("type_of shouldn't see a ty_var_integral"); + cx.tcx.sess.bug(~"type_of shouldn't see a ty_var_integral"); } }; @@ -227,13 +227,13 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) ret named_llty; } -fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> str { +fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { let (name, did, tps) = alt check ty::get(t).struct { ty::ty_enum(did, substs) { - ("enum", did, substs.tps) + (~"enum", did, substs.tps) } ty::ty_class(did, substs) { - ("class", did, substs.tps) + (~"class", did, substs.tps) } }; ret #fmt( diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index ef2a95005da..8d741655d35 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -76,17 +76,18 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) abi, _) { if abi == foreign_abi_rust_intrinsic { let flags = alt check *i.ident { - "size_of" | "pref_align_of" | "min_align_of" | - "init" | "reinterpret_cast" | "move_val" | "move_val_init" { + ~"size_of" | ~"pref_align_of" | ~"min_align_of" | + ~"init" | ~"reinterpret_cast" | + ~"move_val" | ~"move_val_init" { use_repr } - "get_tydesc" | "needs_drop" { use_tydesc } - "atomic_xchng" | "atomic_add" | "atomic_sub" | - "atomic_xchng_acq" | "atomic_add_acq" | "atomic_sub_acq" | - "atomic_xchng_rel" | "atomic_add_rel" | "atomic_sub_rel" { + ~"get_tydesc" | ~"needs_drop" { use_tydesc } + ~"atomic_xchng" | ~"atomic_add" | ~"atomic_sub" | + ~"atomic_xchng_acq" | ~"atomic_add_acq" | ~"atomic_sub_acq" | + ~"atomic_xchng_rel" | ~"atomic_add_rel" | ~"atomic_sub_rel" { 0u } - "visit_tydesc" | "forget" | "addr_of" { 0u } + ~"visit_tydesc" | ~"forget" | ~"addr_of" { 0u } }; for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} } diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index 992ed26ee73..b044d0ac23c 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -9,7 +9,7 @@ export make_free_glue, autoderef, duplicate; fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t) -> block { - let _icx = bcx.insn_ctxt("uniq::make_free_glue"); + let _icx = bcx.insn_ctxt(~"uniq::make_free_glue"); do with_cond(bcx, IsNotNull(bcx, vptr)) |bcx| { let content_ty = content_ty(t); let body_ptr = opaque_box_body(bcx, content_ty, vptr); @@ -32,7 +32,7 @@ fn autoderef(bcx: block, v: ValueRef, t: ty::t) -> {v: ValueRef, t: ty::t} { } fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { - let _icx = bcx.insn_ctxt("uniq::duplicate"); + let _icx = bcx.insn_ctxt(~"uniq::duplicate"); let content_ty = content_ty(t); let {box: dst_box, body: dst_body} = malloc_unique(bcx, content_ty); diff --git a/src/rustc/middle/tstate/ann.rs b/src/rustc/middle/tstate/ann.rs index f20ad0f73dc..d1f19ba6e1f 100644 --- a/src/rustc/middle/tstate/ann.rs +++ b/src/rustc/middle/tstate/ann.rs @@ -239,8 +239,8 @@ fn implies(a: t, b: t) -> bool { ret tritv_doesntcare(tmp); } -fn trit_str(t: trit) -> str { - alt t { dont_care { "?" } ttrue { "1" } tfalse { "0" } } +fn trit_str(t: trit) -> ~str { + alt t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } } } // FIXME (#2538): Would be nice to have unit tests for some of these diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index e6beae9e014..de9a4540d21 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -40,7 +40,7 @@ fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut ~[node_id]) { 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)); + log(debug, int::str(i) + ~" |-> " + uint::str(len)); add_node(ccx, i, empty_ann(len)); } } diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index d50e445482a..a098757175c 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -30,17 +30,17 @@ enum oper_type { } /* logging funs */ -fn def_id_to_str(d: def_id) -> str { - ret int::str(d.crate) + "," + int::str(d.node); +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 { - let mut rslt = ""; +fn comma_str(args: ~[@constr_arg_use]) -> ~str { + let mut rslt = ~""; let mut comma = false; for args.each |a| { - if comma { rslt += ", "; } else { comma = true; } + if comma { rslt += ~", "; } else { comma = true; } alt a.node { - carg_base { rslt += "*"; } + carg_base { rslt += ~"*"; } carg_ident(i) { rslt += *i.ident; } carg_lit(l) { rslt += lit_to_str(l); } } @@ -48,23 +48,23 @@ fn comma_str(args: ~[@constr_arg_use]) -> str { ret rslt; } -fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> str { +fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> ~str { ret #fmt("%s(%s) - arising from %s", path_to_str(c.node.path), comma_str(c.node.args), codemap::span_to_str(c.span, tcx.sess.codemap)); } -fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> str { - let mut s = ""; +fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str { + let mut s = ~""; let mut comma = false; for constraints(fcx).each |p| { alt tritv_get(v, p.bit_num) { dont_care { } tt { s += - if comma { ", " } else { comma = true; "" } + - if tt == tfalse { "!" } else { "" } + + if comma { ~", " } else { comma = true; ~"" } + + if tt == tfalse { ~"!" } else { ~"" } + constraint_to_str(fcx.ccx.tcx, p.c); } } @@ -77,8 +77,8 @@ fn log_tritv(fcx: fn_ctxt, v: tritv::t) { } fn first_difference_string(fcx: fn_ctxt, expected: tritv::t, actual: tritv::t) - -> str { - let mut s = ""; + -> ~str { + let mut s = ~""; for constraints(fcx).each |c| { if tritv_get(expected, c.bit_num) == ttrue && tritv_get(actual, c.bit_num) != ttrue { @@ -93,12 +93,12 @@ fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { log(error, tritv_to_str(fcx, v)); } -fn tos(v: ~[uint]) -> str { - let mut rslt = ""; +fn tos(v: ~[uint]) -> ~str { + let mut rslt = ~""; for v.each |i| { if i == 0u { - rslt += "0"; - } else if i == 1u { rslt += "1"; } else { rslt += "?"; } + rslt += ~"0"; + } else if i == 1u { rslt += ~"1"; } else { rslt += ~"?"; } } ret rslt; } @@ -143,11 +143,11 @@ fn log_states_err(pp: pre_and_post_state) { log_cond_err(p2); } -fn print_ident(i: ident) { log(debug, " " + *i + " "); } +fn print_ident(i: ident) { log(debug, ~" " + *i + ~" "); } fn print_idents(&idents: ~[ident]) { if vec::len::<ident>(idents) == 0u { ret; } - log(debug, "an ident: " + *vec::pop::<ident>(idents)); + log(debug, ~"an ident: " + *vec::pop::<ident>(idents)); print_idents(idents); } @@ -499,23 +499,23 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] { fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>, occ: ~[@constr_arg_use]) -> uint { #debug("match_args: looking at %s", - constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, occ)); + constr_args_to_str(fn@(i: inst) -> ~str { ret *i.ident; }, occ)); for (*occs).each |pd| { log(debug, - "match_args: candidate " + pred_args_to_str(pd)); + ~"match_args: candidate " + pred_args_to_str(pd)); fn eq(p: inst, q: inst) -> bool { ret p.node == q.node; } if ty::args_eq(eq, pd.node.args, occ) { ret pd.node.bit_num; } } - fcx.ccx.tcx.sess.bug("match_args: no match for occurring args"); + fcx.ccx.tcx.sess.bug(~"match_args: no match for occurring args"); } fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { alt tcx.def_map.find(t) { none { - tcx.sess.bug("node_id_for_constr: bad node_id " + int::str(t)); + tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t)); } some(def_fn(i, _)) { ret i; } - _ { tcx.sess.bug("node_id_for_constr: pred is not a function"); } + _ { tcx.sess.bug(~"node_id_for_constr: pred is not a function"); } } } @@ -535,7 +535,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { } none { tcx.sess.span_bug(e.span, - "exprs_to_constr_args: unbound id as pred arg"); + ~"exprs_to_constr_args: unbound id as pred arg"); } } @@ -543,8 +543,8 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { expr_lit(l) { ret @respan(e.span, carg_lit(l)); } _ { tcx.sess.span_fatal(e.span, - "arguments to constrained functions must be " + - "literals or local variables"); + ~"arguments to constrained functions must be " + + ~"literals or local variables"); } } } @@ -569,20 +569,21 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr { } _ { tcx.sess.span_bug(operator.span, - "ill-formed operator in predicate"); + ~"ill-formed operator in predicate"); } } } _ { - tcx.sess.span_bug(e.span, "ill-formed predicate"); + tcx.sess.span_bug(e.span, ~"ill-formed predicate"); } } } -fn pred_args_to_str(p: pred_args) -> str { - "<" + uint::str(p.node.bit_num) + ", " + - constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, p.node.args) - + ">" +fn pred_args_to_str(p: pred_args) -> ~str { + ~"<" + uint::str(p.node.bit_num) + ~", " + + constr_args_to_str(fn@(i: inst) -> ~str {ret *i.ident; }, + p.node.args) + + ~">" } fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) -> @@ -604,7 +605,7 @@ fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) -> if i < num_actuals { ret expr_to_constr_arg(cx, actuals[i]); } else { - cx.sess.span_fatal(a.span, "constraint argument out of bounds"); + cx.sess.span_fatal(a.span, ~"constraint argument out of bounds"); } } carg_base { ret @respan(a.span, carg_base); } @@ -689,18 +690,18 @@ 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 { - let mut rslt = "<"; +fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str { + let mut rslt = ~"<"; for stuff.each |i| { rslt += - " " + + ~" " + alt i { carg_ident(p) { *p.ident } - carg_base { "*" } - carg_lit(_) { "~[lit]" } - } + " "; + carg_base { ~"*" } + carg_lit(_) { ~"~[lit]" } + } + ~" "; } - rslt += ">"; + rslt += ~">"; rslt } @@ -741,13 +742,13 @@ fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) -> } some(_) { fcx.ccx.tcx.sess.span_fatal(sp, - "local_node_id_to_def_id: id \ + ~"local_node_id_to_def_id: id \ isn't a local"); } none { // should really be bug. span_bug()? fcx.ccx.tcx.sess.span_fatal(sp, - "local_node_id_to_def_id: id \ + ~"local_node_id_to_def_id: id \ is unbound"); } } @@ -898,7 +899,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg], node: args[i].id}) } else { tcx.sess.span_bug(a.span, - "index out of bounds in \ + ~"index out of bounds in \ constraint arg"); } } @@ -949,7 +950,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { } _ { // Shouldn't happen; callee should be ty_fn. - fcx.ccx.tcx.sess.bug("non-fn callee type in callee_modes: " + + fcx.ccx.tcx.sess.bug(~"non-fn callee type in callee_modes: " + util::ppaux::ty_to_str(fcx.ccx.tcx, ty)); } } diff --git a/src/rustc/middle/tstate/ck.rs b/src/rustc/middle/tstate/ck.rs index b5e9c5d32c8..d534b764c07 100644 --- a/src/rustc/middle/tstate/ck.rs +++ b/src/rustc/middle/tstate/ck.rs @@ -25,15 +25,15 @@ fn check_states_expr(e: @expr, fcx: fn_ctxt, v: visit::vt<fn_ctxt>) { let pres: prestate = expr_prestate(fcx.ccx, e); if !implies(pres, prec) { - let mut s = ""; + let mut s = ~""; let diff = first_difference_string(fcx, prec, pres); s += - "unsatisfied precondition constraint (for example, " + diff + - ") for expression:\n"; + ~"unsatisfied precondition constraint (for example, " + diff + + ~") for expression:\n"; s += syntax::print::pprust::expr_to_str(e); - s += "\nprecondition:\n"; + s += ~"\nprecondition:\n"; s += tritv_to_str(fcx, prec); - s += "\nprestate:\n"; + s += ~"\nprestate:\n"; s += tritv_to_str(fcx, pres); fcx.ccx.tcx.sess.span_fatal(e.span, s); } @@ -54,15 +54,15 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt<fn_ctxt>) { log_tritv(fcx, pres); if !implies(pres, prec) { - let mut ss = ""; + let mut ss = ~""; let diff = first_difference_string(fcx, prec, pres); ss += - "unsatisfied precondition constraint (for example, " + diff + - ") for statement:\n"; + ~"unsatisfied precondition constraint (for example, " + diff + + ~") for statement:\n"; ss += syntax::print::pprust::stmt_to_str(*s); - ss += "\nprecondition:\n"; + ss += ~"\nprecondition:\n"; ss += tritv_to_str(fcx, prec); - ss += "\nprestate: \n"; + ss += ~"\nprestate: \n"; ss += tritv_to_str(fcx, pres); fcx.ccx.tcx.sess.span_fatal(s.span, ss); } diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index 6c5eebbcb0b..d7bfd031307 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -55,7 +55,7 @@ fn find_locals(tcx: ty::ctxt, fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) -> uint { log(debug, - constraint_to_str(tcx, c) + " |-> " + uint::str(next)); + constraint_to_str(tcx, c) + ~" |-> " + uint::str(next)); let {path: p, def_id: d_id, args: args} = c.node; alt tbl.find(d_id) { diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index fe502e18476..591f152acb3 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -50,12 +50,12 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) { item_foreign_mod(nm) { find_pre_post_foreign_mod(nm); } item_ty(*) | item_enum(*) | item_trait(*) { ret; } item_class(*) { - fail "find_pre_post_item: shouldn't be called on item_class"; + fail ~"find_pre_post_item: shouldn't be called on item_class"; } item_impl(_, _, _, ms) { for ms.each |m| { find_pre_post_method(ccx, m); } } - item_mac(*) { fail "item macros unimplemented" } + item_mac(*) { fail ~"item macros unimplemented" } } } @@ -303,7 +303,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { for (*cap_clause).each |cap_item| { if cap_item.is_move { - log(debug, ("forget_in_postcond: ", cap_item)); + log(debug, (~"forget_in_postcond: ", cap_item)); forget_in_postcond(fcx, e.id, cap_item.id); } } @@ -447,7 +447,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_break { clear_pp(expr_pp(fcx.ccx, e)); } expr_again { clear_pp(expr_pp(fcx.ccx, e)); } - expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); } + expr_mac(_) { fcx.ccx.tcx.sess.bug(~"unexpanded macro"); } } } diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index f6cf240eeca..ebe476b3d7f 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -20,7 +20,7 @@ fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) { alt local_node_id_to_def(fcx, rhs_id) { some(def_upvar(_, _, _)) { fcx.ccx.tcx.sess.span_err(sp, - "tried to deinitialize a variable \ + ~"tried to deinitialize a variable \ declared in a different scope"); } _ { } @@ -309,7 +309,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { expr_log(_, lvl, ex) { ret find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure); } - expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); } + expr_mac(_) { fcx.ccx.tcx.sess.bug(~"unexpanded macro"); } expr_lit(l) { ret pure_exp(fcx.ccx, e.id, pres); } expr_fn(_, _, _, cap_clause) { ret find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause); diff --git a/src/rustc/middle/tstate/tritv.rs b/src/rustc/middle/tstate/tritv.rs index c3e221ef32c..fc158262cb6 100644 --- a/src/rustc/middle/tstate/tritv.rs +++ b/src/rustc/middle/tstate/tritv.rs @@ -264,15 +264,15 @@ fn to_vec(v: t) -> ~[uint] { ret rslt; } -fn to_str(v: t) -> str { +fn to_str(v: t) -> ~str { let mut i: uint = 0u; - let mut rs: str = ""; + let mut rs: ~str = ~""; while i < v.nbits { rs += alt tritv_get(v, i) { - dont_care { "?" } - ttrue { "1" } - tfalse { "0" } + dont_care { ~"?" } + ttrue { ~"1" } + tfalse { ~"0" } }; i += 1u; } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index a0a3c818e5f..c3bcefb9fa5 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -253,7 +253,7 @@ type ctxt = freevars: freevars::freevar_map, tcache: type_cache, rcache: creader_cache, - short_names_cache: hashmap<t, @str/~>, + short_names_cache: hashmap<t, @~str>, needs_drop_cache: hashmap<t, bool>, needs_unwind_cleanup_cache: hashmap<t, bool>, kind_cache: hashmap<t, kind>, @@ -444,26 +444,26 @@ enum region_vid = uint; iface vid { fn to_uint() -> uint; - fn to_str() -> str; + fn to_str() -> ~str; } impl of vid for tv_vid { fn to_uint() -> uint { *self } - fn to_str() -> str { #fmt["<V%u>", self.to_uint()] } + fn to_str() -> ~str { #fmt["<V%u>", self.to_uint()] } } impl of vid for tvi_vid { fn to_uint() -> uint { *self } - fn to_str() -> str { #fmt["<VI%u>", self.to_uint()] } + fn to_str() -> ~str { #fmt["<VI%u>", self.to_uint()] } } impl of vid for region_vid { fn to_uint() -> uint { *self } - fn to_str() -> str { #fmt["<R%u>", self.to_uint()] } + fn to_str() -> ~str { #fmt["<R%u>", self.to_uint()] } } impl of to_str::to_str for purity { - fn to_str() -> str { + fn to_str() -> ~str { purity_to_str(self) } } @@ -1020,10 +1020,10 @@ fn substs_is_noop(substs: substs) -> bool { substs.self_ty.is_none() } -fn substs_to_str(cx: ctxt, substs: substs) -> str { +fn substs_to_str(cx: ctxt, substs: substs) -> ~str { #fmt["substs(self_r=%s, self_ty=%s, tps=%?)", - substs.self_r.map_default("none", |r| region_to_str(cx, r)), - substs.self_ty.map_default("none", |t| ty_to_str(cx, t)), + substs.self_r.map_default(~"none", |r| region_to_str(cx, r)), + substs.self_ty.map_default(~"none", |t| ty_to_str(cx, t)), substs.tps.map(|t| ty_to_str(cx, t))] } @@ -1117,7 +1117,9 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t { alt get(ty).struct { ty_str | ty_estr(_) { ret mk_mach_uint(cx, ast::ty_u8); } ty_vec(mt) | ty_evec(mt, _) | ty_unboxed_vec(mt) { ret mt.ty; } - _ { cx.sess.bug("sequence_element_type called on non-sequence value"); } + _ { cx.sess.bug( + ~"sequence_element_type called on non-sequence value"); + } } } @@ -1125,7 +1127,7 @@ fn get_element_type(ty: t, i: uint) -> t { alt get(ty).struct { ty_rec(flds) { ret flds[i].mt.ty; } ty_tup(ts) { ret ts[i]; } - _ { fail "get_element_type called on invalid type"; } + _ { fail ~"get_element_type called on invalid type"; } } } @@ -1603,10 +1605,10 @@ fn type_kind(cx: ctxt, ty: t) -> kind { // FIXME (#2663): is self ever const? ty_self { kind_noncopyable() } ty_var(_) | ty_var_integral(_) { - cx.sess.bug("Asked to compute kind of a type variable"); + cx.sess.bug(~"Asked to compute kind of a type variable"); } ty_type | ty_opaque_closure_ptr(_) | ty_opaque_box | ty_unboxed_vec(_) { - cx.sess.bug("Asked to compute kind of fictitious type"); + cx.sess.bug(~"Asked to compute kind of fictitious type"); } }; @@ -1785,7 +1787,7 @@ fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool { ty_param(_, _) { true } ty_evec(_, _) | ty_estr(_) { - cx.sess.unimpl("estr/evec in type_allows_implicit_copy"); + cx.sess.unimpl(~"estr/evec in type_allows_implicit_copy"); } ty_vec(mt) { @@ -1889,7 +1891,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { } ty_var(*) | ty_var_integral(*) | ty_self(*) { - cx.sess.bug("non concrete type in type_is_pod"); + cx.sess.bug(~"non concrete type in type_is_pod"); } } @@ -2010,7 +2012,7 @@ fn hash_type_structure(st: sty) -> uint { for c.node.args.each |a| { alt a.node { carg_base { h += h << 2u; } - carg_lit(_) { fail "lit args not implemented yet"; } + carg_lit(_) { fail ~"lit args not implemented yet"; } carg_ident(p) { h += h << 2u; } } } @@ -2166,28 +2168,28 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { 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"; } + _ { fail ~"ty_fn_args() called on non-fn type"; } } } fn ty_fn_proto(fty: t) -> ast::proto { alt get(fty).struct { ty_fn(f) { f.proto } - _ { fail "ty_fn_proto() called on non-fn type"; } + _ { fail ~"ty_fn_proto() called on non-fn type"; } } } pure fn ty_fn_ret(fty: t) -> t { alt get(fty).struct { ty_fn(f) { f.output } - _ { fail "ty_fn_ret() called on non-fn type"; } + _ { fail ~"ty_fn_ret() called on non-fn type"; } } } fn ty_fn_ret_style(fty: t) -> ast::ret_style { alt get(fty).struct { ty_fn(f) { f.ret_style } - _ { fail "ty_fn_ret_style() called on non-fn type"; } + _ { fail ~"ty_fn_ret_style() called on non-fn type"; } } } @@ -2321,11 +2323,11 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { // assertion later on that the type doesn't contain // variables, so in this case we have to be sure to die. tcx.sess.span_fatal - (sp, "type inference failed because I \ + (sp, ~"type inference failed because I \ could not find a type\n that's both of the form " + ty_to_str(tcx, mk_var(tcx, vid)) + - " and of the form " + ty_to_str(tcx, rt) + - " - such a type would have to be infinitely large."); + ~" and of the form " + ty_to_str(tcx, rt) + + ~" - such a type would have to be infinitely large."); } } @@ -2400,7 +2402,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { } } -fn ty_sort_str(cx: ctxt, t: t) -> str { +fn ty_sort_str(cx: ctxt, t: t) -> ~str { alt get(t).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_str | @@ -2409,41 +2411,41 @@ fn ty_sort_str(cx: ctxt, t: t) -> str { } ty_enum(id, _) { #fmt["enum %s", item_path_str(cx, id)] } - ty_box(_) { "@-ptr" } - ty_uniq(_) { "~-ptr" } - ty_evec(_, _) | ty_vec(_) { "vector" } - ty_unboxed_vec(_) { "unboxed vector" } - ty_ptr(_) { "*-ptr" } - ty_rptr(_, _) { "&-ptr" } - ty_rec(_) { "record" } - ty_fn(_) { "fn" } + ty_box(_) { ~"@-ptr" } + ty_uniq(_) { ~"~-ptr" } + ty_evec(_, _) | ty_vec(_) { ~"vector" } + ty_unboxed_vec(_) { ~"unboxed vector" } + ty_ptr(_) { ~"*-ptr" } + ty_rptr(_, _) { ~"&-ptr" } + ty_rec(_) { ~"record" } + ty_fn(_) { ~"fn" } ty_trait(id, _) { #fmt["trait %s", item_path_str(cx, id)] } ty_class(id, _) { #fmt["class %s", item_path_str(cx, id)] } - ty_tup(_) { "tuple" } - ty_var(_) { "variable" } - ty_var_integral(_) { "integral variable" } - ty_param(_, _) { "type parameter" } - ty_self { "self" } + ty_tup(_) { ~"tuple" } + ty_var(_) { ~"variable" } + ty_var_integral(_) { ~"integral variable" } + ty_param(_, _) { ~"type parameter" } + ty_self { ~"self" } ty_constr(t, _) { ty_sort_str(cx, t) } } } -fn type_err_to_str(cx: ctxt, err: type_err) -> str { - fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> str { - alt k { terr_vec { "[]" } terr_str { "str" } } +fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { + fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str { + alt k { terr_vec { ~"[]" } terr_str { ~"str" } } } alt err { - terr_mismatch { ret "types differ"; } + terr_mismatch { ret ~"types differ"; } terr_ret_style_mismatch(expect, actual) { - fn to_str(s: ast::ret_style) -> str { + fn to_str(s: ast::ret_style) -> ~str { alt s { - ast::noreturn { "non-returning" } - ast::return_val { "return-by-value" } + ast::noreturn { ~"non-returning" } + ast::return_val { ~"return-by-value" } } } - ret to_str(actual) + " function found where " + to_str(expect) + - " function was expected"; + ret to_str(actual) + ~" function found where " + to_str(expect) + + ~" function was expected"; } terr_purity_mismatch(f1, f2) { ret #fmt["expected %s fn but found %s fn", f1.to_str(), f2.to_str()]; @@ -2452,45 +2454,45 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> str { ret #fmt["closure protocol mismatch (%s vs %s)", proto_to_str(e), proto_to_str(a)]; } - terr_mutability { ret "values differ in mutability"; } - terr_box_mutability { ret "boxed values differ in mutability"; } - terr_vec_mutability { ret "vectors differ in mutability"; } - terr_ptr_mutability { ret "pointers differ in mutability"; } - terr_ref_mutability { ret "references differ in mutability"; } + terr_mutability { ret ~"values differ in mutability"; } + terr_box_mutability { ret ~"boxed values differ in mutability"; } + terr_vec_mutability { ret ~"vectors differ in mutability"; } + terr_ptr_mutability { ret ~"pointers differ in mutability"; } + terr_ref_mutability { ret ~"references differ in mutability"; } terr_ty_param_size(e_sz, a_sz) { - ret "expected a type with " + uint::to_str(e_sz, 10u) + - " type params but found one with " + uint::to_str(a_sz, 10u) + - " type params"; + ret ~"expected a type with " + uint::to_str(e_sz, 10u) + + ~" type params but found one with " + uint::to_str(a_sz, 10u) + + ~" type params"; } terr_tuple_size(e_sz, a_sz) { - ret "expected a tuple with " + uint::to_str(e_sz, 10u) + - " elements but found one with " + uint::to_str(a_sz, 10u) + - " elements"; + ret ~"expected a tuple with " + uint::to_str(e_sz, 10u) + + ~" elements but found one with " + uint::to_str(a_sz, 10u) + + ~" elements"; } terr_record_size(e_sz, a_sz) { - ret "expected a record with " + uint::to_str(e_sz, 10u) + - " fields but found one with " + uint::to_str(a_sz, 10u) + - " fields"; + ret ~"expected a record with " + uint::to_str(e_sz, 10u) + + ~" fields but found one with " + uint::to_str(a_sz, 10u) + + ~" fields"; } - terr_record_mutability { ret "record elements differ in mutability"; } + terr_record_mutability { ret ~"record elements differ in mutability"; } terr_record_fields(e_fld, a_fld) { - ret "expected a record with field `" + *e_fld + - "` but found one with field `" + *a_fld + "`"; + ret ~"expected a record with field `" + *e_fld + + ~"` but found one with field `" + *a_fld + ~"`"; } - terr_arg_count { ret "incorrect number of function parameters"; } + terr_arg_count { ret ~"incorrect number of function parameters"; } terr_mode_mismatch(e_mode, a_mode) { - ret "expected argument mode " + mode_to_str(e_mode) + " but found " + - mode_to_str(a_mode); + ret ~"expected argument mode " + mode_to_str(e_mode) + + ~" but found " + mode_to_str(a_mode); } terr_constr_len(e_len, a_len) { - ret "expected a type with " + uint::str(e_len) + - " constraints, but found one with " + uint::str(a_len) + - " constraints"; + ret ~"expected a type with " + uint::str(e_len) + + ~" constraints, but found one with " + uint::str(a_len) + + ~" constraints"; } terr_constr_mismatch(e_constr, a_constr) { - ret "expected a type with constraint " + ty_constr_to_str(e_constr) + - " but found one with constraint " + - ty_constr_to_str(a_constr); + ret ~"expected a type with constraint " + ty_constr_to_str(e_constr) + + ~" but found one with constraint " + + ty_constr_to_str(a_constr); } terr_regions_differ(subregion, superregion) { ret #fmt("references with lifetime %s do not necessarily \ @@ -2511,10 +2513,10 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> str { ret #fmt("%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)); } terr_self_substs { - ret "inconsistent self substitution"; // XXX this is more of a bug + ret ~"inconsistent self substitution"; // XXX this is more of a bug } terr_no_integral_type { - ret "couldn't determine an appropriate integral type for integer \ + ret ~"couldn't determine an appropriate integral type for integer \ literal"; } } @@ -2602,7 +2604,7 @@ fn substd_enum_variants(cx: ctxt, } } -fn item_path_str(cx: ctxt, id: ast::def_id) -> str { +fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str { ast_map::path_to_str(item_path(cx, id)) } @@ -2661,7 +2663,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { vec::append_one(*path, ast_map::path_name(nm)) } ast_map::node_dtor(_, _, _, path) { - vec::append_one(*path, ast_map::path_name(@"dtor"/~)) + vec::append_one(*path, ast_map::path_name(@~"dtor")) } @@ -2707,7 +2709,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { // FIXME: issue #1417 disr_val = alt const_eval::eval_const_expr(cx, ex) { const_eval::const_int(val) {val as int} - _ { cx.sess.bug("tag_variants: bad disr expr"); } + _ { cx.sess.bug(~"tag_variants: bad disr expr"); } } } _ {disr_val += 1;} @@ -2720,7 +2722,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { } }) } - _ { cx.sess.bug("tag_variants: id not bound to an enum"); } + _ { cx.sess.bug(~"tag_variants: id not bound to an enum"); } } }; cx.enum_var_cache.insert(id, result); @@ -2738,7 +2740,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id, if ast_util::def_eq(variant.id, variant_id) { ret variant; } i += 1u; } - cx.sess.bug("enum_variant_with_id(): no variant exists with that ID"); + cx.sess.bug(~"enum_variant_with_id(): no variant exists with that ID"); } @@ -2789,7 +2791,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { ast::item_class(_, _, items, _, _) { class_field_tys(items) } - _ { cx.sess.bug("class ID bound to non-class"); } + _ { cx.sess.bug(~"class ID bound to non-class"); } } } _ { @@ -2808,7 +2810,7 @@ fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id) alt vec::find(lookup_class_fields(cx, parent), |f| f.id.node == field_id.node) { some(t) { t } - none { cx.sess.bug("class ID not found in parent's fields"); } + none { cx.sess.bug(~"class ID not found in parent's fields"); } } } @@ -2834,7 +2836,7 @@ fn lookup_class_method_ids(cx: ctxt, did: ast::def_id) vis: m.vis}) } _ { - cx.sess.bug("lookup_class_method_ids: id not bound to a class"); + cx.sess.bug(~"lookup_class_method_ids: id not bound to a class"); } } } @@ -2995,8 +2997,8 @@ fn ast_constr_to_constr<T>(tcx: ctxt, c: @ast::constr_general<T>) -> } _ { tcx.sess.span_fatal(c.span, - "predicate " + path_to_str(c.node.path) + - " is unbound or bound to a non-function or an \ + ~"predicate " + path_to_str(c.node.path) + + ~" is unbound or bound to a non-function or an \ impure function"); } } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 0daf663315b..1d86c47dddb 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -176,7 +176,7 @@ fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def { alt tcx.def_map.find(id) { some(x) { x } _ { - tcx.sess.span_fatal(sp, "internal error looking up a definition") + tcx.sess.span_fatal(sp, ~"internal error looking up a definition") } } } @@ -195,7 +195,7 @@ fn require_same_types( span: span, t1: ty::t, t2: ty::t, - msg: fn() -> str) -> bool { + msg: fn() -> ~str) -> bool { let l_tcx, l_infcx; alt maybe_infcx { @@ -212,7 +212,7 @@ fn require_same_types( alt infer::mk_eqty(l_infcx, t1, t2) { result::ok(()) { true } result::err(terr) { - l_tcx.sess.span_err(span, msg() + ": " + + l_tcx.sess.span_err(span, msg() + ~": " + ty::type_err_to_str(l_tcx, terr)); false } @@ -246,7 +246,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt, alt it.node { ast::item_fn(_,ps,_) if vec::is_not_empty(ps) { tcx.sess.span_err(main_span, - "main function is not allowed to have type parameters"); + ~"main function is not allowed to have type parameters"); ret; } _ {} @@ -269,8 +269,8 @@ fn check_main_fn_ty(ccx: @crate_ctxt, } _ { tcx.sess.span_bug(main_span, - "main has a non-function type: found `" + - ty_to_str(tcx, main_t) + "`"); + ~"main has a non-function type: found `" + + ty_to_str(tcx, main_t) + ~"`"); } } } @@ -280,7 +280,7 @@ fn check_for_main_fn(ccx: @crate_ctxt) { if !tcx.sess.building_library { alt copy tcx.sess.main_fn { some((id, sp)) { check_main_fn_ty(ccx, id, sp); } - none { tcx.sess.err("main function not found"); } + none { tcx.sess.err(~"main function not found"); } } } } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index c785e44b80a..7d09c57dc92 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -57,7 +57,7 @@ iface ast_conv { fn get_region_reporting_err(tcx: ty::ctxt, span: span, - res: result<ty::region, str>) -> ty::region { + res: result<ty::region, ~str>) -> ty::region { alt res { result::ok(r) { r } @@ -197,7 +197,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( if path.types.len() > 0u { tcx.sess.span_err( path.span, - "type parameters are not allowed on this type"); + ~"type parameters are not allowed on this type"); } } @@ -205,7 +205,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( if path.rp.is_some() { tcx.sess.span_err( path.span, - "region parameters are not allowed on this type"); + ~"region parameters are not allowed on this type"); } } } @@ -215,7 +215,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( alt tcx.ast_ty_to_ty_cache.find(ast_ty) { some(ty::atttce_resolved(ty)) { ret ty; } some(ty::atttce_unresolved) { - tcx.sess.span_fatal(ast_ty.span, "illegal recursive type; \ + tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ insert an enum in the cycle, \ if this is desired"); } @@ -289,7 +289,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( } ast::ty_str { check_path_args(tcx, path, NO_TPS); - // This is a bit of a hack, but basically str/& needs to be + // This is a bit of a hack, but basically &str needs to be // converted into a vstore: alt path.rp { none { @@ -317,7 +317,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( } _ { tcx.sess.span_fatal(ast_ty.span, - "found type name used as a variable"); + ~"found type name used as a variable"); } } } @@ -372,7 +372,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( ast::ty_vstore(_, ast::vstore_fixed(none)) { tcx.sess.span_bug( ast_ty.span, - "implied fixed length for bound"); + ~"implied fixed length for bound"); } /* ast::ty_vstore(_, _) { @@ -393,11 +393,11 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( // routine. self.tcx().sess.span_bug( ast_ty.span, - "found `ty_infer` in unexpected place"); + ~"found `ty_infer` in unexpected place"); } ast::ty_mac(_) { tcx.sess.span_bug(ast_ty.span, - "found `ty_mac` in unexpected place"); + ~"found `ty_mac` in unexpected place"); } }; diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 10b7ff78df7..fa43449f30e 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -384,8 +384,9 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { // Check that there's at least one field let (fields,_) = split_class_items(members); if fields.len() < 1u { - ccx.tcx.sess.span_err(it.span, "a class must have at least one \ - field"); + ccx.tcx.sess.span_err( + it.span, + ~"a class must have at least one field"); } // Check that the class is instantiable check_instantiable(ccx.tcx, it.span, it.id); @@ -429,14 +430,14 @@ impl of ast_conv for @fn_ctxt { } impl of region_scope for @fn_ctxt { - fn anon_region() -> result<ty::region, str> { + fn anon_region() -> result<ty::region, ~str> { result::ok(self.infcx.next_region_var()) } - fn named_region(id: ast::ident) -> result<ty::region, str> { + fn named_region(id: ast::ident) -> result<ty::region, ~str> { do empty_rscope.named_region(id).chain_err |_e| { alt self.in_scope_regions.find(ty::br_named(id)) { some(r) { result::ok(r) } - none if *id == "blk" { self.block_region() } + none if *id == ~"blk" { self.block_region() } none { result::err(#fmt["named region `%s` not in scope here", *id]) } @@ -446,11 +447,11 @@ impl of region_scope for @fn_ctxt { } impl methods for @fn_ctxt { - fn tag() -> str { #fmt["%x", ptr::addr_of(*self) as uint] } - fn block_region() -> result<ty::region, str> { + fn tag() -> ~str { #fmt["%x", ptr::addr_of(*self) as uint] } + fn block_region() -> result<ty::region, ~str> { alt vec::last_opt(self.blocks) { some(bid) { result::ok(ty::re_scope(bid)) } - none { result::err("no block is in scope here") } + none { result::err(~"no block is in scope here") } } } #[inline(always)] @@ -554,7 +555,7 @@ impl methods for @fn_ctxt { infer::mk_subr(self.infcx, sub, sup) } - fn require_unsafe(sp: span, op: str) { + fn require_unsafe(sp: span, op: ~str) { alt self.purity { ast::unsafe_fn {/*ok*/} _ { @@ -672,7 +673,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty { self_ty: none, tps: ty::ty_params_to_tys(tcx, ts)})} } - _ { tcx.sess.bug("impl_self_ty: unbound item or item that \ + _ { tcx.sess.bug(~"impl_self_ty: unbound item or item that \ doesn't have a self_ty"); } } } else { @@ -739,7 +740,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // I would like to make this span_err, but it's // really hard due to the way that expr_bind() is // written. - fcx.ccx.tcx.sess.span_fatal(sp, "mismatched types: \ + fcx.ccx.tcx.sess.span_fatal(sp, ~"mismatched types: \ expected function or foreign \ function but found " + fcx.infcx.ty_to_str(in_fty)); @@ -762,15 +763,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, sp, #fmt["this function takes %u parameter%s but %u \ parameter%s supplied", expected_arg_count, if expected_arg_count == 1u { - "" + ~"" } else { - "s" + ~"s" }, supplied_arg_count, if supplied_arg_count == 1u { - " was" + ~" was" } else { - "s were" + ~"s were" }]); fcx.infcx.next_ty_vars(supplied_arg_count) }; @@ -839,7 +840,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fcx.write_ty(call_expr_id, f.output); ret bot; } - _ { fcx.ccx.tcx.sess.span_fatal(sp, "calling non-function"); } + _ { fcx.ccx.tcx.sess.span_fatal(sp, ~"calling non-function"); } } } @@ -881,7 +882,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ret if_bot; } - fn binop_method(op: ast::binop) -> option<str> { + fn binop_method(op: ast::binop) -> option<~str> { alt op { ast::add | ast::subtract | ast::mul | ast::div | ast::rem | ast::bitxor | ast::bitand | ast::bitor | ast::shl | ast::shr @@ -891,7 +892,7 @@ 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: ~[@ast::expr]) + opname: ~str, args: ~[@ast::expr]) -> option<(ty::t, bool)> { let lkup = method::lookup(fcx, op_ex, self_ex, op_ex.id, op_ex.callee_id, @opname, self_t, ~[], false); @@ -975,10 +976,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, check_expr(fcx, rhs, none); tcx.sess.span_err( - ex.span, "binary operation " + ast_util::binop_to_str(op) + - " cannot be applied to type `" + + ex.span, ~"binary operation " + ast_util::binop_to_str(op) + + ~" cannot be applied to type `" + fcx.infcx.ty_to_str(lhs_resolved_t) + - "`"); + ~"`"); // If the or operator is used it might be that the user forgot to // supply the do keyword. Let's be more helpful in that situation. @@ -986,7 +987,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, alt ty::get(lhs_resolved_t).struct { ty::ty_fn(f) { tcx.sess.span_note( - ex.span, "did you forget the 'do' keyword for the call?"); + ex.span, ~"did you forget the 'do' keyword for the call?"); } _ {} } @@ -994,7 +995,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, (lhs_resolved_t, false) } - fn check_user_unop(fcx: @fn_ctxt, op_str: str, mname: str, + 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, ~[]) { @@ -1074,7 +1075,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, some(ix) { if n_tys > 0u { tcx.sess.span_err(expr.span, - "can't provide type parameters \ + ~"can't provide type parameters \ to a field access"); } fcx.write_ty(expr.id, fields[ix].mt.ty); @@ -1133,7 +1134,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, if !is_callee { tcx.sess.span_err( expr.span, - "attempted to take value of method \ + ~"attempted to take value of method \ (try writing an anonymous function)"); } } @@ -1170,7 +1171,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty::mk_evec(tcx, {ty: t, mutbl: mutbl}, tt) } _ { - tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence") + tcx.sess.span_bug(expr.span, ~"vstore modifier on non-sequence") } }; fcx.write_ty(ev.id, typ); @@ -1245,7 +1246,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty::ty_ptr(*) { fcx.require_unsafe( expr.span, - "dereference of unsafe pointer"); + ~"dereference of unsafe pointer"); } _ { /*ok*/ } } @@ -1257,7 +1258,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty::ty_enum(*) { tcx.sess.span_err( expr.span, - "can only dereference enums \ + ~"can only dereference enums \ with a single variant which has a \ single argument"); } @@ -1275,7 +1276,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); if !(ty::type_is_integral(oprnd_t) || ty::get(oprnd_t).struct == ty::ty_bool) { - oprnd_t = check_user_unop(fcx, "!", "!", expr, + oprnd_t = check_user_unop(fcx, ~"!", ~"!", expr, oprnd, oprnd_t); } } @@ -1283,7 +1284,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, oprnd_t = structurally_resolved_type(fcx, oprnd.span, oprnd_t); if !(ty::type_is_integral(oprnd_t) || ty::type_is_fp(oprnd_t)) { - oprnd_t = check_user_unop(fcx, "-", "unary-", expr, + oprnd_t = check_user_unop(fcx, ~"-", ~"unary-", expr, oprnd, oprnd_t); } } @@ -1305,7 +1306,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let tpt = ty_param_bounds_and_ty_for_def(fcx, expr.span, defn); instantiate_path(fcx, pth, tpt, expr.span, expr.id); } - ast::expr_mac(_) { tcx.sess.bug("unexpanded macro"); } + ast::expr_mac(_) { tcx.sess.bug(~"unexpanded macro"); } ast::expr_fail(expr_opt) { bot = true; alt expr_opt { @@ -1327,7 +1328,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, result::ok(_) { /* fall through */ } result::err(_) { tcx.sess.span_err(expr.span, - "`ret;` in function returning non-nil"); } + ~"`ret;` in function returning non-nil"); } } } some(e) { check_expr_with(fcx, e, ret_ty); } @@ -1417,7 +1418,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, (ty::mk_fn(tcx, {output: ty::mk_nil(tcx) with fty}), fty.proto) } _ { - tcx.sess.span_fatal(expr.span, "a `loop` function's last \ + tcx.sess.span_fatal(expr.span, ~"a `loop` function's last \ argument should be of function \ type"); } @@ -1445,7 +1446,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, (ty::mk_fn(tcx, fty), fty.proto) } _ { - tcx.sess.span_fatal(expr.span, "a `do` function's last argument \ + tcx.sess.span_fatal(expr.span, ~"a `do` function's last argument \ should be of function type"); } }; @@ -1491,12 +1492,12 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, _ { if ty::type_is_nil(t_e) { - tcx.sess.span_err(expr.span, "cast from nil: " + - fcx.infcx.ty_to_str(t_e) + " as " + + tcx.sess.span_err(expr.span, ~"cast from nil: " + + fcx.infcx.ty_to_str(t_e) + ~" as " + fcx.infcx.ty_to_str(t_1)); } else if ty::type_is_nil(t_1) { - tcx.sess.span_err(expr.span, "cast to nil: " + - fcx.infcx.ty_to_str(t_e) + " as " + + tcx.sess.span_err(expr.span, ~"cast to nil: " + + fcx.infcx.ty_to_str(t_e) + ~" as " + fcx.infcx.ty_to_str(t_1)); } @@ -1510,8 +1511,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, issue number in this comment. */ tcx.sess.span_err(expr.span, - "non-scalar cast: " + - fcx.infcx.ty_to_str(t_e) + " as " + + ~"non-scalar cast: " + + fcx.infcx.ty_to_str(t_e) + ~" as " + fcx.infcx.ty_to_str(t_1)); } } @@ -1568,7 +1569,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty::ty_rec(flds) { flds } _ { tcx.sess.span_fatal(expr.span, - "record update has non-record base"); + ~"record update has non-record base"); } }; fcx.write_ty(id, bexpr_t); @@ -1582,7 +1583,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } if !found { tcx.sess.span_fatal(f.span, - "unknown field in record update: " + + ~"unknown field in record update: " + *f.node.ident); } } @@ -1606,13 +1607,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, none { let resolved = structurally_resolved_type(fcx, expr.span, raw_base_t); - alt lookup_op_method(fcx, expr, base, resolved, "[]", + alt lookup_op_method(fcx, expr, base, resolved, ~"[]", ~[idx]) { some((ret_ty, _)) { fcx.write_ty(id, ret_ty); } _ { tcx.sess.span_fatal( - expr.span, "cannot index a value of type `" + - fcx.infcx.ty_to_str(base_t) + "`"); + expr.span, ~"cannot index a value of type `" + + fcx.infcx.ty_to_str(base_t) + ~"`"); } } } @@ -1625,7 +1626,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); @@ -1672,7 +1673,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty_to_str(tcx, fcx.expr_ty(expr)), alt expected { some(t) { ty_to_str(tcx, t) } - _ { "empty" } + _ { ~"empty" } }); unifier(); @@ -1683,9 +1684,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) { if !type_is_integral(fcx, sp, t) { - fcx.ccx.tcx.sess.span_err(sp, "mismatched types: expected \ + fcx.ccx.tcx.sess.span_err(sp, ~"mismatched types: expected \ integral type but found `" - + fcx.infcx.ty_to_str(t) + "`"); + + fcx.infcx.ty_to_str(t) + ~"`"); } } @@ -1774,7 +1775,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { } _ { false } } { - fcx.ccx.tcx.sess.span_warn(s.span, "unreachable statement"); + fcx.ccx.tcx.sess.span_warn(s.span, ~"unreachable statement"); warned = true; } bot |= check_stmt(fcx, s); @@ -1783,7 +1784,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { none { fcx.write_nil(blk.node.id); } some(e) { if bot && !warned { - fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression"); + fcx.ccx.tcx.sess.span_warn(e.span, ~"unreachable expression"); } bot |= check_expr(fcx, e, none); let ety = fcx.expr_ty(e); @@ -1846,7 +1847,7 @@ fn check_enum_variants(ccx: @crate_ctxt, } _ { ccx.tcx.sess.span_err(e.span, - "expected signed integer constant"); + ~"expected signed integer constant"); } } } @@ -1854,7 +1855,7 @@ fn check_enum_variants(ccx: @crate_ctxt, } if vec::contains(disr_vals, disr_val) { ccx.tcx.sess.span_err(v.span, - "discriminator value already exists"); + ~"discriminator value already exists"); } vec::push(disr_vals, disr_val); let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id); @@ -1881,7 +1882,7 @@ fn check_enum_variants(ccx: @crate_ctxt, _ { false } } }) { - ccx.tcx.sess.span_err(sp, "illegal recursive enum type; \ + ccx.tcx.sess.span_err(sp, ~"illegal recursive enum type; \ wrap the inner value in a box to \ make it representable"); } @@ -1902,7 +1903,7 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { if !ty::is_pred_ty(fcx.expr_ty(operator)) { fcx.ccx.tcx.sess.span_err (operator.span, - "operator in constraint has non-boolean return type"); + ~"operator in constraint has non-boolean return type"); } alt operator.node { @@ -1913,26 +1914,26 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { } _ { fcx.ccx.tcx.sess.span_err(operator.span, - "impure function as operator \ + ~"impure function as operator \ in constraint"); } } for operands.each |operand| { if !ast_util::is_constraint_arg(operand) { let s = - "constraint args must be slot variables or literals"; + ~"constraint args must be slot variables or literals"; fcx.ccx.tcx.sess.span_err(e.span, s); } } } _ { - let s = "in a constraint, expected the \ + let s = ~"in a constraint, expected the \ constraint name to be an explicit name"; fcx.ccx.tcx.sess.span_err(e.span, s); } } } - _ { fcx.ccx.tcx.sess.span_err(e.span, "check on non-predicate"); } + _ { fcx.ccx.tcx.sess.span_err(e.span, ~"check on non-predicate"); } } ret bot; } @@ -1957,7 +1958,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: ~[@ast::constr], @alt a.node { ast::carg_base { fcx.ccx.tcx.sess.span_bug(a.span, - "check_constraints:\ + ~"check_constraints:\ unexpected carg_base"); } ast::carg_lit(l) { @@ -1982,7 +1983,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: ~[@ast::constr], span: a.span} } else { fcx.ccx.tcx.sess.span_bug( - a.span, "check_constraints:\ + a.span, ~"check_constraints:\ carg_ident index out of bounds"); } } @@ -2018,7 +2019,7 @@ fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> tv_vid { some(x) { x } _ { fcx.ccx.tcx.sess.span_fatal(sp, - "internal error looking up a local var") + ~"internal error looking up a local var") } } } @@ -2048,7 +2049,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ret no_params(self_ty); } none { - fcx.ccx.tcx.sess.span_bug(sp, "def_self with no self_ty"); + fcx.ccx.tcx.sess.span_bug(sp, ~"def_self with no self_ty"); } } } @@ -2068,7 +2069,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ast::def_fn(id, ast::unsafe_fn) { // Unsafe functions can only be touched in an unsafe context - fcx.require_unsafe(sp, "access to unsafe function"); + fcx.require_unsafe(sp, ~"access to unsafe function"); ret ty::lookup_item_type(fcx.ccx.tcx, id); } @@ -2082,7 +2083,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ret no_params(typ); } ast::def_ty(_) | ast::def_prim_ty(_) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found type"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found type"); } ast::def_upvar(_, inner, _) { ret ty_param_bounds_and_ty_for_def(fcx, sp, *inner); @@ -2091,13 +2092,13 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ret no_params(ty::mk_param(fcx.ccx.tcx, n, did)); } ast::def_mod(*) | ast::def_foreign_mod(*) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found module"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found module"); } ast::def_use(*) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found use"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found use"); } ast::def_region(*) { - fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found region"); + fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found region"); } } } @@ -2117,7 +2118,7 @@ fn instantiate_path(fcx: @fn_ctxt, let self_r = alt pth.rp { some(r) if !tpt.rp => { fcx.ccx.tcx.sess.span_err - (sp, "this item is not region-parameterized"); + (sp, ~"this item is not region-parameterized"); none } some(r) => { @@ -2137,15 +2138,15 @@ fn instantiate_path(fcx: @fn_ctxt, fcx.infcx.next_ty_vars(ty_param_count) } else if ty_param_count == 0u { fcx.ccx.tcx.sess.span_err - (sp, "this item does not take type parameters"); + (sp, ~"this item does not take type parameters"); fcx.infcx.next_ty_vars(ty_param_count) } else if ty_substs_len > ty_param_count { fcx.ccx.tcx.sess.span_err - (sp, "too many type parameters provided for this item"); + (sp, ~"too many type parameters provided for this item"); fcx.infcx.next_ty_vars(ty_param_count) } else if ty_substs_len < ty_param_count { fcx.ccx.tcx.sess.span_err - (sp, "not enough type parameters provided for this item"); + (sp, ~"not enough type parameters provided for this item"); fcx.infcx.next_ty_vars(ty_param_count) } else { pth.types.map(|aty| fcx.to_ty(aty)) @@ -2163,7 +2164,7 @@ fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t { result::ok(t_s) if !ty::type_is_var(t_s) { ret t_s; } _ { fcx.ccx.tcx.sess.span_fatal - (sp, "the type of this value must be known in this context"); + (sp, ~"the type of this value must be known in this context"); } } } @@ -2253,45 +2254,45 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_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)) } - "init" { (1u, ~[], param(ccx, 0u)) } - "forget" { (1u, ~[arg(ast::by_move, param(ccx, 0u))], + ~"size_of" | + ~"pref_align_of" | ~"min_align_of" { (1u, ~[], ty::mk_uint(ccx.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" { + ~"move_val" | ~"move_val_init" { (1u, ~[arg(ast::by_mutbl_ref, 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)) } - "atomic_xchng" | "atomic_add" | "atomic_sub" | - "atomic_xchng_acq" | "atomic_add_acq" | "atomic_sub_acq" | - "atomic_xchng_rel" | "atomic_add_rel" | "atomic_sub_rel" { + ~"atomic_xchng" | ~"atomic_add" | ~"atomic_sub" | + ~"atomic_xchng_acq" | ~"atomic_add_acq" | ~"atomic_sub_acq" | + ~"atomic_xchng_rel" | ~"atomic_add_rel" | ~"atomic_sub_rel" { (0u, ~[arg(ast::by_mutbl_ref, ty::mk_int(tcx)), arg(ast::by_val, ty::mk_int(tcx))], ty::mk_int(tcx)) } - "get_tydesc" { + ~"get_tydesc" { // FIXME (#2712): return *intrinsic::tydesc, not *() (1u, ~[], ty::mk_nil_ptr(tcx)) } - "visit_tydesc" { - assert ccx.tcx.intrinsic_defs.contains_key(@"tydesc"/~); - assert ccx.tcx.intrinsic_defs.contains_key(@"ty_visitor"/~); - let (_, tydesc_ty) = ccx.tcx.intrinsic_defs.get(@"tydesc"/~); - let (_, visitor_trait) = ccx.tcx.intrinsic_defs.get(@"ty_visitor"/~); + ~"visit_tydesc" { + assert ccx.tcx.intrinsic_defs.contains_key(@~"tydesc"); + assert ccx.tcx.intrinsic_defs.contains_key(@~"ty_visitor"); + let (_, tydesc_ty) = ccx.tcx.intrinsic_defs.get(@~"tydesc"); + let (_, visitor_trait) = ccx.tcx.intrinsic_defs.get(@~"ty_visitor"); let td_ptr = ty::mk_ptr(ccx.tcx, {ty: tydesc_ty, mutbl: ast::m_imm}); (0u, ~[arg(ast::by_val, td_ptr), arg(ast::by_ref, visitor_trait)], ty::mk_nil(tcx)) } - "frame_address" { + ~"frame_address" { let fty = ty::mk_fn(ccx.tcx, { purity: ast::impure_fn, proto: ast::proto_any, @@ -2308,8 +2309,8 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { (0u, ~[arg(ast::by_ref, fty)], ty::mk_nil(tcx)) } other { - tcx.sess.span_err(it.span, "unrecognized intrinsic function: `" + - other + "`"); + tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" + + other + ~"`"); ret; } }; diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index e45c5f308ea..158d19bb6e2 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -90,9 +90,9 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, let s = #fmt["this pattern has %u field%s, but the \ corresponding variant has %u field%s", subpats_len, - if subpats_len == 1u { "" } else { "s" }, + if subpats_len == 1u { ~"" } else { ~"s" }, arg_len, - if arg_len == 1u { "" } else { "s" }]; + if arg_len == 1u { ~"" } else { ~"s" }]; tcx.sess.span_fatal(pat.span, s); } @@ -106,8 +106,8 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, (pat.span, #fmt["this pattern has %u field%s, \ but the corresponding variant has no fields", subpats_len, - if subpats_len == 1u { "" } - else { "s" }]); + if subpats_len == 1u { ~"" } + else { ~"s" }]); } } _ { @@ -143,12 +143,12 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { #debug["pat_range ending type: %?", e_ty]; if !require_same_types( tcx, some(fcx.infcx), pat.span, b_ty, e_ty, - || "mismatched types in range") { + || ~"mismatched types in range") { // no-op } else if !ty::type_is_numeric(b_ty) { - tcx.sess.span_err(pat.span, "non-numeric type used in range"); + tcx.sess.span_err(pat.span, ~"non-numeric type used in range"); } else if !valid_range_bounds(fcx.ccx, begin, end) { - tcx.sess.span_err(begin.span, "lower range bound must be less \ + tcx.sess.span_err(begin.span, ~"lower range bound must be less \ than upper"); } fcx.write_ty(pat.id, b_ty); @@ -246,9 +246,9 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { _ { tcx.sess.span_fatal( pat.span, - "mismatched types: expected `" + + ~"mismatched types: expected `" + fcx.infcx.ty_to_str(expected) + - "` found box"); + ~"` found box"); } } } @@ -261,9 +261,9 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { _ { tcx.sess.span_fatal( pat.span, - "mismatched types: expected `" + + ~"mismatched types: expected `" + fcx.infcx.ty_to_str(expected) + - "` found uniq"); + ~"` found uniq"); } } } diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index c3829f60c40..2dc80593e02 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -107,7 +107,7 @@ class lookup { if self.candidates.len() > 1u { self.tcx().sess.span_err( self.expr.span, - "multiple applicable methods in scope"); + ~"multiple applicable methods in scope"); for self.candidates.eachi |i, candidate| { alt candidate.entry.origin { @@ -222,14 +222,14 @@ class lookup { if ty::type_has_self(m_fty) { self.tcx().sess.span_err( self.expr.span, - "can not call a method that contains a \ + ~"can not call a method that contains a \ self type through a boxed iface"); } if (*m.tps).len() > 0u { self.tcx().sess.span_err( self.expr.span, - "can not call a generic method through a \ + ~"can not call a generic method through a \ boxed trait"); } @@ -256,7 +256,7 @@ class lookup { if m.vis == ast::private && !self.include_private { self.tcx().sess.span_fatal( self.expr.span, - "Call to private method not allowed outside \ + ~"Call to private method not allowed outside \ its defining class"); } @@ -399,12 +399,12 @@ class lookup { } else if n_tps_m == 0u { tcx.sess.span_err( self.expr.span, - "this method does not take type parameters"); + ~"this method does not take type parameters"); self.fcx.infcx.next_ty_vars(n_tps_m) } else if n_tps_supplied != n_tps_m { tcx.sess.span_err( self.expr.span, - "incorrect number of type \ + ~"incorrect number of type \ parameters given for this method"); self.fcx.infcx.next_ty_vars(n_tps_m) } else { diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index d5401e3a4e7..a883946252c 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -96,11 +96,11 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, for vec::each(*ty::trait_methods(tcx, did)) |m| { if ty::type_has_self(ty::mk_fn(tcx, m.fty)) { tcx.sess.span_err( - sp, "a boxed iface with self types may not be \ + sp, ~"a boxed iface with self types may not be \ passed as a bounded type"); } else if (*m.tps).len() > 0u { tcx.sess.span_err( - sp, "a boxed iface with generic methods may not \ + sp, ~"a boxed iface with generic methods may not \ be passed as a bounded type"); } @@ -162,7 +162,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, 1u { ret found[0]; } _ { fcx.ccx.tcx.sess.span_err( - sp, "multiple applicable methods in scope"); + sp, ~"multiple applicable methods in scope"); ret found[0]; } } @@ -171,8 +171,8 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, } tcx.sess.span_fatal( - sp, "failed to find an implementation of interface " + - ty_to_str(tcx, trait_ty) + " for " + + sp, ~"failed to find an implementation of interface " + + ty_to_str(tcx, trait_ty) + ~" for " + ty_to_str(tcx, ty)); } diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index 4773788593a..d563a4a9916 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -106,7 +106,7 @@ class CoherenceChecker { none { let session = self.crate_context.tcx.sess; session.span_warn(item.span, - "no base type found for inherent \ + ~"no base type found for inherent \ implementation; implement a trait \ instead"); } @@ -194,8 +194,8 @@ class CoherenceChecker { ret some(def_id); } _ { - fail "get_base_type() returned a type that wasn't an \ - enum, class, or trait"; + fail ~"get_base_type() returned a type that \ + wasn't an enum, class, or trait"; } } } @@ -217,10 +217,11 @@ class CoherenceChecker { if self.polytypes_unify(polytype_a, polytype_b) { let session = self.crate_context.tcx.sess; session.span_err(implementation_b.span, - "conflicting implementations for a \ + ~"conflicting implementations for a \ trait"); - session.span_note(implementation_a.span, - "note conflicting implementation here"); + session.span_note( + implementation_a.span, + ~"note conflicting implementation here"); } } } @@ -265,8 +266,9 @@ class CoherenceChecker { ret self.crate_context.tcx.tcache.get(def); } _ { - self.crate_context.tcx.sess.span_bug(implementation.span, - "not an implementation"); + self.crate_context.tcx.sess.span_bug( + implementation.span, + ~"not an implementation"); } } } @@ -328,7 +330,7 @@ class CoherenceChecker { let session = self.crate_context.tcx.sess; session.span_warn(item.span, - "cannot \ + ~"cannot \ implement \ inherent \ methods for a \ @@ -356,7 +358,7 @@ class CoherenceChecker { let session = self .crate_context.tcx.sess; session.span_warn(item.span, - "cannot \ + ~"cannot \ provide \ an \ extension \ diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 5d3842e6085..4004d301646 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -29,7 +29,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { // There ought to be a better approach. Attributes? for crate.node.module.items.each |crate_item| { - if *crate_item.ident == "intrinsic" { + if *crate_item.ident == ~"intrinsic" { alt crate_item.node { ast::item_mod(m) { for m.items.each |intrinsic_item| { @@ -99,7 +99,7 @@ impl of ast_conv for @crate_ctxt { fn ty_infer(span: span) -> ty::t { self.tcx.sess.span_bug(span, - "found `ty_infer` in unexpected place"); + ~"found `ty_infer` in unexpected place"); } } @@ -187,8 +187,8 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, self_ty: ty::t) { if impl_m.tps != if_m.tps { - tcx.sess.span_err(sp, "method `" + *if_m.ident + - "` has an incompatible set of type parameters"); + tcx.sess.span_err(sp, ~"method `" + *if_m.ident + + ~"` has an incompatible set of type parameters"); ret; } @@ -228,7 +228,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, }; require_same_types( tcx, none, sp, impl_fty, if_fty, - || "method `" + *if_m.ident + "` has an incompatible type"); + || ~"method `" + *if_m.ident + ~"` has an incompatible type"); ret; // Replaces bound references to the self region with `with_r`. @@ -449,7 +449,7 @@ fn ty_of_ty_method(self: @crate_ctxt, fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: bool) -> (ast::def_id, ty_param_substs_and_ty) { - let sp = t.path.span, err = "can only implement interface types", + let sp = t.path.span, err = ~"can only implement interface types", sess = ccx.tcx.sess; let rscope = type_rscope(rp); @@ -548,7 +548,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) } ast::item_impl(*) | ast::item_mod(_) | ast::item_foreign_mod(_) { fail; } - ast::item_mac(*) { fail "item macros unimplemented" } + ast::item_mac(*) { fail ~"item macros unimplemented" } } } @@ -579,7 +579,7 @@ fn ty_param_bounds(ccx: @crate_ctxt, } _ { ccx.tcx.sess.span_err( - t.span, "type parameter bounds must be \ + t.span, ~"type parameter bounds must be \ interface types"); ~[] } diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index ab72c5637ff..da28e657758 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -257,7 +257,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) ast::ty_i64 { int_ty_set(INT_TY_SET_i64) } ast::ty_i { int_ty_set(INT_TY_SET_i) } ast::ty_char { tcx.sess.bug( - "char type passed to convert_integral_ty_to_int_ty_set()"); } + ~"char type passed to convert_integral_ty_to_int_ty_set()"); } } } ty_uint(uint_ty) { @@ -269,7 +269,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) ast::ty_u { int_ty_set(INT_TY_SET_u) } } } - _ { tcx.sess.bug("non-integral type passed to \ + _ { tcx.sess.bug(~"non-integral type passed to \ convert_integral_ty_to_int_ty_set()"); } } } @@ -331,13 +331,13 @@ enum fixup_err { cyclic_region(region_vid) } -fn fixup_err_to_str(f: fixup_err) -> str { +fn fixup_err_to_str(f: fixup_err) -> ~str { alt f { - unresolved_int_ty(_) { "unconstrained integral type" } - unresolved_ty(_) { "unconstrained type" } - cyclic_ty(_) { "cyclic type of infinite size" } - unresolved_region(_) { "unconstrained region" } - cyclic_region(_) { "cyclic region" } + unresolved_int_ty(_) { ~"unconstrained integral type" } + unresolved_ty(_) { ~"unconstrained type" } + cyclic_ty(_) { ~"cyclic type of infinite size" } + unresolved_region(_) { ~"unconstrained region" } + cyclic_region(_) { ~"cyclic region" } } } @@ -442,38 +442,38 @@ impl methods<T:copy> for cres<T> { } iface to_str { - fn to_str(cx: infer_ctxt) -> str; + fn to_str(cx: infer_ctxt) -> ~str; } impl of to_str for ty::t { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { ty_to_str(cx.tcx, self) } } impl of to_str for ty::mt { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { mt_to_str(cx.tcx, self) } } impl of to_str for ty::region { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { util::ppaux::region_to_str(cx.tcx, self) } } impl<V:copy to_str> of to_str for bound<V> { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { alt self { some(v) { v.to_str(cx) } - none { "none" } + none { ~"none" } } } } impl<T:copy to_str> of to_str for bounds<T> { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { #fmt["{%s <: %s}", self.lb.to_str(cx), self.ub.to_str(cx)] @@ -481,7 +481,7 @@ impl<T:copy to_str> of to_str for bounds<T> { } impl of to_str for int_ty_set { - fn to_str(_cx: infer_ctxt) -> str { + fn to_str(_cx: infer_ctxt) -> ~str { alt self { int_ty_set(v) { uint::to_str(v, 10u) } } @@ -489,7 +489,7 @@ impl of to_str for int_ty_set { } impl<V:copy vid, T:copy to_str> of to_str for var_value<V,T> { - fn to_str(cx: infer_ctxt) -> str { + fn to_str(cx: infer_ctxt) -> ~str { alt self { redirect(vid) { #fmt("redirect(%s)", vid.to_str()) } root(pt, rk) { #fmt("root(%s, %s)", pt.to_str(cx), @@ -633,7 +633,7 @@ impl methods for infer_ctxt { ty::re_var(self.next_region_var_id()) } - fn ty_to_str(t: ty::t) -> str { + fn ty_to_str(t: ty::t) -> ~str { ty_to_str(self.tcx, self.resolve_type_vars_if_possible(t)) } @@ -1523,7 +1523,7 @@ type cres<T> = result<T,ty::type_err>; iface combine { fn infcx() -> infer_ctxt; - fn tag() -> str; + fn tag() -> ~str; fn mts(a: ty::mt, b: ty::mt) -> cres<ty::mt>; fn contratys(a: ty::t, b: ty::t) -> cres<ty::t>; @@ -1880,7 +1880,7 @@ fn super_tys<C:combine>( impl of combine for sub { fn infcx() -> infer_ctxt { *self } - fn tag() -> str { "sub" } + fn tag() -> ~str { ~"sub" } fn lub() -> lub { lub(*self) } @@ -2059,7 +2059,7 @@ impl of combine for sub { impl of combine for lub { fn infcx() -> infer_ctxt { *self } - fn tag() -> str { "lub" } + fn tag() -> ~str { ~"lub" } fn bot_ty(b: ty::t) -> cres<ty::t> { ok(b) } fn ty_bot(b: ty::t) -> cres<ty::t> { self.bot_ty(b) } // commutative @@ -2243,7 +2243,7 @@ impl of combine for lub { impl of combine for glb { fn infcx() -> infer_ctxt { *self } - fn tag() -> str { "glb" } + fn tag() -> ~str { ~"glb" } fn mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> { let tcx = self.infcx().tcx; diff --git a/src/rustc/middle/typeck/rscope.rs b/src/rustc/middle/typeck/rscope.rs index ec0dbe7ea8e..759ec5496b1 100644 --- a/src/rustc/middle/typeck/rscope.rs +++ b/src/rustc/middle/typeck/rscope.rs @@ -1,36 +1,36 @@ import result::result; iface region_scope { - fn anon_region() -> result<ty::region, str>; - fn named_region(id: ast::ident) -> result<ty::region, str>; + fn anon_region() -> result<ty::region, ~str>; + fn named_region(id: ast::ident) -> result<ty::region, ~str>; } enum empty_rscope { empty_rscope } impl of region_scope for empty_rscope { - fn anon_region() -> result<ty::region, str> { - result::err("region types are not allowed here") + fn anon_region() -> result<ty::region, ~str> { + result::err(~"region types are not allowed here") } - fn named_region(id: ast::ident) -> result<ty::region, str> { - if *id == "static" { result::ok(ty::re_static) } - else { result::err("only the static region is allowed here") } + fn named_region(id: ast::ident) -> result<ty::region, ~str> { + if *id == ~"static" { result::ok(ty::re_static) } + else { result::err(~"only the static region is allowed here") } } } enum type_rscope = bool; impl of region_scope for type_rscope { - fn anon_region() -> result<ty::region, str> { + fn anon_region() -> result<ty::region, ~str> { if *self { result::ok(ty::re_bound(ty::br_self)) } else { - result::err("to use region types here, the containing type \ + result::err(~"to use region types here, the containing type \ must be declared with a region bound") } } - fn named_region(id: ast::ident) -> result<ty::region, str> { + fn named_region(id: ast::ident) -> result<ty::region, ~str> { do empty_rscope.named_region(id).chain_err |_e| { - if *id == "self" { self.anon_region() } + if *id == ~"self" { self.anon_region() } else { - result::err("named regions other than `self` are not \ + result::err(~"named regions other than `self` are not \ allowed as part of a type declaration") } } @@ -43,10 +43,10 @@ fn in_anon_rscope<RS: region_scope copy>(self: RS, r: ty::region) @anon_rscope({anon: r, base: self as region_scope}) } impl of region_scope for @anon_rscope { - fn anon_region() -> result<ty::region, str> { + fn anon_region() -> result<ty::region, ~str> { result::ok(self.anon) } - fn named_region(id: ast::ident) -> result<ty::region, str> { + fn named_region(id: ast::ident) -> result<ty::region, ~str> { self.base.named_region(id) } } @@ -57,10 +57,10 @@ fn in_binding_rscope<RS: region_scope copy>(self: RS) -> @binding_rscope { @binding_rscope({base: base}) } impl of region_scope for @binding_rscope { - fn anon_region() -> result<ty::region, str> { + fn anon_region() -> result<ty::region, ~str> { result::ok(ty::re_bound(ty::br_anon)) } - fn named_region(id: ast::ident) -> result<ty::region, str> { + fn named_region(id: ast::ident) -> result<ty::region, ~str> { do self.base.named_region(id).chain_err |_e| { result::ok(ty::re_bound(ty::br_named(id))) } diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 90ff2fd3228..011b482f577 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -25,7 +25,7 @@ fn indenter() -> _indenter { _indenter(()) } -type flag = hashmap<str, ()>; +type flag = hashmap<~str, ()>; fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; } @@ -74,7 +74,7 @@ fn local_rhs_span(l: @ast::local, def: span) -> span { fn is_main_name(path: syntax::ast_map::path) -> bool { // FIXME (#34): path should be a constrained type, so we know // the call to last doesn't fail. - vec::last(path) == syntax::ast_map::path_name(@"main"/~) + vec::last(path) == syntax::ast_map::path_name(@~"main") } // diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 01593ecea2c..5d62bc31450 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -18,16 +18,16 @@ import syntax::{ast, ast_util}; import syntax::ast_map; import driver::session::session; -fn bound_region_to_str(cx: ctxt, br: bound_region) -> str { +fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { alt br { - br_anon { "&" } + br_anon { ~"&" } br_named(str) { #fmt["&%s", *str] } - br_self if cx.sess.ppregions() { "&<self>" } - br_self { "&self" } + br_self if cx.sess.ppregions() { ~"&<self>" } + br_self { ~"&self" } } } -fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> str { +fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { alt cx.items.find(node_id) { some(ast_map::node_block(blk)) { #fmt("<block at %s>", @@ -62,7 +62,7 @@ fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> str { } } -fn region_to_str(cx: ctxt, region: region) -> str { +fn region_to_str(cx: ctxt, region: region) -> ~str { alt region { re_scope(node_id) { #fmt["&%s", re_scope_id_to_str(cx, node_id)] } re_bound(br) { bound_region_to_str(cx, br) } @@ -78,29 +78,29 @@ fn region_to_str(cx: ctxt, region: region) -> str { // These two should not be seen by end-users (very often, anyhow): re_var(id) { #fmt("&%s", id.to_str()) } - re_static { "&static" } + re_static { ~"&static" } } } -fn mt_to_str(cx: ctxt, m: mt) -> str { +fn mt_to_str(cx: ctxt, m: mt) -> ~str { let mstr = alt m.mutbl { - ast::m_mutbl { "mut " } - ast::m_imm { "" } - ast::m_const { "const " } + ast::m_mutbl { ~"mut " } + ast::m_imm { ~"" } + ast::m_const { ~"const " } }; ret mstr + ty_to_str(cx, m.ty); } -fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> str { +fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { alt vs { ty::vstore_fixed(n) { #fmt["%u", n] } - ty::vstore_uniq { "~" } - ty::vstore_box { "@" } + ty::vstore_uniq { ~"~" } + ty::vstore_box { ~"@" } ty::vstore_slice(r) { region_to_str(cx, r) } } } -fn vstore_ty_to_str(cx: ctxt, ty: str, vs: ty::vstore) -> str { +fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str { alt vs { ty::vstore_fixed(_) { #fmt["%s/%s", ty, vstore_to_str(cx, vs)] @@ -109,22 +109,22 @@ fn vstore_ty_to_str(cx: ctxt, ty: str, vs: ty::vstore) -> str { } } -fn tys_to_str(cx: ctxt, ts: ~[t]) -> str { - let mut rs = ""; +fn tys_to_str(cx: ctxt, ts: ~[t]) -> ~str { + let mut rs = ~""; for ts.each |t| { rs += ty_to_str(cx, t); } rs } -fn ty_to_str(cx: ctxt, typ: t) -> str { +fn ty_to_str(cx: ctxt, typ: t) -> ~str { fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) -> - str { + ~str { let {mode, ty} = input; let modestr = alt canon_mode(cx, mode) { - ast::infer(_) { "" } + ast::infer(_) { ~"" } ast::expl(m) { if !ty::type_needs_infer(ty) && m == ty::default_arg_mode_for_ty(ty) { - "" + ~"" } else { mode_to_str(ast::expl(m)) } @@ -135,37 +135,37 @@ 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 { + constrs: ~[@constr]) -> ~str { let mut s; s = alt purity { - ast::impure_fn {""} - _ {purity_to_str(purity) + " "} + ast::impure_fn {~""} + _ {purity_to_str(purity) + ~" "} }; s += proto_to_str(proto); - alt ident { some(i) { s += " "; s += *i; } _ { } } - s += "("; + alt ident { some(i) { s += ~" "; s += *i; } _ { } } + s += ~"("; let mut strs = ~[]; for inputs.each |a| { vec::push(strs, fn_input_to_str(cx, a)); } - s += str::connect(strs, ", "); - s += ")"; + s += str::connect(strs, ~", "); + s += ~")"; if ty::get(output).struct != ty_nil { - s += " -> "; + s += ~" -> "; alt cf { - ast::noreturn { s += "!"; } + ast::noreturn { s += ~"!"; } ast::return_val { s += ty_to_str(cx, output); } } } s += constrs_str(constrs); ret s; } - fn method_to_str(cx: ctxt, m: method) -> str { + fn method_to_str(cx: ctxt, m: method) -> ~str { ret fn_to_str( cx, m.fty.purity, m.fty.proto, some(m.ident), m.fty.inputs, - m.fty.output, m.fty.ret_style, m.fty.constraints) + ";"; + m.fty.output, m.fty.ret_style, m.fty.constraints) + ~";"; } - fn field_to_str(cx: ctxt, f: field) -> str { - ret *f.ident + ": " + mt_to_str(cx, f.mt); + fn field_to_str(cx: ctxt, f: field) -> ~str { + ret *f.ident + ~": " + mt_to_str(cx, f.mt); } // if there is an id, print that instead of the structural type: @@ -176,40 +176,40 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { // pretty print the structural type representation: ret alt ty::get(typ).struct { - ty_nil { "()" } - ty_bot { "_|_" } - ty_bool { "bool" } - ty_int(ast::ty_i) { "int" } - ty_int(ast::ty_char) { "char" } + ty_nil { ~"()" } + ty_bot { ~"_|_" } + ty_bool { ~"bool" } + ty_int(ast::ty_i) { ~"int" } + ty_int(ast::ty_char) { ~"char" } ty_int(t) { ast_util::int_ty_to_str(t) } - ty_uint(ast::ty_u) { "uint" } + ty_uint(ast::ty_u) { ~"uint" } ty_uint(t) { ast_util::uint_ty_to_str(t) } - ty_float(ast::ty_f) { "float" } + ty_float(ast::ty_f) { ~"float" } ty_float(t) { ast_util::float_ty_to_str(t) } - ty_str { "str" } - ty_box(tm) { "@" + mt_to_str(cx, tm) } - ty_uniq(tm) { "~" + mt_to_str(cx, tm) } - ty_ptr(tm) { "*" + mt_to_str(cx, tm) } + ty_str { ~"str" } + ty_box(tm) { ~"@" + mt_to_str(cx, tm) } + ty_uniq(tm) { ~"~" + mt_to_str(cx, tm) } + ty_ptr(tm) { ~"*" + mt_to_str(cx, tm) } ty_rptr(r, tm) { let rs = region_to_str(cx, r); - if rs == "&" { + if rs == ~"&" { rs + mt_to_str(cx, tm) } else { - rs + "/" + mt_to_str(cx, tm) + rs + ~"/" + mt_to_str(cx, tm) } } - ty_vec(tm) { "[" + mt_to_str(cx, tm) + "]" } - ty_unboxed_vec(tm) { "unboxed_vec<" + mt_to_str(cx, tm) + ">" } - ty_type { "type" } + ty_vec(tm) { ~"[" + mt_to_str(cx, tm) + ~"]" } + ty_unboxed_vec(tm) { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } + ty_type { ~"type" } ty_rec(elems) { - let mut strs: ~[str] = ~[]; + let mut strs: ~[~str] = ~[]; for elems.each |fld| { vec::push(strs, field_to_str(cx, fld)); } - "{" + str::connect(strs, ",") + "}" + ~"{" + str::connect(strs, ~",") + ~"}" } ty_tup(elems) { let mut strs = ~[]; for elems.each |elem| { vec::push(strs, ty_to_str(cx, elem)); } - "(" + str::connect(strs, ",") + ")" + ~"(" + str::connect(strs, ~",") + ~")" } ty_fn(f) { fn_to_str(cx, f.purity, f.proto, none, f.inputs, @@ -218,9 +218,9 @@ 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_self { ~"self" } ty_enum(did, substs) | ty_class(did, substs) { let path = ty::item_path(cx, did); let base = ast_map::path_to_str(path); @@ -234,22 +234,22 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { ty_evec(mt, vs) { vstore_ty_to_str(cx, #fmt["[%s]", mt_to_str(cx, mt)], vs) } - ty_estr(vs) { vstore_ty_to_str(cx, "str", vs) } - ty_opaque_box { "@?" } - ty_constr(t, _) { "@?" } - ty_opaque_closure_ptr(ck_block) { "closure&" } - ty_opaque_closure_ptr(ck_box) { "closure@" } - ty_opaque_closure_ptr(ck_uniq) { "closure~" } + ty_estr(vs) { vstore_ty_to_str(cx, ~"str", vs) } + ty_opaque_box { ~"@?" } + ty_constr(t, _) { ~"@?" } + ty_opaque_closure_ptr(ck_block) { ~"closure&" } + ty_opaque_closure_ptr(ck_box) { ~"closure@" } + ty_opaque_closure_ptr(ck_uniq) { ~"closure~" } } } fn parameterized(cx: ctxt, - base: str, + base: ~str, self_r: option<ty::region>, - tps: ~[ty::t]) -> str { + tps: ~[ty::t]) -> ~str { let r_str = alt self_r { - none { "" } + none { ~"" } some(r) { #fmt["/%s", region_to_str(cx, r)] } @@ -257,35 +257,35 @@ fn parameterized(cx: ctxt, if vec::len(tps) > 0u { let strs = vec::map(tps, |t| ty_to_str(cx, t) ); - #fmt["%s%s<%s>", base, r_str, str::connect(strs, ",")] + #fmt["%s%s<%s>", base, r_str, str::connect(strs, ~",")] } else { #fmt["%s%s", base, r_str] } } -fn ty_to_short_str(cx: ctxt, typ: t) -> str { +fn ty_to_short_str(cx: ctxt, typ: t) -> ~str { let mut s = encoder::encoded_ty(cx, typ); if str::len(s) >= 32u { s = str::slice(s, 0u, 32u); } ret s; } -fn constr_to_str(c: @constr) -> str { +fn constr_to_str(c: @constr) -> ~str { ret path_to_str(c.node.path) + pprust::constr_args_to_str(pprust::uint_to_str, c.node.args); } -fn constrs_str(constrs: ~[@constr]) -> str { - let mut s = ""; +fn constrs_str(constrs: ~[@constr]) -> ~str { + let mut s = ~""; let mut colon = true; for constrs.each |c| { - if colon { s += " : "; colon = false; } else { s += ", "; } + if colon { s += ~" : "; colon = false; } else { s += ~", "; } s += constr_to_str(c); } ret s; } fn ty_constr_to_str<Q>(c: @ast::spanned<ast::constr_general_<@ast::path, Q>>) - -> str { + -> ~str { ret path_to_str(c.node.path) + constr_args_to_str::<@ast::path>(path_to_str, c.node.args); } |
