diff options
| author | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-30 16:01:07 -0700 |
|---|---|---|
| committer | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-30 18:38:15 -0700 |
| commit | a9cc5066ee61f20e7cc59141d5c7213a452a2778 (patch) | |
| tree | e65d0e9b5a3d3abf723d596a32785b5655505af1 /src/rustc | |
| parent | 650fb06d68771828406f4f27e3af5db9c11311c5 (diff) | |
| download | rust-a9cc5066ee61f20e7cc59141d5c7213a452a2778.tar.gz rust-a9cc5066ee61f20e7cc59141d5c7213a452a2778.zip | |
Change syntax extension syntax: `#m[...]` -> `m!{...}`.
Diffstat (limited to 'src/rustc')
63 files changed, 1142 insertions, 1142 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 022b2183ec7..fede7d55af9 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -343,7 +343,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, metas: provided_metas, dep_hashes: ~[@~str]) -> ~str { fn len_and_str(s: ~str) -> ~str { - ret #fmt["%u_%s", str::len(s), s]; + ret fmt!{"%u_%s", str::len(s), s}; } fn len_and_str_lit(l: ast::lit) -> ~str { @@ -379,8 +379,8 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~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]); + sess.warn(fmt!{"missing crate link meta `%s`, using `%s` as default", + name, default}); } fn crate_meta_name(sess: session, _crate: ast::crate, @@ -393,8 +393,8 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, let mut os = str::split_char(path::basename(output), '.'); if (vec::len(os) < 2u) { - sess.fatal(#fmt("output file name `%s` doesn't\ - appear to have an extension", output)); + sess.fatal(fmt!{"output file name `%s` doesn't\ + appear to have an extension", output}); } vec::pop(os); str::connect(os, ~".") @@ -505,7 +505,7 @@ fn mangle(ss: path) -> ~str { for ss.each |s| { alt s { path_name(s) | path_mod(s) { let sani = sanitize(*s); - n += #fmt["%u%s", str::len(sani), sani]; + n += fmt!{"%u%s", str::len(sani), sani}; } } } n += ~"E"; // End name-sequence. @@ -576,12 +576,12 @@ fn link_binary(sess: session, let output = if sess.building_library { let long_libname = - os::dll_filename(#fmt("%s-%s-%s", - *lm.name, lm.extras_hash, *lm.vers)); - #debug("link_meta.name: %s", *lm.name); - #debug("long_libname: %s", long_libname); - #debug("out_filename: %s", out_filename); - #debug("dirname(out_filename): %s", path::dirname(out_filename)); + os::dll_filename(fmt!{"%s-%s-%s", + *lm.name, lm.extras_hash, *lm.vers}); + debug!{"link_meta.name: %s", *lm.name}; + debug!{"long_libname: %s", long_libname}; + debug!{"out_filename: %s", out_filename}; + debug!{"dirname(out_filename): %s", path::dirname(out_filename)}; path::connect(path::dirname(out_filename), long_libname) } else { out_filename }; @@ -698,14 +698,14 @@ fn link_binary(sess: session, // 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, ~" ")]); + 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, ~" ")}); sess.note(prog.err + prog.out); sess.abort_if_errors(); } @@ -718,8 +718,8 @@ fn link_binary(sess: session, // Remove the temporary object file if we aren't saving temps if !sess.opts.save_temps { if ! os::remove_file(obj_filename) { - sess.warn(#fmt["failed to delete object file `%s`", - obj_filename]); + sess.warn(fmt!{"failed to delete object file `%s`", + obj_filename}); } } } diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index bc49898bc1f..4f85fb48f2a 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -21,7 +21,7 @@ fn get_rpath_flags(sess: session::session, out_filename: ~str) -> ~[~str] { ret ~[]; } - #debug("preparing the RPATH!"); + debug!{"preparing the RPATH!"}; let cwd = os::getcwd(); let sysroot = sess.filesearch.sysroot(); @@ -45,20 +45,20 @@ fn get_sysroot_absolute_rt_lib(sess: session::session) -> path::path { } fn rpaths_to_flags(rpaths: ~[~str]) -> ~[~str] { - vec::map(rpaths, |rpath| #fmt("-Wl,-rpath,%s",rpath) ) + 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] { - #debug("cwd: %s", cwd); - #debug("sysroot: %s", sysroot); - #debug("output: %s", output); - #debug("libs:"); + debug!{"cwd: %s", cwd}; + debug!{"sysroot: %s", sysroot}; + debug!{"output: %s", output}; + debug!{"libs:"}; for libs.each |libpath| { - #debug(" %s", libpath); + debug!{" %s", libpath}; } - #debug("target_triple: %s", target_triple); + debug!{"target_triple: %s", target_triple}; // Use relative paths to the libraries. Binaries can be moved // as long as they maintain the relative relationship to the @@ -73,9 +73,9 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, let fallback_rpaths = ~[get_install_prefix_rpath(cwd, target_triple)]; fn log_rpaths(desc: ~str, rpaths: ~[~str]) { - #debug("%s rpaths:", desc); + debug!{"%s rpaths:", desc}; for rpaths.each |rpath| { - #debug(" %s", rpath); + debug!{" %s", rpath}; } } @@ -124,8 +124,8 @@ fn get_rpath_relative_to_output(os: session::os, fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { assert path::path_is_absolute(abs1); assert path::path_is_absolute(abs2); - #debug("finding relative path from %s to %s", - abs1, abs2); + debug!{"finding relative path from %s to %s", + abs1, abs2}; let normal1 = path::normalize(abs1); let normal2 = path::normalize(abs2); let split1 = path::split(normal1); @@ -171,7 +171,7 @@ fn get_absolute(cwd: path::path, lib: path::path) -> path::path { } fn get_install_prefix_rpath(cwd: path::path, target_triple: ~str) -> ~str { - let install_prefix = #env("CFG_PREFIX"); + let install_prefix = env!{"CFG_PREFIX"}; if install_prefix == ~"" { fail ~"rustc compiled without CFG_PREFIX environment variable"; @@ -222,7 +222,7 @@ mod test { #[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 d = path::connect(env!{"CFG_PREFIX"}, ~"/lib/rustc/triple/lib"); assert str::ends_with(res, d); } diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index e88c92d2110..7be6103e34f 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -115,8 +115,8 @@ fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T { let start = std::time::precise_time_s(); let rv = thunk(); let end = std::time::precise_time_s(); - io::stdout().write_str(#fmt("time: %3.3f s\t%s\n", - end - start, what)); + io::stdout().write_str(fmt!{"time: %3.3f s\t%s\n", + end - start, what}); ret rv; } @@ -397,7 +397,7 @@ fn host_triple() -> ~str { // FIXME (#2400): Instead of grabbing the host triple we really should // 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"); + let ht = env!{"CFG_HOST_TRIPLE"}; ret if ht != ~"" { ht } else { @@ -432,8 +432,8 @@ fn build_session_options(match: getopts::match, let lint_name = str::replace(lint_name, ~"-", ~"_"); alt lint_dict.find(lint_name) { none { - early_error(demitter, #fmt("unknown %s flag: %s", - level_name, lint_name)); + early_error(demitter, fmt!{"unknown %s flag: %s", + level_name, lint_name}); } some(lint) { vec::push(lint_opts, (lint.lint, level)); @@ -452,7 +452,7 @@ fn build_session_options(match: getopts::match, if name == debug_flag { this_bit = bit; break; } } if this_bit == 0u { - early_error(demitter, #fmt("unknown debug flag: %s", debug_flag)) + early_error(demitter, fmt!{"unknown debug flag: %s", debug_flag}) } debugging_opts |= this_bit; } diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index b5039b89731..4e457bde044 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -27,14 +27,14 @@ import io::reader_util; fn version(argv0: ~str) { let mut vers = ~"unknown version"; - let env_vers = #env["CFG_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())); + io::println(fmt!{"%s %s", argv0, vers}); + io::println(fmt!{"host: %s", host_triple()}); } fn usage(argv0: ~str) { - io::println(#fmt("Usage: %s [options] <input>\n", argv0) + + io::println(fmt!{"Usage: %s [options] <input>\n", argv0} + ~" Options: @@ -91,14 +91,14 @@ fn describe_warnings() { fn padded(max: uint, s: ~str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } - io::println(#fmt("\nAvailable lint checks:\n")); - io::println(#fmt(" %s %7.7s %s", - padded(max_key, ~"name"), ~"default", ~"meaning")); - io::println(#fmt(" %s %7.7s %s\n", - padded(max_key, ~"----"), ~"-------", ~"-------")); + io::println(fmt!{"\nAvailable lint checks:\n"}); + io::println(fmt!{" %s %7.7s %s", + padded(max_key, ~"name"), ~"default", ~"meaning"}); + io::println(fmt!{" %s %7.7s %s\n", + padded(max_key, ~"----"), ~"-------", ~"-------"}); for lint_dict.each |k, v| { let k = str::replace(k, ~"_", ~"-"); - io::println(#fmt(" %s %7.7s %s", + io::println(fmt!{" %s %7.7s %s", padded(max_key, k), alt v.default { lint::allow { ~"allow" } @@ -106,16 +106,16 @@ fn describe_warnings() { lint::deny { ~"deny" } lint::forbid { ~"forbid" } }, - v.desc)); + v.desc}); } io::println(~""); } fn describe_debug_flags() { - io::println(#fmt("\nAvailable debug options:\n")); + io::println(fmt!{"\nAvailable debug options:\n"}); for session::debugging_opts_map().each |pair| { let (name, desc, _) = pair; - io::println(#fmt(" -Z%-20s -- %s", name, desc)); + io::println(fmt!{" -Z%-20s -- %s", name, desc}); } } diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index ea841c0700c..920d4e2ee8c 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -7,7 +7,7 @@ export inject_intrinsic; fn inject_intrinsic(sess: session, crate: @ast::crate) -> @ast::crate { - let intrinsic_module = @#include_str("intrinsic.rs"); + let intrinsic_module = @include_str!{"intrinsic.rs"}; let item = parse::parse_item_from_source_str(~"<intrinsic>", intrinsic_module, diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 2e9b380314a..1cf825a5e6b 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -99,7 +99,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> option<@ast::item> { vec::push(cx.path, i.ident); - #debug("current path: %s", ast_util::path_name_i(cx.path)); + debug!{"current path: %s", ast_util::path_name_i(cx.path)}; if is_test_fn(i) { alt i.node { @@ -109,12 +109,12 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> ~"unsafe functions cannot be used for tests"); } _ { - #debug("this is a test function"); + debug!{"this is a test function"}; let test = {span: i.span, path: cx.path, ignore: is_ignored(cx, i), should_fail: should_fail(i)}; cx.testfns.push(test); - #debug("have %u test functions", cx.testfns.len()); + debug!{"have %u test functions", cx.testfns.len()}; } } } @@ -201,7 +201,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { vis: ast::public, span: dummy_sp()}; - #debug("Synthetic test module:\n%s\n", pprust::item_to_str(@item)); + debug!{"Synthetic test module:\n%s\n", pprust::item_to_str(@item)}; ret @item; } @@ -276,7 +276,7 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { } fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr { - #debug("building test vector from %u tests", cx.testfns.len()); + debug!{"building test vector from %u tests", cx.testfns.len()}; let mut descs = ~[]; for cx.testfns.each |test| { vec::push(descs, mk_test_desc_rec(cx, test)); @@ -296,7 +296,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let span = test.span; let path = test.path; - #debug("encoding %s", ast_util::path_name_i(path)); + debug!{"encoding %s", ast_util::path_name_i(path)}; let name_lit: ast::lit = nospan(ast::lit_str(@ast_util::path_name_i(path))); diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 7dbefa8e498..68fcb8c9183 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -1090,7 +1090,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> if addrspace == 0u { ~"" } else { - #fmt("addrspace(%u)", addrspace) + fmt!{"addrspace(%u)", addrspace} } }; ret addrstr + ~"*" + diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 28022a37320..03e5fde96a0 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -43,16 +43,16 @@ type cache_entry = { }; fn dump_crates(crate_cache: dvec<cache_entry>) { - #debug("resolved crates:"); + debug!{"resolved crates:"}; for crate_cache.each |entry| { - #debug("cnum: %?", entry.cnum); - #debug("span: %?", entry.span); - #debug("hash: %?", entry.hash); + debug!{"cnum: %?", entry.cnum}; + debug!{"span: %?", entry.span}; + debug!{"hash: %?", entry.hash}; let attrs = ~[ attr::mk_attr(attr::mk_list_item(@~"link", *entry.metas)) ]; for attr::find_linkage_attrs(attrs).each |attr| { - #debug("meta: %s", pprust::attr_to_str(attr)); + debug!{"meta: %s", pprust::attr_to_str(attr)}; } } } @@ -77,7 +77,7 @@ fn warn_if_multiple_versions(diag: span_handler, if matches.len() != 1u { diag.handler().warn( - #fmt("using multiple versions of crate `%s`", *name)); + fmt!{"using multiple versions of crate `%s`", *name}); for matches.each |match| { diag.span_note(match.span, ~"used here"); let attrs = ~[ @@ -102,7 +102,7 @@ type env = @{diag: span_handler, 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); + debug!{"resolving use stmt. ident: %?, meta: %?", ident, meta_items}; let cnum = resolve_crate(e, ident, meta_items, ~"", i.span); cstore::add_use_stmt_cnum(e.cstore, id, cnum); } @@ -238,7 +238,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], // Go through the crate metadata and load any crates that it references fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { - #debug("resolving deps of external crate"); + debug!{"resolving deps of external crate"}; // The map from crate numbers in the crate we're resolving to local crate // numbers let cnum_map = int_hash::<ast::crate_num>(); @@ -246,16 +246,16 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { let extrn_cnum = dep.cnum; let cname = dep.name; let cmetas = metas_with(dep.vers, @~"vers", ~[]); - #debug("resolving dep crate %s ver: %s hash: %s", - *dep.name, *dep.vers, *dep.hash); + 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) { some(local_cnum) { - #debug("already have it"); + debug!{"already have it"}; // We've already seen this crate cnum_map.insert(extrn_cnum, local_cnum); } none { - #debug("need to load it"); + debug!{"need to load it"}; // This is a new one so we've got to load it // FIXME (#2404): Need better error reporting than just a bogus // span. diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 0ba76c49246..91a22b9fe2f 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -46,7 +46,7 @@ fn get_type_param_count(cstore: cstore::cstore, def: ast::def_id) -> uint { fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num, path: ~[ast::ident]) -> ~[ast::def] { let mut result = ~[]; - #debug("lookup_defs: path = %? cnum = %?", path, cnum); + debug!{"lookup_defs: path = %? cnum = %?", path, cnum}; for resolve_path(cstore, cnum, path).each |elt| { let (c, data, def) = elt; vec::push(result, decoder::lookup_def(c, data, def)); @@ -68,8 +68,8 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num, path: ~[ast::ident]) -> ~[(ast::crate_num, @~[u8], ast::def_id)] { let cm = cstore::get_crate_data(cstore, cnum); - #debug("resolve_path %s in crates[%d]:%s", - ast_util::path_name_i(path), cnum, cm.name); + debug!{"resolve_path %s in crates[%d]:%s", + ast_util::path_name_i(path), cnum, cm.name}; let mut result = ~[]; for decoder::resolve_path(path, cm.data).each |def| { if def.crate == ast::local_crate { @@ -181,17 +181,17 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, class_id.crate); let all_items = ebml::get_doc(ebml::doc(cdata.data), tag_items); - #debug("Looking up %?", class_id); + debug!{"Looking up %?", class_id}; let class_doc = expect(tcx.diag, decoder::maybe_find_item(class_id.node, all_items), - || #fmt("get_field_type: class ID %? not found", - class_id) ); - #debug("looking up %? : %?", def, class_doc); + || fmt!{"get_field_type: class ID %? not found", + class_id} ); + debug!{"looking up %? : %?", def, class_doc}; let the_field = expect(tcx.diag, decoder::maybe_find_item(def.node, class_doc), - || #fmt("get_field_type: in class %?, field ID %? not found", - class_id, def) ); - #debug("got field data %?", the_field); + || fmt!{"get_field_type: in class %?, field ID %? not found", + class_id, def} ); + debug!{"got field data %?", the_field}; let ty = decoder::item_type(def, the_field, tcx, cdata); ret {bounds: @~[], rp: false, ty: ty}; } diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index af9b6d57e57..fd541c33d2d 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -160,16 +160,16 @@ fn get_dep_hashes(cstore: cstore) -> ~[@~str] { for p(cstore).use_crate_map.each_value |cnum| { let cdata = cstore::get_crate_data(cstore, cnum); let hash = decoder::get_crate_hash(cdata.data); - #debug("Add hash[%s]: %s", cdata.name, *hash); + debug!{"Add hash[%s]: %s", cdata.name, *hash}; vec::push(result, {name: @cdata.name, hash: hash}); }; fn lteq(a: crate_hash, b: crate_hash) -> bool { ret *a.name <= *b.name; } let sorted = std::sort::merge_sort(lteq, result); - #debug("sorted:"); + debug!{"sorted:"}; for sorted.each |x| { - #debug(" hash[%s]: %s", *x.name, *x.hash); + debug!{" hash[%s]: %s", *x.name, *x.hash}; } fn mapper(ch: crate_hash) -> @~str { ret ch.hash; } ret vec::map(sorted, mapper); diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 6d08b21f7e6..ba5ff3a6a9d 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -100,7 +100,7 @@ fn find_item(item_id: int, items: ebml::doc) -> ebml::doc { fn lookup_item(item_id: int, data: @~[u8]) -> ebml::doc { let items = ebml::get_doc(ebml::doc(data), tag_items); alt maybe_find_item(item_id, items) { - none { fail(#fmt("lookup_item: id not found: %d", item_id)); } + none { fail(fmt!{"lookup_item: id not found: %d", item_id}); } some(d) { d } } } @@ -231,7 +231,7 @@ fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] { let paths = ebml::get_doc(md, tag_paths); let eqer = |a| eq_item(a, s); let mut result: ~[ast::def_id] = ~[]; - #debug("resolve_path: looking up %s", s); + debug!{"resolve_path: looking up %s", s}; for lookup_hash(paths, eqer, hash_path(s)).each |doc| { let did_doc = ebml::get_doc(doc, tag_def_id); vec::push(result, ebml::with_doc_data(did_doc, |d| parse_def_id(d))); @@ -295,7 +295,7 @@ fn item_to_def_like(item: ebml::doc, did: ast::def_id, cnum: ast::crate_num) 'I' { dl_def(ast::def_ty(did)) } 'i' { dl_impl(did) } 'g' | 'j' { dl_field } - ch { fail #fmt("unexpected family code: '%c'", ch) } + ch { fail fmt!{"unexpected family code: '%c'", ch} } } } @@ -351,8 +351,8 @@ fn get_class_method(cdata: cmd, id: ast::node_id, let mut found = none; let cls_items = alt maybe_find_item(id, items) { some(it) { it } - none { fail (#fmt("get_class_method: class id not found \ - when looking up method %s", *name)) }}; + none { fail (fmt!{"get_class_method: class id not found \ + when looking up method %s", *name}) }}; for ebml::tagged_docs(cls_items, tag_item_trait_method) |mid| { let m_did = class_member_id(mid, cdata); if item_name(mid) == name { @@ -361,7 +361,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, } alt found { some(found) { found } - none { fail (#fmt("get_class_method: no method named %s", *name)) } + none { fail (fmt!{"get_class_method: no method named %s", *name}) } } } @@ -370,8 +370,8 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> { let mut found = none; let cls_items = alt maybe_find_item(id, items) { some(it) { it } - none { fail (#fmt("class_dtor: class id not found \ - when looking up dtor for %d", id)); } + none { fail (fmt!{"class_dtor: class id not found \ + when looking up dtor for %d", id}); } }; for ebml::tagged_docs(cls_items, tag_item_dtor) |doc| { let doc1 = ebml::get_doc(doc, tag_def_id); @@ -431,7 +431,7 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { let def_id = class_member_id(item_doc, cdata); // Construct the def for this item. - #debug("(each_path) yielding explicit item: %s", name); + debug!{"(each_path) yielding explicit item: %s", name}; let def_like = item_to_def_like(item_doc, def_id, cdata.cnum); // Hand the information off to the iteratee. @@ -468,8 +468,8 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { // Get the item. alt maybe_find_item(def_id.node, items) { none { - #debug("(each_path) ignoring implicit item: %s", - *path); + debug!{"(each_path) ignoring implicit item: %s", + *path}; } some(item_doc) { // Construct the def for this item. @@ -477,8 +477,8 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { cdata.cnum); // Hand the information off to the iteratee. - #debug("(each_path) yielding implicit item: %s", - *path); + debug!{"(each_path) yielding implicit item: %s", + *path}; let this_path_entry = path_entry(*path, def_like); if (!f(this_path_entry)) { broken = true; // XXX: This is awful. @@ -511,7 +511,7 @@ fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt, id: ast::node_id, decode_inlined_item: decode_inlined_item ) -> csearch::found_ast { - #debug("Looking up item: %d", id); + debug!{"Looking up item: %d", id}; let item_doc = lookup_item(id, cdata.data); let path = vec::init(item_path(item_doc)); alt decode_inlined_item(cdata, tcx, path, item_doc) { @@ -594,8 +594,8 @@ fn get_impls_for_mod(cdata: cmd, for ebml::tagged_docs(mod_item, tag_mod_impl) |doc| { let did = ebml::with_doc_data(doc, |d| parse_def_id(d)); let local_did = translate_def_id(cdata, did); - #debug("(get impls for mod) getting did %? for '%?'", - local_did, name); + debug!{"(get impls for mod) getting did %? for '%?'", + local_did, name}; // The impl may be defined in a different crate. Ask the caller // to give us the metadata let impl_cdata = get_cdata(local_did.crate); @@ -723,7 +723,7 @@ 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)); } + none { fail (fmt!{"describe_def: item not found %?", id}); } }; ret item_family_to_str(item_family(it)); } @@ -800,15 +800,15 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] { fn list_meta_items(meta_items: ebml::doc, out: io::writer) { for get_meta_items(meta_items).each |mi| { - out.write_str(#fmt["%s\n", pprust::meta_item_to_str(*mi)]); + out.write_str(fmt!{"%s\n", pprust::meta_item_to_str(*mi)}); } } fn list_crate_attributes(md: ebml::doc, hash: @~str, out: io::writer) { - out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash)); + 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(fmt!{"%s\n", pprust::attribute_to_str(attr)}); } out.write_str(~"\n\n"); @@ -843,8 +843,8 @@ fn list_crate_deps(data: @~[u8], out: io::writer) { 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(fmt!{"%d %s-%s-%s\n", + dep.cnum, *dep.name, *dep.hash, *dep.vers}); } out.write_str(~"\n"); @@ -871,8 +871,8 @@ fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) { do iter_crate_items(bytes) |tag, path, did| { // Don't print out any metadata info about intrinsics if tag != tag_paths_foreign_path { - out.write_str(#fmt["%s (%s)\n", path, - describe_def(items, did)]); + out.write_str(fmt!{"%s (%s)\n", path, + describe_def(items, did)}); } } out.write_str(~"\n"); diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 6f4716208a2..ee4a8bdd63f 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -273,7 +273,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]) { @@ -318,7 +318,7 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) { some(x) { x } none { ecx.diag.handler().bug( - #fmt("encode_symbol: id not found %d", id)); + fmt!{"encode_symbol: id not found %d", id}); } }; ebml_w.writer.write(str::bytes(sym)); @@ -400,17 +400,17 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, encode_def_id(ebml_w, local_def(id)); encode_family(ebml_w, 'm'); encode_name(ebml_w, name); - #debug("(encoding info for module) encoding info for module ID %d", id); + debug!{"(encoding info for module) encoding info for module ID %d", id}; // the impl map contains ref_ids let impls = ecx.impl_map(id); for impls.each |i| { let (ident, did) = i; - #debug("(encoding info for module) ... encoding impl %s (%?/%?), \ + debug!{"(encoding info for module) ... encoding impl %s (%?/%?), \ exported? %?", *ident, did, ast_map::node_id_to_str(ecx.tcx.items, did.node), - ast_util::is_exported(ident, md)); + ast_util::is_exported(ident, md)}; ebml_w.start_tag(tag_mod_impl); alt ecx.tcx.items.find(did.node) { @@ -456,7 +456,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, vec::push(*index, {val: id, pos: ebml_w.writer.tell()}); vec::push(*global_index, {val: id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); - #debug("encode_info_for_class: doing %s %d", *nm, id); + debug!{"encode_info_for_class: doing %s %d", *nm, id}; encode_visibility(ebml_w, vis); encode_name(ebml_w, nm); encode_path(ebml_w, path, ast_map::path_name(nm)); @@ -473,7 +473,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, {val: m.id, pos: ebml_w.writer.tell()}); let impl_path = vec::append_one(path, ast_map::path_name(m.ident)); - #debug("encode_info_for_class: doing %s %d", *m.ident, m.id); + debug!{"encode_info_for_class: doing %s %d", *m.ident, m.id}; encode_info_for_method(ecx, ebml_w, impl_path, should_inline(m.attrs), id, m, vec::append(class_tps, m.tps)); @@ -496,8 +496,8 @@ fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer, encode_family(ebml_w, purity_fn_family(decl.purity)); encode_type_param_bounds(ebml_w, ecx, tps); let its_ty = node_id_to_type(ecx.tcx, id); - #debug("fn name = %s ty = %s its node id = %d", *ident, - util::ppaux::ty_to_str(ecx.tcx, its_ty), id); + debug!{"fn name = %s ty = %s its node id = %d", *ident, + util::ppaux::ty_to_str(ecx.tcx, its_ty), id}; encode_type(ecx, ebml_w, its_ty); encode_path(ebml_w, path, ast_map::path_name(ident)); alt item { @@ -515,7 +515,7 @@ fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer, impl_path: ast_map::path, should_inline: bool, parent_id: node_id, m: @method, all_tps: ~[ty_param]) { - #debug("encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len()); + debug!{"encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len()}; ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(m.id)); encode_family(ebml_w, purity_fn_family(m.decl.purity)); @@ -838,8 +838,8 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, /* encode ctor, then encode items */ alt i.node { item_class(tps, _, _, some(ctor), m_dtor) { - #debug("encoding info for ctor %s %d", *i.ident, - ctor.node.id); + debug!{"encoding info for ctor %s %d", *i.ident, + ctor.node.id}; vec::push(*index, { val: ctor.node.id, pos: ebml_w.writer.tell() diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index cb773589dcc..9e68ce12a3c 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -62,7 +62,7 @@ fn mk_filesearch(maybe_sysroot: option<path>, } let sysroot = get_sysroot(maybe_sysroot); - #debug("using sysroot = %s", sysroot); + debug!{"using sysroot = %s", sysroot}; {sysroot: sysroot, addl_lib_search_paths: addl_lib_search_paths, target_triple: target_triple} as filesearch @@ -71,16 +71,16 @@ fn mk_filesearch(maybe_sysroot: option<path>, fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option<T> { let mut rslt = none; for filesearch.lib_search_paths().each |lib_search_path| { - #debug("searching %s", lib_search_path); + debug!{"searching %s", lib_search_path}; for os::list_dir_path(lib_search_path).each |path| { - #debug("testing %s", path); + debug!{"testing %s", path}; let maybe_picked = pick(path); if option::is_some(maybe_picked) { - #debug("picked %s", path); + debug!{"picked %s", path}; rslt = maybe_picked; break; } else { - #debug("rejected %s", path); + debug!{"rejected %s", path}; } } if option::is_some(rslt) { break; } @@ -172,7 +172,7 @@ 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 { - let libdir = #env("CFG_LIBDIR"); + let libdir = env!{"CFG_LIBDIR"}; if str::is_empty(libdir) { fail ~"rustc compiled without CFG_LIBDIR environment variable"; } diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index 862e6b90e7d..76cfba66b73 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -41,7 +41,7 @@ fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { some(t) { ret t; } none { cx.diag.span_fatal( - cx.span, #fmt["can't find crate for `%s`", *cx.ident]); + cx.span, fmt!{"can't find crate for `%s`", *cx.ident}); } } } @@ -71,27 +71,27 @@ fn find_library_crate_aux(cx: ctxt, let mut matches = ~[]; filesearch::search(filesearch, |path| { - #debug("inspecting file %s", path); + debug!{"inspecting file %s", 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); + debug!{"skipping %s, doesn't look like %s*%s", path, prefix, + suffix}; option::none::<()> } else { - #debug("%s is a candidate", path); + debug!{"%s is a candidate", path}; alt get_metadata_section(cx.os, path) { option::some(cvec) { if !crate_matches(cvec, cx.metas, cx.hash) { - #debug("skipping %s, metadata doesn't match", path); + debug!{"skipping %s, metadata doesn't match", path}; option::none::<()> } else { - #debug("found %s with matching metadata", path); + debug!{"found %s with matching metadata", path}; vec::push(matches, {ident: path, data: cvec}); option::none::<()> } } _ { - #debug("could not load metadata for %s", path); + debug!{"could not load metadata for %s", path}; option::none::<()> } } @@ -104,10 +104,10 @@ fn find_library_crate_aux(cx: ctxt, some(matches[0]) } else { cx.diag.span_err( - cx.span, #fmt("multiple matching crates for `%s`", *crate_name)); + cx.span, fmt!{"multiple matching crates for `%s`", *crate_name}); cx.diag.handler().note(~"candidates:"); for matches.each |match| { - cx.diag.handler().note(#fmt("path: %s", match.ident)); + cx.diag.handler().note(fmt!{"path: %s", match.ident}); let attrs = decoder::get_crate_attributes(match.data); note_linkage_attrs(cx.diag, attrs); } @@ -133,7 +133,7 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @~str { fn note_linkage_attrs(diag: span_handler, attrs: ~[ast::attribute]) { for attr::find_linkage_attrs(attrs).each |attr| { - diag.handler().note(#fmt("meta: %s", pprust::attr_to_str(attr))); + diag.handler().note(fmt!{"meta: %s", pprust::attr_to_str(attr)}); } } @@ -151,18 +151,18 @@ fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item], fn metadata_matches(extern_metas: ~[@ast::meta_item], local_metas: ~[@ast::meta_item]) -> bool { - #debug("matching %u metadata requirements against %u items", - vec::len(local_metas), vec::len(extern_metas)); + debug!{"matching %u metadata requirements against %u items", + vec::len(local_metas), vec::len(extern_metas)}; - #debug("crate metadata:"); + debug!{"crate metadata:"}; for extern_metas.each |have| { - #debug(" %s", pprust::meta_item_to_str(*have)); + debug!{" %s", pprust::meta_item_to_str(*have)}; } for local_metas.each |needed| { - #debug("looking for %s", pprust::meta_item_to_str(*needed)); + debug!{"looking for %s", pprust::meta_item_to_str(*needed)}; if !attr::contains(extern_metas, needed) { - #debug("missing %s", pprust::meta_item_to_str(*needed)); + debug!{"missing %s", pprust::meta_item_to_str(*needed)}; ret false; } } diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 7ae96eb8032..fad9d2d942f 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -297,16 +297,16 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'B' { ty::mk_opaque_box(st.tcx) } 'a' { - #debug("saw a class"); + debug!{"saw a class"}; assert (next(st) == '['); - #debug("saw a ["); + debug!{"saw a ["}; let did = parse_def(st, conv); - #debug("parsed a def_id %?", did); + debug!{"parsed a def_id %?", did}; let substs = parse_substs(st, conv); assert (next(st) == ']'); ret ty::mk_class(st.tcx, did, substs); } - c { #error("unexpected char in type string: %c", c); fail;} + c { error!{"unexpected char in type string: %c", c}; fail;} } } @@ -389,7 +389,7 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id { let len = vec::len(buf); while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } if colon_idx == len { - #error("didn't find ':' when parsing def id"); + error!{"didn't find ':' when parsing def id"}; fail; } let crate_part = vec::slice(buf, 0u, colon_idx); @@ -397,13 +397,13 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_num = alt uint::parse_buf(crate_part, 10u) { some(cn) { cn as int } - none { fail (#fmt("internal error: parse_def_id: crate number \ - expected, but found %?", crate_part)); } + none { fail (fmt!{"internal error: parse_def_id: crate number \ + expected, but found %?", crate_part}); } }; let def_num = alt uint::parse_buf(def_part, 10u) { some(dn) { dn as int } - none { fail (#fmt("internal error: parse_def_id: id expected, but \ - found %?", def_part)); } + none { fail (fmt!{"internal error: parse_def_id: id expected, but \ + found %?", def_part}); } }; ret {crate: crate_num, node: def_num}; } diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 1471bbd1acb..7bcf6d77841 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -293,15 +293,15 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { ty::ty_opaque_closure_ptr(ty::ck_uniq) { w.write_str(&"C~"); } ty::ty_opaque_box { w.write_char('B'); } ty::ty_class(def, substs) { - #debug("~~~~ %s", ~"a["); + debug!{"~~~~ %s", ~"a["}; w.write_str(&"a["); let s = cx.ds(def); - #debug("~~~~ %s", s); + 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(']'); } } diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 1428d9e8982..bbbf8947792 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -89,9 +89,9 @@ fn encode_inlined_item(ecx: @e::encode_ctxt, path: ast_map::path, ii: ast::inlined_item, maps: maps) { - #debug["> Encoding inlined item: %s::%s (%u)", + debug!{"> Encoding inlined item: %s::%s (%u)", ast_map::path_to_str(path), *ii.ident(), - ebml_w.writer.tell()]; + ebml_w.writer.tell()}; let id_range = ast_util::compute_id_range_for_inlined_item(ii); do ebml_w.wr_tag(c::tag_ast as uint) { @@ -100,9 +100,9 @@ fn encode_inlined_item(ecx: @e::encode_ctxt, encode_side_tables_for_ii(ecx, maps, ebml_w, ii); } - #debug["< Encoded inlined fn: %s::%s (%u)", + debug!{"< Encoded inlined fn: %s::%s (%u)", ast_map::path_to_str(path), *ii.ident(), - ebml_w.writer.tell()]; + ebml_w.writer.tell()}; } fn decode_inlined_item(cdata: cstore::crate_metadata, @@ -114,7 +114,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, alt par_doc.opt_child(c::tag_ast) { none { none } some(ast_doc) { - #debug["> Decoding inlined fn: %s::?", ast_map::path_to_str(path)]; + debug!{"> Decoding inlined fn: %s::?", ast_map::path_to_str(path)}; let ast_dsr = ebml::ebml_deserializer(ast_doc); let from_id_range = ast_util::deserialize_id_range(ast_dsr); let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); @@ -125,14 +125,14 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, let ii = renumber_ast(xcx, raw_ii); ast_map::map_decoded_item(tcx.sess.diagnostic(), dcx.tcx.items, path, ii); - #debug["Fn named: %s", *ii.ident()]; + debug!{"Fn named: %s", *ii.ident()}; decode_side_tables(xcx, ast_doc); - #debug["< Decoded inlined fn: %s::%s", - ast_map::path_to_str(path), *ii.ident()]; + debug!{"< Decoded inlined fn: %s::%s", + ast_map::path_to_str(path), *ii.ident()}; alt ii { ast::ii_item(i) { - #debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", - syntax::print::pprust::item_to_str(i)); + debug!{">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", + syntax::print::pprust::item_to_str(i)}; } _ { } } @@ -641,7 +641,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt, id: ast::node_id) { let tcx = ecx.tcx; - #debug["Encoding side tables for id %d", id]; + debug!{"Encoding side tables for id %d", id}; do option::iter(tcx.def_map.find(id)) |def| { do ebml_w.tag(c::tag_table_def) { @@ -833,9 +833,9 @@ fn decode_side_tables(xcx: extended_decode_ctxt, let id0 = entry_doc[c::tag_table_id as uint].as_int(); let id = xcx.tr_id(id0); - #debug[">> Side table document with tag 0x%x \ + debug!{">> Side table document with tag 0x%x \ found for id %d (orig %d)", - tag, id, id0]; + tag, id, id0}; if tag == (c::tag_table_mutbl as uint) { dcx.maps.mutbl_map.insert(id, ()); @@ -884,11 +884,11 @@ fn decode_side_tables(xcx: extended_decode_ctxt, dcx.tcx.borrowings.insert(id, borrow); } else { xcx.dcx.tcx.sess.bug( - #fmt["unknown tag found in side tables: %x", tag]); + fmt!{"unknown tag found in side tables: %x", tag}); } } - #debug[">< Side table doc loaded"]; + debug!{">< Side table doc loaded"}; } } @@ -931,21 +931,21 @@ fn mk_ctxt() -> fake_ext_ctxt { #[cfg(test)] fn roundtrip(in_item: @ast::item) { - #debug["in_item = %s", pprust::item_to_str(in_item)]; + debug!{"in_item = %s", pprust::item_to_str(in_item)}; let mbuf = io::mem_buffer(); let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf)); encode_item_ast(ebml_w, in_item); let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf)); let out_item = decode_item_ast(ebml_doc); - #debug["out_item = %s", pprust::item_to_str(out_item)]; + debug!{"out_item = %s", pprust::item_to_str(out_item)}; let exp_str = io::with_str_writer(|w| ast::serialize_item(w, *in_item) ); let out_str = io::with_str_writer(|w| ast::serialize_item(w, *out_item) ); - #debug["expected string: %s", exp_str]; - #debug["actual string : %s", out_str]; + debug!{"expected string: %s", exp_str}; + debug!{"actual string : %s", out_str}; assert exp_str == out_str; } @@ -953,7 +953,7 @@ fn roundtrip(in_item: @ast::item) { #[test] fn test_basic() { let ext_cx = mk_ctxt(); - roundtrip(#ast(item){ + roundtrip(#ast[item]{ fn foo() {} }); } @@ -961,7 +961,7 @@ fn test_basic() { #[test] fn test_smalltalk() { let ext_cx = mk_ctxt(); - roundtrip(#ast(item){ + roundtrip(#ast[item]{ fn foo() -> int { 3 + 4 } // first smalltalk program ever executed. }); } @@ -969,7 +969,7 @@ fn test_smalltalk() { #[test] fn test_more() { let ext_cx = mk_ctxt(); - roundtrip(#ast(item){ + roundtrip(#ast[item]{ fn foo(x: uint, y: uint) -> uint { let z = x + y; ret z; @@ -980,14 +980,14 @@ fn test_more() { #[test] fn test_simplification() { let ext_cx = mk_ctxt(); - let item_in = ast::ii_item(#ast(item) { + let item_in = ast::ii_item(#ast[item] { fn new_int_alist<B: copy>() -> alist<int, B> { fn eq_int(&&a: int, &&b: int) -> bool { a == b } ret {eq_fn: eq_int, mut data: ~[]}; } }); let item_out = simplify_ast(item_in); - let item_exp = ast::ii_item(#ast(item) { + let item_exp = ast::ii_item(#ast[item] { fn new_int_alist<B: copy>() -> alist<int, B> { ret {eq_fn: eq_int, mut data: ~[]}; } diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index df09a585f47..2c326aa68ef 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -255,16 +255,16 @@ fn check_crate(tcx: ty::ctxt, if tcx.sess.borrowck_stats() { io::println(~"--- borrowck stats ---"); - io::println(#fmt["paths requiring guarantees: %u", - bccx.guaranteed_paths]); - io::println(#fmt["paths requiring loans : %s", - make_stat(bccx, bccx.loaned_paths_same)]); - io::println(#fmt["paths requiring imm loans : %s", - make_stat(bccx, bccx.loaned_paths_imm)]); - io::println(#fmt["stable paths : %s", - make_stat(bccx, bccx.stable_paths)]); - io::println(#fmt["paths requiring purity : %s", - make_stat(bccx, bccx.req_pure_paths)]); + io::println(fmt!{"paths requiring guarantees: %u", + bccx.guaranteed_paths}); + io::println(fmt!{"paths requiring loans : %s", + make_stat(bccx, bccx.loaned_paths_same)}); + io::println(fmt!{"paths requiring imm loans : %s", + make_stat(bccx, bccx.loaned_paths_imm)}); + io::println(fmt!{"stable paths : %s", + make_stat(bccx, bccx.stable_paths)}); + io::println(fmt!{"paths requiring purity : %s", + make_stat(bccx, bccx.req_pure_paths)}); } ret (bccx.root_map, bccx.mutbl_map); @@ -272,7 +272,7 @@ fn check_crate(tcx: ty::ctxt, 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] + fmt!{"%u (%.0f%%)", stat , stat_f * 100f / total} } } @@ -465,8 +465,8 @@ impl error_methods for borrowck_ctxt { fn report(err: bckerr) { self.span_err( err.cmt.span, - #fmt["illegal borrow: %s", - self.bckerr_code_to_str(err.code)]); + fmt!{"illegal borrow: %s", + self.bckerr_code_to_str(err.code)}); } fn span_err(s: span, m: ~str) { @@ -499,15 +499,15 @@ impl to_str_methods for borrowck_ctxt { 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] } + 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} } cat_deref(cmt, derefs, ptr) { - #fmt["%s->(%s, %u)", self.cat_to_repr(cmt.cat), - self.ptr_sigil(ptr), derefs] + fmt!{"%s->(%s, %u)", self.cat_to_repr(cmt.cat), + self.ptr_sigil(ptr), derefs} } cat_comp(cmt, comp) { - #fmt["%s.%s", self.cat_to_repr(cmt.cat), self.comp_to_repr(comp)] + fmt!{"%s.%s", self.cat_to_repr(cmt.cat), self.comp_to_repr(comp)} } cat_discr(cmt, _) { self.cat_to_repr(cmt.cat) } } @@ -542,29 +542,29 @@ impl to_str_methods for borrowck_ctxt { fn lp_to_str(lp: @loan_path) -> ~str { alt *lp { lp_local(node_id) { - #fmt["local(%d)", node_id] + fmt!{"local(%d)", node_id} } lp_arg(node_id) { - #fmt["arg(%d)", node_id] + fmt!{"arg(%d)", node_id} } lp_deref(lp, ptr) { - #fmt["%s->(%s)", self.lp_to_str(lp), - self.ptr_sigil(ptr)] + fmt!{"%s->(%s)", self.lp_to_str(lp), + self.ptr_sigil(ptr)} } lp_comp(lp, comp) { - #fmt["%s.%s", self.lp_to_str(lp), - self.comp_to_repr(comp)] + fmt!{"%s.%s", self.lp_to_str(lp), + self.comp_to_repr(comp)} } } } fn cmt_to_repr(cmt: cmt) -> ~str { - #fmt["{%s id:%d m:%s lp:%s ty:%s}", + 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) ), - ty_to_str(self.tcx, cmt.ty)] + ty_to_str(self.tcx, cmt.ty)} } fn cmt_to_str(cmt: cmt) -> ~str { @@ -580,8 +580,8 @@ impl to_str_methods for borrowck_ctxt { 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.ptr_sigil(pk)] } + cat_deref(_, _, pk) { fmt!{"dereference of %s %s pointer", + mut_str, self.ptr_sigil(pk)} } cat_stack_upvar(_) { ~"captured outer " + mut_str + ~" variable in a stack closure" } @@ -610,8 +610,8 @@ impl to_str_methods for borrowck_ctxt { 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)] + 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" @@ -626,16 +626,16 @@ impl to_str_methods for borrowck_ctxt { ~"rooting is not permitted" } err_out_of_root_scope(super_scope, sub_scope) { - #fmt["managed value would have to be rooted for lifetime %s, \ + fmt!{"managed value would have to be rooted for lifetime %s, \ but can only be rooted for lifetime %s", self.region_to_str(sub_scope), - self.region_to_str(super_scope)] + self.region_to_str(super_scope)} } err_out_of_scope(super_scope, sub_scope) { - #fmt["borrowed pointer has lifetime %s, \ + fmt!{"borrowed pointer has lifetime %s, \ but the borrowed value only has lifetime %s", self.region_to_str(sub_scope), - self.region_to_str(super_scope)] + self.region_to_str(super_scope)} } } } diff --git a/src/rustc/middle/borrowck/categorization.rs b/src/rustc/middle/borrowck/categorization.rs index d8c88d415ac..6f5b5d139d3 100644 --- a/src/rustc/middle/borrowck/categorization.rs +++ b/src/rustc/middle/borrowck/categorization.rs @@ -89,8 +89,8 @@ fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind { some(k) {k} none { tcx.sess.bug( - #fmt["deref_cat() invoked on non-derefable type %s", - ty_to_str(tcx, t)]); + fmt!{"deref_cat() invoked on non-derefable type %s", + ty_to_str(tcx, t)}); } } } @@ -118,15 +118,15 @@ impl public_methods for borrowck_ctxt { _ { self.tcx.sess.span_bug( expr.span, - #fmt["Borrowing of non-derefable type `%s`", - ty_to_str(self.tcx, expr_ty)]); + fmt!{"Borrowing of non-derefable type `%s`", + ty_to_str(self.tcx, expr_ty)}); } } } fn cat_expr(expr: @ast::expr) -> cmt { - #debug["cat_expr: id=%d expr=%s", - expr.id, pprust::expr_to_str(expr)]; + debug!{"cat_expr: id=%d expr=%s", + expr.id, pprust::expr_to_str(expr)}; let tcx = self.tcx; let expr_ty = tcx.ty(expr); @@ -142,8 +142,8 @@ impl public_methods for borrowck_ctxt { none { tcx.sess.span_bug( e_base.span, - #fmt["Explicit deref of non-derefable type `%s`", - ty_to_str(tcx, tcx.ty(e_base))]); + fmt!{"Explicit deref of non-derefable type `%s`", + ty_to_str(tcx, tcx.ty(e_base))}); } } } @@ -318,8 +318,8 @@ impl public_methods for borrowck_ctxt { none { self.tcx.sess.span_bug( node.span(), - #fmt["Cannot find field `%s` in type `%s`", - *f_name, ty_to_str(self.tcx, base_cmt.ty)]); + fmt!{"Cannot find field `%s` in type `%s`", + *f_name, ty_to_str(self.tcx, base_cmt.ty)}); } }; let m = self.inherited_mutability(base_cmt.mutbl, f_mutbl); @@ -382,8 +382,8 @@ impl public_methods for borrowck_ctxt { none { self.tcx.sess.span_bug( expr.span, - #fmt["Explicit index of non-index type `%s`", - ty_to_str(self.tcx, base_cmt.ty)]); + fmt!{"Explicit index of non-index type `%s`", + ty_to_str(self.tcx, base_cmt.ty)}); } }; diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index d32d5dfd4a9..4306d457378 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -157,12 +157,12 @@ impl methods for check_loan_ctxt { callee_span: span) { let tcx = self.tcx(); - #debug["check_pure_callee_or_arg(pc=%?, expr=%?, \ + debug!{"check_pure_callee_or_arg(pc=%?, expr=%?, \ callee_id=%d, ty=%s)", pc, opt_expr.map(|e| pprust::expr_to_str(e) ), callee_id, - ty_to_str(self.tcx(), ty::node_id_to_type(tcx, callee_id))]; + ty_to_str(self.tcx(), ty::node_id_to_type(tcx, callee_id))}; // Purity rules: an expr B is a legal callee or argument to a // call within a pure function A if at least one of the @@ -202,8 +202,8 @@ impl methods for check_loan_ctxt { ast::impure_fn | ast::unsafe_fn | ast::extern_fn { self.report_purity_error( pc, callee_span, - #fmt["access to %s function", - pprust::purity_to_str(fn_ty.purity)]); + fmt!{"access to %s function", + pprust::purity_to_str(fn_ty.purity)}); } } } @@ -257,14 +257,14 @@ impl methods for check_loan_ctxt { (m_mutbl, m_imm) | (m_imm, m_mutbl) { self.bccx.span_err( new_loan.cmt.span, - #fmt["loan of %s as %s \ + fmt!{"loan of %s as %s \ conflicts with prior loan", self.bccx.cmt_to_str(new_loan.cmt), - self.bccx.mut_to_str(new_loan.mutbl)]); + self.bccx.mut_to_str(new_loan.mutbl)}); self.bccx.span_note( old_loan.cmt.span, - #fmt["prior loan as %s granted here", - self.bccx.mut_to_str(old_loan.mutbl)]); + fmt!{"prior loan as %s granted here", + self.bccx.mut_to_str(old_loan.mutbl)}); } } } @@ -294,8 +294,8 @@ impl methods for check_loan_ctxt { fn check_assignment(at: assignment_type, ex: @ast::expr) { let cmt = self.bccx.cat_expr(ex); - #debug["check_assignment(cmt=%s)", - self.bccx.cmt_to_repr(cmt)]; + debug!{"check_assignment(cmt=%s)", + self.bccx.cmt_to_repr(cmt)}; if self.in_ctor && self.is_self_field(cmt) && at.checked_by_liveness() { @@ -354,12 +354,12 @@ impl methods for check_loan_ctxt { m_imm { self.bccx.span_err( ex.span, - #fmt["%s prohibited due to outstanding loan", - at.ing_form(self.bccx.cmt_to_str(cmt))]); + fmt!{"%s prohibited due to outstanding loan", + at.ing_form(self.bccx.cmt_to_str(cmt))}); self.bccx.span_note( loan.cmt.span, - #fmt["loan of %s granted here", - self.bccx.cmt_to_str(loan.cmt)]); + fmt!{"loan of %s granted here", + self.bccx.cmt_to_str(loan.cmt)}); ret; } } @@ -386,17 +386,17 @@ impl methods for check_loan_ctxt { pc_pure_fn { self.tcx().sess.span_err( sp, - #fmt["%s prohibited in pure context", msg]); + fmt!{"%s prohibited in pure context", msg}); } pc_cmt(e) { if self.reported.insert(e.cmt.id, ()) { self.tcx().sess.span_err( e.cmt.span, - #fmt["illegal borrow unless pure: %s", - self.bccx.bckerr_code_to_str(e.code)]); + fmt!{"illegal borrow unless pure: %s", + self.bccx.bckerr_code_to_str(e.code)}); self.tcx().sess.span_note( sp, - #fmt["impure due to %s", msg]); + fmt!{"impure due to %s", msg}); } } } @@ -408,8 +408,8 @@ impl methods for check_loan_ctxt { } fn check_move_out_from_cmt(cmt: cmt) { - #debug["check_move_out_from_cmt(cmt=%s)", - self.bccx.cmt_to_repr(cmt)]; + debug!{"check_move_out_from_cmt(cmt=%s)", + self.bccx.cmt_to_repr(cmt)}; alt cmt.cat { // Rvalues, locals, and arguments can be moved: @@ -427,7 +427,7 @@ impl methods for check_loan_ctxt { _ { self.bccx.span_err( cmt.span, - #fmt["moving out of %s", self.bccx.cmt_to_str(cmt)]); + fmt!{"moving out of %s", self.bccx.cmt_to_str(cmt)}); ret; } } @@ -442,12 +442,12 @@ impl methods for check_loan_ctxt { for self.walk_loans_of(cmt.id, lp) |loan| { self.bccx.span_err( cmt.span, - #fmt["moving out of %s prohibited due to outstanding loan", - self.bccx.cmt_to_str(cmt)]); + fmt!{"moving out of %s prohibited due to outstanding loan", + self.bccx.cmt_to_str(cmt)}); self.bccx.span_note( loan.cmt.span, - #fmt["loan of %s granted here", - self.bccx.cmt_to_str(loan.cmt)]); + fmt!{"loan of %s granted here", + self.bccx.cmt_to_str(loan.cmt)}); ret; } } @@ -462,8 +462,8 @@ impl methods for check_loan_ctxt { some(lp) { lp } }; for self.walk_loans_of(cmt.id, lp) |_loan| { - #debug["Removing last use entry %? due to outstanding loan", - expr.id]; + debug!{"Removing last use entry %? due to outstanding loan", + expr.id}; self.bccx.last_use_map.remove(expr.id); ret; } @@ -507,7 +507,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, sp: span, id: ast::node_id, &&self: check_loan_ctxt, visitor: visit::vt<check_loan_ctxt>) { - #debug["purity on entry=%?", copy self.declared_purity]; + debug!{"purity on entry=%?", copy self.declared_purity}; do save_and_restore(self.in_ctor) { do save_and_restore(self.declared_purity) { do save_and_restore(self.fn_args) { @@ -543,7 +543,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, } } } - #debug["purity on exit=%?", copy self.declared_purity]; + debug!{"purity on exit=%?", copy self.declared_purity}; } fn check_loans_in_local(local: @ast::local, diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index 87e8ad7a9f2..4b9015eec67 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -90,7 +90,7 @@ fn req_loans_in_expr(ex: @ast::expr, let tcx = bccx.tcx; let old_root_ub = self.root_ub; - #debug["req_loans_in_expr(ex=%s)", pprust::expr_to_str(ex)]; + debug!{"req_loans_in_expr(ex=%s)", pprust::expr_to_str(ex)}; // If this expression is borrowed, have to ensure it remains valid: for tcx.borrowings.find(ex.id).each |borrow| { @@ -258,10 +258,10 @@ impl methods for gather_loan_ctxt { self.bccx.guaranteed_paths += 1; - #debug["guarantee_valid(cmt=%s, req_mutbl=%s, scope_r=%s)", + debug!{"guarantee_valid(cmt=%s, req_mutbl=%s, scope_r=%s)", self.bccx.cmt_to_repr(cmt), self.bccx.mut_to_str(req_mutbl), - region_to_str(self.tcx(), scope_r)]; + region_to_str(self.tcx(), scope_r)}; let _i = indenter(); alt cmt.lp { @@ -290,7 +290,7 @@ impl methods for gather_loan_ctxt { if self.tcx().sess.borrowck_note_loan() { self.bccx.span_note( cmt.span, - #fmt["immutable loan required"]); + fmt!{"immutable loan required"}); } } else { self.bccx.loaned_paths_same += 1; @@ -344,7 +344,7 @@ impl methods for gather_loan_ctxt { if self.tcx().sess.borrowck_note_pure() { self.bccx.span_note( cmt.span, - #fmt["purity required"]); + fmt!{"purity required"}); } } _ => { @@ -443,9 +443,9 @@ impl methods for gather_loan_ctxt { // in the alt, the id of `local(x)->@` is the `@y` pattern, // and the id of `local(x)->@->@` is the id of the `y` pattern. - #debug["gather_pat: id=%d pat=%s cmt=%s arm_id=%d alt_id=%d", + debug!{"gather_pat: id=%d pat=%s cmt=%s arm_id=%d alt_id=%d", pat.id, pprust::pat_to_str(pat), - self.bccx.cmt_to_repr(cmt), arm_id, alt_id]; + self.bccx.cmt_to_repr(cmt), arm_id, alt_id}; let _i = indenter(); let tcx = self.tcx(); @@ -463,8 +463,8 @@ impl methods for gather_loan_ctxt { .find(pat.id) { some(ast::def_variant(enum_did, _)) {enum_did} e {tcx.sess.span_bug(pat.span, - #fmt["resolved to %?, \ - not variant", e])} + fmt!{"resolved to %?, \ + not variant", e})} }; for subpats.each |subpat| { @@ -475,11 +475,11 @@ impl methods for gather_loan_ctxt { ast::pat_ident(_, none) if self.pat_is_variant(pat) { // nullary variant - #debug["nullary variant"]; + debug!{"nullary variant"}; } ast::pat_ident(id, o_pat) { // x or x @ p --- `x` must remain valid for the scope of the alt - #debug["defines identifier %s", pprust::path_to_str(id)]; + debug!{"defines identifier %s", pprust::path_to_str(id)}; // Note: there is a discussion of the function of // cat_discr in the method preserve(): diff --git a/src/rustc/middle/borrowck/loan.rs b/src/rustc/middle/borrowck/loan.rs index 4b1726b69fa..b466cfd3a43 100644 --- a/src/rustc/middle/borrowck/loan.rs +++ b/src/rustc/middle/borrowck/loan.rs @@ -58,9 +58,9 @@ impl loan_methods for loan_ctxt { } fn loan(cmt: cmt, req_mutbl: ast::mutability) -> bckres<()> { - #debug["loan(%s, %s)", + debug!{"loan(%s, %s)", self.bccx.cmt_to_repr(cmt), - self.bccx.mut_to_str(req_mutbl)]; + self.bccx.mut_to_str(req_mutbl)}; let _i = indenter(); // see stable() above; should only be called when `cmt` is lendable diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index 860e4962295..e1e97c0dc6f 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -58,9 +58,9 @@ impl private_methods for &preserve_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } fn preserve(cmt: cmt) -> bckres<preserve_condition> { - #debug["preserve(cmt=%s, root_ub=%?, root_managed_data=%b)", + debug!{"preserve(cmt=%s, root_ub=%?, root_managed_data=%b)", self.bccx.cmt_to_repr(cmt), self.root_ub, - self.root_managed_data]; + self.root_managed_data}; let _i = indenter(); alt cmt.cat { @@ -148,7 +148,7 @@ impl private_methods for &preserve_ctxt { // otherwise we have no guarantee the pointer will stay // live, so we must root the pointer (i.e., inc the ref // count) for the duration of the loan. - #debug["base.mutbl = %?", self.bccx.mut_to_str(base.mutbl)]; + debug!{"base.mutbl = %?", self.bccx.mut_to_str(base.mutbl)}; if base.mutbl == m_imm { let non_rooting_ctxt = preserve_ctxt({root_managed_data: false with **self}); @@ -157,12 +157,12 @@ impl private_methods for &preserve_ctxt { ok(pc_ok) } ok(pc_if_pure(_)) { - #debug["must root @T, otherwise purity req'd"]; + debug!{"must root @T, otherwise purity req'd"}; self.attempt_root(cmt, base, derefs) } err(e) => { - #debug["must root @T, err: %s", - self.bccx.bckerr_code_to_str(e.code)]; + debug!{"must root @T, err: %s", + self.bccx.bckerr_code_to_str(e.code)}; self.attempt_root(cmt, base, derefs) } } diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index 141ec29b5b2..b45d7d66e9e 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -43,16 +43,16 @@ fn check_capture_clause(tcx: ty::ctxt, if !vec::any(*freevars, |fv| fv.def == cap_def ) { tcx.sess.span_warn( cap_item.span, - #fmt("captured variable `%s` not used in closure", - *cap_item.name)); + fmt!{"captured variable `%s` not used in closure", + *cap_item.name}); } let cap_def_id = ast_util::def_id_of_def(cap_def).node; if !seen_defs.insert(cap_def_id, ()) { tcx.sess.span_err( cap_item.span, - #fmt("variable `%s` captured more than once", - *cap_item.name)); + fmt!{"variable `%s` captured more than once", + *cap_item.name}); } } } @@ -67,8 +67,8 @@ fn compute_capture_vars(tcx: ty::ctxt, // first add entries for anything explicitly named in the cap clause for (*cap_clause).each |cap_item| { - #debug("Doing capture var: %s (%?)", - *cap_item.name, cap_item.id); + debug!{"Doing capture var: %s (%?)", + *cap_item.name, cap_item.id}; let cap_def = tcx.def_map.get(cap_item.id); let cap_def_id = ast_util::def_id_of_def(cap_def).node; diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 34529710825..8707cabfdf7 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -213,7 +213,7 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { } fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { - #debug["kind::check_expr(%s)", expr_to_str(e)]; + debug!{"kind::check_expr(%s)", expr_to_str(e)}; alt e.node { expr_assign(_, ex) | expr_unary(box(_), ex) | expr_unary(uniq(_), ex) | @@ -296,10 +296,10 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { }; if vec::len(ts) != vec::len(*bounds) { // Fail earlier to make debugging easier - fail #fmt("Internal error: in kind::check_expr, length \ + fail fmt!{"Internal error: in kind::check_expr, length \ mismatch between actual and declared bounds: actual = \ %s (%u tys), declared = %? (%u tys)", - tys_to_str(cx.tcx, ts), ts.len(), *bounds, (*bounds).len()); + tys_to_str(cx.tcx, ts), ts.len(), *bounds, (*bounds).len()}; } do vec::iter2(ts, *bounds) |ty, bound| { check_bounds(cx, e.id, e.span, ty, bound) @@ -419,7 +419,7 @@ fn check_imm_free_var(cx: ctx, def: def, sp: span) { _ { cx.tcx.sess.span_bug( sp, - #fmt["unknown def for free variable: %?", def]); + fmt!{"unknown def for free variable: %?", def}); } } } @@ -510,7 +510,7 @@ fn check_cast_for_escaping_regions( some(ty::re_bound(*)) | some(ty::re_var(*)) => { cx.tcx.sess.span_bug( source.span, - #fmt["bad region found in kind: %?", target_substs.self_r]); + fmt!{"bad region found in kind: %?", target_substs.self_r}); } } diff --git a/src/rustc/middle/lang_items.rs b/src/rustc/middle/lang_items.rs index 07704de1297..d14d2d5a0c6 100644 --- a/src/rustc/middle/lang_items.rs +++ b/src/rustc/middle/lang_items.rs @@ -132,8 +132,8 @@ class LanguageItemCollector { some(original_def_id) if original_def_id != item_def_id => { - self.session.err(#fmt("duplicate entry for `%s`", - value)); + self.session.err(fmt!{"duplicate entry for `%s`", + value}); } some(_) | none => { // OK. @@ -191,7 +191,7 @@ class LanguageItemCollector { for self.item_refs.each |key, item_ref| { alt copy *item_ref { none => { - self.session.err(#fmt("no item found for `%s`", key)); + self.session.err(fmt!{"no item found for `%s`", key}); } some(did) => { // OK. diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index e047a525eb5..94be6865094 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -253,8 +253,8 @@ impl methods for ctxt { self.span_lint( new_ctxt.get_level(unrecognized_lint), meta.span, - #fmt("unknown `%s` attribute: `%s`", - level_to_str(level), *lintname)); + fmt!{"unknown `%s` attribute: `%s`", + level_to_str(level), *lintname}); } some(lint) { @@ -263,9 +263,9 @@ impl methods for ctxt { self.span_lint( forbid, meta.span, - #fmt("%s(%s) overruled by outer forbid(%s)", + fmt!{"%s(%s) overruled by outer forbid(%s)", level_to_str(level), - *lintname, *lintname)); + *lintname, *lintname}); } // we do multiple unneeded copies of the @@ -435,7 +435,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, _body: ast::blk, span: span, id: ast::node_id) { - #debug["lint check_fn fk=%? id=%?", fk, id]; + debug!{"lint check_fn fk=%? id=%?", fk, id}; // don't complain about blocks, since they tend to get their modes // specified from the outside @@ -450,10 +450,10 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, let mut counter = 0; do vec::iter2(fn_ty.inputs, decl.inputs) |arg_ty, arg_ast| { counter += 1; - #debug["arg %d, ty=%s, mode=%s", + debug!{"arg %d, ty=%s, mode=%s", counter, ty_to_str(tcx, arg_ty.ty), - mode_to_str(arg_ast.mode)]; + mode_to_str(arg_ast.mode)}; alt arg_ast.mode { ast::expl(ast::by_copy) => { /* always allow by-copy */ @@ -463,7 +463,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, tcx.sess.span_lint( deprecated_mode, id, id, span, - #fmt["argument %d uses an explicit mode", counter]); + fmt!{"argument %d uses an explicit mode", counter}); } ast::infer(_) { @@ -472,9 +472,9 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, tcx.sess.span_lint( deprecated_mode, id, id, span, - #fmt["argument %d uses the default mode \ + fmt!{"argument %d uses the default mode \ but shouldn't", - counter]); + counter}); } } } diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 98bf1ac32bf..e7d88b9b2b8 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} } } // ______________________________________________________________________ @@ -243,7 +243,7 @@ class ir_maps { vec::push(self.lnks, lnk); self.num_live_nodes += 1u; - #debug["%s is of kind %?", ln.to_str(), lnk]; + debug!{"%s is of kind %?", ln.to_str(), lnk}; ln } @@ -252,7 +252,7 @@ class ir_maps { let ln = self.add_live_node(lnk); self.live_node_map.insert(node_id, ln); - #debug["%s is node %d", ln.to_str(), node_id]; + debug!{"%s is node %d", ln.to_str(), node_id}; } fn add_variable(vk: var_kind) -> variable { @@ -271,7 +271,7 @@ class ir_maps { } } - #debug["%s is %?", v.to_str(), vk]; + debug!{"%s is %?", v.to_str(), vk}; v } @@ -281,7 +281,7 @@ class ir_maps { some(var) {var} none { self.tcx.sess.span_bug( - span, #fmt("No variable registered for id %d", node_id)); + span, fmt!{"No variable registered for id %d", node_id}); } } } @@ -314,7 +314,7 @@ class ir_maps { fn add_last_use(expr_id: node_id, var: variable) { let vk = self.var_kinds[*var]; - #debug["Node %d is a last use of variable %?", expr_id, vk]; + debug!{"Node %d is a last use of variable %?", expr_id, vk}; alt vk { vk_arg(id, name, by_move) | vk_arg(id, name, by_copy) | @@ -332,7 +332,7 @@ class ir_maps { } vk_arg(_, _, by_ref) | vk_arg(_, _, by_mutbl_ref) | vk_arg(_, _, by_val) | vk_self | vk_field(_) | vk_implicit_ret { - #debug["--but it is not owned"]; + debug!{"--but it is not owned"}; } } } @@ -340,17 +340,17 @@ class ir_maps { fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, id: node_id, &&self: @ir_maps, v: vt<@ir_maps>) { - #debug["visit_fn: id=%d", id]; + debug!{"visit_fn: id=%d", id}; let _i = util::common::indenter(); // swap in a new set of IR maps for this function body: let fn_maps = @ir_maps(self.tcx, self.method_map, self.last_use_map); - #debug["creating fn_maps: %x", ptr::addr_of(*fn_maps) as uint]; + debug!{"creating fn_maps: %x", ptr::addr_of(*fn_maps) as uint}; for decl.inputs.each |arg| { - #debug["adding argument %d", arg.id]; + debug!{"adding argument %d", arg.id}; let mode = ty::resolved_mode(self.tcx, arg.mode); (*fn_maps).add_variable(vk_arg(arg.id, arg.ident, mode)); }; @@ -405,7 +405,7 @@ fn add_class_fields(self: @ir_maps, did: def_id) { fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) { let def_map = self.tcx.def_map; do pat_util::pat_bindings(def_map, local.node.pat) |p_id, sp, path| { - #debug["adding local variable %d", p_id]; + debug!{"adding local variable %d", p_id}; let name = ast_util::path_to_ident(path); (*self).add_live_node_for_node(p_id, lnk_vdef(sp)); (*self).add_variable(vk_local(p_id, name)); @@ -418,7 +418,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { // live nodes required for uses or definitions of variables: expr_path(_) { let def = self.tcx.def_map.get(expr.id); - #debug["expr %d: path that leads to %?", expr.id, def]; + debug!{"expr %d: path that leads to %?", expr.id, def}; if relevant_def(def).is_some() { (*self).add_live_node_for_node(expr.id, lnk_expr(expr.span)); } @@ -540,8 +540,8 @@ class liveness { // code have to agree about which AST nodes are worth // creating liveness nodes for. self.tcx.sess.span_bug( - span, #fmt["No live node registered for node %d", - node_id]); + span, fmt!{"No live node registered for node %d", + node_id}); } } } @@ -664,7 +664,7 @@ class liveness { wr.write_str(~"[ln("); wr.write_uint(*ln); wr.write_str(~") of kind "); - wr.write_str(#fmt["%?", copy self.ir.lnks[*ln]]); + wr.write_str(fmt!{"%?", copy self.ir.lnks[*ln]}); wr.write_str(~" reads"); self.write_vars(wr, ln, |idx| self.users[idx].reader ); wr.write_str(~" writes"); @@ -695,8 +695,8 @@ class liveness { self.indices2(ln, succ_ln, |idx, succ_idx| { self.users[idx] = self.users[succ_idx] }); - #debug["init_from_succ(ln=%s, succ=%s)", - self.ln_str(ln), self.ln_str(succ_ln)]; + debug!{"init_from_succ(ln=%s, succ=%s)", + self.ln_str(ln), self.ln_str(succ_ln)}; } fn merge_from_succ(ln: live_node, succ_ln: live_node, @@ -715,8 +715,8 @@ class liveness { } } - #debug["merge_from_succ(ln=%s, succ=%s, first_merge=%b, changed=%b)", - ln.to_str(), self.ln_str(succ_ln), first_merge, changed]; + debug!{"merge_from_succ(ln=%s, succ=%s, first_merge=%b, changed=%b)", + ln.to_str(), self.ln_str(succ_ln), first_merge, changed}; ret changed; fn copy_if_invalid(src: live_node, &dst: live_node) -> bool { @@ -738,8 +738,8 @@ class liveness { self.users[idx].reader = invalid_node(); self.users[idx].writer = invalid_node(); - #debug["%s defines %s (idx=%u): %s", writer.to_str(), var.to_str(), - idx, self.ln_str(writer)]; + debug!{"%s defines %s (idx=%u): %s", writer.to_str(), var.to_str(), + idx, self.ln_str(writer)}; } // Either read, write, or both depending on the acc bitset @@ -762,8 +762,8 @@ class liveness { self.users[idx].used = true; } - #debug["%s accesses[%x] %s: %s", - ln.to_str(), acc, var.to_str(), self.ln_str(ln)]; + debug!{"%s accesses[%x] %s: %s", + ln.to_str(), acc, var.to_str(), self.ln_str(ln)}; } // _______________________________________________________________________ @@ -778,14 +778,14 @@ class liveness { }); // hack to skip the loop unless #debug is enabled: - #debug["^^ liveness computation results for body %d (entry=%s)", + debug!{"^^ liveness computation results for body %d (entry=%s)", { for uint::range(0u, self.ir.num_live_nodes) |ln_idx| { #debug["%s", self.ln_str(live_node(ln_idx))]; } body.node.id }, - entry_ln.to_str()]; + entry_ln.to_str()}; entry_ln } @@ -1373,7 +1373,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { // No initializer: the variable might be unused; if not, it // should not be live at this point. - #debug["check_local() with no initializer"]; + debug!{"check_local() with no initializer"}; do (*self).pat_bindings(local.node.pat) |ln, var, sp| { if !self.warn_about_unused(sp, ln, var) { alt (*self).live_on_exit(ln, var) { @@ -1487,7 +1487,7 @@ impl check_methods for @liveness { none { /* ok */ } some(lnk_exit) { self.tcx.sess.span_err( - sp, #fmt["field `self.%s` is never initialized", *nm]); + sp, fmt!{"field `self.%s` is never initialized", *nm}); } some(lnk) { self.report_illegal_read( @@ -1525,8 +1525,8 @@ impl check_methods for @liveness { } fn check_move_from_var(span: span, ln: live_node, var: variable) { - #debug["check_move_from_var(%s, %s)", - ln.to_str(), var.to_str()]; + debug!{"check_move_from_var(%s, %s)", + ln.to_str(), var.to_str()}; alt (*self).live_on_exit(ln, var) { none { } @@ -1546,8 +1546,8 @@ impl check_methods for @liveness { } fn check_move_from_expr(expr: @expr, vt: vt<@liveness>) { - #debug["check_move_from_expr(node %d: %s)", - expr.id, expr_to_str(expr)]; + debug!{"check_move_from_expr(node %d: %s)", + expr.id, expr_to_str(expr)}; if self.ir.method_map.contains_key(expr.id) { // actually an rvalue, since this calls a method @@ -1643,7 +1643,7 @@ impl check_methods for @liveness { some(lnk) { self.tcx.sess.span_bug( orig_span, - #fmt["illegal writer: %?", lnk]); + fmt!{"illegal writer: %?", lnk}); } none {} } @@ -1662,14 +1662,14 @@ impl check_methods for @liveness { vk_arg(_, name, _) { self.tcx.sess.span_err( move_span, - #fmt["illegal move from argument `%s`, which is not \ - copy or move mode", *name]); + fmt!{"illegal move from argument `%s`, which is not \ + copy or move mode", *name}); ret; } vk_field(name) { self.tcx.sess.span_err( move_span, - #fmt["illegal move from field `%s`", *name]); + fmt!{"illegal move from field `%s`", *name}); ret; } vk_self { @@ -1682,8 +1682,8 @@ impl check_methods for @liveness { vk_local(*) | vk_implicit_ret { self.tcx.sess.span_bug( move_span, - #fmt["illegal reader (%?) for `%?`", - lnk, vk]); + fmt!{"illegal reader (%?) for `%?`", + lnk, vk}); } } } @@ -1708,18 +1708,18 @@ impl check_methods for @liveness { lnk_freevar(span) { self.tcx.sess.span_err( span, - #fmt["capture of %s: `%s`", msg, *name]); + fmt!{"capture of %s: `%s`", msg, *name}); } lnk_expr(span) { self.tcx.sess.span_err( span, - #fmt["use of %s: `%s`", msg, *name]); + fmt!{"use of %s: `%s`", msg, *name}); } lnk_exit | lnk_vdef(_) { self.tcx.sess.span_bug( chk_span, - #fmt["illegal reader: %?", lnk]); + fmt!{"illegal reader: %?", lnk}); } } } @@ -1776,11 +1776,11 @@ impl check_methods for @liveness { if is_assigned { self.tcx.sess.span_warn( - sp, #fmt["variable `%s` is assigned to, \ - but never used", *name]); + sp, fmt!{"variable `%s` is assigned to, \ + but never used", *name}); } else { self.tcx.sess.span_warn( - sp, #fmt["unused variable: `%s`", *name]); + sp, fmt!{"unused variable: `%s`", *name}); } } ret true; @@ -1793,7 +1793,7 @@ impl check_methods for @liveness { for self.should_warn(var).each |name| { self.tcx.sess.span_warn( sp, - #fmt["value assigned to `%s` is never read", *name]); + fmt!{"value assigned to `%s` is never read", *name}); } } } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index d0dc1ea28f7..e6b2209b44a 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -187,7 +187,7 @@ fn record_parent(cx: ctxt, child_id: ast::node_id) { alt cx.parent { none { /* no-op */ } some(parent_id) { - #debug["parent of node %d is node %d", child_id, parent_id]; + debug!{"parent of node %d is node %d", child_id, parent_id}; cx.region_map.insert(child_id, parent_id); } } @@ -232,11 +232,11 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) { let mut new_cx = cx; alt expr.node { ast::expr_call(*) => { - #debug["node %d: %s", expr.id, pprust::expr_to_str(expr)]; + debug!{"node %d: %s", expr.id, pprust::expr_to_str(expr)}; new_cx.parent = some(expr.id); } ast::expr_alt(subexpr, _, _) => { - #debug["node %d: %s", expr.id, pprust::expr_to_str(expr)]; + debug!{"node %d: %s", expr.id, pprust::expr_to_str(expr)}; new_cx.parent = some(expr.id); } ast::expr_fn(_, _, _, cap_clause) | @@ -289,9 +289,9 @@ fn resolve_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, } }; - #debug["visiting fn with body %d. cx.parent: %? \ + debug!{"visiting fn with body %d. cx.parent: %? \ fn_cx.parent: %?", - body.node.id, cx.parent, fn_cx.parent]; + body.node.id, cx.parent, fn_cx.parent}; for decl.inputs.each |input| { cx.region_map.insert(input.id, body.node.id); @@ -367,19 +367,19 @@ impl methods for determine_rp_ctxt { fn add_rp(id: ast::node_id) { assert id != 0; if self.region_paramd_items.insert(id, ()) { - #debug["add region-parameterized item: %d (%s)", - id, ast_map::node_id_to_str(self.ast_map, id)]; + debug!{"add region-parameterized item: %d (%s)", + id, ast_map::node_id_to_str(self.ast_map, id)}; self.worklist.push(id); } else { - #debug["item %d already region-parameterized", id]; + debug!{"item %d already region-parameterized", id}; } } fn add_dep(from: ast::node_id, to: ast::node_id) { - #debug["add dependency from %d -> %d (%s -> %s)", + debug!{"add dependency from %d -> %d (%s -> %s)", from, to, ast_map::node_id_to_str(self.ast_map, from), - ast_map::node_id_to_str(self.ast_map, to)]; + ast_map::node_id_to_str(self.ast_map, to)}; let vec = alt self.dep_map.find(from) { some(vec) => {vec} none => { @@ -436,7 +436,7 @@ impl methods for determine_rp_ctxt { let old_anon_implies_rp = self.anon_implies_rp; self.item_id = item_id; self.anon_implies_rp = anon_implies_rp; - #debug["with_item_id(%d, %b)", item_id, anon_implies_rp]; + debug!{"with_item_id(%d, %b)", item_id, anon_implies_rp}; let _i = util::common::indenter(); f(); self.item_id = old_item_id; @@ -488,7 +488,7 @@ fn determine_rp_in_ty(ty: @ast::ty, alt ty.node { ast::ty_rptr(r, _) | ast::ty_path(@{rp: some(r), _}, _) => { - #debug["referenced type with regions %s", pprust::ty_to_str(ty)]; + debug!{"referenced type with regions %s", pprust::ty_to_str(ty)}; if cx.region_is_relevant(r) { cx.add_rp(cx.item_id); } @@ -510,8 +510,8 @@ fn determine_rp_in_ty(ty: @ast::ty, } else { let cstore = cx.sess.cstore; if csearch::get_region_param(cstore, did) { - #debug["reference to external, rp'd type %s", - pprust::ty_to_str(ty)]; + debug!{"reference to external, rp'd type %s", + pprust::ty_to_str(ty)}; cx.add_rp(cx.item_id); } } @@ -560,7 +560,7 @@ fn determine_rp_in_crate(sess: session, // propagate indirect dependencies while cx.worklist.len() != 0 { let id = cx.worklist.pop(); - #debug["popped %d from worklist", id]; + debug!{"popped %d from worklist", id}; alt cx.dep_map.find(id) { none {} some(vec) { diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index c49a6889f05..1965d5289be 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -1218,9 +1218,9 @@ class Resolver { if self.block_needs_anonymous_module(block) { let block_id = block.node.id; - #debug("(building reduced graph for block) creating a new \ + debug!{"(building reduced graph for block) creating a new \ anonymous module for block %d", - block_id); + block_id}; let parent_module = self.get_module_from_parent(parent); let new_module = @Module(BlockParentLink(parent_module, block_id), @@ -1245,10 +1245,10 @@ class Resolver { for each_path(self.session.cstore, get(root.def_id).crate) |path_entry| { - #debug("(building reduced graph for external crate) found path \ + debug!{"(building reduced graph for external crate) found path \ entry: %s (%?)", path_entry.path_string, - path_entry.def_like); + path_entry.def_like}; let mut pieces = split_str(path_entry.path_string, ~"::"); let final_ident = pop(pieces); @@ -1267,8 +1267,8 @@ class Resolver { // Define or reuse the module node. alt child_name_bindings.module_def { NoModuleDef { - #debug("(building reduced graph for external crate) \ - autovivifying %s", ident); + debug!{"(building reduced graph for external crate) \ + autovivifying %s", ident}; let parent_link = self.get_parent_link(new_parent, atom); (*child_name_bindings).define_module(parent_link, @@ -1292,9 +1292,9 @@ class Resolver { def_mod(def_id) | def_foreign_mod(def_id) { alt copy child_name_bindings.module_def { NoModuleDef { - #debug("(building reduced graph for \ + debug!{"(building reduced graph for \ external crate) building module \ - %s", final_ident); + %s", final_ident}; let parent_link = self.get_parent_link(new_parent, atom); @@ -1339,10 +1339,10 @@ class Resolver { } } - #debug("(building reduced graph \ + debug!{"(building reduced graph \ for external crate) \ ... creating import \ - resolution"); + resolution"}; new_parent.import_resolutions. insert(atom, resolution); @@ -1350,9 +1350,9 @@ class Resolver { } } ModuleDef(module) { - #debug("(building reduced graph for \ + debug!{"(building reduced graph for \ external crate) already created \ - module"); + module"}; module.def_id = some(def_id); modules.insert(def_id, module); } @@ -1360,13 +1360,13 @@ class Resolver { } def_fn(def_id, _) | def_const(def_id) | def_variant(_, def_id) { - #debug("(building reduced graph for external \ - crate) building value %s", final_ident); + debug!{"(building reduced graph for external \ + crate) building value %s", final_ident}; (*child_name_bindings).define_value(def); } def_ty(def_id) { - #debug("(building reduced graph for external \ - crate) building type %s", final_ident); + debug!{"(building reduced graph for external \ + crate) building type %s", final_ident}; // If this is a trait, add all the method names // to the trait info. @@ -1380,10 +1380,10 @@ class Resolver { let interned_method_names = @atom_hashmap(); for method_names.each |method_name| { - #debug("(building reduced graph for \ + debug!{"(building reduced graph for \ external crate) ... adding \ trait method '%?'", - method_name); + method_name}; let atom = (*self.atom_table).intern (method_name); @@ -1398,10 +1398,10 @@ class Resolver { (*child_name_bindings).define_type(def); } def_class(def_id, has_constructor) { - #debug("(building reduced graph for external \ + debug!{"(building reduced graph for external \ crate) building type %s (value? %d)", final_ident, - if has_constructor { 1 } else { 0 }); + if has_constructor { 1 } else { 0 }}; (*child_name_bindings).define_type(def); if has_constructor { @@ -1412,7 +1412,7 @@ class Resolver { def_prim_ty(*) | def_ty_param(*) | def_binding(*) | def_use(*) | def_upvar(*) | def_region(*) | def_typaram_binder(*) { - fail #fmt("didn't expect `%?`", def); + fail fmt!{"didn't expect `%?`", def}; } } } @@ -1421,12 +1421,12 @@ class Resolver { // written, we can't process this impl now. We'll get it // later. - #debug("(building reduced graph for external crate) \ - ignoring impl %s", final_ident); + debug!{"(building reduced graph for external crate) \ + ignoring impl %s", final_ident}; } dl_field { - #debug("(building reduced graph for external crate) \ - ignoring field %s", final_ident); + debug!{"(building reduced graph for external crate) \ + ignoring field %s", final_ident}; } } } @@ -1462,16 +1462,16 @@ class Resolver { // by the fact that they have no def ID, which we do here in order to // skip them. - #debug("(building reduced graph for impls in external crate) looking \ + debug!{"(building reduced graph for impls in external crate) looking \ for impls in `%s` (%?)", self.module_to_str(module), - copy module.def_id); + copy module.def_id}; alt module.def_id { none { - #debug("(building reduced graph for impls in external \ + debug!{"(building reduced graph for impls in external \ module) no def ID for `%s`, skipping", - self.module_to_str(module)); + self.module_to_str(module)}; ret; } some(_) { @@ -1492,11 +1492,11 @@ class Resolver { } def_ids.insert(implementation.did, ()); - #debug("(building reduced graph for impls in external module) \ + debug!{"(building reduced graph for impls in external module) \ added impl `%s` (%?) to `%s`", *implementation.ident, implementation.did, - self.module_to_str(module)); + self.module_to_str(module)}; let name = (*self.atom_table).intern(implementation.ident); @@ -1559,14 +1559,14 @@ class Resolver { let mut i = 0u; let mut prev_unresolved_imports = 0u; loop { - #debug("(resolving imports) iteration %u, %u imports left", - i, self.unresolved_imports); + debug!{"(resolving imports) iteration %u, %u imports left", + i, self.unresolved_imports}; let module_root = (*self.graph_root).get_module(); self.resolve_imports_for_module_subtree(module_root); if self.unresolved_imports == 0u { - #debug("(resolving imports) success"); + debug!{"(resolving imports) success"}; break; } @@ -1586,8 +1586,8 @@ class Resolver { * submodules. */ fn resolve_imports_for_module_subtree(module: @Module) { - #debug("(resolving imports for module subtree) resolving %s", - self.module_to_str(module)); + debug!{"(resolving imports for module subtree) resolving %s", + self.module_to_str(module)}; self.resolve_imports_for_module(module); for module.children.each |_name, child_node| { @@ -1609,9 +1609,9 @@ class Resolver { /// Attempts to resolve imports for the given module only. fn resolve_imports_for_module(module: @Module) { if (*module).all_imports_resolved() { - #debug("(resolving imports for module) all imports resolved for \ + debug!{"(resolving imports for module) all imports resolved for \ %s", - self.module_to_str(module)); + self.module_to_str(module)}; ret; } @@ -1652,10 +1652,10 @@ class Resolver { let mut resolution_result; let module_path = import_directive.module_path; - #debug("(resolving import for module) resolving import `%s::...` in \ + debug!{"(resolving import for module) resolving import `%s::...` in \ `%s`", *(*self.atom_table).atoms_to_str((*module_path).get()), - self.module_to_str(module)); + self.module_to_str(module)}; // One-level renaming imports of the form `import foo = bar;` are // handled specially. @@ -1736,16 +1736,16 @@ class Resolver { target: Atom, source: Atom) -> ResolveResult<()> { - #debug("(resolving single import) resolving `%s` = `%s::%s` from \ + debug!{"(resolving single import) resolving `%s` = `%s::%s` from \ `%s`", *(*self.atom_table).atom_to_str(target), self.module_to_str(containing_module), *(*self.atom_table).atom_to_str(source), - self.module_to_str(module)); + self.module_to_str(module)}; if !self.name_is_exported(containing_module, source) { - #debug("(resolving single import) name `%s` is unexported", - *(*self.atom_table).atom_to_str(source)); + debug!{"(resolving single import) name `%s` is unexported", + *(*self.atom_table).atom_to_str(source)}; ret Failed; } @@ -1800,8 +1800,8 @@ class Resolver { // able to resolve this import. if containing_module.glob_count > 0u { - #debug("(resolving single import) unresolved glob; \ - bailing out"); + debug!{"(resolving single import) unresolved glob; \ + bailing out"}; ret Indeterminate; } @@ -1883,8 +1883,8 @@ class Resolver { } some(_) { // The import is unresolved. Bail out. - #debug("(resolving single import) unresolved import; \ - bailing out"); + debug!{"(resolving single import) unresolved import; \ + bailing out"}; ret Indeterminate; } } @@ -1897,13 +1897,13 @@ class Resolver { alt module_result { BoundResult(target_module, name_bindings) { - #debug("(resolving single import) found module binding"); + debug!{"(resolving single import) found module binding"}; import_resolution.module_target = some(Target(target_module, name_bindings)); } UnboundResult { - #debug("(resolving single import) didn't find module \ - binding"); + debug!{"(resolving single import) didn't find module \ + binding"}; } UnknownResult { fail ~"module result should be known at this point"; @@ -1954,7 +1954,7 @@ class Resolver { assert import_resolution.outstanding_references >= 1u; import_resolution.outstanding_references -= 1u; - #debug("(resolving single import) successfully resolved import"); + debug!{"(resolving single import) successfully resolved import"}; ret Success(()); } @@ -1976,8 +1976,8 @@ class Resolver { // (including globs). if !(*containing_module).all_imports_resolved() { - #debug("(resolving glob import) target module has unresolved \ - imports; bailing out"); + debug!{"(resolving glob import) target module has unresolved \ + imports; bailing out"}; ret Indeterminate; } @@ -1988,15 +1988,15 @@ class Resolver { |atom, target_import_resolution| { if !self.name_is_exported(containing_module, atom) { - #debug("(resolving glob import) name `%s` is unexported", - *(*self.atom_table).atom_to_str(atom)); + debug!{"(resolving glob import) name `%s` is unexported", + *(*self.atom_table).atom_to_str(atom)}; again; } - #debug("(resolving glob import) writing module resolution \ + debug!{"(resolving glob import) writing module resolution \ %? into `%s`", is_none(target_import_resolution.module_target), - self.module_to_str(module)); + self.module_to_str(module)}; // Here we merge two import resolutions. alt module.import_resolutions.find(atom) { @@ -2065,8 +2065,8 @@ class Resolver { // Add all children from the containing module. for containing_module.children.each |atom, name_bindings| { if !self.name_is_exported(containing_module, atom) { - #debug("(resolving glob import) name `%s` is unexported", - *(*self.atom_table).atom_to_str(atom)); + debug!{"(resolving glob import) name `%s` is unexported", + *(*self.atom_table).atom_to_str(atom)}; again; } @@ -2084,36 +2084,36 @@ class Resolver { } - #debug("(resolving glob import) writing resolution `%s` in `%s` \ + debug!{"(resolving glob import) writing resolution `%s` in `%s` \ to `%s`", *(*self.atom_table).atom_to_str(atom), self.module_to_str(containing_module), - self.module_to_str(module)); + self.module_to_str(module)}; // Merge the child item into the import resolution. if (*name_bindings).defined_in_namespace(ModuleNS) { - #debug("(resolving glob import) ... for module target"); + debug!{"(resolving glob import) ... for module target"}; dest_import_resolution.module_target = some(Target(containing_module, name_bindings)); } if (*name_bindings).defined_in_namespace(ValueNS) { - #debug("(resolving glob import) ... for value target"); + debug!{"(resolving glob import) ... for value target"}; dest_import_resolution.value_target = some(Target(containing_module, name_bindings)); } if (*name_bindings).defined_in_namespace(TypeNS) { - #debug("(resolving glob import) ... for type target"); + debug!{"(resolving glob import) ... for type target"}; dest_import_resolution.type_target = some(Target(containing_module, name_bindings)); } if (*name_bindings).defined_in_namespace(ImplNS) { - #debug("(resolving glob import) ... for impl target"); + debug!{"(resolving glob import) ... for impl target"}; (*dest_import_resolution.impl_target).push (@Target(containing_module, name_bindings)); } } - #debug("(resolving glob import) successfully resolved import"); + debug!{"(resolving glob import) successfully resolved import"}; ret Success(()); } @@ -2142,9 +2142,9 @@ class Resolver { ret Failed; } Indeterminate { - #debug("(resolving module path for import) module \ + debug!{"(resolving module path for import) module \ resolution is indeterminate: %s", - *(*self.atom_table).atom_to_str(name)); + *(*self.atom_table).atom_to_str(name)}; ret Indeterminate; } Success(target) { @@ -2152,9 +2152,9 @@ class Resolver { NoModuleDef { // Not a module. self.session.span_err(span, - #fmt("not a module: %s", + fmt!{"not a module: %s", *(*self.atom_table). - atom_to_str(name))); + atom_to_str(name)}); ret Failed; } ModuleDef(module) { @@ -2183,10 +2183,10 @@ class Resolver { let module_path_len = (*module_path).len(); assert module_path_len > 0u; - #debug("(resolving module path for import) processing `%s` rooted at \ + debug!{"(resolving module path for import) processing `%s` rooted at \ `%s`", *(*self.atom_table).atoms_to_str((*module_path).get()), - self.module_to_str(module)); + self.module_to_str(module)}; // The first element of the module path must be in the current scope // chain. @@ -2199,8 +2199,8 @@ class Resolver { ret Failed; } Indeterminate { - #debug("(resolving module path for import) indeterminate; \ - bailing"); + debug!{"(resolving module path for import) indeterminate; \ + bailing"}; ret Indeterminate; } Success(resulting_module) { @@ -2220,11 +2220,11 @@ class Resolver { namespace: Namespace) -> ResolveResult<Target> { - #debug("(resolving item in lexical scope) resolving `%s` in \ + debug!{"(resolving item in lexical scope) resolving `%s` in \ namespace %? in `%s`", *(*self.atom_table).atom_to_str(name), namespace, - self.module_to_str(module)); + self.module_to_str(module)}; // The current module node is handled specially. First, check for // its immediate children. @@ -2251,9 +2251,9 @@ class Resolver { alt (*import_resolution).target_for_namespace(namespace) { none { // Not found; continue. - #debug("(resolving item in lexical scope) found \ + debug!{"(resolving item in lexical scope) found \ import resolution, but not in namespace %?", - namespace); + namespace}; } some(target) { import_resolution.used = true; @@ -2270,8 +2270,8 @@ class Resolver { alt search_module.parent_link { NoParentLink { // No more parents. This module was unresolved. - #debug("(resolving item in lexical scope) unresolved \ - module"); + debug!{"(resolving item in lexical scope) unresolved \ + module"}; ret Failed; } ModuleParentLink(parent_module_node, _) | @@ -2290,8 +2290,8 @@ class Resolver { // We couldn't see through the higher scope because of an // unresolved import higher up. Bail. - #debug("(resolving item in lexical scope) indeterminate \ - higher scope; bailing"); + debug!{"(resolving item in lexical scope) indeterminate \ + higher scope; bailing"}; ret Indeterminate; } Success(target) { @@ -2309,8 +2309,8 @@ class Resolver { Success(target) { alt target.bindings.module_def { NoModuleDef { - #error("!!! (resolving module in lexical scope) module - wasn't actually a module!"); + error!{"!!! (resolving module in lexical scope) module + wasn't actually a module!"}; ret Failed; } ModuleDef(module) { @@ -2319,13 +2319,13 @@ class Resolver { } } Indeterminate { - #debug("(resolving module in lexical scope) indeterminate; \ - bailing"); + debug!{"(resolving module in lexical scope) indeterminate; \ + bailing"}; ret Indeterminate; } Failed { - #debug("(resolving module in lexical scope) failed to \ - resolve"); + debug!{"(resolving module in lexical scope) failed to \ + resolve"}; ret Failed; } } @@ -2347,13 +2347,13 @@ class Resolver { xray: XrayFlag) -> ResolveResult<Target> { - #debug("(resolving name in module) resolving `%s` in `%s`", + debug!{"(resolving name in module) resolving `%s` in `%s`", *(*self.atom_table).atom_to_str(name), - self.module_to_str(module)); + self.module_to_str(module)}; if xray == NoXray && !self.name_is_exported(module, name) { - #debug("(resolving name in module) name `%s` is unexported", - *(*self.atom_table).atom_to_str(name)); + debug!{"(resolving name in module) name `%s` is unexported", + *(*self.atom_table).atom_to_str(name)}; ret Failed; } @@ -2362,7 +2362,7 @@ class Resolver { some(name_bindings) if (*name_bindings).defined_in_namespace(namespace) { - #debug("(resolving name in module) found node as child"); + debug!{"(resolving name in module) found node as child"}; ret Success(Target(module, name_bindings)); } some(_) | none { @@ -2374,7 +2374,7 @@ class Resolver { // we bail out; we don't know its imports yet. if module.glob_count > 0u { - #debug("(resolving name in module) module has glob; bailing out"); + debug!{"(resolving name in module) module has glob; bailing out"}; ret Indeterminate; } @@ -2382,20 +2382,20 @@ class Resolver { alt module.import_resolutions.find(name) { some(import_resolution) { if import_resolution.outstanding_references != 0u { - #debug("(resolving name in module) import unresolved; \ - bailing out"); + debug!{"(resolving name in module) import unresolved; \ + bailing out"}; ret Indeterminate; } alt (*import_resolution).target_for_namespace(namespace) { none { - #debug("(resolving name in module) name found, but \ + debug!{"(resolving name in module) name found, but \ not in namespace %?", - namespace); + namespace}; } some(target) { - #debug("(resolving name in module) resolved to \ - import"); + debug!{"(resolving name in module) resolved to \ + import"}; import_resolution.used = true; ret Success(copy target); } @@ -2407,8 +2407,8 @@ class Resolver { } // We're out of luck. - #debug("(resolving name in module) failed to resolve %s", - *(*self.atom_table).atom_to_str(name)); + debug!{"(resolving name in module) failed to resolve %s", + *(*self.atom_table).atom_to_str(name)}; ret Failed; } @@ -2433,81 +2433,81 @@ class Resolver { } } - #debug("(resolving one-level naming result) resolving import `%s` = \ + debug!{"(resolving one-level naming result) resolving import `%s` = \ `%s` in `%s`", *(*self.atom_table).atom_to_str(target_name), *(*self.atom_table).atom_to_str(source_name), - self.module_to_str(module)); + self.module_to_str(module)}; // Find the matching items in the lexical scope chain for every // namespace. If any of them come back indeterminate, this entire // import is indeterminate. let mut module_result; - #debug("(resolving one-level naming result) searching for module"); + debug!{"(resolving one-level naming result) searching for module"}; alt self.resolve_item_in_lexical_scope(module, source_name, ModuleNS) { Failed { - #debug("(resolving one-level renaming import) didn't find \ - module result"); + debug!{"(resolving one-level renaming import) didn't find \ + module result"}; module_result = none; } Indeterminate { - #debug("(resolving one-level renaming import) module result \ - is indeterminate; bailing"); + debug!{"(resolving one-level renaming import) module result \ + is indeterminate; bailing"}; ret Indeterminate; } Success(name_bindings) { - #debug("(resolving one-level renaming import) module result \ - found"); + debug!{"(resolving one-level renaming import) module result \ + found"}; module_result = some(copy name_bindings); } } let mut value_result; - #debug("(resolving one-level naming result) searching for value"); + debug!{"(resolving one-level naming result) searching for value"}; alt self.resolve_item_in_lexical_scope(module, source_name, ValueNS) { Failed { - #debug("(resolving one-level renaming import) didn't find \ - value result"); + debug!{"(resolving one-level renaming import) didn't find \ + value result"}; value_result = none; } Indeterminate { - #debug("(resolving one-level renaming import) value result \ - is indeterminate; bailing"); + debug!{"(resolving one-level renaming import) value result \ + is indeterminate; bailing"}; ret Indeterminate; } Success(name_bindings) { - #debug("(resolving one-level renaming import) value result \ - found"); + debug!{"(resolving one-level renaming import) value result \ + found"}; value_result = some(copy name_bindings); } } let mut type_result; - #debug("(resolving one-level naming result) searching for type"); + debug!{"(resolving one-level naming result) searching for type"}; alt self.resolve_item_in_lexical_scope(module, source_name, TypeNS) { Failed { - #debug("(resolving one-level renaming import) didn't find \ - type result"); + debug!{"(resolving one-level renaming import) didn't find \ + type result"}; type_result = none; } Indeterminate { - #debug("(resolving one-level renaming import) type result is \ - indeterminate; bailing"); + debug!{"(resolving one-level renaming import) type result is \ + indeterminate; bailing"}; ret Indeterminate; } Success(name_bindings) { - #debug("(resolving one-level renaming import) type result \ - found"); + debug!{"(resolving one-level renaming import) type result \ + found"}; type_result = some(copy name_bindings); } } @@ -2530,24 +2530,24 @@ class Resolver { // let mut impl_result; - #debug("(resolving one-level naming result) searching for impl"); + debug!{"(resolving one-level naming result) searching for impl"}; alt self.resolve_item_in_lexical_scope(module, source_name, ImplNS) { Failed { - #debug("(resolving one-level renaming import) didn't find \ - impl result"); + debug!{"(resolving one-level renaming import) didn't find \ + impl result"}; impl_result = none; } Indeterminate { - #debug("(resolving one-level renaming import) impl result is \ - indeterminate; bailing"); + debug!{"(resolving one-level renaming import) impl result is \ + indeterminate; bailing"}; ret Indeterminate; } Success(name_bindings) { - #debug("(resolving one-level renaming import) impl result \ - found"); + debug!{"(resolving one-level renaming import) impl result \ + found"}; impl_result = some(@copy name_bindings); } } @@ -2569,11 +2569,11 @@ class Resolver { import resolution name by now"; } some(import_resolution) { - #debug("(resolving one-level renaming import) writing module \ + debug!{"(resolving one-level renaming import) writing module \ result %? for `%s` into `%s`", is_none(module_result), *(*self.atom_table).atom_to_str(target_name), - self.module_to_str(module)); + self.module_to_str(module)}; import_resolution.module_target = module_result; import_resolution.value_target = value_result; @@ -2593,7 +2593,7 @@ class Resolver { } } - #debug("(resolving one-level renaming import) successfully resolved"); + debug!{"(resolving one-level renaming import) successfully resolved"}; ret Success(()); } @@ -2649,9 +2649,9 @@ class Resolver { } some(_) { // Bail out. - #debug("(recording exports for module subtree) not recording \ + debug!{"(recording exports for module subtree) not recording \ exports for `%s`", - self.module_to_str(module)); + self.module_to_str(module)}; ret; } } @@ -2735,9 +2735,9 @@ class Resolver { } some(_) { // Bail out. - #debug("(building impl scopes for module subtree) not \ + debug!{"(building impl scopes for module subtree) not \ resolving implementations for `%s`", - self.module_to_str(module)); + self.module_to_str(module)}; ret; } } @@ -2763,9 +2763,9 @@ class Resolver { fn build_impl_scope_for_module(module: @Module) { let mut impl_scope = ~[]; - #debug("(building impl scope for module) processing module %s (%?)", + debug!{"(building impl scope for module) processing module %s (%?)", self.module_to_str(module), - copy module.def_id); + copy module.def_id}; // Gather up all direct children implementations in the module. for module.children.each |_impl_name, child_name_bindings| { @@ -2774,20 +2774,20 @@ class Resolver { } } - #debug("(building impl scope for module) found %u impl(s) as direct \ + debug!{"(building impl scope for module) found %u impl(s) as direct \ children", - impl_scope.len()); + impl_scope.len()}; // Gather up all imports. for module.import_resolutions.each |_impl_name, import_resolution| { for (*import_resolution.impl_target).each |impl_target| { - #debug("(building impl scope for module) found impl def"); + debug!{"(building impl scope for module) found impl def"}; impl_scope += impl_target.bindings.impl_defs; } } - #debug("(building impl scope for module) found %u impl(s) in total", - impl_scope.len()); + debug!{"(building impl scope for module) found %u impl(s) in total", + impl_scope.len()}; // Determine the parent's implementation scope. let mut parent_impl_scopes; @@ -2840,17 +2840,17 @@ class Resolver { some(name) { alt orig_module.children.find(name) { none { - #debug("!!! (with scope) didn't find `%s` in `%s`", + debug!{"!!! (with scope) didn't find `%s` in `%s`", *(*self.atom_table).atom_to_str(name), - self.module_to_str(orig_module)); + self.module_to_str(orig_module)}; } some(name_bindings) { alt (*name_bindings).get_module_if_available() { none { - #debug("!!! (with scope) didn't find module \ + debug!{"!!! (with scope) didn't find module \ for `%s` in `%s`", *(*self.atom_table).atom_to_str(name), - self.module_to_str(orig_module)); + self.module_to_str(orig_module)}; } some(module) { self.current_module = module; @@ -2995,7 +2995,7 @@ class Resolver { // XXX: This shouldn't be unsafe! fn resolve_crate() unsafe { - #debug("(resolving crate) starting"); + debug!{"(resolving crate) starting"}; // To avoid a failure in metadata encoding later, we have to add the // crate-level implementation scopes @@ -3022,7 +3022,7 @@ class Resolver { } fn resolve_item(item: @item, visitor: ResolveVisitor) { - #debug("(resolving item) resolving %s", *item.ident); + debug!{"(resolving item) resolving %s", *item.ident}; // Items with the !resolve_unexported attribute are X-ray contexts. // This is used to allow the test runner to run unexported tests. @@ -3198,8 +3198,8 @@ class Resolver { for (*type_parameters).eachi |index, type_parameter| { let name = (*self.atom_table).intern(type_parameter.ident); - #debug("with_type_parameter_rib: %d %d", node_id, - type_parameter.id); + debug!{"with_type_parameter_rib: %d %d", node_id, + type_parameter.id}; let def_like = dl_def(def_ty_param (local_def(type_parameter.id), index + initial_index)); @@ -3304,8 +3304,8 @@ class Resolver { self.resolve_type(argument.ty, visitor); - #debug("(resolving function) recorded argument `%s`", - *(*self.atom_table).atom_to_str(name)); + debug!{"(resolving function) recorded argument `%s`", + *(*self.atom_table).atom_to_str(name)}; } self.resolve_type(declaration.output, visitor); @@ -3315,7 +3315,7 @@ class Resolver { // Resolve the function body. self.resolve_block(block, visitor); - #debug("(resolving function) leaving function"); + debug!{"(resolving function) leaving function"}; } (*self.value_ribs).pop(); @@ -3372,7 +3372,7 @@ class Resolver { // definition of the interface into the definition // map. - #debug("(resolving class) found trait def: %?", def); + debug!{"(resolving class) found trait def: %?", def}; self.record_def(interface.ref_id, def); @@ -3530,7 +3530,7 @@ class Resolver { visitor: ResolveVisitor) { // Write the implementations in scope into the module metadata. - #debug("(resolving module) resolving module ID %d", id); + debug!{"(resolving module) resolving module ID %d", id}; self.impl_map.insert(id, self.current_module.impl_scopes); visit_mod(module, span, id, (), visitor); @@ -3577,9 +3577,9 @@ class Resolver { */ for arm.pats.each |p| { do pat_util::pat_bindings(self.def_map, p) |_id, sp, pth| { - self.session.span_note(sp, #fmt("Treating %s as a variable \ + self.session.span_note(sp, fmt!{"Treating %s as a variable \ binding, because it does not denote any variant in scope", - path_to_str(pth))); + path_to_str(pth)}); } }; } @@ -3616,7 +3616,7 @@ class Resolver { } fn resolve_block(block: blk, visitor: ResolveVisitor) { - #debug("(resolving block) entering block"); + debug!{"(resolving block) entering block"}; (*self.value_ribs).push(@Rib(NormalRibKind)); // Move down in the graph, if there's an anonymous module rooted here. @@ -3624,8 +3624,8 @@ class Resolver { alt self.current_module.anonymous_children.find(block.node.id) { none { /* Nothing to do. */ } some(anonymous_module) { - #debug("(resolving block) found anonymous module, moving \ - down"); + debug!{"(resolving block) found anonymous module, moving \ + down"}; self.current_module = anonymous_module; } } @@ -3637,7 +3637,7 @@ class Resolver { self.current_module = orig_module; (*self.value_ribs).pop(); - #debug("(resolving block) leaving block"); + debug!{"(resolving block) leaving block"}; } fn resolve_type(ty: @ty, visitor: ResolveVisitor) { @@ -3652,8 +3652,8 @@ class Resolver { let mut result_def; alt self.resolve_path(path, TypeNS, true, visitor) { some(def) { - #debug("(resolving type) resolved `%s` to type", - *path.idents.last()); + debug!{"(resolving type) resolved `%s` to type", + *path.idents.last()}; result_def = some(def); } none { @@ -3690,17 +3690,17 @@ class Resolver { alt copy result_def { some(def) { // Write the result into the def map. - #debug("(resolving type) writing resolution for `%s` \ + debug!{"(resolving type) writing resolution for `%s` \ (id %d)", connect(path.idents.map(|x| *x), ~"::"), - path_id); + path_id}; self.record_def(path_id, def); } none { self.session.span_err - (ty.span, #fmt("use of undeclared type name `%s`", + (ty.span, fmt!{"use of undeclared type name `%s`", connect(path.idents.map(|x| *x), - ~"::"))); + ~"::")}); } } } @@ -3738,20 +3738,20 @@ class Resolver { alt self.resolve_enum_variant_or_const(atom) { FoundEnumVariant(def) if mode == RefutableMode { - #debug("(resolving pattern) resolving `%s` to \ + debug!{"(resolving pattern) resolving `%s` to \ enum variant", - *path.idents[0]); + *path.idents[0]}; self.record_def(pattern.id, def); } FoundEnumVariant(_) { self.session.span_err(pattern.span, - #fmt("declaration of `%s` \ + fmt!{"declaration of `%s` \ shadows an enum \ that's in scope", *(*self.atom_table). atom_to_str - (atom))); + (atom)}); } FoundConst { self.session.span_err(pattern.span, @@ -3760,8 +3760,8 @@ class Resolver { in scope"); } EnumVariantOrConstNotFound { - #debug("(resolving pattern) binding `%s`", - *path.idents[0]); + debug!{"(resolving pattern) binding `%s`", + *path.idents[0]}; let is_mutable = mutability == Mutable; @@ -3804,9 +3804,9 @@ class Resolver { // in the same disjunct, which is an // error self.session.span_err(pattern.span, - #fmt("Identifier %s is bound more \ + fmt!{"Identifier %s is bound more \ than once in the same pattern", - path_to_str(path))); + path_to_str(path)}); } // Not bound in the same pattern: do nothing } @@ -3833,9 +3833,9 @@ class Resolver { } some(_) { self.session.span_err(path.span, - #fmt("not an enum \ + fmt!{"not an enum \ variant: %s", - *path.idents.last())); + *path.idents.last()}); } none { self.session.span_err(path.span, @@ -3962,9 +3962,9 @@ class Resolver { -> NameDefinition { if xray == NoXray && !self.name_is_exported(containing_module, name) { - #debug("(resolving definition of name in module) name `%s` is \ + debug!{"(resolving definition of name in module) name `%s` is \ unexported", - *(*self.atom_table).atom_to_str(name)); + *(*self.atom_table).atom_to_str(name)}; ret NoNameDefinition; } @@ -4044,9 +4044,9 @@ class Resolver { Failed { self.session.span_err(path.span, - #fmt("use of undeclared module `%s`", + fmt!{"use of undeclared module `%s`", *(*self.atom_table).atoms_to_str - ((*module_path_atoms).get()))); + ((*module_path_atoms).get())}); ret none; } @@ -4067,11 +4067,11 @@ class Resolver { NoNameDefinition { // We failed to resolve the name. Report an error. self.session.span_err(path.span, - #fmt("unresolved name: %s::%s", + fmt!{"unresolved name: %s::%s", *(*self.atom_table).atoms_to_str ((*module_path_atoms).get()), *(*self.atom_table).atom_to_str - (name))); + (name)}); ret none; } ChildNameDefinition(def) | ImportNameDefinition(def) { @@ -4098,9 +4098,9 @@ class Resolver { Failed { self.session.span_err(path.span, - #fmt("use of undeclared module `::%s`", + fmt!{"use of undeclared module `::%s`", *(*self.atom_table).atoms_to_str - ((*module_path_atoms).get()))); + ((*module_path_atoms).get())}); ret none; } @@ -4121,11 +4121,11 @@ class Resolver { NoNameDefinition { // We failed to resolve the name. Report an error. self.session.span_err(path.span, - #fmt("unresolved name: %s::%s", + fmt!{"unresolved name: %s::%s", *(*self.atom_table).atoms_to_str ((*module_path_atoms).get()), *(*self.atom_table).atom_to_str - (name))); + (name)}); ret none; } ChildNameDefinition(def) | ImportNameDefinition(def) { @@ -4159,10 +4159,10 @@ class Resolver { alt copy search_result { some(dl_def(def)) { - #debug("(resolving path in local ribs) resolved `%s` to \ + debug!{"(resolving path in local ribs) resolved `%s` to \ local: %?", *(*self.atom_table).atom_to_str(name), - def); + def}; ret some(def); } some(dl_field) | some(dl_impl(_)) | none { @@ -4189,9 +4189,9 @@ class Resolver { bindings with no def for that namespace?!"; } some(def) { - #debug("(resolving item path in lexical scope) \ + debug!{"(resolving item path in lexical scope) \ resolved `%s` to item", - *(*self.atom_table).atom_to_str(name)); + *(*self.atom_table).atom_to_str(name)}; ret some(def); } } @@ -4228,15 +4228,15 @@ class Resolver { alt self.resolve_path(path, ValueNS, true, visitor) { some(def) { // Write the result into the def map. - #debug("(resolving expr) resolved `%s`", - connect(path.idents.map(|x| *x), ~"::")); + debug!{"(resolving expr) resolved `%s`", + connect(path.idents.map(|x| *x), ~"::")}; self.record_def(expr.id, def); } none { self.session.span_err(expr.span, - #fmt("unresolved name: %s", + fmt!{"unresolved name: %s", connect(path.idents.map(|x| *x), - ~"::"))); + ~"::")}); } } @@ -4280,11 +4280,11 @@ class Resolver { } _ { self.session.span_err(path.span, - #fmt("`%s` does not name a \ + fmt!{"`%s` does not name a \ structure", connect(path.idents.map (|x| *x), - ~"::"))); + ~"::")}); } } @@ -4450,11 +4450,11 @@ class Resolver { alt self.trait_info.find(trait_def_id) { some(trait_info) if trait_info.contains_key(name) { - #debug("(adding trait info if containing method) found trait \ + debug!{"(adding trait info if containing method) found trait \ %d:%d for method '%s'", trait_def_id.crate, trait_def_id.node, - *(*self.atom_table).atom_to_str(name)); + *(*self.atom_table).atom_to_str(name)}; (*found_traits).push(trait_def_id); } some(_) | none { @@ -4470,7 +4470,7 @@ class Resolver { } fn record_def(node_id: node_id, def: def) { - #debug("(recording def) recording %? for %?", def, node_id); + debug!{"(recording def) recording %? for %?", def, node_id}; self.def_map.insert(node_id, def); } @@ -4503,9 +4503,9 @@ class Resolver { } some(_) { // Bail out. - #debug("(checking for unused imports in module subtree) not \ + debug!{"(checking for unused imports in module subtree) not \ checking for unused imports for `%s`", - self.module_to_str(module)); + self.module_to_str(module)}; ret; } } @@ -4600,14 +4600,14 @@ class Resolver { } fn dump_module(module: @Module) { - #debug("Dump of module `%s`:", self.module_to_str(module)); + debug!{"Dump of module `%s`:", self.module_to_str(module)}; - #debug("Children:"); + debug!{"Children:"}; for module.children.each |name, _child| { - #debug("* %s", *(*self.atom_table).atom_to_str(name)); + debug!{"* %s", *(*self.atom_table).atom_to_str(name)}; } - #debug("Import resolutions:"); + debug!{"Import resolutions:"}; for module.import_resolutions.each |name, import_resolution| { let mut module_repr; alt (*import_resolution).target_for_namespace(ModuleNS) { @@ -4645,24 +4645,24 @@ class Resolver { } } - #debug("* %s:%s%s%s%s", + debug!{"* %s:%s%s%s%s", *(*self.atom_table).atom_to_str(name), - module_repr, value_repr, type_repr, impl_repr); + module_repr, value_repr, type_repr, impl_repr}; } } fn dump_impl_scopes(impl_scopes: ImplScopes) { - #debug("Dump of impl scopes:"); + debug!{"Dump of impl scopes:"}; let mut i = 0u; let mut impl_scopes = impl_scopes; loop { alt *impl_scopes { cons(impl_scope, rest_impl_scopes) { - #debug("Impl scope %u:", i); + debug!{"Impl scope %u:", i}; for (*impl_scope).each |implementation| { - #debug("Impl: %s", *implementation.ident); + debug!{"Impl: %s", *implementation.ident}; } i += 1u; diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index b624bc63bfe..2e5d5051a79 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -67,8 +67,8 @@ enum dest { 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)] } + 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" } } } @@ -100,7 +100,7 @@ trait get_insn_ctxt { impl ccx_icx of get_insn_ctxt for @crate_ctxt { fn insn_ctxt(s: ~str) -> icx_popper { - #debug("new insn_ctxt: %s", s); + debug!{"new insn_ctxt: %s", s}; if self.sess.count_llvm_insns() { vec::push(*self.stats.llvm_insn_ctxt, s); } @@ -496,7 +496,7 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { 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)); + log(debug, fmt!{"+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name}); let gvar = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf) }); @@ -1091,60 +1091,60 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, alt ti.take_glue { some(_) { } none { - #debug("+++ lazily_emit_tydesc_glue TAKE %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + 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"); ti.take_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, make_take_glue, ~"take"); - #debug("--- lazily_emit_tydesc_glue TAKE %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + debug!{"--- lazily_emit_tydesc_glue TAKE %s", + ppaux::ty_to_str(ccx.tcx, ti.ty)}; } } } else if field == abi::tydesc_field_drop_glue { alt ti.drop_glue { some(_) { } none { - #debug("+++ lazily_emit_tydesc_glue DROP %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + 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"); ti.drop_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, make_drop_glue, ~"drop"); - #debug("--- lazily_emit_tydesc_glue DROP %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + debug!{"--- lazily_emit_tydesc_glue DROP %s", + ppaux::ty_to_str(ccx.tcx, ti.ty)}; } } } else if field == abi::tydesc_field_free_glue { alt ti.free_glue { some(_) { } none { - #debug("+++ lazily_emit_tydesc_glue FREE %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + 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"); ti.free_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, make_free_glue, ~"free"); - #debug("--- lazily_emit_tydesc_glue FREE %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + debug!{"--- lazily_emit_tydesc_glue FREE %s", + ppaux::ty_to_str(ccx.tcx, ti.ty)}; } } } else if field == abi::tydesc_field_visit_glue { alt ti.visit_glue { some(_) { } none { - #debug("+++ lazily_emit_tydesc_glue VISIT %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + 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"); ti.visit_glue = some(glue_fn); make_generic_glue(ccx, ti.ty, glue_fn, make_visit_glue, ~"visit"); - #debug("--- lazily_emit_tydesc_glue VISIT %s", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + debug!{"--- lazily_emit_tydesc_glue VISIT %s", + ppaux::ty_to_str(ccx.tcx, ti.ty)}; } } } @@ -1698,7 +1698,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)]; + debug!{"%s", expr_to_str(ex)}; let _icx = bcx.insn_ctxt(~"trans_assign_op"); let t = expr_ty(bcx, src); let lhs_res = trans_lval(bcx, dst); @@ -1708,8 +1708,8 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, alt bcx.ccx().maps.method_map.find(ex.id) { some(origin) { let bcx = lhs_res.bcx; - #debug["user-defined method callee_id: %s", - ast_map::node_id_to_str(bcx.tcx().items, ex.callee_id)]; + debug!{"user-defined method callee_id: %s", + ast_map::node_id_to_str(bcx.tcx().items, ex.callee_id)}; let fty = node_id_type(bcx, ex.callee_id); let dty = expr_ty(bcx, dst); @@ -1745,7 +1745,7 @@ fn root_value(bcx: block, val: ValueRef, ty: ty::t, if bcx.sess().trace() { trans_trace( bcx, none, - #fmt["preserving until end of scope %d", scope_id]); + fmt!{"preserving until end of scope %d", scope_id}); } let root_loc = alloca_zeroed(bcx, type_of(bcx.ccx(), ty)); @@ -1764,9 +1764,9 @@ fn autoderef(cx: block, e_id: ast::node_id, let ccx = cx.ccx(); let mut derefs = 0u; while derefs < max { - #debug["autoderef(e_id=%d, v1=%s, t1=%s, derefs=%u)", + debug!{"autoderef(e_id=%d, v1=%s, t1=%s, derefs=%u)", e_id, val_str(ccx.tn, v1), ppaux::ty_to_str(ccx.tcx, t1), - derefs]; + derefs}; // root the autoderef'd value, if necessary: derefs += 1u; @@ -2113,8 +2113,8 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, alt ccx.monomorphized.find(hash_id) { some(val) { - #debug["leaving monomorphic fn %s", - ty::item_path_str(ccx.tcx, fn_id)]; + debug!{"leaving monomorphic fn %s", + ty::item_path_str(ccx.tcx, fn_id)}; ret {val: val, must_cast: must_cast}; } none {} @@ -2124,9 +2124,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let mut llitem_ty = tpt.ty; let map_node = session::expect(ccx.sess, ccx.tcx.items.find(fn_id.node), - || #fmt("While monomorphizing %?, couldn't find it in the item map \ + || fmt!{"While monomorphizing %?, couldn't find it in the item map \ (may have attempted to monomorphize an item defined in a different \ - crate?)", fn_id)); + crate?)", fn_id}); // Get the path so that we can create a symbol let (pt, name, span) = alt map_node { ast_map::node_item(i, pt) { (pt, i.ident, i.span) } @@ -2250,7 +2250,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, }; ccx.monomorphizing.insert(fn_id, depth); - #debug["leaving monomorphic fn %s", ty::item_path_str(ccx.tcx, fn_id)]; + debug!{"leaving monomorphic fn %s", ty::item_path_str(ccx.tcx, fn_id)}; {val: lldecl, must_cast: must_cast} } @@ -2260,8 +2260,8 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) alt ccx.external.find(fn_id) { some(some(node_id)) { // Already inline - #debug["maybe_instantiate_inline(%s): already inline as node id %d", - ty::item_path_str(ccx.tcx, fn_id), node_id]; + debug!{"maybe_instantiate_inline(%s): already inline as node id %d", + ty::item_path_str(ccx.tcx, fn_id), node_id}; local_def(node_id) } some(none) { fn_id } // Not inlinable @@ -2448,8 +2448,8 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { ret {val: slf, kind: lv_owned}; } _ { - cx.sess().unimpl(#fmt("unsupported def type in trans_local_def: %?", - def)); + cx.sess().unimpl(fmt!{"unsupported def type in trans_local_def: %?", + def}); } } } @@ -2534,7 +2534,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, let ix = field_idx_strict(bcx.tcx(), sp, field, fields); - #debug("val = %s ix = %u", bcx.val_str(val), ix); + debug!{"val = %s ix = %u", bcx.val_str(val), ix}; /* self is a class with a dtor, which means we have to select out the object itself @@ -2586,8 +2586,8 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, len = Sub(bcx, len, C_uint(bcx.ccx(), 1u)); } - #debug("trans_index: base %s", val_str(bcx.ccx().tn, base)); - #debug("trans_index: len %s", val_str(bcx.ccx().tn, len)); + debug!{"trans_index: base %s", val_str(bcx.ccx().tn, base)}; + debug!{"trans_index: len %s", val_str(bcx.ccx().tn, len)}; let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len); let bcx = do with_cond(bcx, bounds_check) |bcx| { @@ -2645,8 +2645,8 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { let lv = unrooted(cx, e); if !cx.sess().no_asm_comments() { - add_comment(cx, #fmt["preserving until end of scope %d", - scope_id]); + add_comment(cx, fmt!{"preserving until end of scope %d", + scope_id}); } let _icx = lv.bcx.insn_ctxt(~"root_value_lval"); @@ -2707,7 +2707,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { * wrong address space and thus be the wrong type. */ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { - #debug("non_gc_box_cast"); + debug!{"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))); @@ -2856,7 +2856,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, &temp_cleanups: ~[ValueRef], ret_flag: option<ValueRef>, derefs: uint) -> result { - #debug("+++ trans_arg_expr on %s", expr_to_str(e)); + debug!{"+++ trans_arg_expr on %s", expr_to_str(e)}; let _icx = cx.insn_ctxt(~"trans_arg_expr"); let ccx = cx.ccx(); let e_ty = expr_ty(cx, e); @@ -2881,7 +2881,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, // auto-deref value as required (this only applies to method // call receivers) of method - #debug(" pre-deref value: %s", val_str(lv.bcx.ccx().tn, lv.val)); + debug!{" pre-deref value: %s", val_str(lv.bcx.ccx().tn, lv.val)}; let {lv, e_ty} = if derefs == 0u { {lv: lv, e_ty: e_ty} } else { @@ -2893,11 +2893,11 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, }; // borrow value (convert from @T to &T and so forth) - #debug(" pre-adaptation value: %s", val_str(lv.bcx.ccx().tn, lv.val)); + debug!{" pre-adaptation value: %s", val_str(lv.bcx.ccx().tn, lv.val)}; let {lv, ty: e_ty} = adapt_borrowed_value(lv, e, e_ty); let mut bcx = lv.bcx; let mut val = lv.val; - #debug(" adapted value: %s", val_str(bcx.ccx().tn, val)); + debug!{" adapted value: %s", val_str(bcx.ccx().tn, val)}; // finally, deal with the various modes let arg_mode = ty::resolved_mode(ccx.tcx, arg.mode); @@ -2949,11 +2949,11 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, } if !is_bot && arg.ty != e_ty || ty::type_has_params(arg.ty) { - #debug(" casting from %s", val_str(bcx.ccx().tn, val)); + debug!{" casting from %s", val_str(bcx.ccx().tn, val)}; val = PointerCast(bcx, val, lldestty); } - #debug("--- trans_arg_expr passing %s", val_str(bcx.ccx().tn, val)); + debug!{"--- trans_arg_expr passing %s", val_str(bcx.ccx().tn, val)}; ret rslt(bcx, val); } @@ -2994,9 +2994,9 @@ fn adapt_borrowed_value(lv: lval_result, let (base, len) = tvec::get_base_and_len(bcx, val, e_ty); let p = alloca(bcx, T_struct(~[T_ptr(llunit_ty), ccx.int_type])); - #debug("adapt_borrowed_value: adapting %s to %s", + debug!{"adapt_borrowed_value: adapting %s to %s", val_str(bcx.ccx().tn, val), - val_str(bcx.ccx().tn, p)); + val_str(bcx.ccx().tn, p)}; Store(bcx, base, GEPi(bcx, p, ~[0u, abi::slice_elt_base])); Store(bcx, len, GEPi(bcx, p, ~[0u, abi::slice_elt_len])); @@ -3013,8 +3013,8 @@ fn adapt_borrowed_value(lv: lval_result, _ { bcx.tcx().sess.span_bug( - e.span, #fmt["cannot borrow a value of type %s", - ppaux::ty_to_str(bcx.tcx(), e_ty)]); + e.span, fmt!{"cannot borrow a value of type %s", + ppaux::ty_to_str(bcx.tcx(), e_ty)}); } } } @@ -3566,9 +3566,9 @@ fn lval_result_to_result(lv: lval_result, ty: ty::t) -> result { fn add_root_cleanup(bcx: block, scope_id: ast::node_id, root_loc: ValueRef, ty: ty::t) { - #debug["add_root_cleanup(bcx=%s, scope_id=%d, root_loc=%s, ty=%s)", + debug!{"add_root_cleanup(bcx=%s, scope_id=%d, root_loc=%s, ty=%s)", bcx.to_str(), scope_id, val_str(bcx.ccx().tn, root_loc), - ppaux::ty_to_str(bcx.ccx().tcx, ty)]; + ppaux::ty_to_str(bcx.ccx().tcx, ty)}; let bcx_scope = find_bcx_for_scope(bcx, scope_id); add_clean_temp_mem(bcx_scope, root_loc, ty); @@ -3582,7 +3582,7 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id, alt bcx_sid.parent { none { bcx.tcx().sess.bug( - #fmt["no enclosing scope with id %d", scope_id]); + fmt!{"no enclosing scope with id %d", scope_id}); } some(bcx_par) { bcx_par } } @@ -3607,16 +3607,16 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { ret alt bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { none { unrooted(bcx, e, dest) } some(scope_id) { - #debug["expression %d found in root map with scope %d", - e.id, scope_id]; + debug!{"expression %d found in root map with scope %d", + e.id, scope_id}; let ty = expr_ty(bcx, e); let root_loc = alloca_zeroed(bcx, type_of(bcx.ccx(), ty)); let bcx = unrooted(bcx, e, save_in(root_loc)); if !bcx.sess().no_asm_comments() { - add_comment(bcx, #fmt["preserving until end of scope %d", - scope_id]); + add_comment(bcx, fmt!{"preserving until end of scope %d", + scope_id}); } let _icx = bcx.insn_ctxt(~"root_value_expr"); @@ -3668,9 +3668,9 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { ast::expr_fn_block(decl, body, cap_clause) { alt check ty::get(expr_ty(bcx, e)).struct { ty::ty_fn({proto, _}) { - #debug("translating fn_block %s with type %s", + debug!{"translating fn_block %s with type %s", expr_to_str(e), - ppaux::ty_to_str(tcx, expr_ty(bcx, e))); + ppaux::ty_to_str(tcx, expr_ty(bcx, e))}; ret closure::trans_expr_fn(bcx, proto, decl, body, e.id, cap_clause, none, dest); } @@ -3793,13 +3793,13 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { let ptr_ty = expr_ty(bcx, e); let ptr_ptr_val = alloc_ty(bcx, ptr_ty); - #debug["ptr_ty = %s", ppaux::ty_to_str(tcx, ptr_ty)]; - #debug["ptr_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)]; + debug!{"ptr_ty = %s", ppaux::ty_to_str(tcx, ptr_ty)}; + debug!{"ptr_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)}; let void_ty = ty::mk_nil_ptr(tcx); let llvoid_ty = type_of(ccx, void_ty); let voidval = PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty)); - #debug["voidval = %s", val_str(ccx.tn, voidval)]; + debug!{"voidval = %s", val_str(ccx.tn, voidval)}; let static_ti = get_tydesc(ccx, expr_ty(bcx, val)); lazily_emit_all_tydesc_glue(ccx, static_ti); @@ -3813,9 +3813,9 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { arg_vals(~[lltydesc]), save_in(voidval)); - #debug["dest = %s", dest_str(ccx, dest)]; + debug!{"dest = %s", dest_str(ccx, dest)}; let ptr_val = Load(bcx, ptr_ptr_val); - #debug["ptr_val = %s", val_str(ccx.tn, ptr_val)]; + debug!{"ptr_val = %s", val_str(ccx.tn, ptr_val)}; let bcx = trans_expr(bcx, val, save_in(ptr_val)); store_in_dest(bcx, ptr_val, dest) } @@ -3832,8 +3832,8 @@ fn lval_to_dps(bcx: block, e: @ast::expr, dest: dest) -> block { let ty = expr_ty(bcx, e); let lv = trans_lval(bcx, e); let last_use = (lv.kind == lv_owned && last_use_map.contains_key(e.id)); - #debug["is last use (%s) = %b, %d", expr_to_str(e), last_use, - lv.kind as int]; + debug!{"is last use (%s) = %b, %d", expr_to_str(e), last_use, + lv.kind as int}; lval_result_to_dps(lv, ty, last_use, dest) } @@ -4166,7 +4166,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"); - #debug["trans_stmt(%s)", stmt_to_str(s)]; + debug!{"trans_stmt(%s)", stmt_to_str(s)}; if !cx.sess().no_asm_comments() { add_span_comment(cx, s.span, stmt_to_str(s)); @@ -4303,12 +4303,12 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, let mut cur = bcx, bcx = bcx; let is_lpad = leave == none; loop { - #debug["cleanup_and_leave: leaving %s", cur.to_str()]; + debug!{"cleanup_and_leave: leaving %s", cur.to_str()}; if bcx.sess().trace() { trans_trace( bcx, none, - #fmt["cleanup_and_leave(%s)", cur.to_str()]); + fmt!{"cleanup_and_leave(%s)", cur.to_str()}); } alt cur.kind { @@ -5076,8 +5076,8 @@ fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path, let llfn: ValueRef = decl_fn(ccx.llmod, ps, cc, llfty); ccx.item_symbols.insert(node_id, ps); - #debug["register_fn_fuller created fn %s for item %d with path %s", - val_str(ccx.tn, llfn), node_id, ast_map::path_to_str(path)]; + debug!{"register_fn_fuller created fn %s for item %d with path %s", + val_str(ccx.tn, llfn), node_id, ast_map::path_to_str(path)}; let is_main = is_main_name(path) && !ccx.sess.building_library; if is_main { create_main_wrapper(ccx, sp, llfn, node_type); } @@ -5218,8 +5218,8 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, mono_ty) } none { - ccx.sess.bug(#fmt("get_dtor_symbol: not monomorphizing and \ - couldn't find a symbol for dtor %?", path)); + ccx.sess.bug(fmt!{"get_dtor_symbol: not monomorphizing and \ + couldn't find a symbol for dtor %?", path}); } } } @@ -5436,7 +5436,7 @@ fn trap(bcx: block) { fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) { if ccx.rtcalls.contains_key(name) { - fail #fmt("multiple definitions for runtime call %s", name); + fail fmt!{"multiple definitions for runtime call %s", name}; } ccx.rtcalls.insert(name, did); } @@ -5506,7 +5506,7 @@ fn gather_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { ~[~"exchange_free", ~"exchange_malloc", ~"fail", ~"free", ~"malloc"]; for vec::each(expected_rtcalls) |name| { if !ccx.rtcalls.contains_key(name) { - fail #fmt("no definition for runtime call %s", name); + fail fmt!{"no definition for runtime call %s", name}; } } } @@ -5777,25 +5777,25 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, write_metadata(ccx, crate); if ccx.sess.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", - ccx.stats.n_glues_created)); - io::println(#fmt("n_null_glues: %u", ccx.stats.n_null_glues)); - io::println(#fmt("n_real_glues: %u", ccx.stats.n_real_glues)); + io::println(fmt!{"n_static_tydescs: %u", + ccx.stats.n_static_tydescs}); + io::println(fmt!{"n_glues_created: %u", + ccx.stats.n_glues_created}); + io::println(fmt!{"n_null_glues: %u", ccx.stats.n_null_glues}); + io::println(fmt!{"n_real_glues: %u", ccx.stats.n_real_glues}); // FIXME (#2280): this temporary shouldn't be // necessary, but seems to be, for borrowing. let times = copy *ccx.stats.fn_times; for vec::each(times) |timing| { - io::println(#fmt("time: %s took %d ms", timing.ident, - timing.time)); + io::println(fmt!{"time: %s took %d ms", timing.ident, + timing.time}); } } if ccx.sess.count_llvm_insns() { for ccx.stats.llvm_insns.each |k, v| { - io::println(#fmt("%-7u %s", v, k)); + io::println(fmt!{"%-7u %s", v, k}); } } ret (llmod, link_meta); diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 4519be6bd33..5fa90ecece2 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -139,10 +139,10 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - #debug["Invoke(%s with arguments (%s))", + 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"); llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), @@ -410,9 +410,9 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef { fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) { if cx.unreachable { ret; } - #debug["Store %s -> %s", + debug!{"Store %s -> %s", val_str(cx.ccx().tn, Val), - val_str(cx.ccx().tn, Ptr)]; + val_str(cx.ccx().tn, Ptr)}; count_insn(cx, ~"store"); llvm::LLVMBuildStore(B(cx), Val, Ptr); } @@ -670,9 +670,9 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { unsafe { count_insn(cx, ~"call"); - #debug["Call(Fn=%s, Args=%?)", + debug!{"Call(Fn=%s, Args=%?)", val_str(cx.ccx().tn, Fn), - Args.map(|arg| val_str(cx.ccx().tn, arg))]; + Args.map(|arg| val_str(cx.ccx().tn, arg))}; ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 5cfc1d98ec6..c216b890ace 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -102,12 +102,12 @@ enum environment_value { 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)) } - env_move(v, t, lk) { #fmt("move(%s,%s)", val_str(ccx.tn, v), - ty_to_str(ccx.tcx, t)) } - env_ref(v, t, lk) { #fmt("ref(%s,%s)", val_str(ccx.tn, v), - ty_to_str(ccx.tcx, t)) } + env_copy(v, t, lk) { fmt!{"copy(%s,%s)", val_str(ccx.tn, v), + ty_to_str(ccx.tcx, t)} } + env_move(v, t, lk) { fmt!{"move(%s,%s)", val_str(ccx.tn, v), + ty_to_str(ccx.tcx, t)} } + env_ref(v, t, lk) { fmt!{"ref(%s,%s)", val_str(ccx.tn, v), + ty_to_str(ccx.tcx, t)} } } } @@ -131,7 +131,7 @@ fn mk_closure_tys(tcx: ty::ctxt, }); } let cdata_ty = ty::mk_tup(tcx, bound_tys); - #debug["cdata_ty=%s", ty_to_str(tcx, cdata_ty)]; + debug!{"cdata_ty=%s", ty_to_str(tcx, cdata_ty)}; ret cdata_ty; } @@ -201,16 +201,16 @@ fn store_environment(bcx: block, let cboxptr_ty = ty::mk_ptr(tcx, {ty:cbox_ty, mutbl:ast::m_imm}); let llbox = PointerCast(bcx, llbox, type_of(ccx, cboxptr_ty)); - #debug["tuplify_box_ty = %s", ty_to_str(tcx, cbox_ty)]; + debug!{"tuplify_box_ty = %s", ty_to_str(tcx, cbox_ty)}; // Copy expr values into boxed bindings. let mut bcx = bcx; do vec::iteri(bound_values) |i, bv| { - #debug["Copy %s into closure", ev_to_str(ccx, bv)]; + debug!{"Copy %s into closure", ev_to_str(ccx, bv)}; if !ccx.sess.no_asm_comments() { - add_comment(bcx, #fmt("Copy %s into closure", - ev_to_str(ccx, bv))); + add_comment(bcx, fmt!{"Copy %s into closure", + ev_to_str(ccx, bv)}); } let bound_data = GEPi(bcx, llbox, @@ -231,9 +231,9 @@ fn store_environment(bcx: block, bcx = move_val(bcx, INIT, bound_data, src, ty); } env_ref(val, ty, lv_owned) { - #debug["> storing %s into %s", + debug!{"> storing %s into %s", val_str(bcx.ccx().tn, val), - val_str(bcx.ccx().tn, bound_data)]; + val_str(bcx.ccx().tn, bound_data)}; Store(bcx, val, bound_data); } env_ref(val, ty, lv_owned_imm) { @@ -265,11 +265,11 @@ fn build_closure(bcx0: block, // Package up the captured upvars do vec::iter(cap_vars) |cap_var| { - #debug["Building closure: captured variable %?", cap_var]; + debug!{"Building closure: captured variable %?", cap_var}; let lv = trans_local_var(bcx, cap_var.def); let nid = ast_util::def_id_of_def(cap_var.def).node; - #debug["Node id is %s", - syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)]; + debug!{"Node id is %s", + syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)}; let mut ty = node_id_type(bcx, nid); alt cap_var.mode { capture::cap_ref { diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index b66fb82c9f8..bfb7676024a 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -248,9 +248,9 @@ fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype { fn add_clean(cx: block, val: ValueRef, ty: ty::t) { if !ty::type_needs_drop(cx.tcx(), ty) { ret; } - #debug["add_clean(%s, %s, %s)", + debug!{"add_clean(%s, %s, %s)", cx.to_str(), val_str(cx.ccx().tn, val), - ty_to_str(cx.ccx().tcx, ty)]; + ty_to_str(cx.ccx().tcx, ty)}; let cleanup_type = cleanup_type(cx.tcx(), ty); do in_scope_cx(cx) |info| { vec::push(info.cleanups, clean(|a| base::drop_ty(a, val, ty), @@ -260,9 +260,9 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) { } fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { if !ty::type_needs_drop(cx.tcx(), ty) { ret; } - #debug["add_clean_temp(%s, %s, %s)", + debug!{"add_clean_temp(%s, %s, %s)", cx.to_str(), val_str(cx.ccx().tn, val), - ty_to_str(cx.ccx().tcx, ty)]; + ty_to_str(cx.ccx().tcx, ty)}; let cleanup_type = cleanup_type(cx.tcx(), ty); fn do_drop(bcx: block, val: ValueRef, ty: ty::t) -> block { @@ -280,9 +280,9 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { } fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) { if !ty::type_needs_drop(cx.tcx(), ty) { ret; } - #debug["add_clean_temp_mem(%s, %s, %s)", + debug!{"add_clean_temp_mem(%s, %s, %s)", cx.to_str(), val_str(cx.ccx().tn, val), - ty_to_str(cx.ccx().tcx, ty)]; + ty_to_str(cx.ccx().tcx, ty)}; let cleanup_type = cleanup_type(cx.tcx(), ty); do in_scope_cx(cx) |info| { vec::push(info.cleanups, @@ -459,8 +459,8 @@ fn in_scope_cx(cx: block, f: fn(scope_info)) { fn block_parent(cx: block) -> block { alt cx.parent { some(b) { b } - none { cx.sess().bug(#fmt("block_parent called on root block %?", - cx)); } + none { cx.sess().bug(fmt!{"block_parent called on root block %?", + cx}); } } } @@ -480,10 +480,10 @@ impl bcx_cxs for block { fn to_str() -> ~str { alt self.node_info { some(node_info) { - #fmt["[block %d]", node_info.id] + fmt!{"[block %d]", node_info.id} } none { - #fmt["[block %x]", ptr::addr_of(*self) as uint] + fmt!{"[block %x]", ptr::addr_of(*self) as uint} } } } @@ -997,8 +997,8 @@ fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident, fields: ~[ty::field]) -> uint { alt ty::field_idx(ident, fields) { - none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \ - have a field named %s", *ident)); } + none { cx.sess.span_bug(sp, fmt!{"base expr doesn't appear to \ + have a field named %s", *ident}); } some(i) { i } } } diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index b18569a093b..3197dc00884 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -178,7 +178,7 @@ fn create_compile_unit(cx: @crate_ctxt) lli32(DW_LANG_RUST), llstr(crate_name), llstr(work_dir), - llstr(#env["CFG_VERSION"]), + llstr(env!{"CFG_VERSION"}), lli1(true), // deprecated: main compile unit lli1(cx.sess.opts.optimize != 0u), llstr(~""), // flags (???) @@ -734,7 +734,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { let cx = fcx.ccx; let dbg_cx = option::get(cx.dbg_cx); - #debug("~~"); + debug!{"~~"}; log(debug, fcx.id); let sp = option::get(fcx.span); diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 747549e78b8..5313cee2323 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -937,10 +937,10 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, ast_map::node_expr(e) { e.span } }; ccx.sess.span_fatal( - sp, #fmt("reinterpret_cast called on types \ + sp, fmt!{"reinterpret_cast called on types \ with different size: %s (%u) to %s (%u)", ty_to_str(ccx.tcx, tp_ty), tp_sz, - ty_to_str(ccx.tcx, substs.tys[1]), out_sz)); + ty_to_str(ccx.tcx, substs.tys[1]), out_sz}); } if !ty::type_is_nil(substs.tys[1]) { let cast = PointerCast(bcx, get_param(decl, first_real_arg), diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 0be970357e8..0250b17f6fe 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -177,8 +177,8 @@ fn traverse_inline_body(cx: ctx, body: blk) { some(d) { traverse_def_id(cx, def_id_of_def(d)); } - none { cx.tcx.sess.span_bug(e.span, #fmt("Unbound node \ - id %? while traversing %s", e.id, expr_to_str(e))); } + none { cx.tcx.sess.span_bug(e.span, fmt!{"Unbound node \ + id %? while traversing %s", e.id, expr_to_str(e)}); } } } expr_field(_, _, _) { diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 56444f1d281..82cb96f660d 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -62,15 +62,15 @@ impl methods for reflector { let get_lval = |bcx| { let callee = impl::trans_trait_callee(bcx, v, mth_ty, mth_idx); - #debug("calling mth ty %s, lltype %s", + debug!{"calling mth ty %s, lltype %s", ty_to_str(bcx.ccx().tcx, mth_ty), - val_str(bcx.ccx().tn, callee.val)); + val_str(bcx.ccx().tn, callee.val)}; callee }; - #debug("passing %u args:", vec::len(args)); + debug!{"passing %u args:", vec::len(args)}; let bcx = self.bcx; for args.eachi |i, a| { - #debug("arg %u: %s", i, val_str(bcx.ccx().tn, a)); + debug!{"arg %u: %s", i, val_str(bcx.ccx().tn, a)}; } let d = empty_dest_cell(); let bcx = @@ -111,8 +111,8 @@ impl methods for reflector { fn visit_ty(t: ty::t) { let bcx = self.bcx; - #debug("reflect::visit_ty %s", - ty_to_str(bcx.ccx().tcx, t)); + debug!{"reflect::visit_ty %s", + ty_to_str(bcx.ccx().tcx, t)}; alt ty::get(t).struct { ty::ty_bot { self.leaf(~"bot") } diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index bc698e6e3d2..bfd2f18bac9 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -189,9 +189,9 @@ fn trans_evec(bcx: block, args: ~[@ast::expr], // Store the individual elements. let mut i = 0u, temp_cleanups = ~[val]; - #debug("trans_evec: v: %s, dataptr: %s", + debug!{"trans_evec: v: %s, dataptr: %s", val_str(ccx.tn, val), - val_str(ccx.tn, dataptr)); + val_str(ccx.tn, dataptr)}; for vec::each(args) |e| { let lleltptr = InBoundsGEP(bcx, dataptr, ~[C_uint(ccx, i)]); bcx = base::trans_expr_save_in(bcx, e, lleltptr); @@ -259,7 +259,7 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) (base, len) } ty::vstore_uniq | ty::vstore_box { - #debug["get_base_and_len: %s", val_str(ccx.tn, v)]; + debug!{"get_base_and_len: %s", val_str(ccx.tn, v)}; let body = tvec::get_bodyptr(cx, v); (tvec::get_dataptr(cx, body), tvec::get_fill(cx, body)) } @@ -276,13 +276,13 @@ fn trans_estr(bcx: block, s: @~str, vstore: ast::vstore, ast::vstore_fixed(_) { // "hello"/_ => "hello"/5 => ~[i8 x 6] in llvm - #debug("trans_estr: fixed: %s", *s); + debug!{"trans_estr: fixed: %s", *s}; C_postr(*s) } ast::vstore_slice(_) { // "hello" => (*i8, 6u) in llvm - #debug("trans_estr: slice '%s'", *s); + debug!{"trans_estr: slice '%s'", *s}; C_estr_slice(ccx, *s) } @@ -303,7 +303,7 @@ fn trans_estr(bcx: block, s: @~str, vstore: ast::vstore, } }; - #debug("trans_estr: type: %s", val_str(ccx.tn, c)); + debug!{"trans_estr: type: %s", val_str(ccx.tn, c)}; base::store_in_dest(bcx, c, dest) } diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index ab3384dad25..d06bf94f5e1 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -66,7 +66,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef { } fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { - #debug("type_of %?: %?", t, ty::get(t)); + debug!{"type_of %?: %?", t, ty::get(t)}; // Check the cache. if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); } @@ -197,7 +197,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) -> TypeRef { - #debug("type_of_enum %?: %?", t, ty::get(t)); + debug!{"type_of_enum %?: %?", t, ty::get(t)}; // Every enum type has a unique name. When we find our roots // for GC and unwinding we will use this name to rediscover @@ -233,7 +233,7 @@ fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { (~"class", did, substs.tps) } }; - ret #fmt( + ret fmt!{ "%s %s[#%d]", name, util::ppaux::parameterized( @@ -242,7 +242,7 @@ fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { none, tps), did.crate - ); + }; } fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef { diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index e7167eee91a..6bb19724afe 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -61,8 +61,8 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) } let map_node = alt ccx.tcx.items.find(fn_id_loc.node) { some(x) { x } - none { ccx.sess.bug(#fmt("type_uses_for: unbound item ID %?", - fn_id_loc)); } + none { ccx.sess.bug(fmt!{"type_uses_for: unbound item ID %?", + fn_id_loc}); } }; alt check map_node { ast_map::node_item(@{node: item_fn(_, _, body), _}, _) | diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index b1d7762ec7b..27379552a8c 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -40,8 +40,8 @@ fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { let src_box = v; let src_body = opaque_box_body(bcx, content_ty, src_box); let src_body = load_if_immediate(bcx, src_body, content_ty); - #debug("ST: %?", val_str(bcx.ccx().tn, src_body)); - #debug("DT: %?", val_str(bcx.ccx().tn, dst_body)); + debug!{"ST: %?", val_str(bcx.ccx().tn, src_body)}; + debug!{"DT: %?", val_str(bcx.ccx().tn, dst_body)}; let bcx = copy_val(bcx, INIT, dst_body, src_body, content_ty); let src_tydesc_ptr = GEPi(bcx, src_box, diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index de9a4540d21..f4b2e5e6442 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -16,8 +16,8 @@ fn collect_ids_block(b: blk, rs: @mut ~[node_id]) { fn collect_ids_stmt(s: @stmt, rs: @mut ~[node_id]) { alt s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { - #debug["node_id %s", int::str(id)]; - #debug["%s", stmt_to_str(*s)]; + debug!{"node_id %s", int::str(id)}; + debug!{"%s", stmt_to_str(*s)}; vec::push(*rs, id); } } diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index 1e6bcd52ede..0f8185a0ee9 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -49,10 +49,10 @@ fn comma_str(args: ~[@constr_arg_use]) -> ~str { } fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> ~str { - ret #fmt("%s(%s) - arising from %s", + 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)); + codemap::span_to_str(c.span, tcx.sess.codemap)}; } fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str { @@ -110,36 +110,36 @@ fn log_cond_err(v: ~[uint]) { log(error, tos(v)); } fn log_pp(pp: pre_and_post) { let p1 = pp.precondition.to_vec(); let p2 = pp.postcondition.to_vec(); - #debug("pre:"); + debug!{"pre:"}; log_cond(p1); - #debug("post:"); + debug!{"post:"}; log_cond(p2); } fn log_pp_err(pp: pre_and_post) { let p1 = pp.precondition.to_vec(); let p2 = pp.postcondition.to_vec(); - #error("pre:"); + error!{"pre:"}; log_cond_err(p1); - #error("post:"); + error!{"post:"}; log_cond_err(p2); } fn log_states(pp: pre_and_post_state) { let p1 = pp.prestate.to_vec(); let p2 = pp.poststate.to_vec(); - #debug("prestate:"); + debug!{"prestate:"}; log_cond(p1); - #debug("poststate:"); + debug!{"poststate:"}; log_cond(p2); } fn log_states_err(pp: pre_and_post_state) { let p1 = pp.prestate.to_vec(); let p2 = pp.poststate.to_vec(); - #error("prestate:"); + error!{"prestate:"}; log_cond_err(p1); - #error("poststate:"); + error!{"poststate:"}; log_cond_err(p2); } @@ -263,7 +263,7 @@ fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option<ts_ann> { fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann { alt get_ts_ann(ccx, id) { none { - #error("node_id_to_ts_ann: no ts_ann for node_id %d", id); + error!{"node_id_to_ts_ann: no ts_ann for node_id %d", id}; fail; } some(tt) { ret tt; } @@ -271,12 +271,12 @@ fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann { } fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate { - #debug("node_id_to_poststate"); + debug!{"node_id_to_poststate"}; ret node_id_to_ts_ann(ccx, id).states.poststate; } fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { - #debug("stmt_to_ann"); + debug!{"stmt_to_ann"}; alt s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { ret node_id_to_ts_ann(ccx, id); @@ -287,14 +287,14 @@ fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { /* fails if e has no annotation */ fn expr_states(ccx: crate_ctxt, e: @expr) -> pre_and_post_state { - #debug("expr_states"); + debug!{"expr_states"}; ret node_id_to_ts_ann(ccx, e.id).states; } /* fails if e has no annotation */ fn expr_pp(ccx: crate_ctxt, e: @expr) -> pre_and_post { - #debug("expr_pp"); + debug!{"expr_pp"}; ret node_id_to_ts_ann(ccx, e.id).conditions; } @@ -305,7 +305,7 @@ fn stmt_pp(ccx: crate_ctxt, s: stmt) -> pre_and_post { /* fails if b has no annotation */ fn block_pp(ccx: crate_ctxt, b: blk) -> pre_and_post { - #debug("block_pp"); + debug!{"block_pp"}; ret node_id_to_ts_ann(ccx, b.node.id).conditions; } @@ -320,7 +320,7 @@ fn clear_precond(ccx: crate_ctxt, id: node_id) { } fn block_states(ccx: crate_ctxt, b: blk) -> pre_and_post_state { - #debug("block_states"); + debug!{"block_states"}; ret node_id_to_ts_ann(ccx, b.node.id).states; } @@ -381,43 +381,43 @@ fn block_poststate(ccx: crate_ctxt, b: blk) -> poststate { } fn set_prestate_ann(ccx: crate_ctxt, id: node_id, pre: prestate) -> bool { - #debug("set_prestate_ann"); + debug!{"set_prestate_ann"}; ret set_prestate(node_id_to_ts_ann(ccx, id), pre); } fn extend_prestate_ann(ccx: crate_ctxt, id: node_id, pre: prestate) -> bool { - #debug("extend_prestate_ann"); + debug!{"extend_prestate_ann"}; ret extend_prestate(node_id_to_ts_ann(ccx, id).states.prestate, pre); } fn set_poststate_ann(ccx: crate_ctxt, id: node_id, post: poststate) -> bool { - #debug("set_poststate_ann"); + debug!{"set_poststate_ann"}; ret set_poststate(node_id_to_ts_ann(ccx, id), post); } fn extend_poststate_ann(ccx: crate_ctxt, id: node_id, post: poststate) -> bool { - #debug("extend_poststate_ann"); + debug!{"extend_poststate_ann"}; ret extend_poststate(node_id_to_ts_ann(ccx, id).states.poststate, post); } fn set_pre_and_post(ccx: crate_ctxt, id: node_id, pre: precond, post: postcond) { - #debug("set_pre_and_post"); + debug!{"set_pre_and_post"}; let tt = node_id_to_ts_ann(ccx, id); set_precondition(tt, pre); set_postcondition(tt, post); } fn copy_pre_post(ccx: crate_ctxt, id: node_id, sub: @expr) { - #debug("set_pre_and_post"); + debug!{"set_pre_and_post"}; let p = expr_pp(ccx, sub); copy_pre_post_(ccx, id, p.precondition, p.postcondition); } fn copy_pre_post_(ccx: crate_ctxt, id: node_id, pre: prestate, post: poststate) { - #debug("set_pre_and_post"); + debug!{"set_pre_and_post"}; let tt = node_id_to_ts_ann(ccx, id); set_precondition(tt, pre); set_postcondition(tt, post); @@ -460,7 +460,7 @@ fn constraints_expr(cx: ty::ctxt, e: @expr) -> ~[@ty::constr] { fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def { alt cx.def_map.find(id) { none { - #error("node_id_to_def: node_id %d has no def", id); + error!{"node_id_to_def: node_id %d has no def", id}; fail; } some(d) { ret d; } @@ -498,8 +498,8 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] { // should freeze it at some earlier point. 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)); + debug!{"match_args: looking at %s", + 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)); @@ -530,8 +530,8 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { } some(what) { tcx.sess.span_bug(e.span, - #fmt("exprs_to_constr_args: non-local variable %? \ - as pred arg", what)); + fmt!{"exprs_to_constr_args: non-local variable %? \ + as pred arg", what}); } none { tcx.sess.span_bug(e.span, @@ -824,9 +824,9 @@ fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) { let d = local_node_id_to_local_def_id(fcx, dead_v); do option::iter(d) |d_id| { do for_constraints_mentioning(fcx, d_id) |c| { - #debug("clearing constraint %u %s", + debug!{"clearing constraint %u %s", c.bit_num, - constraint_to_str(fcx.ccx.tcx, c.c)); + constraint_to_str(fcx.ccx.tcx, c.c)}; clear_in_postcond(c.bit_num, node_id_to_ts_ann(fcx.ccx, parent_exp).conditions); diff --git a/src/rustc/middle/tstate/ck.rs b/src/rustc/middle/tstate/ck.rs index d534b764c07..f1dc6a566af 100644 --- a/src/rustc/middle/tstate/ck.rs +++ b/src/rustc/middle/tstate/ck.rs @@ -46,11 +46,11 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt<fn_ctxt>) { let prec: precond = ann_precond(a); let pres: prestate = ann_prestate(a); - #debug("check_states_stmt:"); + debug!{"check_states_stmt:"}; log(debug, print::pprust::stmt_to_str(*s)); - #debug("prec = "); + debug!{"prec = "}; log_tritv(fcx, prec); - #debug("pres = "); + debug!{"pres = "}; log_tritv(fcx, pres); if !implies(pres, prec) { diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index d7bfd031307..448b7a5231f 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -87,15 +87,15 @@ fn contains_constrained_calls(tcx: ty::ctxt, body: blk) -> bool { fn visit_expr(e: @expr, &&cx: cx, v: visit::vt<cx>) { import syntax::print::pprust; - #debug("visiting %?", pprust::expr_to_str(e)); + debug!{"visiting %?", pprust::expr_to_str(e)}; visit::visit_expr(e, cx, v); if constraints_expr(cx.tcx, e).is_not_empty() { - #debug("has constraints"); + debug!{"has constraints"}; cx.has = true; } else { - #debug("has not constraints"); + debug!{"has not constraints"}; } } } @@ -140,7 +140,7 @@ fn mk_fn_info(ccx: crate_ctxt, used_vars: v, ignore: ignore}; ccx.fm.insert(id, rslt); - #debug("%s has %u constraints", *name, num_constraints(rslt)); + debug!{"%s has %u constraints", *name, num_constraints(rslt)}; } diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 36b7d9c7308..08f0736c1da 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -16,12 +16,12 @@ import driver::session::session; import std::map::hashmap; fn find_pre_post_mod(_m: _mod) -> _mod { - #debug("implement find_pre_post_mod!"); + debug!{"implement find_pre_post_mod!"}; fail; } fn find_pre_post_foreign_mod(_m: foreign_mod) -> foreign_mod { - #debug("implement find_pre_post_foreign_mod"); + debug!{"implement find_pre_post_foreign_mod"}; fail; } @@ -66,7 +66,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) { be the union of all postconditions for <args> */ fn find_pre_post_exprs(fcx: fn_ctxt, args: ~[@expr], id: node_id) { if vec::len::<@expr>(args) > 0u { - #debug["find_pre_post_exprs: oper = %s", expr_to_str(args[0])]; + debug!{"find_pre_post_exprs: oper = %s", expr_to_str(args[0])}; } fn do_one(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, e); } for args.each |e| { do_one(fcx, e); } @@ -452,7 +452,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { - #debug["stmt = %s", stmt_to_str(s)]; + debug!{"stmt = %s", stmt_to_str(s)}; alt s.node { stmt_decl(adecl, id) { alt adecl.node { diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index e427841103f..9c4285774f7 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -174,9 +174,9 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr, // bug) if vec::len(bs) != vec::len(ops) { fcx.ccx.tcx.sess.span_bug(a.span, - #fmt["mismatched arg lengths: \ + fmt!{"mismatched arg lengths: \ %u exprs vs. %u ops", - vec::len(bs), vec::len(ops)]); + vec::len(bs), vec::len(ops)}); } ret find_pre_post_state_exprs(fcx, pres, id, ops, bs, cf) || changed; @@ -299,7 +299,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { return_val); } expr_call(operator, operands, _) { - #debug["hey it's a call: %s", expr_to_str(e)]; + debug!{"hey it's a call: %s", expr_to_str(e)}; ret find_pre_post_state_call(fcx, pres, operator, e.id, callee_arg_init_ops(fcx, operator.id), operands, @@ -505,10 +505,10 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { let stmt_ann = stmt_to_ann(fcx.ccx, *s); - #debug["[ %s ]", *fcx.name]; - #debug["*At beginning: stmt = %s", stmt_to_str(*s)]; - #debug["*prestate = %s", stmt_ann.states.prestate.to_str()]; - #debug["*poststate = %s", stmt_ann.states.prestate.to_str()]; + debug!{"[ %s ]", *fcx.name}; + debug!{"*At beginning: stmt = %s", stmt_to_str(*s)}; + debug!{"*prestate = %s", stmt_ann.states.prestate.to_str()}; + debug!{"*poststate = %s", stmt_ann.states.prestate.to_str()}; alt s.node { stmt_decl(adecl, id) { @@ -524,10 +524,10 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { let mut changed = set_poststate(stmt_ann, c_and_p.post) | c_and_p.changed; - #debug["Summary: stmt = %s", stmt_to_str(*s)]; - #debug["prestate = %s", stmt_ann.states.prestate.to_str()]; - #debug["poststate = %s", stmt_ann.states.poststate.to_str()]; - #debug["changed = %s", bool::to_str(changed)]; + debug!{"Summary: stmt = %s", stmt_to_str(*s)}; + debug!{"prestate = %s", stmt_ann.states.prestate.to_str()}; + debug!{"poststate = %s", stmt_ann.states.poststate.to_str()}; + debug!{"changed = %s", bool::to_str(changed)}; ret changed; } @@ -544,10 +544,10 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { set_poststate(stmt_ann, expr_poststate(fcx.ccx, ex)); - #debug["Finally: %s", stmt_to_str(*s)]; - #debug["prestate = %s", stmt_ann.states.prestate.to_str()]; - #debug["poststate = %s", stmt_ann.states.poststate.to_str()]; - #debug["changed = %s", bool::to_str(changed)]; + debug!{"Finally: %s", stmt_to_str(*s)}; + debug!{"prestate = %s", stmt_ann.states.prestate.to_str()}; + debug!{"poststate = %s", stmt_ann.states.poststate.to_str()}; + debug!{"changed = %s", bool::to_str(changed)}; ret changed; } @@ -602,7 +602,7 @@ fn find_pre_post_state_fn(fcx: fn_ctxt, let mut changed = find_pre_post_state_block(fcx, block_pre, f_body); /* - #error("find_pre_post_state_fn"); + error!{"find_pre_post_state_fn"}; log(error, changed); fcx.ccx.tcx.sess.span_note(f_body.span, fcx.name); */ diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index a2ba9277fd0..cb055055091 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -483,17 +483,17 @@ iface vid { 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()} } } trait purity_to_str { @@ -1050,23 +1050,23 @@ fn substs_is_noop(substs: substs) -> bool { } fn substs_to_str(cx: ctxt, substs: substs) -> ~str { - #fmt["substs(self_r=%s, self_ty=%s, tps=%?)", + 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.tps.map(|t| ty_to_str(cx, t))] + substs.tps.map(|t| ty_to_str(cx, t))} } fn subst(cx: ctxt, substs: substs, typ: t) -> t { - #debug["subst(substs=%s, typ=%s)", + debug!{"subst(substs=%s, typ=%s)", substs_to_str(cx, substs), - ty_to_str(cx, typ)]; + ty_to_str(cx, typ)}; if substs_is_noop(substs) { ret typ; } let r = do_subst(cx, substs, typ); - #debug[" r = %s", ty_to_str(cx, r)]; + debug!{" r = %s", ty_to_str(cx, r)}; ret r; fn do_subst(cx: ctxt, @@ -1799,27 +1799,27 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { fn type_requires(cx: ctxt, seen: @mut ~[def_id], r_ty: t, ty: t) -> bool { - #debug["type_requires(%s, %s)?", + debug!{"type_requires(%s, %s)?", ty_to_str(cx, r_ty), - ty_to_str(cx, ty)]; + ty_to_str(cx, ty)}; let r = { get(r_ty).struct == get(ty).struct || subtypes_require(cx, seen, r_ty, ty) }; - #debug["type_requires(%s, %s)? %b", + debug!{"type_requires(%s, %s)? %b", ty_to_str(cx, r_ty), ty_to_str(cx, ty), - r]; + r}; ret r; } fn subtypes_require(cx: ctxt, seen: @mut ~[def_id], r_ty: t, ty: t) -> bool { - #debug["subtypes_require(%s, %s)?", + debug!{"subtypes_require(%s, %s)?", ty_to_str(cx, r_ty), - ty_to_str(cx, ty)]; + ty_to_str(cx, ty)}; let r = alt get(ty).struct { ty_nil | @@ -1895,10 +1895,10 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { } }; - #debug["subtypes_require(%s, %s)? %b", + debug!{"subtypes_require(%s, %s)? %b", ty_to_str(cx, r_ty), ty_to_str(cx, ty), - r]; + r}; ret r; } @@ -1910,7 +1910,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> bool { let sty = get(ty).struct; - #debug("type_structurally_contains: %s", ty_to_str(cx, ty)); + debug!{"type_structurally_contains: %s", ty_to_str(cx, ty)}; if test(sty) { ret true; } alt sty { ty_enum(did, substs) { @@ -2232,8 +2232,8 @@ fn hash_type_structure(st: sty) -> uint { fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { alt smallintmap::find(*cx.node_types, id as uint) { some(t) { t } - none { cx.sess.bug(#fmt("node_id_to_type: unbound node ID %s", - ast_map::node_id_to_str(cx.items, id))); } + none { cx.sess.bug(fmt!{"node_id_to_type: unbound node ID %s", + ast_map::node_id_to_str(cx.items, id)}); } } } @@ -2298,15 +2298,15 @@ fn is_pred_ty(fty: t) -> bool { fn ty_var_id(typ: t) -> tv_vid { alt get(typ).struct { ty_var(vid) { ret vid; } - _ { #error("ty_var_id called on non-var ty"); fail; } + _ { error!{"ty_var_id called on non-var ty"}; fail; } } } fn ty_var_integral_id(typ: t) -> tvi_vid { alt get(typ).struct { ty_var_integral(vid) { ret vid; } - _ { #error("ty_var_integral_id called on ty other than \ - ty_var_integral"); + _ { error!{"ty_var_integral_id called on ty other than \ + ty_var_integral"}; fail; } } } @@ -2462,7 +2462,7 @@ fn canon_mode(cx: ctxt, m0: ast::mode) -> ast::mode { fn resolved_mode(cx: ctxt, m: ast::mode) -> ast::rmode { alt canon_mode(cx, m) { ast::infer(_) { - cx.sess.bug(#fmt["mode %? was never resolved", m]); + cx.sess.bug(fmt!{"mode %? was never resolved", m}); } ast::expl(m0) { m0 } } @@ -2510,7 +2510,7 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str { ty_to_str(cx, t) } - ty_enum(id, _) { #fmt["enum %s", item_path_str(cx, id)] } + ty_enum(id, _) { fmt!{"enum %s", item_path_str(cx, id)} } ty_box(_) { ~"@-ptr" } ty_uniq(_) { ~"~-ptr" } ty_evec(_, _) { ~"vector" } @@ -2519,8 +2519,8 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str { 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_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" } @@ -2547,12 +2547,12 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { ~" function was expected"; } terr_purity_mismatch(f1, f2) { - ret #fmt["expected %s fn but found %s fn", - purity_to_str(f1), purity_to_str(f2)]; + ret fmt!{"expected %s fn but found %s fn", + purity_to_str(f1), purity_to_str(f2)}; } terr_proto_mismatch(e, a) { - ret #fmt["closure protocol mismatch (%s vs %s)", - proto_to_str(e), proto_to_str(a)]; + 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"; } @@ -2585,22 +2585,22 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { ~" but found " + mode_to_str(a_mode); } terr_regions_differ(subregion, superregion) { - ret #fmt("references with lifetime %s do not necessarily \ + ret fmt!{"references with lifetime %s do not necessarily \ outlive references with lifetime %s", region_to_str(cx, subregion), - region_to_str(cx, superregion)); + region_to_str(cx, superregion)}; } terr_vstores_differ(k, e_vs, a_vs) { - ret #fmt("%s storage differs: expected %s but found %s", + ret fmt!{"%s storage differs: expected %s but found %s", terr_vstore_kind_to_str(k), vstore_to_str(cx, e_vs), - vstore_to_str(cx, a_vs)); + vstore_to_str(cx, a_vs)}; } terr_in_field(err, fname) { - ret #fmt("in field `%s`, %s", *fname, type_err_to_str(cx, *err)); + ret fmt!{"in field `%s`, %s", *fname, type_err_to_str(cx, *err)}; } terr_sorts(exp, act) { - ret #fmt("%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)); + 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 @@ -2638,7 +2638,7 @@ fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { if id.crate == ast::local_crate { - #debug("(impl_traits) searching for trait impl %?", id); + debug!{"(impl_traits) searching for trait impl %?", id}; alt cx.items.find(id.node) { some(ast_map::node_item(@{ node: ast::item_impl(_, trait_refs, _, _), @@ -2654,12 +2654,12 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { alt cx.def_map.find(id.node) { some(def_ty(trait_id)) { // XXX: Doesn't work cross-crate. - #debug("(impl_traits) found trait id %?", trait_id); + debug!{"(impl_traits) found trait id %?", trait_id}; ~[node_id_to_type(cx, trait_id.node)] } some(x) { - cx.sess.bug(#fmt("impl_traits: trait ref is in trait map \ - but is bound to %?", x)); + cx.sess.bug(fmt!{"impl_traits: trait ref is in trait map \ + but is bound to %?", x}); } none { ~[] @@ -2765,7 +2765,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { ast_map::node_expr(_) | ast_map::node_arg(_, _) | ast_map::node_local(_) | ast_map::node_export(_, _) | ast_map::node_block(_) { - cx.sess.bug(#fmt["cannot find item_path for node %?", node]); + cx.sess.bug(fmt!{"cannot find item_path for node %?", node}); } } } @@ -2899,8 +2899,8 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { } } _ { - cx.sess.bug(#fmt("class ID not bound to an item: %s", - ast_map::node_id_to_str(cx.items, did.node))); + cx.sess.bug(fmt!{"class ID not bound to an item: %s", + ast_map::node_id_to_str(cx.items, did.node)}); } } } @@ -2962,8 +2962,8 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, ret ast_util::local_def(m.id); } } - cx.sess.span_fatal(sp, #fmt("Class doesn't have a method \ - named %s", *name)); + cx.sess.span_fatal(sp, fmt!{"Class doesn't have a method \ + named %s", *name}); } else { csearch::get_class_method(cx.sess.cstore, did, name) diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index f12bec35cfc..2338aa6368c 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -167,7 +167,7 @@ enum crate_ctxt { // Functions that write types into the node type table fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) { - #debug["write_ty_to_tcx(%d, %s)", node_id, ty_to_str(tcx, ty)]; + debug!{"write_ty_to_tcx(%d, %s)", node_id, ty_to_str(tcx, ty)}; smallintmap::insert(*tcx.node_types, node_id as uint, ty); } fn write_substs_to_tcx(tcx: ty::ctxt, @@ -266,10 +266,10 @@ fn check_main_fn_ty(ccx: @crate_ctxt, arg_is_argv_ty(tcx, inputs[0]); if !ok { tcx.sess.span_err(main_span, - #fmt("Wrong type in main function: found `%s`, \ + fmt!{"Wrong type in main function: found `%s`, \ expected `extern fn(~[str]) -> ()` \ or `extern fn() -> ()`", - ty_to_str(tcx, main_t))); + ty_to_str(tcx, main_t)}); } } _ { diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index 3baea12ab48..341d9460c4b 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -87,8 +87,8 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>( let {bounds: decl_bounds, rp: decl_rp, ty: decl_ty} = self.get_item_ty(did); - #debug["ast_path_to_substs_and_ty: did=%? decl_rp=%b", - did, decl_rp]; + debug!{"ast_path_to_substs_and_ty: did=%? decl_rp=%b", + did, decl_rp}; // If the type is parameterized by the self region, then replace self // region with the current anon region binding (in other words, @@ -100,9 +100,9 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>( (false, some(_)) { tcx.sess.span_err( path.span, - #fmt["no region bound is allowed on `%s`, \ + fmt!{"no region bound is allowed on `%s`, \ which is not declared as containing region pointers", - ty::item_path_str(tcx, did)]); + ty::item_path_str(tcx, did)}); none } (true, none) { @@ -119,8 +119,8 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>( if !vec::same_length(*decl_bounds, path.types) { self.tcx().sess.span_fatal( path.span, - #fmt["wrong number of type arguments: expected %u but found %u", - (*decl_bounds).len(), path.types.len()]); + fmt!{"wrong number of type arguments: expected %u but found %u", + (*decl_bounds).len(), path.types.len()}); } let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, a_t)); @@ -266,8 +266,8 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( } ast::ty_path(path, id) { let a_def = alt tcx.def_map.find(id) { - none { tcx.sess.span_fatal(ast_ty.span, #fmt("unbound path %s", - path_to_str(path))); } + none { tcx.sess.span_fatal(ast_ty.span, fmt!{"unbound path %s", + path_to_str(path)}); } some(d) { d }}; alt a_def { ast::def_ty(did) | ast::def_class(did, _) { @@ -322,8 +322,8 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( |ty| { tcx.sess.span_err( a_t.span, - #fmt["bound not allowed on a %s", - ty::ty_sort_str(tcx, ty.ty)]); + fmt!{"bound not allowed on a %s", + ty::ty_sort_str(tcx, ty.ty)}); ty.ty }) } @@ -400,7 +400,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy owned>( decl: ast::fn_decl, expected_tys: expected_tys) -> ty::fn_ty { - #debug["ty_of_fn_decl"]; + debug!{"ty_of_fn_decl"}; do indent { // new region names that appear inside of the fn decl are bound to // that function type diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index e7575ff0f1f..1f589a1b960 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -201,10 +201,10 @@ fn check_fn(ccx: @crate_ctxt, let arg_tys = fn_ty.inputs.map(|a| a.ty); let ret_ty = fn_ty.output; - #debug["check_fn(arg_tys=%?, ret_ty=%?, self_ty=%?)", + debug!{"check_fn(arg_tys=%?, ret_ty=%?, self_ty=%?)", arg_tys.map(|a| ty_to_str(tcx, a)), ty_to_str(tcx, ret_ty), - option::map(self_ty, |st| ty_to_str(tcx, st))]; + option::map(self_ty, |st| ty_to_str(tcx, st))}; // ______________________________________________________________________ // Create the function context. This is either derived from scratch or, @@ -299,8 +299,8 @@ fn check_fn(ccx: @crate_ctxt, // Add formal parameters. do vec::iter2(arg_tys, decl.inputs) |arg_ty, input| { assign(input.id, some(arg_ty)); - #debug["Argument %s is assigned to %s", - *input.ident, fcx.locals.get(input.id).to_str()]; + debug!{"Argument %s is assigned to %s", + *input.ident, fcx.locals.get(input.id).to_str()}; } // Add explicitly-declared locals. @@ -311,9 +311,9 @@ fn check_fn(ccx: @crate_ctxt, _ { some(fcx.to_ty(local.node.ty)) } }; assign(local.node.id, o_ty); - #debug["Local variable %s is assigned to %s", + debug!{"Local variable %s is assigned to %s", pat_to_str(local.node.pat), - fcx.locals.get(local.node.id).to_str()]; + fcx.locals.get(local.node.id).to_str()}; visit::visit_local(local, e, v); }; @@ -323,9 +323,9 @@ fn check_fn(ccx: @crate_ctxt, ast::pat_ident(path, _) if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) { assign(p.id, none); - #debug["Pattern binding %s is assigned to %s", + debug!{"Pattern binding %s is assigned to %s", *path.idents[0], - fcx.locals.get(p.id).to_str()]; + fcx.locals.get(p.id).to_str()}; } _ {} } @@ -381,9 +381,9 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields: let (id, sp) = p; alt field_names.find(id) { some(orig_sp) { - tcx.sess.span_err(sp, #fmt("Duplicate field \ + tcx.sess.span_err(sp, fmt!{"Duplicate field \ name %s in record type declaration", - *id)); + *id}); tcx.sess.span_note(orig_sp, ~"First declaration of \ this field occurred here"); break; @@ -407,8 +407,8 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { } ast::item_impl(tps, _, ty, ms) { let rp = ccx.tcx.region_paramd_items.contains_key(it.id); - #debug["item_impl %s with id %d rp %b", - *it.ident, it.id, rp]; + debug!{"item_impl %s with id %d rp %b", + *it.ident, it.id, rp}; let self_ty = ccx.to_ty(rscope::type_rscope(rp), ty); for ms.each |m| { check_method(ccx, m, self_ty);} } @@ -470,7 +470,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { if (*tpt.bounds).is_not_empty() { ccx.tcx.sess.span_err( item.span, - #fmt["foreign items may not have type parameters"]); + fmt!{"foreign items may not have type parameters"}); } } } @@ -502,7 +502,7 @@ impl of region_scope for @fn_ctxt { some(r) { result::ok(r) } none if *id == ~"blk" { self.block_region() } none { - result::err(#fmt["named region `%s` not in scope here", *id]) + result::err(fmt!{"named region `%s` not in scope here", *id}) } } } @@ -510,14 +510,14 @@ impl of region_scope for @fn_ctxt { } impl methods for @fn_ctxt { - fn tag() -> ~str { #fmt["%x", ptr::addr_of(*self) as uint] } + fn tag() -> ~str { fmt!{"%x", ptr::addr_of(*self) as uint} } fn block_region() -> result<ty::region, ~str> { result::ok(ty::re_scope(self.region_lb)) } #[inline(always)] fn write_ty(node_id: ast::node_id, ty: ty::t) { - #debug["write_ty(%d, %s) in fcx %s", - node_id, ty_to_str(self.tcx(), ty), self.tag()]; + debug!{"write_ty(%d, %s) in fcx %s", + node_id, ty_to_str(self.tcx(), ty), self.tag()}; self.node_types.insert(node_id, ty); } fn write_substs(node_id: ast::node_id, +substs: ty::substs) { @@ -546,8 +546,8 @@ impl methods for @fn_ctxt { alt self.node_types.find(ex.id) { some(t) { t } none { - self.tcx().sess.bug(#fmt["no type for expr %d (%s) in fcx %s", - ex.id, expr_to_str(ex), self.tag()]); + self.tcx().sess.bug(fmt!{"no type for expr %d (%s) in fcx %s", + ex.id, expr_to_str(ex), self.tag()}); } } } @@ -556,9 +556,9 @@ impl methods for @fn_ctxt { some(t) { t } none { self.tcx().sess.bug( - #fmt["no type for node %d: %s in fcx %s", + fmt!{"no type for node %d: %s in fcx %s", id, ast_map::node_id_to_str(self.tcx().items, id), - self.tag()]); + self.tag()}); } } } @@ -567,9 +567,9 @@ impl methods for @fn_ctxt { some(ts) { ts } none { self.tcx().sess.bug( - #fmt["no type substs for node %d: %s in fcx %s", + fmt!{"no type substs for node %d: %s in fcx %s", id, ast_map::node_id_to_str(self.tcx().items, id), - self.tag()]); + self.tag()}); } } } @@ -581,10 +581,10 @@ impl methods for @fn_ctxt { err: ty::type_err) { self.ccx.tcx.sess.span_err( sp, - #fmt["mismatched types: expected `%s` but found `%s` (%s)", + fmt!{"mismatched types: expected `%s` but found `%s` (%s)", self.infcx.ty_to_str(e), self.infcx.ty_to_str(a), - ty::type_err_to_str(self.ccx.tcx, err)]); + ty::type_err_to_str(self.ccx.tcx, err)}); } fn mk_subty(sub: ty::t, sup: ty::t) -> result<(), ty::type_err> { @@ -621,7 +621,7 @@ impl methods for @fn_ctxt { _ { self.ccx.tcx.sess.span_err( sp, - #fmt["%s requires unsafe function or block", op]); + fmt!{"%s requires unsafe function or block", op}); } } } @@ -775,8 +775,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expected: option<ty::t>, unifier: fn()) -> bool { - #debug(">> typechecking expr %d (%s)", - expr.id, syntax::print::pprust::expr_to_str(expr)); + debug!{">> typechecking expr %d (%s)", + expr.id, syntax::print::pprust::expr_to_str(expr)}; // A generic function to factor out common logic from call and // overloaded operations @@ -789,8 +789,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // Replace all region parameters in the arguments and return // type with fresh region variables. - #debug["check_call_inner: before universal quant., in_fty=%s", - fcx.infcx.ty_to_str(in_fty)]; + debug!{"check_call_inner: before universal quant., in_fty=%s", + fcx.infcx.ty_to_str(in_fty)}; // This is subtle: we expect `fty` to be a function type, which // normally introduce a level of binding. In this case, we want to @@ -815,8 +815,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }; let fty = ty::mk_fn(fcx.tcx(), fn_ty); - #debug["check_call_inner: after universal quant., fty=%s", - fcx.infcx.ty_to_str(fty)]; + debug!{"check_call_inner: after universal quant., fty=%s", + fcx.infcx.ty_to_str(fty)}; let supplied_arg_count = vec::len(args); @@ -827,7 +827,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn_ty.inputs.map(|a| a.ty) } else { fcx.ccx.tcx.sess.span_err( - sp, #fmt["this function takes %u parameter%s but %u \ + sp, fmt!{"this function takes %u parameter%s but %u \ parameter%s supplied", expected_arg_count, if expected_arg_count == 1u { ~"" @@ -839,7 +839,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ~" was" } else { ~"s were" - }]); + }}); fcx.infcx.next_ty_vars(supplied_arg_count) }; @@ -999,8 +999,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // separate case below. tcx.sess.span_bug( expr.span, - #fmt["comparison operator in expr_binop: %s", - ast_util::binop_to_str(op)]); + fmt!{"comparison operator in expr_binop: %s", + ast_util::binop_to_str(op)}); } _ { lhs_t } }; @@ -1061,8 +1061,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, some((ret_ty, _)) { ret_ty } _ { fcx.ccx.tcx.sess.span_err( - ex.span, #fmt["cannot apply unary operator `%s` to type `%s`", - op_str, fcx.infcx.ty_to_str(rhs_t)]); + ex.span, fmt!{"cannot apply unary operator `%s` to type `%s`", + op_str, fcx.infcx.ty_to_str(rhs_t)}); rhs_t } } @@ -1118,8 +1118,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, decl, expected_tys); let fty = ty::mk_fn(tcx, fn_ty); - #debug("check_expr_fn_with_unifier %s fty=%s", - expr_to_str(expr), fcx.infcx.ty_to_str(fty)); + debug!{"check_expr_fn_with_unifier %s fty=%s", + expr_to_str(expr), fcx.infcx.ty_to_str(fty)}; fcx.write_ty(expr.id, fty); @@ -1159,7 +1159,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // (1) verify that the class id actually has a field called // field - #debug("class named %s", ty_to_str(tcx, base_t)); + debug!{"class named %s", ty_to_str(tcx, base_t)}; /* check whether this is a self-reference or not, which determines whether we look at all fields or only public @@ -1209,10 +1209,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } none { let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t); - let msg = #fmt["attempted access of field `%s` on type `%s`, \ + let msg = fmt!{"attempted access of field `%s` on type `%s`, \ but no public field or method with that name \ was found", - *field, fcx.infcx.ty_to_str(t_err)]; + *field, fcx.infcx.ty_to_str(t_err)}; tcx.sess.span_err(expr.span, msg); // NB: Adding a bogus type to allow typechecking to continue fcx.write_ty(expr.id, fcx.infcx.next_ty_var()); @@ -1334,8 +1334,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, _ { tcx.sess.span_err( expr.span, - #fmt["type %s cannot be dereferenced", - fcx.infcx.ty_to_str(oprnd_t)]); + fmt!{"type %s cannot be dereferenced", + fcx.infcx.ty_to_str(oprnd_t)}); } } } @@ -1472,9 +1472,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, result::ok(_) {} result::err(err) { tcx.sess.span_fatal( - expr.span, #fmt("a `loop` function's last argument \ + expr.span, fmt!{"a `loop` function's last argument \ should return `bool`, not `%s`", - fcx.infcx.ty_to_str(fty.output))); + fcx.infcx.ty_to_str(fty.output)}); } } (ty::mk_fn(tcx, {output: ty::mk_nil(tcx) with fty}), fty.proto) @@ -1545,8 +1545,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let t_1 = fcx.to_ty(t); let t_e = fcx.expr_ty(e); - #debug["t_1=%s", fcx.infcx.ty_to_str(t_1)]; - #debug["t_e=%s", fcx.infcx.ty_to_str(t_e)]; + debug!{"t_1=%s", fcx.infcx.ty_to_str(t_1)}; + debug!{"t_e=%s", fcx.infcx.ty_to_str(t_e)}; alt ty::get(t_1).struct { // This will be looked up later on @@ -1743,15 +1743,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, alt class_field_map.find(*field.node.ident) { none => { tcx.sess.span_err(field.span, - #fmt("structure has no field named \ + fmt!{"structure has no field named \ field named `%s`", - *field.node.ident)); + *field.node.ident}); } some((_, true)) => { tcx.sess.span_err(field.span, - #fmt("field `%s` specified more than \ + fmt!{"field `%s` specified more than \ once", - *field.node.ident)); + *field.node.ident}); } some((field_id, false)) => { let expected_field_type = @@ -1779,13 +1779,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } tcx.sess.span_err(expr.span, - #fmt("missing field%s: %s", + fmt!{"missing field%s: %s", if missing_fields.len() == 1 { ~"" } else { ~"s" }, - str::connect(missing_fields, ~", "))); + str::connect(missing_fields, ~", ")}); } // Write in the resulting type. @@ -1851,8 +1851,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, none { let t_err = fcx.infcx.resolve_type_vars_if_possible(p_ty); - let msg = #fmt["no `alloc()` method found for type `%s`", - fcx.infcx.ty_to_str(t_err)]; + let msg = fmt!{"no `alloc()` method found for type `%s`", + fcx.infcx.ty_to_str(t_err)}; tcx.sess.span_err(expr.span, msg); } } @@ -1868,17 +1868,17 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } if bot { fcx.write_bot(expr.id); } - #debug("type of expr %s is %s, expected is %s", + debug!{"type of expr %s is %s, expected is %s", syntax::print::pprust::expr_to_str(expr), ty_to_str(tcx, fcx.expr_ty(expr)), alt expected { some(t) { ty_to_str(tcx, t) } _ { ~"empty" } - }); + }}; unifier(); - #debug("<< bot=%b", bot); + debug!{"<< bot=%b", bot}; ret bot; } @@ -2025,10 +2025,10 @@ fn check_instantiable(tcx: ty::ctxt, item_id: ast::node_id) { let item_ty = ty::node_id_to_type(tcx, item_id); if !ty::is_instantiable(tcx, item_ty) { - tcx.sess.span_err(sp, #fmt["this type cannot be instantiated \ + tcx.sess.span_err(sp, fmt!{"this type cannot be instantiated \ without an instance of itself; \ consider using `option<%s>`", - ty_to_str(tcx, item_ty)]); + ty_to_str(tcx, item_ty)}); } } @@ -2299,7 +2299,7 @@ fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, ast::vstore_fixed(none) { ty::vstore_fixed(n) } ast::vstore_fixed(some(u)) { if n != u { - let s = #fmt("fixed-size sequence mismatch: %u vs. %u",u, n); + let s = fmt!{"fixed-size sequence mismatch: %u vs. %u",u, n}; fcx.ccx.tcx.sess.span_err(e.span,s); } ty::vstore_fixed(u) @@ -2344,7 +2344,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt, for tps_used.eachi |i, b| { if !b { ccx.tcx.sess.span_err( - span, #fmt["type parameter `%s` is unused", *tps[i].ident]); + span, fmt!{"type parameter `%s` is unused", *tps[i].ident}); } } } @@ -2424,14 +2424,14 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id)); let i_n_tps = (*i_ty.bounds).len(); if i_n_tps != n_tps { - tcx.sess.span_err(it.span, #fmt("intrinsic has wrong number \ + tcx.sess.span_err(it.span, fmt!{"intrinsic has wrong number \ of type parameters: found %u, \ - expected %u", i_n_tps, n_tps)); + expected %u", i_n_tps, n_tps}); } else { require_same_types( tcx, none, it.span, i_ty.ty, fty, - || #fmt["intrinsic has wrong type: \ + || fmt!{"intrinsic has wrong type: \ expected `%s`", - ty_to_str(ccx.tcx, fty)]); + ty_to_str(ccx.tcx, fty)}); } } diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index 2b32c8e3564..db35398a49c 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -88,12 +88,12 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, if arg_len > 0u { // N-ary variant. if arg_len != subpats_len { - let s = #fmt["this pattern has %u field%s, but the \ + 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" }, arg_len, - if arg_len == 1u { ~"" } else { ~"s" }]; + if arg_len == 1u { ~"" } else { ~"s" }}; tcx.sess.span_fatal(pat.span, s); } @@ -104,18 +104,18 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, }; } else if subpats_len > 0u { tcx.sess.span_fatal - (pat.span, #fmt["this pattern has %u field%s, \ + (pat.span, fmt!{"this pattern has %u field%s, \ but the corresponding variant has no fields", subpats_len, if subpats_len == 1u { ~"" } - else { ~"s" }]); + else { ~"s" }}); } } _ { tcx.sess.span_fatal (pat.span, - #fmt["mismatched types: expected enum but found `%s`", - fcx.infcx.ty_to_str(expected)]); + fmt!{"mismatched types: expected enum but found `%s`", + fcx.infcx.ty_to_str(expected)}); } } } @@ -141,8 +141,8 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(begin)); let e_ty = fcx.infcx.resolve_type_vars_if_possible(fcx.expr_ty(end)); - #debug["pat_range beginning type: %?", b_ty]; - #debug["pat_range ending type: %?", e_ty]; + debug!{"pat_range beginning type: %?", b_ty}; + 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") { @@ -183,18 +183,18 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { _ { tcx.sess.span_fatal (pat.span, - #fmt["mismatched types: expected `%s` but found record", - fcx.infcx.ty_to_str(expected)]); + fmt!{"mismatched types: expected `%s` but found record", + fcx.infcx.ty_to_str(expected)}); } }; let f_count = vec::len(fields); let ex_f_count = vec::len(ex_fields); if ex_f_count < f_count || !etc && ex_f_count > f_count { tcx.sess.span_fatal - (pat.span, #fmt["mismatched types: expected a record \ + (pat.span, fmt!{"mismatched types: expected a record \ with %u fields, found one with %u \ fields", - ex_f_count, f_count]); + ex_f_count, f_count}); } fn matches(name: ast::ident, f: ty::field) -> bool { ret str::eq(*name, *f.ident); @@ -206,9 +206,9 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } none { tcx.sess.span_fatal(pat.span, - #fmt["mismatched types: did not \ + fmt!{"mismatched types: did not \ expect a record with a field `%s`", - *f.ident]); + *f.ident}); } } } @@ -220,16 +220,16 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { _ { tcx.sess.span_fatal (pat.span, - #fmt["mismatched types: expected `%s`, found tuple", - fcx.infcx.ty_to_str(expected)]); + fmt!{"mismatched types: expected `%s`, found tuple", + fcx.infcx.ty_to_str(expected)}); } }; let e_count = vec::len(elts); if e_count != vec::len(ex_elts) { tcx.sess.span_fatal - (pat.span, #fmt["mismatched types: expected a tuple \ + (pat.span, fmt!{"mismatched types: expected a tuple \ with %u fields, found one with %u \ - fields", vec::len(ex_elts), e_count]); + fields", vec::len(ex_elts), e_count}); } let mut i = 0u; for elts.each |elt| { diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 585d0ccf5cf..277891c4eff 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -58,9 +58,9 @@ class lookup { // Entrypoint: fn method() -> option<method_map_entry> { - #debug["method lookup(m_name=%s, self_ty=%s, %?)", + debug!{"method lookup(m_name=%s, self_ty=%s, %?)", *self.m_name, self.fcx.infcx.ty_to_str(self.self_ty), - ty::get(self.self_ty).struct]; + ty::get(self.self_ty).struct}; // Determine if there are any inherent methods we can call. let optional_inherent_methods; @@ -71,15 +71,15 @@ class lookup { optional_inherent_methods = none; } some(base_type_def_id) { - #debug("(checking method) found base type"); + debug!{"(checking method) found base type"}; optional_inherent_methods = self.fcx.ccx.coherence_info.inherent_methods.find (base_type_def_id); if optional_inherent_methods.is_none() { - #debug("(checking method) ... no inherent methods found"); + debug!{"(checking method) ... no inherent methods found"}; } else { - #debug("(checking method) ... inherent methods found"); + debug!{"(checking method) ... inherent methods found"}; } } } @@ -173,30 +173,30 @@ class lookup { }; self.tcx().sess.span_note( span, - #fmt["candidate #%u is `%s`", + fmt!{"candidate #%u is `%s`", (idx+1u), - ty::item_path_str(self.tcx(), did)]); + ty::item_path_str(self.tcx(), did)}); } fn report_param_candidate(idx: uint, did: ast::def_id) { self.tcx().sess.span_note( self.expr.span, - #fmt["candidate #%u derives from the bound `%s`", + fmt!{"candidate #%u derives from the bound `%s`", (idx+1u), - ty::item_path_str(self.tcx(), did)]); + ty::item_path_str(self.tcx(), did)}); } fn report_trait_candidate(idx: uint, did: ast::def_id) { self.tcx().sess.span_note( self.expr.span, - #fmt["candidate #%u derives from the type of the receiver, \ + fmt!{"candidate #%u derives from the type of the receiver, \ which is the trait `%s`", (idx+1u), - ty::item_path_str(self.tcx(), did)]); + ty::item_path_str(self.tcx(), did)}); } fn add_candidates_from_param(n: uint, did: ast::def_id) { - #debug["candidates_from_param"]; + debug!{"candidates_from_param"}; let tcx = self.tcx(); let mut trait_bnd_idx = 0u; // count only trait bounds @@ -246,7 +246,7 @@ class lookup { fn add_candidates_from_trait(did: ast::def_id, trait_substs: ty::substs) { - #debug["method_from_trait"]; + debug!{"method_from_trait"}; let ms = *ty::trait_methods(self.tcx(), did); for ms.eachi |i, m| { @@ -281,7 +281,7 @@ class lookup { fn add_candidates_from_class(did: ast::def_id, class_substs: ty::substs) { - #debug["method_from_class"]; + debug!{"method_from_class"}; let ms = *ty::trait_methods(self.tcx(), did); @@ -341,7 +341,7 @@ class lookup { let impls_vecs = self.fcx.ccx.impl_map.get(self.expr.id); let mut added_any = false; - #debug["method_from_scope"]; + debug!{"method_from_scope"}; for list::each(impls_vecs) |impls| { for vec::each(*impls) |im| { @@ -379,7 +379,7 @@ class lookup { } else { self.fcx.can_mk_subty(self.self_ty, impl_ty) }; - #debug["matches = %?", matches]; + debug!{"matches = %?", matches}; alt matches { result::err(_) { /* keep looking */ } result::ok(_) { @@ -431,13 +431,13 @@ class lookup { // Continue. } some(inherent_methods) { - #debug("(adding inherent and extension candidates) adding \ - inherent candidates"); + debug!{"(adding inherent and extension candidates) adding \ + inherent candidates"}; for inherent_methods.each |implementation| { - #debug("(adding inherent and extension candidates) \ + debug!{"(adding inherent and extension candidates) \ adding candidates from impl: %s", node_id_to_str(self.tcx().items, - implementation.did.node)); + implementation.did.node)}; self.add_candidates_from_impl(implementation, use_assignability); } @@ -451,9 +451,9 @@ class lookup { } some(trait_ids) { for (*trait_ids).each |trait_id| { - #debug("(adding inherent and extension candidates) \ + debug!{"(adding inherent and extension candidates) \ trying trait: %s", - self.def_id_to_str(trait_id)); + self.def_id_to_str(trait_id)}; let coherence_info = self.fcx.ccx.coherence_info; alt coherence_info.extension_methods.find(trait_id) { @@ -462,10 +462,10 @@ class lookup { } some(extension_methods) { for extension_methods.each |implementation| { - #debug("(adding inherent and extension \ + debug!{"(adding inherent and extension \ candidates) adding impl %s", self.def_id_to_str - (implementation.did)); + (implementation.did)}; self.add_candidates_from_impl (implementation, use_assignability); } @@ -487,10 +487,10 @@ class lookup { fn write_mty_from_candidate(cand: candidate) -> method_map_entry { let tcx = self.fcx.ccx.tcx; - #debug["write_mty_from_candidate(n_tps_m=%u, fty=%s, entry=%?)", + debug!{"write_mty_from_candidate(n_tps_m=%u, fty=%s, entry=%?)", cand.n_tps_m, self.fcx.infcx.ty_to_str(cand.fty), - cand.entry]; + cand.entry}; // Make the actual receiver type (cand.self_ty) assignable to the // required receiver type (cand.rcvr_ty). If this method is not @@ -501,9 +501,9 @@ class lookup { result::err(_) { self.tcx().sess.span_bug( self.expr.span, - #fmt["%s was assignable to %s but now is not?", + fmt!{"%s was assignable to %s but now is not?", self.fcx.infcx.ty_to_str(cand.self_ty), - self.fcx.infcx.ty_to_str(cand.rcvr_ty)]); + self.fcx.infcx.ty_to_str(cand.rcvr_ty)}); } } diff --git a/src/rustc/middle/typeck/check/regionck.rs b/src/rustc/middle/typeck/check/regionck.rs index 850181576ab..06307c1c70c 100644 --- a/src/rustc/middle/typeck/check/regionck.rs +++ b/src/rustc/middle/typeck/check/regionck.rs @@ -107,7 +107,7 @@ fn visit_pat(p: @ast::pat, &&rcx: @rcx, v: rvt) { alt p.node { ast::pat_ident(path, _) if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) { - #debug["visit_pat binding=%s", *path.idents[0]]; + debug!{"visit_pat binding=%s", *path.idents[0]}; visit_node(p.id, p.span, rcx); } _ {} @@ -121,7 +121,7 @@ fn visit_block(b: ast::blk, &&rcx: @rcx, v: rvt) { } fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { - #debug["visit_expr(e=%s)", pprust::expr_to_str(e)]; + debug!{"visit_expr(e=%s)", pprust::expr_to_str(e)}; alt e.node { ast::expr_path(*) { @@ -200,10 +200,10 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool { let tcx = fcx.ccx.tcx; let encl_region = ty::encl_region(tcx, id); - #debug["visit_node(ty=%s, id=%d, encl_region=%s)", + debug!{"visit_node(ty=%s, id=%d, encl_region=%s)", ppaux::ty_to_str(tcx, ty), id, - ppaux::region_to_str(tcx, encl_region)]; + ppaux::region_to_str(tcx, encl_region)}; // Otherwise, look at the type and see if it is a region pointer. ret constrain_regions_in_type(rcx, encl_region, span, ty); @@ -228,9 +228,9 @@ fn constrain_regions_in_type( region: ty::region) { let tcx = rcx.fcx.ccx.tcx; - #debug["constrain_region(encl_region=%s, region=%s)", + debug!{"constrain_region(encl_region=%s, region=%s)", ppaux::region_to_str(tcx, encl_region), - ppaux::region_to_str(tcx, region)]; + ppaux::region_to_str(tcx, region)}; alt region { ty::re_bound(_) { @@ -248,9 +248,9 @@ fn constrain_regions_in_type( let region1 = rcx.fcx.infcx.resolve_region_if_possible(region); tcx.sess.span_err( span, - #fmt["reference is not valid outside \ + fmt!{"reference is not valid outside \ of its lifetime, %s", - ppaux::region_to_str(tcx, region1)]); + ppaux::region_to_str(tcx, region1)}); rcx.errors_reported += 1u; } result::ok(()) { diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index 06455e8887a..efb50b1eb8f 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -14,14 +14,14 @@ fn replace_bound_regions_in_fn_ty( let mut all_tys = ty::tys_in_fn_ty(fn_ty); for self_ty.each |t| { vec::push(all_tys, t) } - #debug["replace_bound_regions_in_fn_ty(self_ty=%?, fn_ty=%s, all_tys=%?)", + debug!{"replace_bound_regions_in_fn_ty(self_ty=%?, fn_ty=%s, all_tys=%?)", self_ty.map(|t| ty_to_str(tcx, t)), ty_to_str(tcx, ty::mk_fn(tcx, fn_ty)), - all_tys.map(|t| ty_to_str(tcx, t))]; + all_tys.map(|t| ty_to_str(tcx, t))}; let _i = indenter(); let isr = do create_bound_region_mapping(tcx, isr, all_tys) |br| { - #debug["br=%?", br]; + debug!{"br=%?", br}; mapf(br) }; let t_fn = ty::fold_sty_to_ty(tcx, ty::ty_fn(fn_ty), |t| { @@ -29,9 +29,9 @@ fn replace_bound_regions_in_fn_ty( }); let t_self = self_ty.map(|t| replace_bound_regions(tcx, isr, t)); - #debug["result of replace_bound_regions_in_fn_ty: self_ty=%?, fn_ty=%s", + debug!{"result of replace_bound_regions_in_fn_ty: self_ty=%?, fn_ty=%s", t_self.map(|t| ty_to_str(tcx, t)), - ty_to_str(tcx, t_fn)]; + ty_to_str(tcx, t_fn)}; ret {isr: isr, self_ty: t_self, @@ -122,9 +122,9 @@ fn replace_bound_regions_in_fn_ty( none if in_fn { r } none { tcx.sess.bug( - #fmt["Bound region not found in \ + fmt!{"Bound region not found in \ in_scope_regions list: %s", - region_to_str(tcx, r)]); + region_to_str(tcx, r)}); } } } @@ -145,7 +145,7 @@ fn replace_bound_regions_in_fn_ty( * stack position and so the resulting region will be the enclosing block. */ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region { - #debug["region_of(expr=%s)", expr_to_str(expr)]; + debug!{"region_of(expr=%s)", expr_to_str(expr)}; ret alt expr.node { ast::expr_path(path) { def(fcx, expr, lookup_def(fcx, path.span, expr.id))} @@ -178,12 +178,12 @@ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region { ast::def_arg(local_id, _) | ast::def_local(local_id, _) | ast::def_binding(local_id) { - #debug["region_of.def/arg/local/binding(id=%d)", local_id]; + debug!{"region_of.def/arg/local/binding(id=%d)", local_id}; let local_scope = fcx.ccx.tcx.region_map.get(local_id); ty::re_scope(local_scope) } ast::def_upvar(_, inner, _) { - #debug["region_of.def/upvar"]; + debug!{"region_of.def/upvar"}; def(fcx, expr, *inner) } ast::def_self(*) { diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index f023f3aeae7..70fddb190fb 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -56,8 +56,8 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, allow_unsafe: bool) -> vtable_origin { - #debug["lookup_vtable(ty=%s, trait_ty=%s)", - fcx.infcx.ty_to_str(ty), fcx.infcx.ty_to_str(trait_ty)]; + debug!{"lookup_vtable(ty=%s, trait_ty=%s)", + fcx.infcx.ty_to_str(ty), fcx.infcx.ty_to_str(trait_ty)}; let _i = indenter(); let tcx = fcx.ccx.tcx; @@ -78,8 +78,8 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, alt check ty::get(ity).struct { ty::ty_trait(idid, substs) { if trait_id == idid { - #debug("(checking vtable) @0 relating ty to trait ty - with did %?", idid); + debug!{"(checking vtable) @0 relating ty to trait ty + with did %?", idid}; relate_trait_tys(fcx, sp, trait_ty, ity); ret vtable_param(n, n_bound); } @@ -92,8 +92,8 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, } ty::ty_trait(did, substs) if trait_id == did { - #debug("(checking vtable) @1 relating ty to trait ty with did %?", - did); + debug!{"(checking vtable) @1 relating ty to trait ty with did %?", + did}; relate_trait_tys(fcx, sp, trait_ty, ty); if !allow_unsafe { @@ -153,10 +153,10 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, } // check that desired trait type unifies - #debug("(checking vtable) @2 relating trait ty %s to \ + debug!{"(checking vtable) @2 relating trait ty %s to \ of_ty %s", fcx.infcx.ty_to_str(trait_ty), - fcx.infcx.ty_to_str(of_ty)); + fcx.infcx.ty_to_str(of_ty)}; let of_ty = ty::subst(tcx, substs, of_ty); relate_trait_tys(fcx, sp, trait_ty, of_ty); @@ -201,9 +201,9 @@ fn fixup_ty(fcx: @fn_ctxt, sp: span, ty: ty::t) -> ty::t { result::err(e) { tcx.sess.span_fatal( sp, - #fmt["cannot determine a type \ + fmt!{"cannot determine a type \ for this bounded type parameter: %s", - fixup_err_to_str(e)]) + fixup_err_to_str(e)}) } } } @@ -215,8 +215,8 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], // XXX: This should work for multiple traits. let ity = ty::impl_traits(tcx, impl_did)[0]; let trait_ty = ty::subst_tps(tcx, impl_tys, ity); - #debug("(connect trait tps) trait type is %?, impl did is %?", - ty::get(trait_ty).struct, impl_did); + debug!{"(connect trait tps) trait type is %?, impl did is %?", + ty::get(trait_ty).struct, impl_did}; alt check ty::get(trait_ty).struct { ty::ty_trait(_, substs) { vec::iter2(substs.tps, trait_tys, diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index f97ff61dbf4..d9615c88583 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -16,9 +16,9 @@ fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) -> if !fcx.ccx.tcx.sess.has_errors() { fcx.ccx.tcx.sess.span_err( sp, - #fmt["cannot determine a type \ + fmt!{"cannot determine a type \ for this expression: %s", - infer::fixup_err_to_str(e)]) + infer::fixup_err_to_str(e)}) } ret none; } @@ -35,8 +35,8 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) } some(t) { - #debug["resolve_type_vars_for_node(id=%d, n_ty=%s, t=%s)", - id, ty_to_str(tcx, n_ty), ty_to_str(tcx, t)]; + debug!{"resolve_type_vars_for_node(id=%d, n_ty=%s, t=%s)", + id, ty_to_str(tcx, n_ty), ty_to_str(tcx, t)}; write_ty_to_tcx(tcx, id, t); alt fcx.opt_node_ty_substs(id) { some(substs) { @@ -120,11 +120,11 @@ fn visit_block(b: ast::blk, wbcx: wb_ctxt, v: wb_vt) { fn visit_pat(p: @ast::pat, wbcx: wb_ctxt, v: wb_vt) { if !wbcx.success { ret; } resolve_type_vars_for_node(wbcx, p.span, p.id); - #debug["Type for pattern binding %s (id %d) resolved to %s", + debug!{"Type for pattern binding %s (id %d) resolved to %s", pat_to_str(p), p.id, wbcx.fcx.infcx.ty_to_str( ty::node_id_to_type(wbcx.fcx.ccx.tcx, - p.id))]; + p.id))}; visit::visit_pat(p, wbcx, v); } fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) { @@ -133,17 +133,17 @@ fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) { let var_ty = ty::mk_var(wbcx.fcx.tcx(), var_id); alt resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) { result::ok(lty) { - #debug["Type for local %s (id %d) resolved to %s", + debug!{"Type for local %s (id %d) resolved to %s", pat_to_str(l.node.pat), l.node.id, - wbcx.fcx.infcx.ty_to_str(lty)]; + wbcx.fcx.infcx.ty_to_str(lty)}; write_ty_to_tcx(wbcx.fcx.ccx.tcx, l.node.id, lty); } result::err(e) { wbcx.fcx.ccx.tcx.sess.span_err( l.span, - #fmt["cannot determine a type \ + fmt!{"cannot determine a type \ for this local variable: %s", - infer::fixup_err_to_str(e)]); + infer::fixup_err_to_str(e)}); wbcx.success = false; } } diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index 005f87e601b..e3fdd0424b7 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -60,13 +60,13 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t) ty_uniq(base_mutability_and_type) | ty_ptr(base_mutability_and_type) | ty_rptr(_, base_mutability_and_type) { - #debug("(getting base type) recurring"); + debug!{"(getting base type) recurring"}; get_base_type(inference_context, span, base_mutability_and_type.ty) } ty_enum(*) | ty_trait(*) | ty_class(*) { - #debug("(getting base type) found base type"); + debug!{"(getting base type) found base type"}; some(resolved_type) } @@ -75,8 +75,8 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t) ty_fn(*) | ty_tup(*) | ty_var(*) | ty_var_integral(*) | ty_param(*) | ty_self | ty_type | ty_opaque_box | ty_opaque_closure_ptr(*) | ty_unboxed_vec(*) { - #debug("(getting base type) no base type; found %?", - get(original_type).struct); + debug!{"(getting base type) no base type; found %?", + get(original_type).struct}; none } } @@ -158,7 +158,7 @@ class CoherenceChecker { visit_crate(*crate, (), mk_simple_visitor(@{ visit_item: |item| { - #debug("(checking coherence) item '%s'", *item.ident); + debug!{"(checking coherence) item '%s'", *item.ident}; alt item.node { item_impl(_, associated_traits, _, _) { @@ -199,9 +199,9 @@ class CoherenceChecker { // base type. if associated_traits.len() == 0 { - #debug("(checking implementation) no associated traits for item \ + debug!{"(checking implementation) no associated traits for item \ '%s'", - *item.ident); + *item.ident}; alt get_base_type_def_id(self.inference_context, item.span, @@ -222,11 +222,11 @@ class CoherenceChecker { for associated_traits.each |associated_trait| { let def = self.crate_context.tcx.def_map.get (associated_trait.ref_id); - #debug("(checking implementation) adding impl for trait \ + debug!{"(checking implementation) adding impl for trait \ '%s', item '%s'", ast_map::node_id_to_str(self.crate_context.tcx.items, associated_trait.ref_id), - *item.ident); + *item.ident}; let implementation = self.create_impl_from_item(item); self.add_trait_method(def_id_of_def(def), implementation); @@ -368,10 +368,10 @@ class CoherenceChecker { let privileged_types = self.gather_privileged_types(module.items); for privileged_types.each |privileged_type| { - #debug("(checking privileged scopes) entering \ + debug!{"(checking privileged scopes) entering \ privileged scope of %d:%d", privileged_type.crate, - privileged_type.node); + privileged_type.node}; self.privileged_types.insert(privileged_type, ()); } @@ -584,11 +584,11 @@ class CoherenceChecker { self_type.ty) { none { let session = self.crate_context.tcx.sess; - session.bug(#fmt("no base type for external impl \ + session.bug(fmt!{"no base type for external impl \ with no trait: %s (type %s)!", *implementation.ident, ty_to_str(self.crate_context.tcx, - self_type.ty))); + self_type.ty)}); } some(_) { // Nothing to do. diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index d695101f877..83bc02a3755 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -92,8 +92,8 @@ impl of ast_conv for @crate_ctxt { ty_of_foreign_item(self, foreign_item) } x { - self.tcx.sess.bug(#fmt["unexpected sort of item \ - in get_item_ty(): %?", x]); + self.tcx.sess.bug(fmt!{"unexpected sort of item \ + in get_item_ty(): %?", x}); } } } @@ -194,11 +194,11 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, } if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) { - tcx.sess.span_err(sp,#fmt["method `%s` has %u parameters \ + tcx.sess.span_err(sp,fmt!{"method `%s` has %u parameters \ but the trait has %u", *if_m.ident, vec::len(impl_m.fty.inputs), - vec::len(if_m.fty.inputs)]); + vec::len(if_m.fty.inputs)}); ret; } @@ -258,9 +258,9 @@ fn check_methods_against_trait(ccx: @crate_ctxt, some({mty: m, id, span}) { if m.purity != if_m.purity { ccx.tcx.sess.span_err( - span, #fmt["method `%s`'s purity does \ + span, fmt!{"method `%s`'s purity does \ not match the trait method's \ - purity", *m.ident]); + purity", *m.ident}); } compare_impl_method( ccx.tcx, span, m, vec::len(tps), @@ -272,7 +272,7 @@ fn check_methods_against_trait(ccx: @crate_ctxt, tcx.sess.span_err( a_trait_ty.path.span, - #fmt["missing method `%s`", *if_m.ident]); + fmt!{"missing method `%s`", *if_m.ident}); } } // alt } // |if_m| @@ -316,7 +316,7 @@ fn convert_methods(ccx: @crate_ctxt, fn convert(ccx: @crate_ctxt, it: @ast::item) { let tcx = ccx.tcx; let rp = tcx.region_paramd_items.contains_key(it.id); - #debug["convert: item %s with id %d rp %b", *it.ident, it.id, rp]; + debug!{"convert: item %s with id %d rp %b", *it.ident, it.id, rp}; alt it.node { // These don't define types. ast::item_foreign_mod(_) | ast::item_mod(_) {} @@ -341,8 +341,8 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { } ast::item_trait(*) { let tpt = ty_of_item(ccx, it); - #debug["item_trait(it.id=%d, tpt.ty=%s)", - it.id, ty_to_str(tcx, tpt.ty)]; + debug!{"item_trait(it.id=%d, tpt.ty=%s)", + it.id, ty_to_str(tcx, tpt.ty)}; write_ty_to_tcx(tcx, it.id, tpt.ty); ensure_trait_methods(ccx, it.id); } @@ -501,8 +501,8 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) let tpt = {bounds: bounds, rp: false, // functions do not have a self ty: ty::mk_fn(ccx.tcx, tofd)}; - #debug["type of %s (id %d) is %s", - *it.ident, it.id, ty_to_str(tcx, tpt.ty)]; + debug!{"type of %s (id %d) is %s", + *it.ident, it.id, ty_to_str(tcx, tpt.ty)}; ccx.tcx.tcache.insert(local_def(it.id), tpt); ret tpt; } diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index 77b7f5cec3b..e3075ff0058 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -231,7 +231,7 @@ fn intersection(a: int_ty_set, b: int_ty_set) -> int_ty_set { fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) -> option<ty::t> { - #debug["single_type_contained_in(a=%s)", uint::to_str(*a, 10u)]; + debug!{"single_type_contained_in(a=%s)", uint::to_str(*a, 10u)}; if *a == INT_TY_SET_i8 { ret some(ty::mk_i8(tcx)); } if *a == INT_TY_SET_u8 { ret some(ty::mk_u8(tcx)); } @@ -345,8 +345,8 @@ fn fixup_err_to_str(f: fixup_err) -> ~str { cyclic_ty(_) { ~"cyclic type of infinite size" } unresolved_region(_) { ~"unconstrained region" } region_var_bound_by_region_var(r1, r2) { - #fmt["region var %? bound by another region var %?; this is \ - a bug in rustc", r1, r2] + fmt!{"region var %? bound by another region var %?; this is \ + a bug in rustc", r1, r2} } } } @@ -365,29 +365,29 @@ fn new_infer_ctxt(tcx: ty::ctxt) -> infer_ctxt { borrowings: dvec()})} fn mk_subty(cx: infer_ctxt, a: ty::t, b: ty::t) -> ures { - #debug["mk_subty(%s <: %s)", a.to_str(cx), b.to_str(cx)]; + debug!{"mk_subty(%s <: %s)", a.to_str(cx), b.to_str(cx)}; indent(|| cx.commit(|| sub(cx).tys(a, b) ) ).to_ures() } fn can_mk_subty(cx: infer_ctxt, a: ty::t, b: ty::t) -> ures { - #debug["can_mk_subty(%s <: %s)", a.to_str(cx), b.to_str(cx)]; + debug!{"can_mk_subty(%s <: %s)", a.to_str(cx), b.to_str(cx)}; indent(|| cx.probe(|| sub(cx).tys(a, b) ) ).to_ures() } fn mk_subr(cx: infer_ctxt, a: ty::region, b: ty::region) -> ures { - #debug["mk_subr(%s <: %s)", a.to_str(cx), b.to_str(cx)]; + debug!{"mk_subr(%s <: %s)", a.to_str(cx), b.to_str(cx)}; indent(|| cx.commit(|| sub(cx).regions(a, b) ) ).to_ures() } fn mk_eqty(cx: infer_ctxt, a: ty::t, b: ty::t) -> ures { - #debug["mk_eqty(%s <: %s)", a.to_str(cx), b.to_str(cx)]; + debug!{"mk_eqty(%s <: %s)", a.to_str(cx), b.to_str(cx)}; indent(|| cx.commit(|| cx.eq_tys(a, b) ) ).to_ures() } fn mk_assignty(cx: infer_ctxt, anmnt: assignment, a: ty::t, b: ty::t) -> ures { - #debug["mk_assignty(%? / %s <: %s)", - anmnt, a.to_str(cx), b.to_str(cx)]; + debug!{"mk_assignty(%? / %s <: %s)", + anmnt, a.to_str(cx), b.to_str(cx)}; indent(|| cx.commit(|| cx.assign_tys(anmnt, a, b) ) ).to_ures() @@ -395,8 +395,8 @@ fn mk_assignty(cx: infer_ctxt, anmnt: assignment, fn can_mk_assignty(cx: infer_ctxt, anmnt: assignment, a: ty::t, b: ty::t) -> ures { - #debug["can_mk_assignty(%? / %s <: %s)", - anmnt, a.to_str(cx), b.to_str(cx)]; + debug!{"can_mk_assignty(%? / %s <: %s)", + anmnt, a.to_str(cx), b.to_str(cx)}; // FIXME(#2593)---this will not unroll any entries we make in the // borrowings table. But this is OK for the moment because this @@ -424,8 +424,8 @@ fn resolve_borrowings(cx: infer_ctxt) { for cx.borrowings.each |item| { alt resolve_region(cx, item.scope, resolve_all|force_all) { ok(region) => { - #debug["borrowing for expr %d resolved to region %?, mutbl %?", - item.expr_id, region, item.mutbl]; + debug!{"borrowing for expr %d resolved to region %?, mutbl %?", + item.expr_id, region, item.mutbl}; cx.tcx.borrowings.insert( item.expr_id, {region: region, mutbl: item.mutbl}); } @@ -434,7 +434,7 @@ fn resolve_borrowings(cx: infer_ctxt) { let str = fixup_err_to_str(e); cx.tcx.sess.span_err( item.span, - #fmt["could not resolve lifetime for borrow: %s", str]); + fmt!{"could not resolve lifetime for borrow: %s", str}); } } } @@ -509,9 +509,9 @@ impl<V:copy to_str> of to_str for bound<V> { impl<T:copy to_str> of to_str for bounds<T> { fn to_str(cx: infer_ctxt) -> ~str { - #fmt["{%s <: %s}", + fmt!{"{%s <: %s}", self.lb.to_str(cx), - self.ub.to_str(cx)] + self.ub.to_str(cx)} } } @@ -526,9 +526,9 @@ 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 { alt self { - redirect(vid) { #fmt("redirect(%s)", vid.to_str()) } - root(pt, rk) { #fmt("root(%s, %s)", pt.to_str(cx), - uint::to_str(rk, 10u)) } + redirect(vid) { fmt!{"redirect(%s)", vid.to_str()} } + root(pt, rk) { fmt!{"root(%s, %s)", pt.to_str(cx), + uint::to_str(rk, 10u)} } } } } @@ -604,12 +604,12 @@ impl transaction_methods for infer_ctxt { let rbl = self.rb.bindings.len(); let bl = self.borrowings.len(); - #debug["try(tvbl=%u, rbl=%u)", tvbl, rbl]; + debug!{"try(tvbl=%u, rbl=%u)", tvbl, rbl}; let r <- f(); alt r { - result::ok(_) { #debug["try--ok"]; } + result::ok(_) { debug!{"try--ok"}; } result::err(_) { - #debug["try--rollback"]; + debug!{"try--rollback"}; rollback_to(self.tvb, tvbl); rollback_to(self.rb, rbl); while self.borrowings.len() != bl { self.borrowings.pop(); } @@ -709,8 +709,8 @@ impl unify_methods for infer_ctxt { vec::push(vb.bindings, (vid, old_v)); vb.vals.insert(vid.to_uint(), new_v); - #debug["Updating variable %s from %s to %s", - vid.to_str(), old_v.to_str(self), new_v.to_str(self)]; + debug!{"Updating variable %s from %s to %s", + vid.to_str(), old_v.to_str(self), new_v.to_str(self)}; } fn get<V:copy vid, T:copy>( @@ -720,7 +720,7 @@ impl unify_methods for infer_ctxt { let vid_u = vid.to_uint(); alt vb.vals.find(vid_u) { none { - self.tcx.sess.bug(#fmt["failed lookup of vid `%u`", vid_u]); + self.tcx.sess.bug(fmt!{"failed lookup of vid `%u`", vid_u}); } some(var_val) { alt var_val { @@ -745,7 +745,7 @@ impl unify_methods for infer_ctxt { a: bound<V>, b: bound<V>, merge_op: fn(V,V) -> cres<V>) -> cres<bound<V>> { - #debug["merge_bnd(%s,%s)", a.to_str(self), b.to_str(self)]; + debug!{"merge_bnd(%s,%s)", a.to_str(self), b.to_str(self)}; let _r = indenter(); alt (a, b) { @@ -773,13 +773,13 @@ impl unify_methods for infer_ctxt { let _r = indenter(); do self.merge_bnd(a.ub, b.ub, glb).chain |ub| { - #debug["glb of ubs %s and %s is %s", + debug!{"glb of ubs %s and %s is %s", a.ub.to_str(self), b.ub.to_str(self), - ub.to_str(self)]; + ub.to_str(self)}; do self.merge_bnd(a.lb, b.lb, lub).chain |lb| { - #debug["lub of lbs %s and %s is %s", + debug!{"lub of lbs %s and %s is %s", a.lb.to_str(self), b.lb.to_str(self), - lb.to_str(self)]; + lb.to_str(self)}; ok({lb: lb, ub: ub}) } } @@ -813,10 +813,10 @@ impl unify_methods for infer_ctxt { // A \ / A // B - #debug["merge(%s,%s,%s)", + debug!{"merge(%s,%s,%s)", v_id.to_str(), a.to_str(self), - b.to_str(self)]; + b.to_str(self)}; // First, relate the lower/upper bounds of A and B. // Note that these relations *must* hold for us to @@ -830,9 +830,9 @@ impl unify_methods for infer_ctxt { do self.merge_bnd(a.ub, b.ub, |x, y| x.glb(self, y) ).chain |ub| { do self.merge_bnd(a.lb, b.lb, |x, y| x.lub(self, y) ).chain |lb| { let bnds = {lb: lb, ub: ub}; - #debug["merge(%s): bnds=%s", + debug!{"merge(%s): bnds=%s", v_id.to_str(), - bnds.to_str(self)]; + bnds.to_str(self)}; // the new bounds must themselves // be relatable: @@ -855,9 +855,9 @@ impl unify_methods for infer_ctxt { let a_bounds = nde_a.possible_types; let b_bounds = nde_b.possible_types; - #debug["vars(%s=%s <: %s=%s)", + debug!{"vars(%s=%s <: %s=%s)", a_id.to_str(), a_bounds.to_str(self), - b_id.to_str(), b_bounds.to_str(self)]; + b_id.to_str(), b_bounds.to_str(self)}; if a_id == b_id { ret uok(); } @@ -883,20 +883,20 @@ impl unify_methods for infer_ctxt { // Make the node with greater rank the parent of the node with // smaller rank. if nde_a.rank > nde_b.rank { - #debug["vars(): a has smaller rank"]; + debug!{"vars(): a has smaller rank"}; // a has greater rank, so a should become b's parent, // i.e., b should redirect to a. self.set(vb, b_id, redirect(a_id)); self.set_var_to_merged_bounds( vb, a_id, a_bounds, b_bounds, nde_a.rank).then(|| uok() ) } else if nde_a.rank < nde_b.rank { - #debug["vars(): b has smaller rank"]; + debug!{"vars(): b has smaller rank"}; // b has greater rank, so a should redirect to b. self.set(vb, a_id, redirect(b_id)); self.set_var_to_merged_bounds( vb, b_id, a_bounds, b_bounds, nde_b.rank).then(|| uok() ) } else { - #debug["vars(): a and b have equal rank"]; + debug!{"vars(): a and b have equal rank"}; assert nde_a.rank == nde_b.rank; // If equal, just redirect one to the other and increment // the other's rank. We choose arbitrarily to redirect b @@ -932,18 +932,18 @@ impl unify_methods for infer_ctxt { // Rank optimization if nde_a.rank > nde_b.rank { - #debug["vars_integral(): a has smaller rank"]; + debug!{"vars_integral(): a has smaller rank"}; // a has greater rank, so a should become b's parent, // i.e., b should redirect to a. self.set(vb, a_id, root(intersection, nde_a.rank)); self.set(vb, b_id, redirect(a_id)); } else if nde_a.rank < nde_b.rank { - #debug["vars_integral(): b has smaller rank"]; + debug!{"vars_integral(): b has smaller rank"}; // b has greater rank, so a should redirect to b. self.set(vb, b_id, root(intersection, nde_b.rank)); self.set(vb, a_id, redirect(b_id)); } else { - #debug["vars_integral(): a and b have equal rank"]; + debug!{"vars_integral(): a and b have equal rank"}; assert nde_a.rank == nde_b.rank; // If equal, just redirect one to the other and increment // the other's rank. We choose arbitrarily to redirect b @@ -963,9 +963,9 @@ impl unify_methods for infer_ctxt { let a_id = nde_a.root; let a_bounds = nde_a.possible_types; - #debug["vart(%s=%s <: %s)", + debug!{"vart(%s=%s <: %s)", a_id.to_str(), a_bounds.to_str(self), - b.to_str(self)]; + b.to_str(self)}; let b_bounds = {lb: none, ub: some(b)}; self.set_var_to_merged_bounds(vb, a_id, a_bounds, b_bounds, nde_a.rank) @@ -1000,9 +1000,9 @@ impl unify_methods for infer_ctxt { let b_id = nde_b.root; let b_bounds = nde_b.possible_types; - #debug["tvar(%s <: %s=%s)", + debug!{"tvar(%s <: %s=%s)", a.to_str(self), - b_id.to_str(), b_bounds.to_str(self)]; + b_id.to_str(), b_bounds.to_str(self)}; self.set_var_to_merged_bounds(vb, b_id, a_bounds, b_bounds, nde_b.rank) } @@ -1030,7 +1030,7 @@ impl unify_methods for infer_ctxt { fn bnds<T:copy to_str st>( a: bound<T>, b: bound<T>) -> ures { - #debug("bnds(%s <: %s)", a.to_str(self), b.to_str(self)); + debug!{"bnds(%s <: %s)", a.to_str(self), b.to_str(self)}; do indent { alt (a, b) { (none, none) | @@ -1060,8 +1060,8 @@ impl unify_methods for infer_ctxt { } fn eq_regions(a: ty::region, b: ty::region) -> ures { - #debug["eq_regions(%s, %s)", - a.to_str(self), b.to_str(self)]; + debug!{"eq_regions(%s, %s)", + a.to_str(self), b.to_str(self)}; do indent { do self.sub_regions(a, b).then { self.sub_regions(b, a) @@ -1141,9 +1141,9 @@ impl methods for resolve_state { fn resolve_type_chk(typ: ty::t) -> fres<ty::t> { self.err = none; - #debug["Resolving %s (modes=%x)", + debug!{"Resolving %s (modes=%x)", ty_to_str(self.infcx.tcx, typ), - self.modes]; + self.modes}; // n.b. This is a hokey mess because the current fold doesn't // allow us to pass back errors in any useful way. @@ -1153,9 +1153,9 @@ impl methods for resolve_state { assert vec::is_empty(self.v_seen); alt self.err { none { - #debug["Resolved to %s (modes=%x)", + debug!{"Resolved to %s (modes=%x)", ty_to_str(self.infcx.tcx, rty), - self.modes]; + self.modes}; ret ok(rty); } some(e) { ret err(e); } @@ -1172,7 +1172,7 @@ impl methods for resolve_state { } fn resolve_type(typ: ty::t) -> ty::t { - #debug("resolve_type(%s)", typ.to_str(self.infcx)); + debug!{"resolve_type(%s)", typ.to_str(self.infcx)}; indent(fn&() -> ty::t { if !ty::type_needs_infer(typ) { ret typ; } @@ -1201,7 +1201,7 @@ impl methods for resolve_state { } fn resolve_nested_tvar(typ: ty::t) -> ty::t { - #debug("Resolve_if_deep(%s)", typ.to_str(self.infcx)); + debug!{"Resolve_if_deep(%s)", typ.to_str(self.infcx)}; if !self.should(resolve_nested_tvar) { typ } else { @@ -1210,7 +1210,7 @@ impl methods for resolve_state { } fn resolve_region(orig: ty::region) -> ty::region { - #debug("Resolve_region(%s)", orig.to_str(self.infcx)); + debug!{"Resolve_region(%s)", orig.to_str(self.infcx)}; alt orig { ty::re_var(rid) { self.resolve_region_var(rid) } _ { orig } @@ -1372,8 +1372,8 @@ impl assignment for infer_ctxt { } } - #debug["assign_tys(anmnt=%?, %s -> %s)", - anmnt, a.to_str(self), b.to_str(self)]; + debug!{"assign_tys(anmnt=%?, %s -> %s)", + anmnt, a.to_str(self), b.to_str(self)}; let _r = indenter(); alt (ty::get(a).struct, ty::get(b).struct) { @@ -1419,9 +1419,9 @@ impl assignment for infer_ctxt { a: ty::t, b: ty::t, a_bnd: option<ty::t>, b_bnd: option<ty::t>) -> ures { - #debug["assign_tys_or_sub(anmnt=%?, %s -> %s, %s -> %s)", + debug!{"assign_tys_or_sub(anmnt=%?, %s -> %s, %s -> %s)", anmnt, a.to_str(self), b.to_str(self), - a_bnd.to_str(self), b_bnd.to_str(self)]; + a_bnd.to_str(self), b_bnd.to_str(self)}; let _r = indenter(); fn is_borrowable(v: ty::vstore) -> bool { @@ -1475,9 +1475,9 @@ impl assignment for infer_ctxt { m: ast::mutability, r_b: ty::region) -> ures { - #debug["crosspollinate(anmnt=%?, a=%s, nr_b=%s, r_b=%s)", + debug!{"crosspollinate(anmnt=%?, a=%s, nr_b=%s, r_b=%s)", anmnt, a.to_str(self), nr_b.to_str(self), - r_b.to_str(self)]; + r_b.to_str(self)}; do indent { do self.sub_tys(a, nr_b).then { @@ -1485,12 +1485,12 @@ impl assignment for infer_ctxt { // borrow bounds: let r_a = self.next_region_var_with_scope_lb(anmnt.borrow_lb); - #debug["anmnt=%?", anmnt]; + debug!{"anmnt=%?", anmnt}; do sub(self).contraregions(r_a, r_b).chain |_r| { // if successful, add an entry indicating that // borrowing occurred - #debug["borrowing expression #%?, scope=%?, m=%?", - anmnt, r_a, m]; + debug!{"borrowing expression #%?, scope=%?, m=%?", + anmnt, r_a, m}; self.borrowings.push({expr_id: anmnt.expr_id, span: anmnt.span, scope: r_a, @@ -1596,10 +1596,10 @@ fn super_substs<C:combine>( // consistently have a region parameter or not have a // region parameter. infcx.tcx.sess.bug( - #fmt["substitution a had opt_region %s and \ + fmt!{"substitution a had opt_region %s and \ b had opt_region %s", a.to_str(infcx), - b.to_str(infcx)]); + b.to_str(infcx)}); } } } @@ -1751,10 +1751,10 @@ fn super_tys<C:combine>( (ty::ty_var(_), _) | (_, ty::ty_var(_)) { tcx.sess.bug( - #fmt["%s: bot and var types should have been handled (%s,%s)", + fmt!{"%s: bot and var types should have been handled (%s,%s)", self.tag(), a.to_str(self.infcx()), - b.to_str(self.infcx())]); + b.to_str(self.infcx())}); } // Have to handle these first @@ -1904,10 +1904,10 @@ impl of combine for sub { } fn regions(a: ty::region, b: ty::region) -> cres<ty::region> { - #debug["%s.regions(%s, %s)", + debug!{"%s.regions(%s, %s)", self.tag(), a.to_str(self.infcx()), - b.to_str(self.infcx())]; + b.to_str(self.infcx())}; do indent { alt (a, b) { (ty::re_var(a_id), ty::re_var(b_id)) { @@ -1935,7 +1935,7 @@ impl of combine for sub { } fn mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> { - #debug("mts(%s <: %s)", a.to_str(*self), b.to_str(*self)); + debug!{"mts(%s <: %s)", a.to_str(*self), b.to_str(*self)}; if a.mutbl != b.mutbl && b.mutbl != m_const { ret err(ty::terr_mutability); @@ -1973,8 +1973,8 @@ impl of combine for sub { } fn tys(a: ty::t, b: ty::t) -> cres<ty::t> { - #debug("%s.tys(%s, %s)", self.tag(), - a.to_str(*self), b.to_str(*self)); + debug!{"%s.tys(%s, %s)", self.tag(), + a.to_str(*self), b.to_str(*self)}; if a == b { ret ok(a); } do indent { alt (ty::get(a).struct, ty::get(b).struct) { @@ -2015,9 +2015,9 @@ impl of combine for sub { // for it. The only thing we're doing with `br` here is // using it in the debug message. let rvar = self.infcx().next_region_var_nb(); - #debug["Bound region %s maps to %s", + debug!{"Bound region %s maps to %s", bound_region_to_str(self.tcx, br), - region_to_str(self.tcx, rvar)]; + region_to_str(self.tcx, rvar)}; rvar } }; @@ -2078,10 +2078,10 @@ impl of combine for lub { fn mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> { let tcx = self.infcx().tcx; - #debug("%s.mts(%s, %s)", + debug!{"%s.mts(%s, %s)", self.tag(), mt_to_str(tcx, a), - mt_to_str(tcx, b)); + mt_to_str(tcx, b)}; let m = if a.mutbl == b.mutbl { a.mutbl @@ -2150,10 +2150,10 @@ impl of combine for lub { } fn regions(a: ty::region, b: ty::region) -> cres<ty::region> { - #debug["%s.regions(%?, %?)", + debug!{"%s.regions(%?, %?)", self.tag(), a.to_str(self.infcx()), - b.to_str(self.infcx())]; + b.to_str(self.infcx())}; do indent { alt (a, b) { @@ -2259,10 +2259,10 @@ impl of combine for glb { fn mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> { let tcx = self.infcx().tcx; - #debug("%s.mts(%s, %s)", + debug!{"%s.mts(%s, %s)", self.tag(), mt_to_str(tcx, a), - mt_to_str(tcx, b)); + mt_to_str(tcx, b)}; alt (a.mutbl, b.mutbl) { // If one side or both is mut, then the GLB must use @@ -2347,10 +2347,10 @@ impl of combine for glb { } fn regions(a: ty::region, b: ty::region) -> cres<ty::region> { - #debug["%s.regions(%?, %?)", + debug!{"%s.regions(%?, %?)", self.tag(), a.to_str(self.infcx()), - b.to_str(self.infcx())]; + b.to_str(self.infcx())}; do indent { alt (a, b) { @@ -2486,9 +2486,9 @@ impl of lattice_ops for glb { fn lattice_tys<L:lattice_ops combine>( self: L, a: ty::t, b: ty::t) -> cres<ty::t> { - #debug("%s.lattice_tys(%s, %s)", self.tag(), + debug!{"%s.lattice_tys(%s, %s)", self.tag(), a.to_str(self.infcx()), - b.to_str(self.infcx())); + b.to_str(self.infcx())}; if a == b { ret ok(a); } do indent { alt (ty::get(a).struct, ty::get(b).struct) { @@ -2536,11 +2536,11 @@ fn lattice_rvars<L:lattice_ops combine>( _ { self.infcx().tcx.sess.bug( - #fmt["%s: lattice_rvars invoked with a=%s and b=%s, \ + fmt!{"%s: lattice_rvars invoked with a=%s and b=%s, \ neither of which are region variables", self.tag(), a.to_str(self.infcx()), - b.to_str(self.infcx())]); + b.to_str(self.infcx())}); } } } @@ -2562,10 +2562,10 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>( let a_bounds = nde_a.possible_types; let b_bounds = nde_b.possible_types; - #debug["%s.lattice_vars(%s=%s <: %s=%s)", + debug!{"%s.lattice_vars(%s=%s <: %s=%s)", self.tag(), a_vid.to_str(), a_bounds.to_str(self.infcx()), - b_vid.to_str(), b_bounds.to_str(self.infcx())]; + b_vid.to_str(), b_bounds.to_str(self.infcx())}; if a_vid == b_vid { ret ok(a_t); @@ -2601,21 +2601,21 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>( // The comments in this function are written for LUB, but they // apply equally well to GLB if you inverse upper/lower/sub/super/etc. - #debug["%s.lattice_vart(%s=%s <: %s)", + debug!{"%s.lattice_vart(%s=%s <: %s)", self.tag(), a_id.to_str(), a_bounds.to_str(self.infcx()), - b.to_str(self.infcx())]; + b.to_str(self.infcx())}; alt self.bnd(a_bounds) { some(a_bnd) { // If a has an upper bound, return the LUB(a.ub, b) - #debug["bnd=some(%s)", a_bnd.to_str(self.infcx())]; + debug!{"bnd=some(%s)", a_bnd.to_str(self.infcx())}; ret c_ts(a_bnd, b); } none { // If a does not have an upper bound, make b the upper bound of a // and then return b. - #debug["bnd=none"]; + debug!{"bnd=none"}; let a_bounds = self.with_bnd(a_bounds, b); do self.infcx().bnds(a_bounds.lb, a_bounds.ub).then { self.infcx().set(vb, a_id, root(a_bounds, diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 011b482f577..b9f4d3d76ae 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -8,20 +8,20 @@ import syntax::print; fn indent<R>(op: fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` // to make debug output more readable. - #debug[">>"]; + debug!{">>"}; let r <- op(); - #debug["<< (Result = %?)", r]; + debug!{"<< (Result = %?)", r}; ret r; } class _indenter { let _i: (); new(_i: ()) { self._i = (); } - drop { #debug["<<"]; } + drop { debug!{"<<"}; } } fn indenter() -> _indenter { - #debug[">>"]; + debug!{">>"}; _indenter(()) } diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index d3c05ea6bec..bf97df5fd5f 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -22,7 +22,7 @@ import driver::session::session; fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { alt br { br_anon => { ~"&" } - br_named(str) => { #fmt["&%s", *str] } + br_named(str) => { fmt!{"&%s", *str} } br_self if cx.sess.ppregions() => { ~"&<self>" } br_self => { ~"&self" } @@ -30,7 +30,7 @@ fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { // does not fail br_cap_avoid(id, br) => { if cx.sess.ppregions() { - #fmt["br_cap_avoid(%?, %s)", id, bound_region_to_str(cx, *br)] + fmt!{"br_cap_avoid(%?, %s)", id, bound_region_to_str(cx, *br)} } else { bound_region_to_str(cx, *br) } @@ -41,50 +41,50 @@ fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~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>", - codemap::span_to_str(blk.span, cx.sess.codemap)) + fmt!{"<block at %s>", + codemap::span_to_str(blk.span, cx.sess.codemap)} } some(ast_map::node_expr(expr)) { alt expr.node { ast::expr_call(*) { - #fmt("<call at %s>", - codemap::span_to_str(expr.span, cx.sess.codemap)) + fmt!{"<call at %s>", + codemap::span_to_str(expr.span, cx.sess.codemap)} } ast::expr_alt(*) { - #fmt("<alt at %s>", - codemap::span_to_str(expr.span, cx.sess.codemap)) + fmt!{"<alt at %s>", + codemap::span_to_str(expr.span, cx.sess.codemap)} } ast::expr_assign_op(*) | ast::expr_field(*) | ast::expr_unary(*) | ast::expr_binary(*) | ast::expr_index(*) { - #fmt("<method at %s>", - codemap::span_to_str(expr.span, cx.sess.codemap)) + fmt!{"<method at %s>", + codemap::span_to_str(expr.span, cx.sess.codemap)} } _ { - #fmt("<expression at %s>", - codemap::span_to_str(expr.span, cx.sess.codemap)) + fmt!{"<expression at %s>", + codemap::span_to_str(expr.span, cx.sess.codemap)} } } } none { - #fmt["<unknown-%d>", node_id] + fmt!{"<unknown-%d>", node_id} } _ { cx.sess.bug( - #fmt["re_scope refers to %s", - ast_map::node_id_to_str(cx.items, node_id)]) } + fmt!{"re_scope refers to %s", + ast_map::node_id_to_str(cx.items, node_id)}) } } } 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_scope(node_id) { fmt!{"&%s", re_scope_id_to_str(cx, node_id)} } re_bound(br) { bound_region_to_str(cx, br) } re_free(id, br) { if cx.sess.ppregions() { // For debugging, this version is sometimes helpful: - #fmt["{%d} %s", id, bound_region_to_str(cx, br)] + fmt!{"{%d} %s", id, bound_region_to_str(cx, br)} } else { // But this version is what the user expects to see: bound_region_to_str(cx, br) @@ -92,7 +92,7 @@ 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_var(id) { fmt!{"&%s", id.to_str()} } re_static { ~"&static" } } } @@ -108,7 +108,7 @@ fn mt_to_str(cx: ctxt, m: mt) -> ~str { fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { alt vs { - ty::vstore_fixed(n) { #fmt["%u", n] } + ty::vstore_fixed(n) { fmt!{"%u", n} } ty::vstore_uniq { ~"~" } ty::vstore_box { ~"@" } ty::vstore_slice(r) { region_to_str(cx, r) } @@ -118,9 +118,9 @@ fn vstore_to_str(cx: ctxt, 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)] + fmt!{"%s/%s", ty, vstore_to_str(cx, vs)} } - _ { #fmt["%s%s", vstore_to_str(cx, vs), ty] } + _ { fmt!{"%s%s", vstore_to_str(cx, vs), ty} } } } @@ -243,7 +243,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { parameterized(cx, base, substs.self_r, substs.tps) } ty_evec(mt, vs) { - vstore_ty_to_str(cx, #fmt["[%s]", mt_to_str(cx, 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 { ~"@?" } @@ -261,15 +261,15 @@ fn parameterized(cx: ctxt, let r_str = alt self_r { none { ~"" } some(r) { - #fmt["/%s", region_to_str(cx, r)] + fmt!{"/%s", region_to_str(cx, r)} } }; 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] + fmt!{"%s%s", base, r_str} } } |
