1
Fork 0

Change syntax extension syntax: #m[...] -> m!{...}.

This commit is contained in:
Paul Stansifer 2012-07-30 16:01:07 -07:00
parent 650fb06d68
commit a9cc5066ee
365 changed files with 2760 additions and 2759 deletions

View file

@ -369,7 +369,7 @@ fn rest(s: ~str, start: uint) -> ~str {
fn need_dir(s: ~str) { fn need_dir(s: ~str) {
if os::path_is_dir(s) { ret; } if os::path_is_dir(s) { ret; }
if !os::make_dir(s, 493_i32 /* oct: 755 */) { if !os::make_dir(s, 493_i32 /* oct: 755 */) {
fail #fmt["can't make_dir %s", s]; fail fmt!{"can't make_dir %s", s};
} }
} }
@ -387,7 +387,7 @@ fn valid_pkg_name(s: ~str) -> bool {
fn parse_source(name: ~str, j: json::json) -> source { fn parse_source(name: ~str, j: json::json) -> source {
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
fail #fmt("'%s' is an invalid source name", name); fail fmt!{"'%s' is an invalid source name", name};
} }
alt j { alt j {
@ -438,11 +438,11 @@ fn try_parse_sources(filename: ~str, sources: map::hashmap<~str, source>) {
ok(json::dict(j)) { ok(json::dict(j)) {
for j.each |k, v| { for j.each |k, v| {
sources.insert(k, parse_source(k, v)); sources.insert(k, parse_source(k, v));
#debug("source: %s", k); debug!{"source: %s", k};
} }
} }
ok(_) { fail ~"malformed sources.json"; } ok(_) { fail ~"malformed sources.json"; }
err(e) { fail #fmt("%s:%s", filename, e.to_str()); } err(e) { fail fmt!{"%s:%s", filename, e.to_str()}; }
} }
} }
@ -565,7 +565,7 @@ fn load_source_info(c: cargo, src: source) {
~"(source info is not a dict)"); ~"(source info is not a dict)");
} }
err(e) { err(e) {
warn(#fmt("%s:%s", src.name, e.to_str())); warn(fmt!{"%s:%s", src.name, e.to_str()});
} }
}; };
} }
@ -594,7 +594,7 @@ fn load_source_packages(c: cargo, src: source) {
~"(packages is not a list)"); ~"(packages is not a list)");
} }
err(e) { err(e) {
warn(#fmt("%s:%s", src.name, e.to_str())); warn(fmt!{"%s:%s", src.name, e.to_str()});
} }
}; };
} }
@ -603,7 +603,7 @@ fn build_cargo_options(argv: ~[~str]) -> options {
let match = alt getopts::getopts(argv, opts()) { let match = alt getopts::getopts(argv, opts()) {
result::ok(m) { m } result::ok(m) { m }
result::err(f) { result::err(f) {
fail #fmt["%s", getopts::fail_str(f)]; fail fmt!{"%s", getopts::fail_str(f)};
} }
}; };
@ -713,11 +713,11 @@ fn run_in_buildpath(what: ~str, path: ~str, subdir: ~str, cf: ~str,
extra_flags: ~[~str]) -> option<~str> { extra_flags: ~[~str]) -> option<~str> {
let buildpath = path::connect(path, subdir); let buildpath = path::connect(path, subdir);
need_dir(buildpath); need_dir(buildpath);
#debug("%s: %s -> %s", what, cf, buildpath); debug!{"%s: %s -> %s", what, cf, buildpath};
let p = run::program_output(rustc_sysroot(), let p = run::program_output(rustc_sysroot(),
~[~"--out-dir", buildpath, cf] + extra_flags); ~[~"--out-dir", buildpath, cf] + extra_flags);
if p.status != 0 { if p.status != 0 {
error(#fmt["rustc failed: %d\n%s\n%s", p.status, p.err, p.out]); error(fmt!{"rustc failed: %d\n%s\n%s", p.status, p.err, p.out});
ret none; ret none;
} }
some(buildpath) some(buildpath)
@ -744,7 +744,7 @@ fn install_one_crate(c: cargo, path: ~str, cf: ~str) {
if (exec_suffix != ~"" && str::ends_with(ct, exec_suffix)) || if (exec_suffix != ~"" && str::ends_with(ct, exec_suffix)) ||
(exec_suffix == ~"" && !str::starts_with(path::basename(ct), (exec_suffix == ~"" && !str::starts_with(path::basename(ct),
~"lib")) { ~"lib")) {
#debug(" bin: %s", ct); debug!{" bin: %s", ct};
install_to_dir(ct, c.bindir); install_to_dir(ct, c.bindir);
if c.opts.mode == system_mode { if c.opts.mode == system_mode {
// FIXME (#2662): Put this file in PATH / symlink it so it can // FIXME (#2662): Put this file in PATH / symlink it so it can
@ -752,7 +752,7 @@ fn install_one_crate(c: cargo, path: ~str, cf: ~str) {
// `cargo install -G rustray` and `rustray file.obj` // `cargo install -G rustray` and `rustray file.obj`
} }
} else { } else {
#debug(" lib: %s", ct); debug!{" lib: %s", ct};
install_to_dir(ct, c.libdir); install_to_dir(ct, c.libdir);
} }
} }
@ -764,7 +764,7 @@ fn rustc_sysroot() -> ~str {
some(path) { some(path) {
let path = ~[path, ~"..", ~"bin", ~"rustc"]; let path = ~[path, ~"..", ~"bin", ~"rustc"];
let rustc = path::normalize(path::connect_many(path)); let rustc = path::normalize(path::connect_many(path));
#debug(" rustc: %s", rustc); debug!{" rustc: %s", rustc};
rustc rustc
} }
none { ~"rustc" } none { ~"rustc" }
@ -772,7 +772,7 @@ fn rustc_sysroot() -> ~str {
} }
fn install_source(c: cargo, path: ~str) { fn install_source(c: cargo, path: ~str) {
#debug("source: %s", path); debug!{"source: %s", path};
os::change_dir(path); os::change_dir(path);
let mut cratefiles = ~[]; let mut cratefiles = ~[];
@ -798,7 +798,7 @@ fn install_source(c: cargo, path: ~str) {
let wd_base = c.workdir + path::path_sep(); let wd_base = c.workdir + path::path_sep();
let wd = alt tempfile::mkdtemp(wd_base, ~"") { let wd = alt tempfile::mkdtemp(wd_base, ~"") {
some(wd) { wd } some(wd) { wd }
none { fail #fmt("needed temp dir: %s", wd_base); } none { fail fmt!{"needed temp dir: %s", wd_base}; }
}; };
install_query(c, wd, query); install_query(c, wd, query);
@ -831,7 +831,7 @@ fn install_curl(c: cargo, wd: ~str, url: ~str) {
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
tarpath, url]); tarpath, url]);
if p.status != 0 { if p.status != 0 {
fail #fmt["fetch of %s failed: %s", url, p.err]; fail fmt!{"fetch of %s failed: %s", url, p.err};
} }
run::run_program(~"tar", ~[~"-x", ~"--strip-components=1", run::run_program(~"tar", ~[~"-x", ~"--strip-components=1",
~"-C", wd, ~"-f", tarpath]); ~"-C", wd, ~"-f", tarpath]);
@ -852,7 +852,7 @@ fn install_package(c: cargo, src: ~str, wd: ~str, pkg: package) {
_ { ~"curl" } _ { ~"curl" }
}; };
info(#fmt["installing %s/%s via %s...", src, pkg.name, method]); info(fmt!{"installing %s/%s via %s...", src, pkg.name, method});
alt method { alt method {
~"git" { install_git(c, wd, url, copy pkg.ref); } ~"git" { install_git(c, wd, url, copy pkg.ref); }
@ -1082,7 +1082,7 @@ fn cmd_install(c: cargo) unsafe {
let wd_base = c.workdir + path::path_sep(); let wd_base = c.workdir + path::path_sep();
let wd = alt tempfile::mkdtemp(wd_base, ~"") { let wd = alt tempfile::mkdtemp(wd_base, ~"") {
some(wd) { wd } some(wd) { wd }
none { fail #fmt("needed temp dir: %s", wd_base); } none { fail fmt!{"needed temp dir: %s", wd_base}; }
}; };
if vec::len(c.opts.free) == 2u { if vec::len(c.opts.free) == 2u {
@ -1090,7 +1090,7 @@ fn cmd_install(c: cargo) unsafe {
let status = run::run_program(~"cp", ~[~"-R", cwd, wd]); let status = run::run_program(~"cp", ~[~"-R", cwd, wd]);
if status != 0 { if status != 0 {
fail #fmt("could not copy directory: %s", cwd); fail fmt!{"could not copy directory: %s", cwd};
} }
install_source(c, wd); install_source(c, wd);
@ -1126,7 +1126,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
let mut has_src_file = false; let mut has_src_file = false;
if !os::copy_file(path::connect(url, ~"packages.json"), pkgfile) { if !os::copy_file(path::connect(url, ~"packages.json"), pkgfile) {
error(#fmt["fetch for source %s (url %s) failed", name, url]); error(fmt!{"fetch for source %s (url %s) failed", name, url});
ret false; ret false;
} }
@ -1142,7 +1142,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
let p = run::program_output(~"curl", let p = run::program_output(~"curl",
~[~"-f", ~"-s", ~"-o", keyfile, u]); ~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (key %s) failed", name, u]); error(fmt!{"fetch for source %s (key %s) failed", name, u});
ret false; ret false;
} }
pgp::add(c.root, keyfile); pgp::add(c.root, keyfile);
@ -1154,8 +1154,8 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
let r = pgp::verify(c.root, pkgfile, sigfile, f); let r = pgp::verify(c.root, pkgfile, sigfile, f);
if !r { if !r {
error(#fmt["signature verification failed for source %s", error(fmt!{"signature verification failed for source %s",
name]); name});
ret false; ret false;
} }
@ -1163,8 +1163,8 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
let e = pgp::verify(c.root, srcfile, srcsigfile, f); let e = pgp::verify(c.root, srcfile, srcsigfile, f);
if !e { if !e {
error(#fmt["signature verification failed for source %s", error(fmt!{"signature verification failed for source %s",
name]); name});
ret false; ret false;
} }
} }
@ -1184,7 +1184,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
os::remove_file(pkgfile); os::remove_file(pkgfile);
os::remove_file(sigfile); os::remove_file(sigfile);
info(#fmt["synced source: %s", name]); info(fmt!{"synced source: %s", name});
ret true; ret true;
} }
@ -1200,7 +1200,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
fn rollback(name: ~str, dir: ~str, insecure: bool) { fn rollback(name: ~str, dir: ~str, insecure: bool) {
fn msg(name: ~str, insecure: bool) { fn msg(name: ~str, insecure: bool) {
error(#fmt["could not rollback source: %s", name]); error(fmt!{"could not rollback source: %s", name});
if insecure { if insecure {
warn(~"a past security check failed on source " + warn(~"a past security check failed on source " +
@ -1226,20 +1226,20 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
let p = run::program_output(~"git", ~[~"clone", url, dir]); let p = run::program_output(~"git", ~[~"clone", url, dir]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (url %s) failed", name, url]); error(fmt!{"fetch for source %s (url %s) failed", name, url});
ret false; ret false;
} }
} }
else { else {
if !os::change_dir(dir) { if !os::change_dir(dir) {
error(#fmt["fetch for source %s (url %s) failed", name, url]); error(fmt!{"fetch for source %s (url %s) failed", name, url});
ret false; ret false;
} }
let p = run::program_output(~"git", ~[~"pull"]); let p = run::program_output(~"git", ~[~"pull"]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (url %s) failed", name, url]); error(fmt!{"fetch for source %s (url %s) failed", name, url});
ret false; ret false;
} }
} }
@ -1251,7 +1251,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
let p = run::program_output(~"curl", let p = run::program_output(~"curl",
~[~"-f", ~"-s", ~"-o", keyfile, u]); ~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (key %s) failed", name, u]); error(fmt!{"fetch for source %s (key %s) failed", name, u});
rollback(name, dir, false); rollback(name, dir, false);
ret false; ret false;
} }
@ -1264,8 +1264,8 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
let r = pgp::verify(c.root, pkgfile, sigfile, f); let r = pgp::verify(c.root, pkgfile, sigfile, f);
if !r { if !r {
error(#fmt["signature verification failed for source %s", error(fmt!{"signature verification failed for source %s",
name]); name});
rollback(name, dir, false); rollback(name, dir, false);
ret false; ret false;
} }
@ -1274,8 +1274,8 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
let e = pgp::verify(c.root, srcfile, srcsigfile, f); let e = pgp::verify(c.root, srcfile, srcsigfile, f);
if !e { if !e {
error(#fmt["signature verification failed for source %s", error(fmt!{"signature verification failed for source %s",
name]); name});
rollback(name, dir, false); rollback(name, dir, false);
ret false; ret false;
} }
@ -1286,7 +1286,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
os::remove_file(keyfile); os::remove_file(keyfile);
info(#fmt["synced source: %s", name]); info(fmt!{"synced source: %s", name});
ret true; ret true;
} }
@ -1312,7 +1312,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
~[~"-f", ~"-s", ~"-o", pkgfile, url]); ~[~"-f", ~"-s", ~"-o", pkgfile, url]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (url %s) failed", name, url]); error(fmt!{"fetch for source %s (url %s) failed", name, url});
ret false; ret false;
} }
if smart { if smart {
@ -1331,7 +1331,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
let p = run::program_output(~"curl", let p = run::program_output(~"curl",
~[~"-f", ~"-s", ~"-o", keyfile, u]); ~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (key %s) failed", name, u]); error(fmt!{"fetch for source %s (key %s) failed", name, u});
ret false; ret false;
} }
pgp::add(c.root, keyfile); pgp::add(c.root, keyfile);
@ -1350,15 +1350,15 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
let mut p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", let mut p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
sigfile, url]); sigfile, url]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (sig %s) failed", name, url]); error(fmt!{"fetch for source %s (sig %s) failed", name, url});
ret false; ret false;
} }
let r = pgp::verify(c.root, pkgfile, sigfile, f); let r = pgp::verify(c.root, pkgfile, sigfile, f);
if !r { if !r {
error(#fmt["signature verification failed for source %s", error(fmt!{"signature verification failed for source %s",
name]); name});
ret false; ret false;
} }
@ -1369,8 +1369,8 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
~[~"-f", ~"-s", ~"-o", ~[~"-f", ~"-s", ~"-o",
srcsigfile, url]); srcsigfile, url]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch for source %s (sig %s) failed", error(fmt!{"fetch for source %s (sig %s) failed",
name, url]); name, url});
ret false; ret false;
} }
@ -1398,7 +1398,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
os::remove_file(pkgfile); os::remove_file(pkgfile);
os::remove_file(sigfile); os::remove_file(sigfile);
info(#fmt["synced source: %s", name]); info(fmt!{"synced source: %s", name});
ret true; ret true;
} }
@ -1407,7 +1407,7 @@ fn sync_one(c: cargo, src: source) {
let name = src.name; let name = src.name;
let dir = path::connect(c.sourcedir, name); let dir = path::connect(c.sourcedir, name);
info(#fmt["syncing source: %s...", name]); info(fmt!{"syncing source: %s...", name});
need_dir(dir); need_dir(dir);
@ -1434,20 +1434,20 @@ fn cmd_init(c: cargo) {
let p = let p =
run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", srcfile, srcurl]); run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", srcfile, srcurl]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch of sources.json failed: %s", p.out]); error(fmt!{"fetch of sources.json failed: %s", p.out});
ret; ret;
} }
let p = let p =
run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", sigfile, sigurl]); run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", sigfile, sigurl]);
if p.status != 0 { if p.status != 0 {
error(#fmt["fetch of sources.json.sig failed: %s", p.out]); error(fmt!{"fetch of sources.json.sig failed: %s", p.out});
ret; ret;
} }
let r = pgp::verify(c.root, srcfile, sigfile, pgp::signing_key_fp()); let r = pgp::verify(c.root, srcfile, sigfile, pgp::signing_key_fp());
if !r { if !r {
error(#fmt["signature verification failed for '%s'", srcfile]); error(fmt!{"signature verification failed for '%s'", srcfile});
ret; ret;
} }
@ -1455,7 +1455,7 @@ fn cmd_init(c: cargo) {
os::remove_file(srcfile); os::remove_file(srcfile);
os::remove_file(sigfile); os::remove_file(sigfile);
info(#fmt["initialized .cargo in %s", c.root]); info(fmt!{"initialized .cargo in %s", c.root});
} }
fn print_pkg(s: source, p: package) { fn print_pkg(s: source, p: package) {
@ -1496,14 +1496,14 @@ fn cmd_list(c: cargo) {
if vec::len(c.opts.free) >= 3u { if vec::len(c.opts.free) >= 3u {
do vec::iter_between(c.opts.free, 2u, vec::len(c.opts.free)) |name| { do vec::iter_between(c.opts.free, 2u, vec::len(c.opts.free)) |name| {
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(fmt!{"'%s' is an invalid source name", name});
} else { } else {
alt c.sources.find(name) { alt c.sources.find(name) {
some(source) { some(source) {
print_source(source); print_source(source);
} }
none { none {
error(#fmt("no such source: %s", name)); error(fmt!{"no such source: %s", name});
} }
} }
} }
@ -1533,7 +1533,7 @@ fn cmd_search(c: cargo) {
n += 1; n += 1;
} }
}); });
info(#fmt["found %d packages", n]); info(fmt!{"found %d packages", n});
} }
fn install_to_dir(srcfile: ~str, destdir: ~str) { fn install_to_dir(srcfile: ~str, destdir: ~str) {
@ -1541,9 +1541,9 @@ fn install_to_dir(srcfile: ~str, destdir: ~str) {
let status = run::run_program(~"cp", ~[~"-r", srcfile, newfile]); let status = run::run_program(~"cp", ~[~"-r", srcfile, newfile]);
if status == 0 { if status == 0 {
info(#fmt["installed: '%s'", newfile]); info(fmt!{"installed: '%s'", newfile});
} else { } else {
error(#fmt["could not install: '%s'", newfile]); error(fmt!{"could not install: '%s'", newfile});
} }
} }
@ -1601,22 +1601,22 @@ fn dump_sources(c: cargo) {
writer.write_str(json::to_str(root)); writer.write_str(json::to_str(root));
} }
result::err(e) { result::err(e) {
error(#fmt("could not dump sources: %s", e)); error(fmt!{"could not dump sources: %s", e});
} }
} }
} }
fn copy_warn(srcfile: ~str, destfile: ~str) { fn copy_warn(srcfile: ~str, destfile: ~str) {
if !os::copy_file(srcfile, destfile) { if !os::copy_file(srcfile, destfile) {
warn(#fmt["copying %s to %s failed", srcfile, destfile]); warn(fmt!{"copying %s to %s failed", srcfile, destfile});
} }
} }
fn cmd_sources(c: cargo) { fn cmd_sources(c: cargo) {
if vec::len(c.opts.free) < 3u { if vec::len(c.opts.free) < 3u {
for c.sources.each_value |v| { for c.sources.each_value |v| {
info(#fmt("%s (%s) via %s", info(fmt!{"%s (%s) via %s",
v.name, v.url, v.method)); v.name, v.url, v.method});
} }
ret; ret;
} }
@ -1641,13 +1641,13 @@ fn cmd_sources(c: cargo) {
let url = c.opts.free[4u]; let url = c.opts.free[4u];
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(fmt!{"'%s' is an invalid source name", name});
ret; ret;
} }
alt c.sources.find(name) { alt c.sources.find(name) {
some(source) { some(source) {
error(#fmt("source already exists: %s", name)); error(fmt!{"source already exists: %s", name});
} }
none { none {
c.sources.insert(name, @{ c.sources.insert(name, @{
@ -1658,7 +1658,7 @@ fn cmd_sources(c: cargo) {
mut keyfp: none, mut keyfp: none,
mut packages: ~[mut] mut packages: ~[mut]
}); });
info(#fmt("added source: %s", name)); info(fmt!{"added source: %s", name});
} }
} }
} }
@ -1671,17 +1671,17 @@ fn cmd_sources(c: cargo) {
let name = c.opts.free[3u]; let name = c.opts.free[3u];
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(fmt!{"'%s' is an invalid source name", name});
ret; ret;
} }
alt c.sources.find(name) { alt c.sources.find(name) {
some(source) { some(source) {
c.sources.remove(name); c.sources.remove(name);
info(#fmt("removed source: %s", name)); info(fmt!{"removed source: %s", name});
} }
none { none {
error(#fmt("no such source: %s", name)); error(fmt!{"no such source: %s", name});
} }
} }
} }
@ -1695,7 +1695,7 @@ fn cmd_sources(c: cargo) {
let url = c.opts.free[4u]; let url = c.opts.free[4u];
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(fmt!{"'%s' is an invalid source name", name});
ret; ret;
} }
@ -1709,10 +1709,10 @@ fn cmd_sources(c: cargo) {
c.sources.insert(name, source); c.sources.insert(name, source);
info(#fmt("changed source url: '%s' to '%s'", old, url)); info(fmt!{"changed source url: '%s' to '%s'", old, url});
} }
none { none {
error(#fmt("no such source: %s", name)); error(fmt!{"no such source: %s", name});
} }
} }
} }
@ -1726,7 +1726,7 @@ fn cmd_sources(c: cargo) {
let method = c.opts.free[4u]; let method = c.opts.free[4u];
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(fmt!{"'%s' is an invalid source name", name});
ret; ret;
} }
@ -1742,11 +1742,11 @@ fn cmd_sources(c: cargo) {
c.sources.insert(name, source); c.sources.insert(name, source);
info(#fmt("changed source method: '%s' to '%s'", old, info(fmt!{"changed source method: '%s' to '%s'", old,
method)); method});
} }
none { none {
error(#fmt("no such source: %s", name)); error(fmt!{"no such source: %s", name});
} }
} }
} }
@ -1760,11 +1760,11 @@ fn cmd_sources(c: cargo) {
let newn = c.opts.free[4u]; let newn = c.opts.free[4u];
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(fmt!{"'%s' is an invalid source name", name});
ret; ret;
} }
if !valid_pkg_name(newn) { if !valid_pkg_name(newn) {
error(#fmt("'%s' is an invalid source name", newn)); error(fmt!{"'%s' is an invalid source name", newn});
ret; ret;
} }
@ -1772,10 +1772,10 @@ fn cmd_sources(c: cargo) {
some(source) { some(source) {
c.sources.remove(name); c.sources.remove(name);
c.sources.insert(newn, source); c.sources.insert(newn, source);
info(#fmt("renamed source: %s to %s", name, newn)); info(fmt!{"renamed source: %s to %s", name, newn});
} }
none { none {
error(#fmt("no such source: %s", name)); error(fmt!{"no such source: %s", name});
} }
} }
} }

View file

@ -68,20 +68,20 @@ fn parse_config(args: ~[~str]) -> config {
fn log_config(config: config) { fn log_config(config: config) {
let c = config; let c = config;
logv(c, #fmt["configuration:"]); logv(c, fmt!{"configuration:"});
logv(c, #fmt["compile_lib_path: %s", config.compile_lib_path]); logv(c, fmt!{"compile_lib_path: %s", config.compile_lib_path});
logv(c, #fmt["run_lib_path: %s", config.run_lib_path]); logv(c, fmt!{"run_lib_path: %s", config.run_lib_path});
logv(c, #fmt["rustc_path: %s", config.rustc_path]); logv(c, fmt!{"rustc_path: %s", config.rustc_path});
logv(c, #fmt["src_base: %s", config.src_base]); logv(c, fmt!{"src_base: %s", config.src_base});
logv(c, #fmt["build_base: %s", config.build_base]); logv(c, fmt!{"build_base: %s", config.build_base});
logv(c, #fmt["stage_id: %s", config.stage_id]); logv(c, fmt!{"stage_id: %s", config.stage_id});
logv(c, #fmt["mode: %s", mode_str(config.mode)]); logv(c, fmt!{"mode: %s", mode_str(config.mode)});
logv(c, #fmt["run_ignored: %b", config.run_ignored]); logv(c, fmt!{"run_ignored: %b", config.run_ignored});
logv(c, #fmt["filter: %s", opt_str(config.filter)]); logv(c, fmt!{"filter: %s", opt_str(config.filter)});
logv(c, #fmt["runtool: %s", opt_str(config.runtool)]); logv(c, fmt!{"runtool: %s", opt_str(config.runtool)});
logv(c, #fmt["rustcflags: %s", opt_str(config.rustcflags)]); logv(c, fmt!{"rustcflags: %s", opt_str(config.rustcflags)});
logv(c, #fmt["verbose: %b", config.verbose]); logv(c, fmt!{"verbose: %b", config.verbose});
logv(c, #fmt["\n"]); logv(c, fmt!{"\n"});
} }
fn opt_str(maybestr: option<~str>) -> ~str { fn opt_str(maybestr: option<~str>) -> ~str {
@ -134,11 +134,11 @@ fn test_opts(config: config) -> test::test_opts {
} }
fn make_tests(config: config) -> ~[test::test_desc] { fn make_tests(config: config) -> ~[test::test_desc] {
#debug("making tests from %s", config.src_base); debug!{"making tests from %s", config.src_base};
let mut tests = ~[]; let mut tests = ~[];
for os::list_dir_path(config.src_base).each |file| { for os::list_dir_path(config.src_base).each |file| {
let file = file; let file = file;
#debug("inspecting file %s", file); debug!{"inspecting file %s", file};
if is_test(config, file) { if is_test(config, file) {
vec::push(tests, make_test(config, file)) vec::push(tests, make_test(config, file))
} }
@ -177,7 +177,7 @@ fn make_test(config: config, testfile: ~str) ->
} }
fn make_test_name(config: config, testfile: ~str) -> ~str { fn make_test_name(config: config, testfile: ~str) -> ~str {
#fmt["[%s] %s", mode_str(config.mode), testfile] fmt!{"[%s] %s", mode_str(config.mode), testfile}
} }
fn make_test_closure(config: config, testfile: ~str) -> test::test_fn { fn make_test_closure(config: config, testfile: ~str) -> test::test_fn {

View file

@ -47,7 +47,7 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
while idx < len && line[idx] == (' ' as u8) { idx += 1u; } while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
let msg = str::slice(line, idx, len); let msg = str::slice(line, idx, len);
#debug("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg); debug!{"line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg};
ret ~[{line: line_num - adjust_line, kind: kind, msg: msg}]; ret ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
} }

View file

@ -110,7 +110,7 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
alt strs.len() { alt strs.len() {
1u { (strs[0], ~"") } 1u { (strs[0], ~"") }
2u { (strs[0], strs[1]) } 2u { (strs[0], strs[1]) }
n { fail #fmt["Expected 1 or 2 strings, not %u", n]; } n { fail fmt!{"Expected 1 or 2 strings, not %u", n}; }
} }
} }
} }
@ -139,7 +139,7 @@ fn parse_name_value_directive(line: ~str,
option::some(colon) { option::some(colon) {
let value = str::slice(line, colon + str::len(keycolon), let value = str::slice(line, colon + str::len(keycolon),
str::len(line)); str::len(line));
#debug("%s: %s", directive, value); debug!{"%s: %s", directive, value};
option::some(value) option::some(value)
} }
option::none { option::none } option::none { option::none }

View file

@ -16,7 +16,7 @@ fn run(config: config, testfile: ~str) {
// We're going to be dumping a lot of info. Start on a new line. // We're going to be dumping a lot of info. Start on a new line.
io::stdout().write_str(~"\n\n"); io::stdout().write_str(~"\n\n");
} }
#debug("running %s", testfile); debug!{"running %s", testfile};
let props = load_props(testfile); let props = load_props(testfile);
alt config.mode { alt config.mode {
mode_compile_fail { run_cfail_test(config, props, testfile); } mode_compile_fail { run_cfail_test(config, props, testfile); }
@ -68,8 +68,8 @@ fn check_correct_failure_status(procres: procres) {
const rust_err: int = 101; const rust_err: int = 101;
if procres.status != rust_err { if procres.status != rust_err {
fatal_procres( fatal_procres(
#fmt("failure produced the wrong error code: %d", fmt!{"failure produced the wrong error code: %d",
procres.status), procres.status},
procres); procres);
} }
} }
@ -96,11 +96,11 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
let mut round = 0; let mut round = 0;
while round < rounds { while round < rounds {
logv(config, #fmt["pretty-printing round %d", round]); logv(config, fmt!{"pretty-printing round %d", round});
let procres = print_source(config, testfile, srcs[round]); let procres = print_source(config, testfile, srcs[round]);
if procres.status != 0 { if procres.status != 0 {
fatal_procres(#fmt["pretty-printing failed in round %d", round], fatal_procres(fmt!{"pretty-printing failed in round %d", round},
procres); procres);
} }
@ -151,7 +151,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
if expected != actual { if expected != actual {
error(~"pretty-printed source does not match expected source"); error(~"pretty-printed source does not match expected source");
let msg = let msg =
#fmt["\n\ fmt!{"\n\
expected:\n\ expected:\n\
------------------------------------------\n\ ------------------------------------------\n\
%s\n\ %s\n\
@ -161,7 +161,7 @@ actual:\n\
%s\n\ %s\n\
------------------------------------------\n\ ------------------------------------------\n\
\n", \n",
expected, actual]; expected, actual};
io::stdout().write_str(msg); io::stdout().write_str(msg);
fail; fail;
} }
@ -201,10 +201,10 @@ fn check_error_patterns(props: test_props,
let mut done = false; let mut done = false;
for str::split_char(procres.stderr, '\n').each |line| { for str::split_char(procres.stderr, '\n').each |line| {
if str::contains(line, next_err_pat) { if str::contains(line, next_err_pat) {
#debug("found error pattern %s", next_err_pat); debug!{"found error pattern %s", next_err_pat};
next_err_idx += 1u; next_err_idx += 1u;
if next_err_idx == vec::len(props.error_patterns) { if next_err_idx == vec::len(props.error_patterns) {
#debug("found all error patterns"); debug!{"found all error patterns"};
done = true; done = true;
break; break;
} }
@ -217,11 +217,11 @@ fn check_error_patterns(props: test_props,
vec::slice(props.error_patterns, next_err_idx, vec::slice(props.error_patterns, next_err_idx,
vec::len(props.error_patterns)); vec::len(props.error_patterns));
if vec::len(missing_patterns) == 1u { if vec::len(missing_patterns) == 1u {
fatal_procres(#fmt["error pattern '%s' not found!", fatal_procres(fmt!{"error pattern '%s' not found!",
missing_patterns[0]], procres); missing_patterns[0]}, procres);
} else { } else {
for missing_patterns.each |pattern| { for missing_patterns.each |pattern| {
error(#fmt["error pattern '%s' not found!", pattern]); error(fmt!{"error pattern '%s' not found!", pattern});
} }
fatal_procres(~"multiple error patterns not found", procres); fatal_procres(~"multiple error patterns not found", procres);
} }
@ -240,7 +240,7 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
} }
let prefixes = vec::map(expected_errors, |ee| { let prefixes = vec::map(expected_errors, |ee| {
#fmt("%s:%u:", testfile, ee.line) fmt!{"%s:%u:", testfile, ee.line}
}); });
// Scan and extract our error/warning messages, // Scan and extract our error/warning messages,
@ -253,8 +253,8 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
let mut was_expected = false; let mut was_expected = false;
for vec::eachi(expected_errors) |i, ee| { for vec::eachi(expected_errors) |i, ee| {
if !found_flags[i] { if !found_flags[i] {
#debug["prefix=%s ee.kind=%s ee.msg=%s line=%s", debug!{"prefix=%s ee.kind=%s ee.msg=%s line=%s",
prefixes[i], ee.kind, ee.msg, line]; prefixes[i], ee.kind, ee.msg, line};
if (str::starts_with(line, prefixes[i]) && if (str::starts_with(line, prefixes[i]) &&
str::contains(line, ee.kind) && str::contains(line, ee.kind) &&
str::contains(line, ee.msg)) { str::contains(line, ee.msg)) {
@ -272,7 +272,7 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
if !was_expected && (str::contains(line, ~"error") || if !was_expected && (str::contains(line, ~"error") ||
str::contains(line, ~"warning")) { str::contains(line, ~"warning")) {
fatal_procres(#fmt["unexpected error pattern '%s'!", line], fatal_procres(fmt!{"unexpected error pattern '%s'!", line},
procres); procres);
} }
} }
@ -280,8 +280,8 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
for uint::range(0u, vec::len(found_flags)) |i| { for uint::range(0u, vec::len(found_flags)) |i| {
if !found_flags[i] { if !found_flags[i] {
let ee = expected_errors[i]; let ee = expected_errors[i];
fatal_procres(#fmt["expected %s on line %u not found: %s", fatal_procres(fmt!{"expected %s on line %u not found: %s",
ee.kind, ee.line, ee.msg], procres); ee.kind, ee.line, ee.msg}, procres);
} }
} }
} }
@ -330,7 +330,7 @@ fn compose_and_run_compiler(
config.compile_lib_path, option::none); config.compile_lib_path, option::none);
if auxres.status != 0 { if auxres.status != 0 {
fatal_procres( fatal_procres(
#fmt["auxiliary build of %s failed to compile: ", abs_ab], fmt!{"auxiliary build of %s failed to compile: ", abs_ab},
auxres); auxres);
} }
} }
@ -342,7 +342,7 @@ fn compose_and_run_compiler(
fn ensure_dir(path: path) { fn ensure_dir(path: path) {
if os::path_is_dir(path) { ret; } if os::path_is_dir(path) { ret; }
if !os::make_dir(path, 0x1c0i32) { if !os::make_dir(path, 0x1c0i32) {
fail #fmt("can't make dir %s", path); fail fmt!{"can't make dir %s", path};
} }
} }
@ -414,7 +414,7 @@ fn program_output(config: config, testfile: ~str, lib_path: ~str, prog: ~str,
let cmdline = let cmdline =
{ {
let cmdline = make_cmdline(lib_path, prog, args); let cmdline = make_cmdline(lib_path, prog, args);
logv(config, #fmt["executing %s", cmdline]); logv(config, fmt!{"executing %s", cmdline});
cmdline cmdline
}; };
let res = procsrv::run(lib_path, prog, args, env, input); let res = procsrv::run(lib_path, prog, args, env, input);
@ -430,19 +430,19 @@ fn program_output(config: config, testfile: ~str, lib_path: ~str, prog: ~str,
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
fn make_cmdline(_libpath: ~str, prog: ~str, args: ~[~str]) -> ~str { fn make_cmdline(_libpath: ~str, prog: ~str, args: ~[~str]) -> ~str {
#fmt["%s %s", prog, str::connect(args, ~" ")] fmt!{"%s %s", prog, str::connect(args, ~" ")}
} }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn make_cmdline(libpath: ~str, prog: ~str, args: ~[~str]) -> ~str { fn make_cmdline(libpath: ~str, prog: ~str, args: ~[~str]) -> ~str {
#fmt["%s %s %s", lib_path_cmd_prefix(libpath), prog, fmt!{"%s %s %s", lib_path_cmd_prefix(libpath), prog,
str::connect(args, ~" ")] str::connect(args, ~" ")}
} }
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line // Build the LD_LIBRARY_PATH variable as it would be seen on the command line
// for diagnostic purposes // for diagnostic purposes
fn lib_path_cmd_prefix(path: ~str) -> ~str { fn lib_path_cmd_prefix(path: ~str) -> ~str {
#fmt["%s=\"%s\"", util::lib_path_env_var(), util::make_new_path(path)] fmt!{"%s=\"%s\"", util::lib_path_env_var(), util::make_new_path(path)}
} }
fn dump_output(config: config, testfile: ~str, out: ~str, err: ~str) { fn dump_output(config: config, testfile: ~str, out: ~str, err: ~str) {
@ -475,13 +475,13 @@ fn output_testname(testfile: ~str) -> ~str {
fn output_base_name(config: config, testfile: ~str) -> ~str { fn output_base_name(config: config, testfile: ~str) -> ~str {
let base = config.build_base; let base = config.build_base;
let filename = output_testname(testfile); let filename = output_testname(testfile);
#fmt["%s%s.%s", base, filename, config.stage_id] fmt!{"%s%s.%s", base, filename, config.stage_id}
} }
fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) { fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) {
if config.verbose { if config.verbose {
let sep1 = #fmt["------%s------------------------------", ~"stdout"]; let sep1 = fmt!{"------%s------------------------------", ~"stdout"};
let sep2 = #fmt["------%s------------------------------", ~"stderr"]; let sep2 = fmt!{"------%s------------------------------", ~"stderr"};
let sep3 = ~"------------------------------------------"; let sep3 = ~"------------------------------------------";
io::stdout().write_line(sep1); io::stdout().write_line(sep1);
io::stdout().write_line(out); io::stdout().write_line(out);
@ -491,13 +491,13 @@ fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) {
} }
} }
fn error(err: ~str) { io::stdout().write_line(#fmt["\nerror: %s", err]); } fn error(err: ~str) { io::stdout().write_line(fmt!{"\nerror: %s", err}); }
fn fatal(err: ~str) -> ! { error(err); fail; } fn fatal(err: ~str) -> ! { error(err); fail; }
fn fatal_procres(err: ~str, procres: procres) -> ! { fn fatal_procres(err: ~str, procres: procres) -> ! {
let msg = let msg =
#fmt["\n\ fmt!{"\n\
error: %s\n\ error: %s\n\
command: %s\n\ command: %s\n\
stdout:\n\ stdout:\n\
@ -509,7 +509,7 @@ stderr:\n\
%s\n\ %s\n\
------------------------------------------\n\ ------------------------------------------\n\
\n", \n",
err, procres.cmdline, procres.stdout, procres.stderr]; err, procres.cmdline, procres.stdout, procres.stderr};
io::stdout().write_str(msg); io::stdout().write_str(msg);
fail; fail;
} }

View file

@ -9,7 +9,7 @@ fn make_new_path(path: ~str) -> ~str {
// maintain the current value while adding our own // maintain the current value while adding our own
alt getenv(lib_path_env_var()) { alt getenv(lib_path_env_var()) {
option::some(curr) { option::some(curr) {
#fmt["%s%s%s", path, path_div(), curr] fmt!{"%s%s%s", path, path_div(), curr}
} }
option::none { path } option::none { path }
} }

View file

@ -26,5 +26,5 @@ fn main() {
assert (!vec_equal(~[5, 5], ~[4, 5], builtin_equal_int)); assert (!vec_equal(~[5, 5], ~[4, 5], builtin_equal_int));
assert (vec_equal(~[5, 5], ~[5, 5], builtin_equal_int)); assert (vec_equal(~[5, 5], ~[5, 5], builtin_equal_int));
#error("Pass"); error!{"Pass"};
} }

View file

@ -246,8 +246,8 @@ fn check_variants_T<T: copy>(
replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate, replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate,
cx: context cx: context
) { ) {
#error("%s contains %u %s objects", filename, error!{"%s contains %u %s objects", filename,
vec::len(things), thing_label); vec::len(things), thing_label};
let L = vec::len(things); let L = vec::len(things);
@ -277,9 +277,9 @@ fn check_variants_T<T: copy>(
check_roundtrip_convergence(str3, 1u); check_roundtrip_convergence(str3, 1u);
} }
tm_run { tm_run {
let file_label = #fmt("rusttmp/%s_%s_%u_%u", let file_label = fmt!{"rusttmp/%s_%s_%u_%u",
last_part(filename), last_part(filename),
thing_label, i, j); thing_label, i, j};
let safe_to_run = !(content_is_dangerous_to_run(*str3) let safe_to_run = !(content_is_dangerous_to_run(*str3)
|| has_raw_pointers(*crate2)); || has_raw_pointers(*crate2));
check_whole_compiler(*str3, file_label, safe_to_run); check_whole_compiler(*str3, file_label, safe_to_run);
@ -389,7 +389,7 @@ fn check_compiling(filename: ~str) -> happiness {
stage1/bin/rustc", stage1/bin/rustc",
~[filename]); ~[filename]);
//#error("Status: %d", p.status); //error!{"Status: %d", p.status};
if p.status == 0 { if p.status == 0 {
passed passed
} else if p.err != ~"" { } else if p.err != ~"" {
@ -519,9 +519,9 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
} }
if oldv == newv { if oldv == newv {
#error("Converged after %u iterations", i); error!{"Converged after %u iterations", i};
} else { } else {
#error("Did not converge after %u iterations!", i); error!{"Did not converge after %u iterations!", i};
write_file(~"round-trip-a.rs", *oldv); write_file(~"round-trip-a.rs", *oldv);
write_file(~"round-trip-b.rs", *newv); write_file(~"round-trip-b.rs", *newv);
run::run_program(~"diff", run::run_program(~"diff",
@ -532,12 +532,12 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
} }
fn check_convergence(files: ~[~str]) { fn check_convergence(files: ~[~str]) {
#error("pp convergence tests: %u files", vec::len(files)); error!{"pp convergence tests: %u files", vec::len(files)};
for files.each |file| { for files.each |file| {
if !file_might_not_converge(file) { if !file_might_not_converge(file) {
let s = @result::get(io::read_whole_file_str(file)); let s = @result::get(io::read_whole_file_str(file));
if !content_might_not_converge(*s) { if !content_might_not_converge(*s) {
#error("pp converge: %s", file); error!{"pp converge: %s", file};
// Change from 7u to 2u once // Change from 7u to 2u once
// https://github.com/mozilla/rust/issues/850 is fixed // https://github.com/mozilla/rust/issues/850 is fixed
check_roundtrip_convergence(s, 7u); check_roundtrip_convergence(s, 7u);
@ -549,8 +549,8 @@ fn check_convergence(files: ~[~str]) {
fn check_variants(files: ~[~str], cx: context) { fn check_variants(files: ~[~str], cx: context) {
for files.each |file| { for files.each |file| {
if cx.mode == tm_converge && file_might_not_converge(file) { if cx.mode == tm_converge && file_might_not_converge(file) {
#error("Skipping convergence test based on\ error!{"Skipping convergence test based on\
file_might_not_converge"); file_might_not_converge"};
again; again;
} }
@ -572,7 +572,7 @@ fn check_variants(files: ~[~str], cx: context) {
file, file,
s, ~[], sess); s, ~[], sess);
io::with_str_reader(*s, |rdr| { io::with_str_reader(*s, |rdr| {
#error("%s", error!{"%s",
as_str(|a| pprust::print_crate( as_str(|a| pprust::print_crate(
sess.cm, sess.cm,
// Assuming no token_trees // Assuming no token_trees
@ -583,7 +583,7 @@ fn check_variants(files: ~[~str], cx: context) {
file, file,
rdr, a, rdr, a,
pprust::no_ann(), pprust::no_ann(),
false) )) false) )}
}); });
check_variants_of_ast(*crate, sess.cm, file, cx); check_variants_of_ast(*crate, sess.cm, file, cx);
} }
@ -591,21 +591,21 @@ fn check_variants(files: ~[~str], cx: context) {
fn main(args: ~[~str]) { fn main(args: ~[~str]) {
if vec::len(args) != 2u { if vec::len(args) != 2u {
#error("usage: %s <testdir>", args[0]); error!{"usage: %s <testdir>", args[0]};
ret; ret;
} }
let mut files = ~[]; let mut files = ~[];
let root = args[1]; let root = args[1];
find_rust_files(files, root); find_rust_files(files, root);
#error("== check_convergence =="); error!{"== check_convergence =="};
check_convergence(files); check_convergence(files);
#error("== check_variants: converge =="); error!{"== check_variants: converge =="};
check_variants(files, { mode: tm_converge }); check_variants(files, { mode: tm_converge });
#error("== check_variants: run =="); error!{"== check_variants: run =="};
check_variants(files, { mode: tm_run }); check_variants(files, { mode: tm_run });
#error("Fuzzer done"); error!{"Fuzzer done"};
} }
// Local Variables: // Local Variables:

View file

@ -21,7 +21,7 @@ combinations at the moment.
Example: Example:
#debug("hello, %s!", "world"); debug!{"hello, %s!", "world"};
*/ */
@ -438,7 +438,7 @@ mod test {
#[test] #[test]
fn fmt_slice() { fn fmt_slice() {
let s = "abc"; let s = "abc";
let _s = #fmt("%s", s); let _s = fmt!{"%s", s};
} }
} }

View file

@ -7,7 +7,7 @@
* ~~~ * ~~~
* let delayed_fib = future::spawn {|| fib(5000) }; * let delayed_fib = future::spawn {|| fib(5000) };
* make_a_sandwich(); * make_a_sandwich();
* io::println(#fmt("fib(5000) = %?", delayed_fib.get())) * io::println(fmt!{"fib(5000) = %?", delayed_fib.get()})
* ~~~ * ~~~
*/ */

View file

@ -20,7 +20,7 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 {
let mut v2 : u64 = k0 ^ 0x6c79_6765_6e65_7261; let mut v2 : u64 = k0 ^ 0x6c79_6765_6e65_7261;
let mut v3 : u64 = k1 ^ 0x7465_6462_7974_6573; let mut v3 : u64 = k1 ^ 0x7465_6462_7974_6573;
#macro([#u8to64_le(buf,i), #macro[[#u8to64_le(buf,i),
(buf[0+i] as u64 | (buf[0+i] as u64 |
buf[1+i] as u64 << 8 | buf[1+i] as u64 << 8 |
buf[2+i] as u64 << 16 | buf[2+i] as u64 << 16 |
@ -28,16 +28,16 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 {
buf[4+i] as u64 << 32 | buf[4+i] as u64 << 32 |
buf[5+i] as u64 << 40 | buf[5+i] as u64 << 40 |
buf[6+i] as u64 << 48 | buf[6+i] as u64 << 48 |
buf[7+i] as u64 << 56)]); buf[7+i] as u64 << 56)]];
#macro([#rotl(x,b), (x << b) | (x >> (64 - b))]); #macro[[#rotl(x,b), (x << b) | (x >> (64 - b))]];
#macro([#compress(v0,v1,v2,v3), { #macro[[#compress(v0,v1,v2,v3), {
v0 += v1; v1 = #rotl(v1, 13); v1 ^= v0; v0 = #rotl(v0, 32); v0 += v1; v1 = #rotl(v1, 13); v1 ^= v0; v0 = #rotl(v0, 32);
v2 += v3; v3 = #rotl(v3, 16); v3 ^= v2; v2 += v3; v3 = #rotl(v3, 16); v3 ^= v2;
v0 += v3; v3 = #rotl(v3, 21); v3 ^= v0; v0 += v3; v3 = #rotl(v3, 21); v3 ^= v0;
v2 += v1; v1 = #rotl(v1, 17); v1 ^= v2; v2 = #rotl(v2, 32); v2 += v1; v1 = #rotl(v1, 17); v1 ^= v2; v2 = #rotl(v2, 32);
}]); }]];
let len = vec::len(buf); let len = vec::len(buf);
let end = len & (!0x7); let end = len & (!0x7);
@ -45,10 +45,10 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 {
let mut i = 0; let mut i = 0;
while i < end { while i < end {
let m = #u8to64_le(buf, i); let m = u8to64_le!{buf, i};
v3 ^= m; v3 ^= m;
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
v0 ^= m; v0 ^= m;
i += 8; i += 8;
} }
@ -64,16 +64,16 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 {
if left > 6 { b |= buf[i + 6] as u64 << 48; } if left > 6 { b |= buf[i + 6] as u64 << 48; }
v3 ^= b; v3 ^= b;
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
v0 ^= b; v0 ^= b;
v2 ^= 0xff; v2 ^= 0xff;
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
#compress(v0,v1,v2,v3); compress!{v0,v1,v2,v3};
ret v0 ^ v1 ^ v2 ^ v3; ret v0 ^ v1 ^ v2 ^ v3;
} }
@ -127,11 +127,11 @@ fn siphash(key0 : u64, key1 : u64) -> streaming {
t += 1; t += 1;
} }
let m = #u8to64_le(st.tail, 0); let m = u8to64_le!{st.tail, 0};
st.v3 ^= m; st.v3 ^= m;
#compress(st.v0, st.v1, st.v2, st.v3); compress!{st.v0, st.v1, st.v2, st.v3};
#compress(st.v0, st.v1, st.v2, st.v3); compress!{st.v0, st.v1, st.v2, st.v3};
st.v0 ^= m; st.v0 ^= m;
st.ntail = 0; st.ntail = 0;
@ -143,11 +143,11 @@ fn siphash(key0 : u64, key1 : u64) -> streaming {
let mut i = needed; let mut i = needed;
while i < end { while i < end {
let mi = #u8to64_le(msg, i); let mi = u8to64_le!{msg, i};
st.v3 ^= mi; st.v3 ^= mi;
#compress(st.v0, st.v1, st.v2, st.v3); compress!{st.v0, st.v1, st.v2, st.v3};
#compress(st.v0, st.v1, st.v2, st.v3); compress!{st.v0, st.v1, st.v2, st.v3};
st.v0 ^= mi; st.v0 ^= mi;
i += 8; i += 8;
@ -179,15 +179,15 @@ fn siphash(key0 : u64, key1 : u64) -> streaming {
if st.ntail > 6 { b |= st.tail[6] as u64 << 48; } if st.ntail > 6 { b |= st.tail[6] as u64 << 48; }
v3 ^= b; v3 ^= b;
#compress(v0, v1, v2, v3); compress!{v0, v1, v2, v3};
#compress(v0, v1, v2, v3); compress!{v0, v1, v2, v3};
v0 ^= b; v0 ^= b;
v2 ^= 0xff; v2 ^= 0xff;
#compress(v0, v1, v2, v3); compress!{v0, v1, v2, v3};
#compress(v0, v1, v2, v3); compress!{v0, v1, v2, v3};
#compress(v0, v1, v2, v3); compress!{v0, v1, v2, v3};
#compress(v0, v1, v2, v3); compress!{v0, v1, v2, v3};
let h = v0 ^ v1 ^ v2 ^ v3; let h = v0 ^ v1 ^ v2 ^ v3;
@ -323,10 +323,10 @@ fn test_siphash() {
} }
while t < 64 { while t < 64 {
#debug("siphash test %?", t); debug!{"siphash test %?", t};
let vec = #u8to64_le(vecs[t], 0); let vec = u8to64_le!{vecs[t], 0};
let out = hash_bytes_keyed(buf, k0, k1); let out = hash_bytes_keyed(buf, k0, k1);
#debug("got %?, expected %?", out, vec); debug!{"got %?, expected %?", out, vec};
assert vec == out; assert vec == out;
stream_full.reset(); stream_full.reset();
@ -334,7 +334,7 @@ fn test_siphash() {
let f = stream_full.result_str(); let f = stream_full.result_str();
let i = stream_inc.result_str(); let i = stream_inc.result_str();
let v = to_hex_str(vecs[t]); let v = to_hex_str(vecs[t]);
#debug["%d: (%s) => inc=%s full=%s", t, v, i, f]; debug!{"%d: (%s) => inc=%s full=%s", t, v, i, f};
assert f == i && f == v; assert f == i && f == v;

View file

@ -144,8 +144,8 @@ impl times of iter::times for T {
`for int::range(0, x) |_i| { /* anything */ }`."] `for int::range(0, x) |_i| { /* anything */ }`."]
fn times(it: fn() -> bool) { fn times(it: fn() -> bool) {
if self < 0 { if self < 0 {
fail #fmt("The .times method expects a nonnegative number, \ fail fmt!{"The .times method expects a nonnegative number, \
but found %?", self); but found %?", self};
} }
let mut i = self; let mut i = self;
while i > 0 { while i > 0 {
@ -161,8 +161,8 @@ impl timesi of iter::timesi for T {
fn timesi(it: fn(uint) -> bool) { fn timesi(it: fn(uint) -> bool) {
let slf = self as uint; let slf = self as uint;
if slf < 0u { if slf < 0u {
fail #fmt("The .timesi method expects a nonnegative number, \ fail fmt!{"The .timesi method expects a nonnegative number, \
but found %?", self); but found %?", self};
} }
let mut i = 0u; let mut i = 0u;
while i < slf { while i < slf {

View file

@ -291,7 +291,7 @@ impl of reader for byte_buf {
ret b as int; ret b as int;
} }
// FIXME (#2738): implement this // FIXME (#2738): implement this
fn unread_byte(_byte: int) { #error("Unimplemented: unread_byte"); fail; } fn unread_byte(_byte: int) { error!{"Unimplemented: unread_byte"}; fail; }
fn eof() -> bool { self.pos == self.len } fn eof() -> bool { self.pos == self.len }
fn seek(offset: int, whence: seek_style) { fn seek(offset: int, whence: seek_style) {
let pos = self.pos; let pos = self.pos;
@ -357,7 +357,7 @@ impl of writer for *libc::FILE {
let nout = libc::fwrite(vbuf as *c_void, len as size_t, let nout = libc::fwrite(vbuf as *c_void, len as size_t,
1u as size_t, self); 1u as size_t, self);
if nout < 1 as size_t { if nout < 1 as size_t {
#error("error writing buffer"); error!{"error writing buffer"};
log(error, os::last_os_error()); log(error, os::last_os_error());
fail; fail;
} }
@ -392,7 +392,7 @@ impl of writer for fd_t {
let vb = ptr::const_offset(vbuf, count) as *c_void; let vb = ptr::const_offset(vbuf, count) as *c_void;
let nout = libc::write(self, vb, len as size_t); let nout = libc::write(self, vb, len as size_t);
if nout < 0 as ssize_t { if nout < 0 as ssize_t {
#error("error writing buffer"); error!{"error writing buffer"};
log(error, os::last_os_error()); log(error, os::last_os_error());
fail; fail;
} }
@ -401,11 +401,11 @@ impl of writer for fd_t {
} }
} }
fn seek(_offset: int, _whence: seek_style) { fn seek(_offset: int, _whence: seek_style) {
#error("need 64-bit foreign calls for seek, sorry"); error!{"need 64-bit foreign calls for seek, sorry"};
fail; fail;
} }
fn tell() -> uint { fn tell() -> uint {
#error("need 64-bit foreign calls for tell, sorry"); error!{"need 64-bit foreign calls for tell, sorry"};
fail; fail;
} }
fn flush() -> int { 0 } fn flush() -> int { 0 }
@ -452,7 +452,7 @@ fn mk_file_writer(path: ~str, flags: ~[fileflag])
(S_IRUSR | S_IWUSR) as c_int) (S_IRUSR | S_IWUSR) as c_int)
}; };
if fd < (0 as c_int) { if fd < (0 as c_int) {
result::err(#fmt("error opening %s: %s", path, os::last_os_error())) result::err(fmt!{"error opening %s: %s", path, os::last_os_error()})
} else { } else {
result::ok(fd_writer(fd, true)) result::ok(fd_writer(fd, true))
} }

View file

@ -169,7 +169,7 @@ fn max<A:copy,IA:base_iter<A>>(self: IA) -> A {
#[test] #[test]
fn test_enumerate() { fn test_enumerate() {
enumerate(["0", "1", "2"]) {|i,j| enumerate(["0", "1", "2"]) {|i,j|
assert #fmt["%u",i] == j; assert fmt!{"%u",i} == j;
} }
} }
@ -247,7 +247,7 @@ fn test_flat_map_with_list() {
let a = bind vec::iter(~[0, 1, 2, 3], _); let a = bind vec::iter(~[0, 1, 2, 3], _);
let b = bind flat_map(a, repeat, _); let b = bind flat_map(a, repeat, _);
let c = to_vec(b); let c = to_vec(b);
#debug["c = %?", c]; debug!{"c = %?", c};
assert c == ~[1, 2, 2, 3, 3, 3]; assert c == ~[1, 2, 2, 3, 3, 3];
} }
@ -258,7 +258,7 @@ fn test_repeat() {
c += ~[(i * i)]; c += ~[(i * i)];
i += 1u; i += 1u;
}; };
#debug["c = %?", c]; debug!{"c = %?", c};
assert c == ~[0u, 1u, 4u, 9u, 16u]; assert c == ~[0u, 1u, 4u, 9u, 16u];
} }

View file

@ -995,7 +995,7 @@ mod tests {
assert (libc::fclose(ostream) == (0u as c_int)); assert (libc::fclose(ostream) == (0u as c_int));
let rs = os::copy_file(in, out); let rs = os::copy_file(in, out);
if (!os::path_exists(in)) { if (!os::path_exists(in)) {
fail (#fmt("%s doesn't exist", in)); fail (fmt!{"%s doesn't exist", in});
} }
assert(rs); assert(rs);
let rslt = run::run_program(~"diff", ~[in, out]); let rslt = run::run_program(~"diff", ~[in, out]);

View file

@ -222,7 +222,7 @@ class buffer_resource<T: send> {
let buffer: ~buffer<T>; let buffer: ~buffer<T>;
new(+b: ~buffer<T>) { new(+b: ~buffer<T>) {
//let p = ptr::addr_of(*b); //let p = ptr::addr_of(*b);
//#error("take %?", p); //error!{"take %?", p};
atomic_add_acq(b.header.ref_count, 1); atomic_add_acq(b.header.ref_count, 1);
self.buffer = b; self.buffer = b;
} }
@ -230,7 +230,7 @@ class buffer_resource<T: send> {
drop unsafe { drop unsafe {
let b = move!{self.buffer}; let b = move!{self.buffer};
//let p = ptr::addr_of(*b); //let p = ptr::addr_of(*b);
//#error("drop %?", p); //error!{"drop %?", p};
let old_count = atomic_sub_rel(b.header.ref_count, 1); let old_count = atomic_sub_rel(b.header.ref_count, 1);
//let old_count = atomic_xchng_rel(b.header.ref_count, 0); //let old_count = atomic_xchng_rel(b.header.ref_count, 0);
if old_count == 1 { if old_count == 1 {
@ -262,7 +262,7 @@ fn send<T: send, Tbuffer: send>(-p: send_packet_buffered<T, Tbuffer>,
} }
full { fail ~"duplicate send" } full { fail ~"duplicate send" }
blocked { blocked {
#debug("waking up task for %?", p_); debug!{"waking up task for %?", p_};
alt p.header.blocked_task { alt p.header.blocked_task {
some(task) { some(task) {
rustrt::task_signal_event( rustrt::task_signal_event(
@ -301,7 +301,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>)
blocked); blocked);
alt old_state { alt old_state {
empty { empty {
#debug("no data available on %?, going to sleep.", p_); debug!{"no data available on %?, going to sleep.", p_};
if count == 0 { if count == 0 {
wait_event(this); wait_event(this);
} }
@ -314,7 +314,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>)
// sometimes blocking the thing we are waiting on. // sometimes blocking the thing we are waiting on.
task::yield(); task::yield();
} }
#debug("woke up, p.state = %?", copy p.header.state); debug!{"woke up, p.state = %?", copy p.header.state};
} }
blocked { blocked {
if first { if first {
@ -418,7 +418,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint {
} }
while !data_avail { while !data_avail {
#debug("sleeping on %? packets", pkts.len()); debug!{"sleeping on %? packets", pkts.len()};
let event = wait_event(this) as *packet_header; let event = wait_event(this) as *packet_header;
let pos = vec::position(pkts, |p| p == event); let pos = vec::position(pkts, |p| p == event);
@ -428,16 +428,16 @@ fn wait_many(pkts: &[*packet_header]) -> uint {
data_avail = true; data_avail = true;
} }
none { none {
#debug("ignoring spurious event, %?", event); debug!{"ignoring spurious event, %?", event};
} }
} }
} }
#debug("%?", pkts[ready_packet]); debug!{"%?", pkts[ready_packet]};
for pkts.each |p| { unsafe{ (*p).unblock()} } for pkts.each |p| { unsafe{ (*p).unblock()} }
#debug("%?, %?", ready_packet, pkts[ready_packet]); debug!{"%?, %?", ready_packet, pkts[ready_packet]};
unsafe { unsafe {
assert (*pkts[ready_packet]).state == full assert (*pkts[ready_packet]).state == full
@ -510,7 +510,7 @@ class send_packet_buffered<T: send, Tbuffer: send> {
let mut p: option<*packet<T>>; let mut p: option<*packet<T>>;
let mut buffer: option<buffer_resource<Tbuffer>>; let mut buffer: option<buffer_resource<Tbuffer>>;
new(p: *packet<T>) { new(p: *packet<T>) {
//#debug("take send %?", p); //debug!{"take send %?", p};
self.p = some(p); self.p = some(p);
unsafe { unsafe {
self.buffer = some( self.buffer = some(
@ -520,17 +520,17 @@ class send_packet_buffered<T: send, Tbuffer: send> {
} }
drop { drop {
//if self.p != none { //if self.p != none {
// #debug("drop send %?", option::get(self.p)); // debug!{"drop send %?", option::get(self.p)};
//} //}
if self.p != none { if self.p != none {
let mut p = none; let mut p = none;
p <-> self.p; p <-> self.p;
sender_terminate(option::unwrap(p)) sender_terminate(option::unwrap(p))
} }
//unsafe { #error("send_drop: %?", //unsafe { error!{"send_drop: %?",
// if self.buffer == none { // if self.buffer == none {
// "none" // "none"
// } else { "some" }); } // } else { "some" }}; }
} }
fn unwrap() -> *packet<T> { fn unwrap() -> *packet<T> {
let mut p = none; let mut p = none;
@ -553,7 +553,7 @@ class send_packet_buffered<T: send, Tbuffer: send> {
} }
fn reuse_buffer() -> buffer_resource<Tbuffer> { fn reuse_buffer() -> buffer_resource<Tbuffer> {
//#error("send reuse_buffer"); //error!{"send reuse_buffer"};
let mut tmp = none; let mut tmp = none;
tmp <-> self.buffer; tmp <-> self.buffer;
option::unwrap(tmp) option::unwrap(tmp)
@ -570,7 +570,7 @@ class recv_packet_buffered<T: send, Tbuffer: send> : selectable {
let mut p: option<*packet<T>>; let mut p: option<*packet<T>>;
let mut buffer: option<buffer_resource<Tbuffer>>; let mut buffer: option<buffer_resource<Tbuffer>>;
new(p: *packet<T>) { new(p: *packet<T>) {
//#debug("take recv %?", p); //debug!{"take recv %?", p};
self.p = some(p); self.p = some(p);
unsafe { unsafe {
self.buffer = some( self.buffer = some(
@ -580,17 +580,17 @@ class recv_packet_buffered<T: send, Tbuffer: send> : selectable {
} }
drop { drop {
//if self.p != none { //if self.p != none {
// #debug("drop recv %?", option::get(self.p)); // debug!{"drop recv %?", option::get(self.p)};
//} //}
if self.p != none { if self.p != none {
let mut p = none; let mut p = none;
p <-> self.p; p <-> self.p;
receiver_terminate(option::unwrap(p)) receiver_terminate(option::unwrap(p))
} }
//unsafe { #error("recv_drop: %?", //unsafe { error!{"recv_drop: %?",
// if self.buffer == none { // if self.buffer == none {
// "none" // "none"
// } else { "some" }); } // } else { "some" }}; }
} }
fn unwrap() -> *packet<T> { fn unwrap() -> *packet<T> {
let mut p = none; let mut p = none;
@ -613,7 +613,7 @@ class recv_packet_buffered<T: send, Tbuffer: send> : selectable {
} }
fn reuse_buffer() -> buffer_resource<Tbuffer> { fn reuse_buffer() -> buffer_resource<Tbuffer> {
//#error("recv reuse_buffer"); //error!{"recv reuse_buffer"};
let mut tmp = none; let mut tmp = none;
tmp <-> self.buffer; tmp <-> self.buffer;
option::unwrap(tmp) option::unwrap(tmp)

View file

@ -65,7 +65,7 @@ unsafe fn chan_from_global_ptr<T: send>(
log(debug,~"BEFORE COMPARE AND SWAP"); log(debug,~"BEFORE COMPARE AND SWAP");
let swapped = compare_and_swap( let swapped = compare_and_swap(
global, 0u, unsafe::reinterpret_cast(ch)); global, 0u, unsafe::reinterpret_cast(ch));
log(debug,#fmt("AFTER .. swapped? %?", swapped)); log(debug,fmt!{"AFTER .. swapped? %?", swapped});
if swapped { if swapped {
// Success! // Success!

View file

@ -327,7 +327,7 @@ mod tests {
let ra = rand::seeded_rng(seed); let ra = rand::seeded_rng(seed);
// Regression test that isaac is actually using the above vector // Regression test that isaac is actually using the above vector
let r = ra.next(); let r = ra.next();
#error("%?", r); error!{"%?", r};
assert r == 890007737u32 // on x86_64 assert r == 890007737u32 // on x86_64
|| r == 2935188040u32; // on x86 || r == 2935188040u32; // on x86
} }

View file

@ -21,7 +21,7 @@ pure fn get<T: copy, U>(res: result<T, U>) -> T {
alt res { alt res {
ok(t) { t } ok(t) { t }
err(the_err) { err(the_err) {
unchecked{ fail #fmt("get called on error result: %?", the_err); } unchecked{ fail fmt!{"get called on error result: %?", the_err}; }
} }
} }
} }

View file

@ -103,7 +103,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>,
for vec::each(es) |e| { for vec::each(es) |e| {
let (k,v) = e; let (k,v) = e;
let t = @(#fmt("%s=%s", k, v)); let t = @(fmt!{"%s=%s", k, v});
vec::push(tmps, t); vec::push(tmps, t);
vec::push_all(ptrs, str::as_c_str(*t, |b| ~[b])); vec::push_all(ptrs, str::as_c_str(*t, |b| ~[b]));
} }
@ -130,7 +130,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>,
let mut blk : ~[u8] = ~[]; let mut blk : ~[u8] = ~[];
for vec::each(es) |e| { for vec::each(es) |e| {
let (k,v) = e; let (k,v) = e;
let t = #fmt("%s=%s", k, v); let t = fmt!{"%s=%s", k, v};
let mut v : ~[u8] = ::unsafe::reinterpret_cast(t); let mut v : ~[u8] = ::unsafe::reinterpret_cast(t);
blk += v; blk += v;
::unsafe::forget(v); ::unsafe::forget(v);
@ -329,7 +329,7 @@ fn program_output(prog: ~str, args: ~[~str]) ->
fn writeclose(fd: c_int, s: ~str) { fn writeclose(fd: c_int, s: ~str) {
import io::writer_util; import io::writer_util;
#error("writeclose %d, %s", fd as int, s); error!{"writeclose %d, %s", fd as int, s};
let writer = io::fd_writer(fd, false); let writer = io::fd_writer(fd, false);
writer.write_str(s); writer.write_str(s);

View file

@ -78,7 +78,7 @@ mod linear {
pure fn next_bucket(idx: uint, len_buckets: uint) -> uint { pure fn next_bucket(idx: uint, len_buckets: uint) -> uint {
let n = (idx + 1) % len_buckets; let n = (idx + 1) % len_buckets;
unsafe{ // argh. log not considered pure. unsafe{ // argh. log not considered pure.
#debug["next_bucket(%?, %?) = %?", idx, len_buckets, n]; debug!{"next_bucket(%?, %?) = %?", idx, len_buckets, n};
} }
ret n; ret n;
} }
@ -163,15 +163,15 @@ mod linear {
unsafe{borrow(k)}) { unsafe{borrow(k)}) {
table_full => {fail ~"Internal logic error";} table_full => {fail ~"Internal logic error";}
found_hole(idx) { found_hole(idx) {
#debug["insert fresh (%?->%?) at idx %?, hash %?", debug!{"insert fresh (%?->%?) at idx %?, hash %?",
k, v, idx, hash]; k, v, idx, hash};
self.buckets[idx] = some({hash: hash, key: k, value: v}); self.buckets[idx] = some({hash: hash, key: k, value: v});
self.size += 1; self.size += 1;
ret true; ret true;
} }
found_entry(idx) => { found_entry(idx) => {
#debug["insert overwrite (%?->%?) at idx %?, hash %?", debug!{"insert overwrite (%?->%?) at idx %?, hash %?",
k, v, idx, hash]; k, v, idx, hash};
self.buckets[idx] = some({hash: hash, key: k, value: v}); self.buckets[idx] = some({hash: hash, key: k, value: v});
ret false; ret false;
} }
@ -269,7 +269,7 @@ mod linear {
fn get(k: &K) -> V { fn get(k: &K) -> V {
let value = self.find(k); let value = self.find(k);
if value.is_none() { if value.is_none() {
fail #fmt["No entry found for key: %?", k]; fail fmt!{"No entry found for key: %?", k};
} }
option::unwrap(value) option::unwrap(value)
} }

View file

@ -16,7 +16,7 @@ class frame {
fn walk_stack(visit: fn(frame) -> bool) { fn walk_stack(visit: fn(frame) -> bool) {
#debug("beginning stack walk"); debug!{"beginning stack walk"};
do frame_address |frame_pointer| { do frame_address |frame_pointer| {
let mut frame_address: *word = unsafe { let mut frame_address: *word = unsafe {
@ -25,14 +25,14 @@ fn walk_stack(visit: fn(frame) -> bool) {
loop { loop {
let fr = frame(frame_address); let fr = frame(frame_address);
#debug("frame: %x", unsafe { reinterpret_cast(fr.fp) }); debug!{"frame: %x", unsafe { reinterpret_cast(fr.fp) }};
visit(fr); visit(fr);
unsafe { unsafe {
let next_fp: **word = reinterpret_cast(frame_address); let next_fp: **word = reinterpret_cast(frame_address);
frame_address = *next_fp; frame_address = *next_fp;
if *frame_address == 0u { if *frame_address == 0u {
#debug("encountered task_start_wrapper. ending walk"); debug!{"encountered task_start_wrapper. ending walk"};
// This is the task_start_wrapper_frame. There is // This is the task_start_wrapper_frame. There is
// no stack beneath it and it is a foreign frame. // no stack beneath it and it is a foreign frame.
break; break;

View file

@ -1461,7 +1461,7 @@ pure fn is_char_boundary(s: &str, index: uint) -> bool {
* let i = 0u; * let i = 0u;
* while i < str::len(s) { * while i < str::len(s) {
* let {ch, next} = str::char_range_at(s, i); * let {ch, next} = str::char_range_at(s, i);
* std::io::println(#fmt("%u: %c",i,ch)); * std::io::println(fmt!{"%u: %c",i,ch});
* i = next; * i = next;
* } * }
* ~~~ * ~~~
@ -2141,7 +2141,7 @@ mod tests {
fn t(s: ~str, c: char, u: ~[~str]) { fn t(s: ~str, c: char, u: ~[~str]) {
log(debug, ~"split_byte: " + s); log(debug, ~"split_byte: " + s);
let v = split_char(s, c); let v = split_char(s, c);
#debug("split_byte to: %?", v); debug!{"split_byte to: %?", v};
assert vec::all2(v, u, |a,b| a == b); assert vec::all2(v, u, |a,b| a == b);
} }
t(~"abc.hello.there", '.', ~[~"abc", ~"hello", ~"there"]); t(~"abc.hello.there", '.', ~[~"abc", ~"hello", ~"there"]);
@ -2170,8 +2170,8 @@ mod tests {
fn t(s: ~str, c: char, n: uint, u: ~[~str]) { fn t(s: ~str, c: char, n: uint, u: ~[~str]) {
log(debug, ~"splitn_byte: " + s); log(debug, ~"splitn_byte: " + s);
let v = splitn_char(s, c, n); let v = splitn_char(s, c, n);
#debug("split_byte to: %?", v); debug!{"split_byte to: %?", v};
#debug("comparing vs. %?", u); debug!{"comparing vs. %?", u};
assert vec::all2(v, u, |a,b| a == b); assert vec::all2(v, u, |a,b| a == b);
} }
t(~"abc.hello.there", '.', 0u, ~[~"abc.hello.there"]); t(~"abc.hello.there", '.', 0u, ~[~"abc.hello.there"]);

View file

@ -278,37 +278,37 @@ mod tests {
fn reccyeq(a: reccy, b: reccy) -> bool { fn reccyeq(a: reccy, b: reccy) -> bool {
ret a.x == b.x && a.y == b.y && taggyeq(a.t, b.t); ret a.x == b.x && a.y == b.y && taggyeq(a.t, b.t);
} }
#debug("*** test boxes"); debug!{"*** test boxes"};
test_boxes(@5, @72, @64, @175); test_boxes(@5, @72, @64, @175);
#debug("*** end test boxes"); debug!{"*** end test boxes"};
#debug("test parameterized: int"); debug!{"test parameterized: int"};
let eq1: eqfn<int> = inteq; let eq1: eqfn<int> = inteq;
test_parameterized::<int>(eq1, 5, 72, 64, 175); test_parameterized::<int>(eq1, 5, 72, 64, 175);
#debug("*** test parameterized: @int"); debug!{"*** test parameterized: @int"};
let eq2: eqfn<@int> = intboxeq; let eq2: eqfn<@int> = intboxeq;
test_parameterized::<@int>(eq2, @5, @72, @64, @175); test_parameterized::<@int>(eq2, @5, @72, @64, @175);
#debug("*** end test parameterized @int"); debug!{"*** end test parameterized @int"};
#debug("test parameterized: taggy"); debug!{"test parameterized: taggy"};
let eq3: eqfn<taggy> = taggyeq; let eq3: eqfn<taggy> = taggyeq;
test_parameterized::<taggy>(eq3, one(1), two(1, 2), three(1, 2, 3), test_parameterized::<taggy>(eq3, one(1), two(1, 2), three(1, 2, 3),
two(17, 42)); two(17, 42));
#debug("*** test parameterized: taggypar<int>"); debug!{"*** test parameterized: taggypar<int>"};
let eq4: eqfn<taggypar<int>> = |x,y| taggypareq::<int>(x, y); let eq4: eqfn<taggypar<int>> = |x,y| taggypareq::<int>(x, y);
test_parameterized::<taggypar<int>>(eq4, onepar::<int>(1), test_parameterized::<taggypar<int>>(eq4, onepar::<int>(1),
twopar::<int>(1, 2), twopar::<int>(1, 2),
threepar::<int>(1, 2, 3), threepar::<int>(1, 2, 3),
twopar::<int>(17, 42)); twopar::<int>(17, 42));
#debug("*** end test parameterized: taggypar::<int>"); debug!{"*** end test parameterized: taggypar::<int>"};
#debug("*** test parameterized: reccy"); debug!{"*** test parameterized: reccy"};
let reccy1: reccy = {x: 1, y: 2, t: one(1)}; let reccy1: reccy = {x: 1, y: 2, t: one(1)};
let reccy2: reccy = {x: 345, y: 2, t: two(1, 2)}; let reccy2: reccy = {x: 345, y: 2, t: two(1, 2)};
let reccy3: reccy = {x: 1, y: 777, t: three(1, 2, 3)}; let reccy3: reccy = {x: 1, y: 777, t: three(1, 2, 3)};
let reccy4: reccy = {x: 19, y: 252, t: two(17, 42)}; let reccy4: reccy = {x: 19, y: 252, t: two(17, 42)};
let eq5: eqfn<reccy> = reccyeq; let eq5: eqfn<reccy> = reccyeq;
test_parameterized::<reccy>(eq5, reccy1, reccy2, reccy3, reccy4); test_parameterized::<reccy>(eq5, reccy1, reccy2, reccy3, reccy4);
#debug("*** end test parameterized: reccy"); debug!{"*** end test parameterized: reccy"};
#debug("*** done"); debug!{"*** done"};
} }
} }

View file

@ -80,7 +80,7 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} {
(data[start + 2u] as uint) << 8u | (data[start + 2u] as uint) << 8u |
(data[start + 3u] as uint), (data[start + 3u] as uint),
next: start + 4u}; next: start + 4u};
} else { #error("vint too big"); fail; } } else { error!{"vint too big"}; fail; }
} }
fn doc(data: @~[u8]) -> doc { fn doc(data: @~[u8]) -> doc {
@ -112,7 +112,7 @@ fn get_doc(d: doc, tg: uint) -> doc {
alt maybe_get_doc(d, tg) { alt maybe_get_doc(d, tg) {
some(d) { ret d; } some(d) { ret d; }
none { none {
#error("failed to find block with tag %u", tg); error!{"failed to find block with tag %u", tg};
fail; fail;
} }
} }
@ -200,7 +200,7 @@ fn write_sized_vuint(w: io::writer, n: uint, size: uint) {
w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8, w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
(n >> 8_u) as u8, n as u8]); (n >> 8_u) as u8, n as u8]);
} }
_ { fail #fmt("vint to write too big: %?", n); } _ { fail fmt!{"vint to write too big: %?", n}; }
}; };
} }
@ -209,7 +209,7 @@ fn write_vuint(w: io::writer, n: uint) {
if n < 0x4000_u { write_sized_vuint(w, n, 2u); ret; } if n < 0x4000_u { write_sized_vuint(w, n, 2u); ret; }
if n < 0x200000_u { write_sized_vuint(w, n, 3u); ret; } if n < 0x200000_u { write_sized_vuint(w, n, 3u); ret; }
if n < 0x10000000_u { write_sized_vuint(w, n, 4u); ret; } if n < 0x10000000_u { write_sized_vuint(w, n, 4u); ret; }
fail #fmt("vint to write too big: %?", n); fail fmt!{"vint to write too big: %?", n};
} }
fn writer(w: io::writer) -> writer { fn writer(w: io::writer) -> writer {
@ -220,7 +220,7 @@ fn writer(w: io::writer) -> writer {
// FIXME (#2741): Provide a function to write the standard ebml header. // FIXME (#2741): Provide a function to write the standard ebml header.
impl writer for writer { impl writer for writer {
fn start_tag(tag_id: uint) { fn start_tag(tag_id: uint) {
#debug["Start tag %u", tag_id]; debug!{"Start tag %u", tag_id};
// Write the enum ID: // Write the enum ID:
write_vuint(self.writer, tag_id); write_vuint(self.writer, tag_id);
@ -239,7 +239,7 @@ impl writer for writer {
write_sized_vuint(self.writer, size, 4u); write_sized_vuint(self.writer, size, 4u);
self.writer.seek(cur_pos as int, io::seek_set); self.writer.seek(cur_pos as int, io::seek_set);
#debug["End tag (size = %u)", size]; debug!{"End tag (size = %u)", size};
} }
fn wr_tag(tag_id: uint, blk: fn()) { fn wr_tag(tag_id: uint, blk: fn()) {
@ -309,12 +309,12 @@ impl writer for writer {
} }
fn wr_bytes(b: &[u8]) { fn wr_bytes(b: &[u8]) {
#debug["Write %u bytes", vec::len(b)]; debug!{"Write %u bytes", vec::len(b)};
self.writer.write(b); self.writer.write(b);
} }
fn wr_str(s: ~str) { fn wr_str(s: ~str) {
#debug["Write str: %?", s]; debug!{"Write str: %?", s};
self.writer.write(str::bytes(s)); self.writer.write(str::bytes(s));
} }
} }
@ -437,29 +437,29 @@ impl deserializer_priv for ebml_deserializer {
self.pos = r_doc.end; self.pos = r_doc.end;
let str = ebml::doc_as_str(r_doc); let str = ebml::doc_as_str(r_doc);
if lbl != str { if lbl != str {
fail #fmt["Expected label %s but found %s", lbl, str]; fail fmt!{"Expected label %s but found %s", lbl, str};
} }
} }
} }
} }
fn next_doc(exp_tag: ebml_serializer_tag) -> ebml::doc { fn next_doc(exp_tag: ebml_serializer_tag) -> ebml::doc {
#debug[". next_doc(exp_tag=%?)", exp_tag]; debug!{". next_doc(exp_tag=%?)", exp_tag};
if self.pos >= self.parent.end { if self.pos >= self.parent.end {
fail ~"no more documents in current node!"; fail ~"no more documents in current node!";
} }
let {tag: r_tag, doc: r_doc} = let {tag: r_tag, doc: r_doc} =
ebml::doc_at(self.parent.data, self.pos); ebml::doc_at(self.parent.data, self.pos);
#debug["self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?", debug!{"self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?",
copy self.parent.start, copy self.parent.end, copy self.parent.start, copy self.parent.end,
copy self.pos, r_tag, r_doc.start, r_doc.end]; copy self.pos, r_tag, r_doc.start, r_doc.end};
if r_tag != (exp_tag as uint) { if r_tag != (exp_tag as uint) {
fail #fmt["expected EMBL doc with tag %? but found tag %?", fail fmt!{"expected EMBL doc with tag %? but found tag %?",
exp_tag, r_tag]; exp_tag, r_tag};
} }
if r_doc.end > self.parent.end { if r_doc.end > self.parent.end {
fail #fmt["invalid EBML, child extends to 0x%x, parent to 0x%x", fail fmt!{"invalid EBML, child extends to 0x%x, parent to 0x%x",
r_doc.end, self.parent.end]; r_doc.end, self.parent.end};
} }
self.pos = r_doc.end; self.pos = r_doc.end;
ret r_doc; ret r_doc;
@ -478,7 +478,7 @@ impl deserializer_priv for ebml_deserializer {
fn _next_uint(exp_tag: ebml_serializer_tag) -> uint { fn _next_uint(exp_tag: ebml_serializer_tag) -> uint {
let r = ebml::doc_as_u32(self.next_doc(exp_tag)); let r = ebml::doc_as_u32(self.next_doc(exp_tag));
#debug["_next_uint exp_tag=%? result=%?", exp_tag, r]; debug!{"_next_uint exp_tag=%? result=%?", exp_tag, r};
ret r as uint; ret r as uint;
} }
} }
@ -493,7 +493,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer {
fn read_uint() -> uint { fn read_uint() -> uint {
let v = ebml::doc_as_u64(self.next_doc(es_uint)); let v = ebml::doc_as_u64(self.next_doc(es_uint));
if v > (core::uint::max_value as u64) { if v > (core::uint::max_value as u64) {
fail #fmt["uint %? too large for this architecture", v]; fail fmt!{"uint %? too large for this architecture", v};
} }
ret v as uint; ret v as uint;
} }
@ -505,7 +505,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer {
fn read_int() -> int { fn read_int() -> int {
let v = ebml::doc_as_u64(self.next_doc(es_int)) as i64; let v = ebml::doc_as_u64(self.next_doc(es_int)) as i64;
if v > (int::max_value as i64) || v < (int::min_value as i64) { if v > (int::max_value as i64) || v < (int::min_value as i64) {
fail #fmt["int %? out of range for this architecture", v]; fail fmt!{"int %? out of range for this architecture", v};
} }
ret v as int; ret v as int;
} }
@ -520,67 +520,67 @@ impl deserializer of serialization::deserializer for ebml_deserializer {
// Compound types: // Compound types:
fn read_enum<T:copy>(name: ~str, f: fn() -> T) -> T { fn read_enum<T:copy>(name: ~str, f: fn() -> T) -> T {
#debug["read_enum(%s)", name]; debug!{"read_enum(%s)", name};
self._check_label(name); self._check_label(name);
self.push_doc(self.next_doc(es_enum), f) self.push_doc(self.next_doc(es_enum), f)
} }
fn read_enum_variant<T:copy>(f: fn(uint) -> T) -> T { fn read_enum_variant<T:copy>(f: fn(uint) -> T) -> T {
#debug["read_enum_variant()"]; debug!{"read_enum_variant()"};
let idx = self._next_uint(es_enum_vid); let idx = self._next_uint(es_enum_vid);
#debug[" idx=%u", idx]; debug!{" idx=%u", idx};
do self.push_doc(self.next_doc(es_enum_body)) { do self.push_doc(self.next_doc(es_enum_body)) {
f(idx) f(idx)
} }
} }
fn read_enum_variant_arg<T:copy>(idx: uint, f: fn() -> T) -> T { fn read_enum_variant_arg<T:copy>(idx: uint, f: fn() -> T) -> T {
#debug["read_enum_variant_arg(idx=%u)", idx]; debug!{"read_enum_variant_arg(idx=%u)", idx};
f() f()
} }
fn read_vec<T:copy>(f: fn(uint) -> T) -> T { fn read_vec<T:copy>(f: fn(uint) -> T) -> T {
#debug["read_vec()"]; debug!{"read_vec()"};
do self.push_doc(self.next_doc(es_vec)) { do self.push_doc(self.next_doc(es_vec)) {
let len = self._next_uint(es_vec_len); let len = self._next_uint(es_vec_len);
#debug[" len=%u", len]; debug!{" len=%u", len};
f(len) f(len)
} }
} }
fn read_vec_elt<T:copy>(idx: uint, f: fn() -> T) -> T { fn read_vec_elt<T:copy>(idx: uint, f: fn() -> T) -> T {
#debug["read_vec_elt(idx=%u)", idx]; debug!{"read_vec_elt(idx=%u)", idx};
self.push_doc(self.next_doc(es_vec_elt), f) self.push_doc(self.next_doc(es_vec_elt), f)
} }
fn read_box<T:copy>(f: fn() -> T) -> T { fn read_box<T:copy>(f: fn() -> T) -> T {
#debug["read_box()"]; debug!{"read_box()"};
f() f()
} }
fn read_uniq<T:copy>(f: fn() -> T) -> T { fn read_uniq<T:copy>(f: fn() -> T) -> T {
#debug["read_uniq()"]; debug!{"read_uniq()"};
f() f()
} }
fn read_rec<T:copy>(f: fn() -> T) -> T { fn read_rec<T:copy>(f: fn() -> T) -> T {
#debug["read_rec()"]; debug!{"read_rec()"};
f() f()
} }
fn read_rec_field<T:copy>(f_name: ~str, f_idx: uint, f: fn() -> T) -> T { fn read_rec_field<T:copy>(f_name: ~str, f_idx: uint, f: fn() -> T) -> T {
#debug["read_rec_field(%s, idx=%u)", f_name, f_idx]; debug!{"read_rec_field(%s, idx=%u)", f_name, f_idx};
self._check_label(f_name); self._check_label(f_name);
f() f()
} }
fn read_tup<T:copy>(sz: uint, f: fn() -> T) -> T { fn read_tup<T:copy>(sz: uint, f: fn() -> T) -> T {
#debug["read_tup(sz=%u)", sz]; debug!{"read_tup(sz=%u)", sz};
f() f()
} }
fn read_tup_elt<T:copy>(idx: uint, f: fn() -> T) -> T { fn read_tup_elt<T:copy>(idx: uint, f: fn() -> T) -> T {
#debug["read_tup_elt(idx=%u)", idx]; debug!{"read_tup_elt(idx=%u)", idx};
f() f()
} }
} }
@ -631,14 +631,14 @@ fn test_option_int() {
} }
fn test_v(v: option<int>) { fn test_v(v: option<int>) {
#debug["v == %?", v]; debug!{"v == %?", v};
let mbuf = io::mem_buffer(); let mbuf = io::mem_buffer();
let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf)); let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf));
serialize_0(ebml_w, v); serialize_0(ebml_w, v);
let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf)); let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf));
let deser = ebml_deserializer(ebml_doc); let deser = ebml_deserializer(ebml_doc);
let v1 = deserialize_0(deser); let v1 = deserialize_0(deser);
#debug["v1 == %?", v1]; debug!{"v1 == %?", v1};
assert v == v1; assert v == v1;
} }

View file

@ -314,7 +314,7 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe {
fn opt_vals(m: match, nm: ~str) -> ~[optval] { fn opt_vals(m: match, nm: ~str) -> ~[optval] {
ret alt find_opt(m.opts, mkname(nm)) { ret alt find_opt(m.opts, mkname(nm)) {
some(id) { m.vals[id] } some(id) { m.vals[id] }
none { #error("No option '%s' defined", nm); fail } none { error!{"No option '%s' defined", nm}; fail }
}; };
} }

View file

@ -632,7 +632,7 @@ impl of to_str::to_str for json {
impl of to_str::to_str for error { impl of to_str::to_str for error {
fn to_str() -> ~str { fn to_str() -> ~str {
#fmt("%u:%u: %s", self.line, self.col, *self.msg) fmt!{"%u:%u: %s", self.line, self.col, *self.msg}
} }
} }

View file

@ -122,16 +122,16 @@ mod chained {
loop { loop {
alt copy e0.next { alt copy e0.next {
absent { absent {
#debug("search_tbl: absent, comp %u, hash %u, idx %u", debug!{"search_tbl: absent, comp %u, hash %u, idx %u",
comp, h, idx); comp, h, idx};
ret not_found; ret not_found;
} }
present(e1) { present(e1) {
comp += 1u; comp += 1u;
if e1.hash == h && self.eqer(e1.key, k) { if e1.hash == h && self.eqer(e1.key, k) {
#debug("search_tbl: present, comp %u, \ debug!{"search_tbl: present, comp %u, \
hash %u, idx %u", hash %u, idx %u",
comp, h, idx); comp, h, idx};
ret found_after(e0, e1); ret found_after(e0, e1);
} else { } else {
e0 = e1; e0 = e1;
@ -145,14 +145,14 @@ mod chained {
let idx = h % vec::len(self.chains); let idx = h % vec::len(self.chains);
alt copy self.chains[idx] { alt copy self.chains[idx] {
absent { absent {
#debug("search_tbl: absent, comp %u, hash %u, idx %u", debug!{"search_tbl: absent, comp %u, hash %u, idx %u",
0u, h, idx); 0u, h, idx};
ret not_found; ret not_found;
} }
present(e) { present(e) {
if e.hash == h && self.eqer(e.key, k) { if e.hash == h && self.eqer(e.key, k) {
#debug("search_tbl: present, comp %u, hash %u, idx %u", debug!{"search_tbl: present, comp %u, hash %u, idx %u",
1u, h, idx); 1u, h, idx};
ret found_first(idx, e); ret found_first(idx, e);
} else { } else {
ret self.search_rem(k, h, idx, e); ret self.search_rem(k, h, idx, e);
@ -248,7 +248,7 @@ mod chained {
fn get(k: K) -> V { fn get(k: K) -> V {
alt self.find(k) { alt self.find(k) {
some(v) => {v} some(v) => {v}
none => {fail #fmt["Key not found in table: %?", k]} none => {fail fmt!{"Key not found in table: %?", k}}
} }
} }
@ -427,14 +427,14 @@ mod tests {
#[test] #[test]
fn test_simple() { fn test_simple() {
#debug("*** starting test_simple"); debug!{"*** starting test_simple"};
fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; }
fn uint_id(&&x: uint) -> uint { x } fn uint_id(&&x: uint) -> uint { x }
let hasher_uint: map::hashfn<uint> = uint_id; let hasher_uint: map::hashfn<uint> = uint_id;
let eqer_uint: map::eqfn<uint> = eq_uint; let eqer_uint: map::eqfn<uint> = eq_uint;
let hasher_str: map::hashfn<~str> = str::hash; let hasher_str: map::hashfn<~str> = str::hash;
let eqer_str: map::eqfn<~str> = str::eq; let eqer_str: map::eqfn<~str> = str::eq;
#debug("uint -> uint"); debug!{"uint -> uint"};
let hm_uu: map::hashmap<uint, uint> = let hm_uu: map::hashmap<uint, uint> =
map::hashmap::<uint, uint>(hasher_uint, eqer_uint); map::hashmap::<uint, uint>(hasher_uint, eqer_uint);
assert (hm_uu.insert(10u, 12u)); assert (hm_uu.insert(10u, 12u));
@ -450,7 +450,7 @@ mod tests {
let ten: ~str = ~"ten"; let ten: ~str = ~"ten";
let eleven: ~str = ~"eleven"; let eleven: ~str = ~"eleven";
let twelve: ~str = ~"twelve"; let twelve: ~str = ~"twelve";
#debug("str -> uint"); debug!{"str -> uint"};
let hm_su: map::hashmap<~str, uint> = let hm_su: map::hashmap<~str, uint> =
map::hashmap::<~str, uint>(hasher_str, eqer_str); map::hashmap::<~str, uint>(hasher_str, eqer_str);
assert (hm_su.insert(~"ten", 12u)); assert (hm_su.insert(~"ten", 12u));
@ -464,7 +464,7 @@ mod tests {
assert (hm_su.get(~"twelve") == 14u); assert (hm_su.get(~"twelve") == 14u);
assert (!hm_su.insert(~"twelve", 12u)); assert (!hm_su.insert(~"twelve", 12u));
assert (hm_su.get(~"twelve") == 12u); assert (hm_su.get(~"twelve") == 12u);
#debug("uint -> str"); debug!{"uint -> str"};
let hm_us: map::hashmap<uint, ~str> = let hm_us: map::hashmap<uint, ~str> =
map::hashmap::<uint, ~str>(hasher_uint, eqer_uint); map::hashmap::<uint, ~str>(hasher_uint, eqer_uint);
assert (hm_us.insert(10u, ~"twelve")); assert (hm_us.insert(10u, ~"twelve"));
@ -477,7 +477,7 @@ mod tests {
assert (str::eq(hm_us.get(12u), ~"fourteen")); assert (str::eq(hm_us.get(12u), ~"fourteen"));
assert (!hm_us.insert(12u, ~"twelve")); assert (!hm_us.insert(12u, ~"twelve"));
assert (str::eq(hm_us.get(12u), ~"twelve")); assert (str::eq(hm_us.get(12u), ~"twelve"));
#debug("str -> str"); debug!{"str -> str"};
let hm_ss: map::hashmap<~str, ~str> = let hm_ss: map::hashmap<~str, ~str> =
map::hashmap::<~str, ~str>(hasher_str, eqer_str); map::hashmap::<~str, ~str>(hasher_str, eqer_str);
assert (hm_ss.insert(ten, ~"twelve")); assert (hm_ss.insert(ten, ~"twelve"));
@ -490,7 +490,7 @@ mod tests {
assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen"));
assert (!hm_ss.insert(~"twelve", ~"twelve")); assert (!hm_ss.insert(~"twelve", ~"twelve"));
assert (str::eq(hm_ss.get(~"twelve"), ~"twelve")); assert (str::eq(hm_ss.get(~"twelve"), ~"twelve"));
#debug("*** finished test_simple"); debug!{"*** finished test_simple"};
} }
@ -499,11 +499,11 @@ mod tests {
*/ */
#[test] #[test]
fn test_growth() { fn test_growth() {
#debug("*** starting test_growth"); debug!{"*** starting test_growth"};
let num_to_insert: uint = 64u; let num_to_insert: uint = 64u;
fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; }
fn uint_id(&&x: uint) -> uint { x } fn uint_id(&&x: uint) -> uint { x }
#debug("uint -> uint"); debug!{"uint -> uint"};
let hasher_uint: map::hashfn<uint> = uint_id; let hasher_uint: map::hashfn<uint> = uint_id;
let eqer_uint: map::eqfn<uint> = eq_uint; let eqer_uint: map::eqfn<uint> = eq_uint;
let hm_uu: map::hashmap<uint, uint> = let hm_uu: map::hashmap<uint, uint> =
@ -511,26 +511,26 @@ mod tests {
let mut i: uint = 0u; let mut i: uint = 0u;
while i < num_to_insert { while i < num_to_insert {
assert (hm_uu.insert(i, i * i)); assert (hm_uu.insert(i, i * i));
#debug("inserting %u -> %u", i, i*i); debug!{"inserting %u -> %u", i, i*i};
i += 1u; i += 1u;
} }
#debug("-----"); debug!{"-----"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(%u) = %u", i, hm_uu.get(i)); debug!{"get(%u) = %u", i, hm_uu.get(i)};
assert (hm_uu.get(i) == i * i); assert (hm_uu.get(i) == i * i);
i += 1u; i += 1u;
} }
assert (hm_uu.insert(num_to_insert, 17u)); assert (hm_uu.insert(num_to_insert, 17u));
assert (hm_uu.get(num_to_insert) == 17u); assert (hm_uu.get(num_to_insert) == 17u);
#debug("-----"); debug!{"-----"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(%u) = %u", i, hm_uu.get(i)); debug!{"get(%u) = %u", i, hm_uu.get(i)};
assert (hm_uu.get(i) == i * i); assert (hm_uu.get(i) == i * i);
i += 1u; i += 1u;
} }
#debug("str -> str"); debug!{"str -> str"};
let hasher_str: map::hashfn<~str> = str::hash; let hasher_str: map::hashfn<~str> = str::hash;
let eqer_str: map::eqfn<~str> = str::eq; let eqer_str: map::eqfn<~str> = str::eq;
let hm_ss: map::hashmap<~str, ~str> = let hm_ss: map::hashmap<~str, ~str> =
@ -538,17 +538,17 @@ mod tests {
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
assert hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u)); assert hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u));
#debug("inserting \"%s\" -> \"%s\"", debug!{"inserting \"%s\" -> \"%s\"",
uint::to_str(i, 2u), uint::to_str(i, 2u),
uint::to_str(i*i, 2u)); uint::to_str(i*i, 2u)};
i += 1u; i += 1u;
} }
#debug("-----"); debug!{"-----"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(\"%s\") = \"%s\"", debug!{"get(\"%s\") = \"%s\"",
uint::to_str(i, 2u), uint::to_str(i, 2u),
hm_ss.get(uint::to_str(i, 2u))); hm_ss.get(uint::to_str(i, 2u))};
assert (str::eq(hm_ss.get(uint::to_str(i, 2u)), assert (str::eq(hm_ss.get(uint::to_str(i, 2u)),
uint::to_str(i * i, 2u))); uint::to_str(i * i, 2u)));
i += 1u; i += 1u;
@ -557,22 +557,22 @@ mod tests {
uint::to_str(17u, 2u))); uint::to_str(17u, 2u)));
assert (str::eq(hm_ss.get(uint::to_str(num_to_insert, 2u)), assert (str::eq(hm_ss.get(uint::to_str(num_to_insert, 2u)),
uint::to_str(17u, 2u))); uint::to_str(17u, 2u)));
#debug("-----"); debug!{"-----"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(\"%s\") = \"%s\"", debug!{"get(\"%s\") = \"%s\"",
uint::to_str(i, 2u), uint::to_str(i, 2u),
hm_ss.get(uint::to_str(i, 2u))); hm_ss.get(uint::to_str(i, 2u))};
assert (str::eq(hm_ss.get(uint::to_str(i, 2u)), assert (str::eq(hm_ss.get(uint::to_str(i, 2u)),
uint::to_str(i * i, 2u))); uint::to_str(i * i, 2u)));
i += 1u; i += 1u;
} }
#debug("*** finished test_growth"); debug!{"*** finished test_growth"};
} }
#[test] #[test]
fn test_removal() { fn test_removal() {
#debug("*** starting test_removal"); debug!{"*** starting test_removal"};
let num_to_insert: uint = 64u; let num_to_insert: uint = 64u;
fn eq(&&x: uint, &&y: uint) -> bool { ret x == y; } fn eq(&&x: uint, &&y: uint) -> bool { ret x == y; }
fn hash(&&u: uint) -> uint { fn hash(&&u: uint) -> uint {
@ -591,12 +591,12 @@ mod tests {
let mut i: uint = 0u; let mut i: uint = 0u;
while i < num_to_insert { while i < num_to_insert {
assert (hm.insert(i, i * i)); assert (hm.insert(i, i * i));
#debug("inserting %u -> %u", i, i*i); debug!{"inserting %u -> %u", i, i*i};
i += 1u; i += 1u;
} }
assert (hm.size() == num_to_insert); assert (hm.size() == num_to_insert);
#debug("-----"); debug!{"-----"};
#debug("removing evens"); debug!{"removing evens"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
let v = hm.remove(i); let v = hm.remove(i);
@ -607,44 +607,44 @@ mod tests {
i += 2u; i += 2u;
} }
assert (hm.size() == num_to_insert / 2u); assert (hm.size() == num_to_insert / 2u);
#debug("-----"); debug!{"-----"};
i = 1u; i = 1u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(%u) = %u", i, hm.get(i)); debug!{"get(%u) = %u", i, hm.get(i)};
assert (hm.get(i) == i * i); assert (hm.get(i) == i * i);
i += 2u; i += 2u;
} }
#debug("-----"); debug!{"-----"};
i = 1u; i = 1u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(%u) = %u", i, hm.get(i)); debug!{"get(%u) = %u", i, hm.get(i)};
assert (hm.get(i) == i * i); assert (hm.get(i) == i * i);
i += 2u; i += 2u;
} }
#debug("-----"); debug!{"-----"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
assert (hm.insert(i, i * i)); assert (hm.insert(i, i * i));
#debug("inserting %u -> %u", i, i*i); debug!{"inserting %u -> %u", i, i*i};
i += 2u; i += 2u;
} }
assert (hm.size() == num_to_insert); assert (hm.size() == num_to_insert);
#debug("-----"); debug!{"-----"};
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(%u) = %u", i, hm.get(i)); debug!{"get(%u) = %u", i, hm.get(i)};
assert (hm.get(i) == i * i); assert (hm.get(i) == i * i);
i += 1u; i += 1u;
} }
#debug("-----"); debug!{"-----"};
assert (hm.size() == num_to_insert); assert (hm.size() == num_to_insert);
i = 0u; i = 0u;
while i < num_to_insert { while i < num_to_insert {
#debug("get(%u) = %u", i, hm.get(i)); debug!{"get(%u) = %u", i, hm.get(i)};
assert (hm.get(i) == i * i); assert (hm.get(i) == i * i);
i += 1u; i += 1u;
} }
#debug("*** finished test_removal"); debug!{"*** finished test_removal"};
} }
#[test] #[test]

View file

@ -92,7 +92,7 @@ fn get_addr(++node: ~str, iotask: iotask)
-> result::result<~[ip_addr], ip_get_addr_err> unsafe { -> result::result<~[ip_addr], ip_get_addr_err> unsafe {
do comm::listen |output_ch| { do comm::listen |output_ch| {
do str::as_buf(node) |node_ptr, len| { do str::as_buf(node) |node_ptr, len| {
log(debug, #fmt("slice len %?", len)); log(debug, fmt!{"slice len %?", len});
let handle = create_uv_getaddrinfo_t(); let handle = create_uv_getaddrinfo_t();
let handle_ptr = ptr::addr_of(handle); let handle_ptr = ptr::addr_of(handle);
let handle_data: get_addr_data = { let handle_data: get_addr_data = {
@ -167,10 +167,10 @@ mod v4 {
} }
}); });
if vec::len(parts) != 4u { if vec::len(parts) != 4u {
result::err(#fmt("'%s' doesn't have 4 parts", ip)) result::err(fmt!{"'%s' doesn't have 4 parts", ip})
} }
else if vec::contains(parts, 256u) { else if vec::contains(parts, 256u) {
result::err(#fmt("invalid octal in addr '%s'", ip)) result::err(fmt!{"invalid octal in addr '%s'", ip})
} }
else { else {
result::ok({a: parts[0] as u8, b: parts[1] as u8, result::ok({a: parts[0] as u8, b: parts[1] as u8,
@ -191,8 +191,8 @@ mod v4 {
let new_addr = uv_ip4_addr(ip, 22); let new_addr = uv_ip4_addr(ip, 22);
let reformatted_name = uv_ip4_name(&new_addr); let reformatted_name = uv_ip4_name(&new_addr);
log(debug, #fmt("try_parse_addr: input ip: %s reparsed ip: %s", log(debug, fmt!{"try_parse_addr: input ip: %s reparsed ip: %s",
ip, reformatted_name)); ip, reformatted_name});
let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name); let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name);
if result::is_err(ref_ip_rep_result) { if result::is_err(ref_ip_rep_result) {
let err_str = result::get_err(ref_ip_rep_result); let err_str = result::get_err(ref_ip_rep_result);
@ -238,13 +238,13 @@ mod v6 {
// need to figure out how to establish a parse failure.. // need to figure out how to establish a parse failure..
let new_addr = uv_ip6_addr(ip, 22); let new_addr = uv_ip6_addr(ip, 22);
let reparsed_name = uv_ip6_name(&new_addr); let reparsed_name = uv_ip6_name(&new_addr);
log(debug, #fmt("v6::try_parse_addr ip: '%s' reparsed '%s'", log(debug, fmt!{"v6::try_parse_addr ip: '%s' reparsed '%s'",
ip, reparsed_name)); ip, reparsed_name});
// '::' appears to be uv_ip6_name() returns for bogus // '::' appears to be uv_ip6_name() returns for bogus
// parses.. // parses..
if ip != ~"::" && reparsed_name == ~"::" { if ip != ~"::" && reparsed_name == ~"::" {
result::err({err_msg:#fmt("failed to parse '%s'", result::err({err_msg:fmt!{"failed to parse '%s'",
ip)}) ip}})
} }
else { else {
result::ok(ipv6(new_addr)) result::ok(ipv6(new_addr))
@ -265,7 +265,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
if status == 0i32 { if status == 0i32 {
if res != (ptr::null::<addrinfo>()) { if res != (ptr::null::<addrinfo>()) {
let mut out_vec = ~[]; let mut out_vec = ~[];
log(debug, #fmt("initial addrinfo: %?", res)); log(debug, fmt!{"initial addrinfo: %?", res});
let mut curr_addr = res; let mut curr_addr = res;
loop { loop {
let new_ip_addr = if ll::is_ipv4_addrinfo(curr_addr) { let new_ip_addr = if ll::is_ipv4_addrinfo(curr_addr) {
@ -292,11 +292,11 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
} }
else { else {
curr_addr = next_addr; curr_addr = next_addr;
log(debug, #fmt("next_addr addrinfo: %?", curr_addr)); log(debug, fmt!{"next_addr addrinfo: %?", curr_addr});
} }
} }
log(debug, #fmt("successful process addrinfo result, len: %?", log(debug, fmt!{"successful process addrinfo result, len: %?",
vec::len(out_vec))); vec::len(out_vec)});
(*handle_data).output_ch.send(result::ok(out_vec)); (*handle_data).output_ch.send(result::ok(out_vec));
} }
else { else {
@ -328,19 +328,19 @@ mod test {
fn test_ip_ipv6_parse_and_format_ip() { fn test_ip_ipv6_parse_and_format_ip() {
let localhost_str = ~"::1"; let localhost_str = ~"::1";
let format_result = format_addr(v6::parse_addr(localhost_str)); let format_result = format_addr(v6::parse_addr(localhost_str));
log(debug, #fmt("results: expected: '%s' actual: '%s'", log(debug, fmt!{"results: expected: '%s' actual: '%s'",
localhost_str, format_result)); localhost_str, format_result});
assert format_result == localhost_str; assert format_result == localhost_str;
} }
#[test] #[test]
fn test_ip_ipv4_bad_parse() { fn test_ip_ipv4_bad_parse() {
alt v4::try_parse_addr(~"b4df00d") { alt v4::try_parse_addr(~"b4df00d") {
result::err(err_info) { result::err(err_info) {
log(debug, #fmt("got error as expected %?", err_info)); log(debug, fmt!{"got error as expected %?", err_info});
assert true; assert true;
} }
result::ok(addr) { result::ok(addr) {
fail #fmt("Expected failure, but got addr %?", addr); fail fmt!{"Expected failure, but got addr %?", addr};
} }
} }
} }
@ -349,11 +349,11 @@ mod test {
fn test_ip_ipv6_bad_parse() { fn test_ip_ipv6_bad_parse() {
alt v6::try_parse_addr(~"::,~2234k;") { alt v6::try_parse_addr(~"::,~2234k;") {
result::err(err_info) { result::err(err_info) {
log(debug, #fmt("got error as expected %?", err_info)); log(debug, fmt!{"got error as expected %?", err_info});
assert true; assert true;
} }
result::ok(addr) { result::ok(addr) {
fail #fmt("Expected failure, but got addr %?", addr); fail fmt!{"Expected failure, but got addr %?", addr};
} }
} }
} }
@ -369,8 +369,8 @@ mod test {
// note really sure how to realiably test/assert // note really sure how to realiably test/assert
// this.. mostly just wanting to see it work, atm. // this.. mostly just wanting to see it work, atm.
let results = result::unwrap(ga_result); let results = result::unwrap(ga_result);
log(debug, #fmt("test_get_addr: Number of results for %s: %?", log(debug, fmt!{"test_get_addr: Number of results for %s: %?",
localhost_name, vec::len(results))); localhost_name, vec::len(results)});
for vec::each(results) |r| { for vec::each(results) |r| {
let ipv_prefix = alt r { let ipv_prefix = alt r {
ipv4(_) { ipv4(_) {
@ -380,8 +380,8 @@ mod test {
~"IPv6" ~"IPv6"
} }
}; };
log(debug, #fmt("test_get_addr: result %s: '%s'", log(debug, fmt!{"test_get_addr: result %s: '%s'",
ipv_prefix, format_addr(r))); ipv_prefix, format_addr(r)});
} }
// at least one result.. this is going to vary from system // at least one result.. this is going to vary from system
// to system, based on stuff like the contents of /etc/hosts // to system, based on stuff like the contents of /etc/hosts

View file

@ -142,15 +142,15 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
iotask: iotask iotask: iotask
}; };
let socket_data_ptr = ptr::addr_of(*socket_data); let socket_data_ptr = ptr::addr_of(*socket_data);
log(debug, #fmt("tcp_connect result_ch %?", conn_data.result_ch)); log(debug, fmt!{"tcp_connect result_ch %?", conn_data.result_ch});
// get an unsafe representation of our stream_handle_ptr that // get an unsafe representation of our stream_handle_ptr that
// we can send into the interact cb to be handled in libuv.. // we can send into the interact cb to be handled in libuv..
log(debug, #fmt("stream_handle_ptr outside interact %?", log(debug, fmt!{"stream_handle_ptr outside interact %?",
stream_handle_ptr)); stream_handle_ptr});
do iotask::interact(iotask) |loop_ptr| { do iotask::interact(iotask) |loop_ptr| {
log(debug, ~"in interact cb for tcp client connect.."); log(debug, ~"in interact cb for tcp client connect..");
log(debug, #fmt("stream_handle_ptr in interact %?", log(debug, fmt!{"stream_handle_ptr in interact %?",
stream_handle_ptr)); stream_handle_ptr});
alt uv::ll::tcp_init( loop_ptr, stream_handle_ptr) { alt uv::ll::tcp_init( loop_ptr, stream_handle_ptr) {
0i32 { 0i32 {
log(debug, ~"tcp_init successful"); log(debug, ~"tcp_init successful");
@ -167,7 +167,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
// info.. should probably add an additional // info.. should probably add an additional
// rust type that actually is closer to // rust type that actually is closer to
// what the libuv API expects (ip str + port num) // what the libuv API expects (ip str + port num)
log(debug, #fmt("addr: %?", addr)); log(debug, fmt!{"addr: %?", addr});
let in_addr = uv::ll::ip4_addr(addr_str, port as int); let in_addr = uv::ll::ip4_addr(addr_str, port as int);
uv::ll::tcp_connect( uv::ll::tcp_connect(
connect_req_ptr, connect_req_ptr,
@ -176,7 +176,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
tcp_connect_on_connect_cb) tcp_connect_on_connect_cb)
} }
ip::ipv6(addr) { ip::ipv6(addr) {
log(debug, #fmt("addr: %?", addr)); log(debug, fmt!{"addr: %?", addr});
let in_addr = uv::ll::ip6_addr(addr_str, port as int); let in_addr = uv::ll::ip6_addr(addr_str, port as int);
uv::ll::tcp_connect6( uv::ll::tcp_connect6(
connect_req_ptr, connect_req_ptr,
@ -334,7 +334,7 @@ fn read_start(sock: tcp_socket)
fn read_stop(sock: tcp_socket, fn read_stop(sock: tcp_socket,
-read_port: comm::port<result::result<~[u8], tcp_err_data>>) -> -read_port: comm::port<result::result<~[u8], tcp_err_data>>) ->
result::result<(), tcp_err_data> unsafe { result::result<(), tcp_err_data> unsafe {
log(debug, #fmt("taking the read_port out of commission %?", read_port)); log(debug, fmt!{"taking the read_port out of commission %?", read_port});
let socket_data = ptr::addr_of(*sock.socket_data); let socket_data = ptr::addr_of(*sock.socket_data);
read_stop_common_impl(socket_data) read_stop_common_impl(socket_data)
} }
@ -622,13 +622,13 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
let addr_str = ip::format_addr(loc_ip); let addr_str = ip::format_addr(loc_ip);
let bind_result = alt loc_ip { let bind_result = alt loc_ip {
ip::ipv4(addr) { ip::ipv4(addr) {
log(debug, #fmt("addr: %?", addr)); log(debug, fmt!{"addr: %?", addr});
let in_addr = uv::ll::ip4_addr(addr_str, port as int); let in_addr = uv::ll::ip4_addr(addr_str, port as int);
uv::ll::tcp_bind(server_stream_ptr, uv::ll::tcp_bind(server_stream_ptr,
ptr::addr_of(in_addr)) ptr::addr_of(in_addr))
} }
ip::ipv6(addr) { ip::ipv6(addr) {
log(debug, #fmt("addr: %?", addr)); log(debug, fmt!{"addr: %?", addr});
let in_addr = uv::ll::ip6_addr(addr_str, port as int); let in_addr = uv::ll::ip6_addr(addr_str, port as int);
uv::ll::tcp_bind6(server_stream_ptr, uv::ll::tcp_bind6(server_stream_ptr,
ptr::addr_of(in_addr)) ptr::addr_of(in_addr))
@ -668,8 +668,8 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
alt setup_result { alt setup_result {
some(err_data) { some(err_data) {
do iotask::interact(iotask) |loop_ptr| { do iotask::interact(iotask) |loop_ptr| {
log(debug, #fmt("tcp::listen post-kill recv hl interact %?", log(debug, fmt!{"tcp::listen post-kill recv hl interact %?",
loop_ptr)); loop_ptr});
(*server_data_ptr).active = false; (*server_data_ptr).active = false;
uv::ll::close(server_stream_ptr, tcp_lfc_close_cb); uv::ll::close(server_stream_ptr, tcp_lfc_close_cb);
}; };
@ -684,8 +684,8 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
result::err(address_in_use) result::err(address_in_use)
} }
_ { _ {
log(debug, #fmt("Got '%s' '%s' libuv error", log(debug, fmt!{"Got '%s' '%s' libuv error",
err_data.err_name, err_data.err_msg)); err_data.err_name, err_data.err_msg});
result::err( result::err(
generic_listen_err(err_data.err_name, err_data.err_msg)) generic_listen_err(err_data.err_name, err_data.err_msg))
} }
@ -695,8 +695,8 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
on_establish_cb(kill_ch); on_establish_cb(kill_ch);
let kill_result = comm::recv(kill_po); let kill_result = comm::recv(kill_po);
do iotask::interact(iotask) |loop_ptr| { do iotask::interact(iotask) |loop_ptr| {
log(debug, #fmt("tcp::listen post-kill recv hl interact %?", log(debug, fmt!{"tcp::listen post-kill recv hl interact %?",
loop_ptr)); loop_ptr});
(*server_data_ptr).active = false; (*server_data_ptr).active = false;
uv::ll::close(server_stream_ptr, tcp_lfc_close_cb); uv::ll::close(server_stream_ptr, tcp_lfc_close_cb);
}; };
@ -776,8 +776,8 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf {
if err_data.err_name == ~"EOF" { if err_data.err_name == ~"EOF" {
break; break;
} else { } else {
#debug("ERROR sock_buf as io::reader.read err %? %?", debug!{"ERROR sock_buf as io::reader.read err %? %?",
err_data.err_name, err_data.err_msg); err_data.err_name, err_data.err_msg};
ret 0; ret 0;
} }
@ -809,7 +809,7 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf {
false // noop false // noop
} }
fn seek(dist: int, seek: io::seek_style) { fn seek(dist: int, seek: io::seek_style) {
log(debug, #fmt("tcp_socket_buf seek stub %? %?", dist, seek)); log(debug, fmt!{"tcp_socket_buf seek stub %? %?", dist, seek});
// noop // noop
} }
fn tell() -> uint { fn tell() -> uint {
@ -826,12 +826,12 @@ impl tcp_socket_buf of io::writer for @tcp_socket_buf {
vec::slice(data, 0, vec::len(data))); vec::slice(data, 0, vec::len(data)));
if w_result.is_err() { if w_result.is_err() {
let err_data = w_result.get_err(); let err_data = w_result.get_err();
log(debug, #fmt("ERROR sock_buf as io::writer.writer err: %? %?", log(debug, fmt!{"ERROR sock_buf as io::writer.writer err: %? %?",
err_data.err_name, err_data.err_msg)); err_data.err_name, err_data.err_msg});
} }
} }
fn seek(dist: int, seek: io::seek_style) { fn seek(dist: int, seek: io::seek_style) {
log(debug, #fmt("tcp_socket_buf seek stub %? %?", dist, seek)); log(debug, fmt!{"tcp_socket_buf seek stub %? %?", dist, seek});
// noop // noop
} }
fn tell() -> uint { fn tell() -> uint {
@ -856,14 +856,14 @@ fn tear_down_socket_data(socket_data: @tcp_socket_data) unsafe {
let close_data_ptr = ptr::addr_of(close_data); let close_data_ptr = ptr::addr_of(close_data);
let stream_handle_ptr = (*socket_data).stream_handle_ptr; let stream_handle_ptr = (*socket_data).stream_handle_ptr;
do iotask::interact((*socket_data).iotask) |loop_ptr| { do iotask::interact((*socket_data).iotask) |loop_ptr| {
log(debug, #fmt("interact dtor for tcp_socket stream %? loop %?", log(debug, fmt!{"interact dtor for tcp_socket stream %? loop %?",
stream_handle_ptr, loop_ptr)); stream_handle_ptr, loop_ptr});
uv::ll::set_data_for_uv_handle(stream_handle_ptr, uv::ll::set_data_for_uv_handle(stream_handle_ptr,
close_data_ptr); close_data_ptr);
uv::ll::close(stream_handle_ptr, tcp_socket_dtor_close_cb); uv::ll::close(stream_handle_ptr, tcp_socket_dtor_close_cb);
}; };
comm::recv(closed_po); comm::recv(closed_po);
log(debug, #fmt("about to free socket_data at %?", socket_data)); log(debug, fmt!{"about to free socket_data at %?", socket_data});
rustrt::rust_uv_current_kernel_free(stream_handle_ptr rustrt::rust_uv_current_kernel_free(stream_handle_ptr
as *libc::c_void); as *libc::c_void);
log(debug, ~"exiting dtor for tcp_socket"); log(debug, ~"exiting dtor for tcp_socket");
@ -946,7 +946,7 @@ fn read_start_common_impl(socket_data: *tcp_socket_data)
let start_ch = comm::chan(start_po); let start_ch = comm::chan(start_po);
log(debug, ~"in tcp::read_start before interact loop"); log(debug, ~"in tcp::read_start before interact loop");
do iotask::interact((*socket_data).iotask) |loop_ptr| { do iotask::interact((*socket_data).iotask) |loop_ptr| {
log(debug, #fmt("in tcp::read_start interact cb %?", loop_ptr)); log(debug, fmt!{"in tcp::read_start interact cb %?", loop_ptr});
alt uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t, alt uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t,
on_alloc_cb, on_alloc_cb,
on_tcp_read_cb) { on_tcp_read_cb) {
@ -990,7 +990,7 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data,
}; };
let write_data_ptr = ptr::addr_of(write_data); let write_data_ptr = ptr::addr_of(write_data);
do iotask::interact((*socket_data_ptr).iotask) |loop_ptr| { do iotask::interact((*socket_data_ptr).iotask) |loop_ptr| {
log(debug, #fmt("in interact cb for tcp::write %?", loop_ptr)); log(debug, fmt!{"in interact cb for tcp::write %?", loop_ptr});
alt uv::ll::write(write_req_ptr, alt uv::ll::write(write_req_ptr,
stream_handle_ptr, stream_handle_ptr,
write_buf_vec_ptr, write_buf_vec_ptr,
@ -1096,8 +1096,8 @@ impl of to_tcp_err_iface for uv::ll::uv_err_data {
extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t, extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t,
nread: libc::ssize_t, nread: libc::ssize_t,
++buf: uv::ll::uv_buf_t) unsafe { ++buf: uv::ll::uv_buf_t) unsafe {
log(debug, #fmt("entering on_tcp_read_cb stream: %? nread: %?", log(debug, fmt!{"entering on_tcp_read_cb stream: %? nread: %?",
stream, nread)); stream, nread});
let loop_ptr = uv::ll::get_loop_for_uv_handle(stream); let loop_ptr = uv::ll::get_loop_for_uv_handle(stream);
let socket_data_ptr = uv::ll::get_data_for_uv_handle(stream) let socket_data_ptr = uv::ll::get_data_for_uv_handle(stream)
as *tcp_socket_data; as *tcp_socket_data;
@ -1105,8 +1105,8 @@ extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t,
// incoming err.. probably eof // incoming err.. probably eof
-1 { -1 {
let err_data = uv::ll::get_last_err_data(loop_ptr).to_tcp_err(); let err_data = uv::ll::get_last_err_data(loop_ptr).to_tcp_err();
log(debug, #fmt("on_tcp_read_cb: incoming err.. name %? msg %?", log(debug, fmt!{"on_tcp_read_cb: incoming err.. name %? msg %?",
err_data.err_name, err_data.err_msg)); err_data.err_name, err_data.err_msg});
let reader_ch = (*socket_data_ptr).reader_ch; let reader_ch = (*socket_data_ptr).reader_ch;
comm::send(reader_ch, result::err(err_data)); comm::send(reader_ch, result::err(err_data));
} }
@ -1115,7 +1115,7 @@ extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t,
// have data // have data
_ { _ {
// we have data // we have data
log(debug, #fmt("tcp on_read_cb nread: %d", nread as int)); log(debug, fmt!{"tcp on_read_cb nread: %d", nread as int});
let reader_ch = (*socket_data_ptr).reader_ch; let reader_ch = (*socket_data_ptr).reader_ch;
let buf_base = uv::ll::get_base_from_buf(buf); let buf_base = uv::ll::get_base_from_buf(buf);
let new_bytes = vec::unsafe::from_buf(buf_base, nread as uint); let new_bytes = vec::unsafe::from_buf(buf_base, nread as uint);
@ -1131,10 +1131,10 @@ extern fn on_alloc_cb(handle: *libc::c_void,
-> uv::ll::uv_buf_t unsafe { -> uv::ll::uv_buf_t unsafe {
log(debug, ~"tcp read on_alloc_cb!"); log(debug, ~"tcp read on_alloc_cb!");
let char_ptr = uv::ll::malloc_buf_base_of(suggested_size); let char_ptr = uv::ll::malloc_buf_base_of(suggested_size);
log(debug, #fmt("tcp read on_alloc_cb h: %? char_ptr: %u sugsize: %u", log(debug, fmt!{"tcp read on_alloc_cb h: %? char_ptr: %u sugsize: %u",
handle, handle,
char_ptr as uint, char_ptr as uint,
suggested_size as uint)); suggested_size as uint});
uv::ll::buf_init(char_ptr, suggested_size as uint) uv::ll::buf_init(char_ptr, suggested_size as uint)
} }
@ -1180,11 +1180,11 @@ extern fn stream_error_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
let data = uv::ll::get_data_for_uv_handle(handle) as let data = uv::ll::get_data_for_uv_handle(handle) as
*connect_req_data; *connect_req_data;
comm::send((*data).closed_signal_ch, ()); comm::send((*data).closed_signal_ch, ());
log(debug, #fmt("exiting steam_error_close_cb for %?", handle)); log(debug, fmt!{"exiting steam_error_close_cb for %?", handle});
} }
extern fn tcp_connect_close_cb(handle: *uv::ll::uv_tcp_t) unsafe { extern fn tcp_connect_close_cb(handle: *uv::ll::uv_tcp_t) unsafe {
log(debug, #fmt("closed client tcp handle %?", handle)); log(debug, fmt!{"closed client tcp handle %?", handle});
} }
extern fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t, extern fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t,
@ -1192,7 +1192,7 @@ extern fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t,
let conn_data_ptr = (uv::ll::get_data_for_req(connect_req_ptr) let conn_data_ptr = (uv::ll::get_data_for_req(connect_req_ptr)
as *connect_req_data); as *connect_req_data);
let result_ch = (*conn_data_ptr).result_ch; let result_ch = (*conn_data_ptr).result_ch;
log(debug, #fmt("tcp_connect result_ch %?", result_ch)); log(debug, fmt!{"tcp_connect result_ch %?", result_ch});
let tcp_stream_ptr = let tcp_stream_ptr =
uv::ll::get_stream_handle_from_connect_req(connect_req_ptr); uv::ll::get_stream_handle_from_connect_req(connect_req_ptr);
alt status { alt status {
@ -1204,8 +1204,8 @@ extern fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t,
log(debug, ~"error in tcp_connect_on_connect_cb"); log(debug, ~"error in tcp_connect_on_connect_cb");
let loop_ptr = uv::ll::get_loop_for_uv_handle(tcp_stream_ptr); let loop_ptr = uv::ll::get_loop_for_uv_handle(tcp_stream_ptr);
let err_data = uv::ll::get_last_err_data(loop_ptr); let err_data = uv::ll::get_last_err_data(loop_ptr);
log(debug, #fmt("err_data %? %?", err_data.err_name, log(debug, fmt!{"err_data %? %?", err_data.err_name,
err_data.err_msg)); err_data.err_msg});
comm::send(result_ch, conn_failure(err_data)); comm::send(result_ch, conn_failure(err_data));
uv::ll::set_data_for_uv_handle(tcp_stream_ptr, uv::ll::set_data_for_uv_handle(tcp_stream_ptr,
conn_data_ptr); conn_data_ptr);
@ -1334,10 +1334,10 @@ mod test {
assert actual_resp_result.is_ok(); assert actual_resp_result.is_ok();
let actual_resp = actual_resp_result.get(); let actual_resp = actual_resp_result.get();
let actual_req = comm::recv(server_result_po); let actual_req = comm::recv(server_result_po);
log(debug, #fmt("REQ: expected: '%s' actual: '%s'", log(debug, fmt!{"REQ: expected: '%s' actual: '%s'",
expected_req, actual_req)); expected_req, actual_req});
log(debug, #fmt("RESP: expected: '%s' actual: '%s'", log(debug, fmt!{"RESP: expected: '%s' actual: '%s'",
expected_resp, actual_resp)); expected_resp, actual_resp});
assert str::contains(actual_req, expected_req); assert str::contains(actual_req, expected_req);
assert str::contains(actual_resp, expected_resp); assert str::contains(actual_resp, expected_resp);
} }
@ -1476,27 +1476,27 @@ mod test {
}; };
let actual_req = comm::recv(server_result_po); let actual_req = comm::recv(server_result_po);
log(debug, #fmt("REQ: expected: '%s' actual: '%s'", log(debug, fmt!{"REQ: expected: '%s' actual: '%s'",
expected_req, actual_req)); expected_req, actual_req});
log(debug, #fmt("RESP: expected: '%s' actual: '%s'", log(debug, fmt!{"RESP: expected: '%s' actual: '%s'",
expected_resp, actual_resp)); expected_resp, actual_resp});
assert str::contains(actual_req, expected_req); assert str::contains(actual_req, expected_req);
assert str::contains(actual_resp, expected_resp); assert str::contains(actual_resp, expected_resp);
} }
fn buf_write(+w: io::writer, val: ~str) { fn buf_write(+w: io::writer, val: ~str) {
log(debug, #fmt("BUF_WRITE: val len %?", str::len(val))); log(debug, fmt!{"BUF_WRITE: val len %?", str::len(val)});
do str::byte_slice(val) |b_slice| { do str::byte_slice(val) |b_slice| {
log(debug, #fmt("BUF_WRITE: b_slice len %?", log(debug, fmt!{"BUF_WRITE: b_slice len %?",
vec::len(b_slice))); vec::len(b_slice)});
w.write(b_slice) w.write(b_slice)
} }
} }
fn buf_read(+r: io::reader, len: uint) -> ~str { fn buf_read(+r: io::reader, len: uint) -> ~str {
let new_bytes = r.read_bytes(len); let new_bytes = r.read_bytes(len);
log(debug, #fmt("in buf_read.. new_bytes len: %?", log(debug, fmt!{"in buf_read.. new_bytes len: %?",
vec::len(new_bytes))); vec::len(new_bytes)});
str::from_bytes(new_bytes) str::from_bytes(new_bytes)
} }
@ -1508,8 +1508,8 @@ mod test {
let listen_result = listen(server_ip_addr, server_port, 128u, iotask, let listen_result = listen(server_ip_addr, server_port, 128u, iotask,
// on_establish_cb -- called when listener is set up // on_establish_cb -- called when listener is set up
|kill_ch| { |kill_ch| {
log(debug, #fmt("establish_cb %?", log(debug, fmt!{"establish_cb %?",
kill_ch)); kill_ch});
comm::send(cont_ch, ()); comm::send(cont_ch, ());
}, },
// risky to run this on the loop, but some users // risky to run this on the loop, but some users
@ -1541,8 +1541,8 @@ mod test {
alt received_req_bytes { alt received_req_bytes {
result::ok(data) { result::ok(data) {
log(debug, ~"SERVER: got REQ str::from_bytes.."); log(debug, ~"SERVER: got REQ str::from_bytes..");
log(debug, #fmt("SERVER: REQ data len: %?", log(debug, fmt!{"SERVER: REQ data len: %?",
vec::len(data))); vec::len(data)});
server_ch.send( server_ch.send(
str::from_bytes(data)); str::from_bytes(data));
log(debug, ~"SERVER: before write"); log(debug, ~"SERVER: before write");
@ -1551,8 +1551,8 @@ mod test {
comm::send(kill_ch, none); comm::send(kill_ch, none);
} }
result::err(err_data) { result::err(err_data) {
log(debug, #fmt("SERVER: error recvd: %s %s", log(debug, fmt!{"SERVER: error recvd: %s %s",
err_data.err_name, err_data.err_msg)); err_data.err_name, err_data.err_msg});
comm::send(kill_ch, some(err_data)); comm::send(kill_ch, some(err_data));
server_ch.send(~""); server_ch.send(~"");
} }
@ -1569,8 +1569,8 @@ mod test {
if result::is_err(listen_result) { if result::is_err(listen_result) {
alt result::get_err(listen_result) { alt result::get_err(listen_result) {
generic_listen_err(name, msg) { generic_listen_err(name, msg) {
fail #fmt("SERVER: exited abnormally name %s msg %s", fail fmt!{"SERVER: exited abnormally name %s msg %s",
name, msg); name, msg};
} }
access_denied { access_denied {
fail ~"SERVER: exited abnormally, got access denied.."; fail ~"SERVER: exited abnormally, got access denied..";
@ -1581,7 +1581,7 @@ mod test {
} }
} }
let ret_val = server_ch.recv(); let ret_val = server_ch.recv();
log(debug, #fmt("SERVER: exited and got ret val: '%s'", ret_val)); log(debug, fmt!{"SERVER: exited and got ret val: '%s'", ret_val});
ret_val ret_val
} }
@ -1591,12 +1591,12 @@ mod test {
let listen_result = listen(server_ip_addr, server_port, 128u, iotask, let listen_result = listen(server_ip_addr, server_port, 128u, iotask,
// on_establish_cb -- called when listener is set up // on_establish_cb -- called when listener is set up
|kill_ch| { |kill_ch| {
log(debug, #fmt("establish_cb %?", log(debug, fmt!{"establish_cb %?",
kill_ch)); kill_ch});
}, },
|new_conn, kill_ch| { |new_conn, kill_ch| {
fail #fmt("SERVER: shouldn't be called.. %? %?", fail fmt!{"SERVER: shouldn't be called.. %? %?",
new_conn, kill_ch); new_conn, kill_ch};
}); });
// err check on listen_result // err check on listen_result
if result::is_err(listen_result) { if result::is_err(listen_result) {
@ -1632,8 +1632,8 @@ mod test {
else { else {
client_ch.send(str::from_bytes(read_result.get())); client_ch.send(str::from_bytes(read_result.get()));
let ret_val = client_ch.recv(); let ret_val = client_ch.recv();
log(debug, #fmt("CLIENT: after client_ch recv ret: '%s'", log(debug, fmt!{"CLIENT: after client_ch recv ret: '%s'",
ret_val)); ret_val});
ok(ret_val) ok(ret_val)
} }
} }
@ -1645,8 +1645,8 @@ mod test {
if result::is_err(write_result) { if result::is_err(write_result) {
log(debug, ~"tcp_write_single: write failed!"); log(debug, ~"tcp_write_single: write failed!");
let err_data = result::get_err(write_result); let err_data = result::get_err(write_result);
log(debug, #fmt("tcp_write_single err name: %s msg: %s", log(debug, fmt!{"tcp_write_single err name: %s msg: %s",
err_data.err_name, err_data.err_msg)); err_data.err_name, err_data.err_msg});
// meh. torn on what to do here. // meh. torn on what to do here.
fail ~"tcp_write_single failed"; fail ~"tcp_write_single failed";
} }

View file

@ -72,7 +72,7 @@ fn query_to_str(query: query) -> ~str {
let mut strvec = ~[]; let mut strvec = ~[];
for query.each |kv| { for query.each |kv| {
let (k, v) = kv; let (k, v) = kv;
strvec += ~[#fmt("%s=%s", k, v)]; strvec += ~[fmt!{"%s=%s", k, v}];
}; };
ret str::connect(strvec, ~"&"); ret str::connect(strvec, ~"&");
} }

View file

@ -53,11 +53,11 @@ fn map_slices<A: copy send, B: copy send>(
let len = end - base; let len = end - base;
let slice = (ptr::offset(p, base), let slice = (ptr::offset(p, base),
len * sys::size_of::<A>()); len * sys::size_of::<A>());
log(info, #fmt("pre-slice: %?", (base, slice))); log(info, fmt!{"pre-slice: %?", (base, slice)});
let slice : &[A] = let slice : &[A] =
unsafe::reinterpret_cast(slice); unsafe::reinterpret_cast(slice);
log(info, #fmt("slice: %?", log(info, fmt!{"slice: %?",
(base, vec::len(slice), end - base))); (base, vec::len(slice), end - base)});
assert(vec::len(slice) == end - base); assert(vec::len(slice) == end - base);
f(base, slice) f(base, slice)
} }
@ -68,7 +68,7 @@ fn map_slices<A: copy send, B: copy send>(
} }
log(info, ~"tasks spawned"); log(info, ~"tasks spawned");
log(info, #fmt("num_tasks: %?", (num_tasks, futures.len()))); log(info, fmt!{"num_tasks: %?", (num_tasks, futures.len())});
assert(num_tasks == futures.len()); assert(num_tasks == futures.len());
let r = do futures.map() |ys| { let r = do futures.map() |ys| {

View file

@ -8,63 +8,63 @@ impl of serializer for writer {
} }
fn emit_uint(v: uint) { fn emit_uint(v: uint) {
self.write_str(#fmt["%?u", v]); self.write_str(fmt!{"%?u", v});
} }
fn emit_u64(v: u64) { fn emit_u64(v: u64) {
self.write_str(#fmt["%?_u64", v]); self.write_str(fmt!{"%?_u64", v});
} }
fn emit_u32(v: u32) { fn emit_u32(v: u32) {
self.write_str(#fmt["%?_u32", v]); self.write_str(fmt!{"%?_u32", v});
} }
fn emit_u16(v: u16) { fn emit_u16(v: u16) {
self.write_str(#fmt["%?_u16", v]); self.write_str(fmt!{"%?_u16", v});
} }
fn emit_u8(v: u8) { fn emit_u8(v: u8) {
self.write_str(#fmt["%?_u8", v]); self.write_str(fmt!{"%?_u8", v});
} }
fn emit_int(v: int) { fn emit_int(v: int) {
self.write_str(#fmt["%?", v]); self.write_str(fmt!{"%?", v});
} }
fn emit_i64(v: i64) { fn emit_i64(v: i64) {
self.write_str(#fmt["%?_i64", v]); self.write_str(fmt!{"%?_i64", v});
} }
fn emit_i32(v: i32) { fn emit_i32(v: i32) {
self.write_str(#fmt["%?_i32", v]); self.write_str(fmt!{"%?_i32", v});
} }
fn emit_i16(v: i16) { fn emit_i16(v: i16) {
self.write_str(#fmt["%?_i16", v]); self.write_str(fmt!{"%?_i16", v});
} }
fn emit_i8(v: i8) { fn emit_i8(v: i8) {
self.write_str(#fmt["%?_i8", v]); self.write_str(fmt!{"%?_i8", v});
} }
fn emit_bool(v: bool) { fn emit_bool(v: bool) {
self.write_str(#fmt["%b", v]); self.write_str(fmt!{"%b", v});
} }
fn emit_float(v: float) { fn emit_float(v: float) {
self.write_str(#fmt["%?_f", v]); self.write_str(fmt!{"%?_f", v});
} }
fn emit_f64(v: f64) { fn emit_f64(v: f64) {
self.write_str(#fmt["%?_f64", v]); self.write_str(fmt!{"%?_f64", v});
} }
fn emit_f32(v: f32) { fn emit_f32(v: f32) {
self.write_str(#fmt["%?_f32", v]); self.write_str(fmt!{"%?_f32", v});
} }
fn emit_str(v: ~str) { fn emit_str(v: ~str) {
self.write_str(#fmt["%?", v]); self.write_str(fmt!{"%?", v});
} }
fn emit_enum(_name: ~str, f: fn()) { fn emit_enum(_name: ~str, f: fn()) {

View file

@ -27,7 +27,7 @@ fn mk<T: copy>() -> smallintmap<T> {
*/ */
#[inline(always)] #[inline(always)]
fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) { fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) {
//io::println(#fmt("%?", key)); //io::println(fmt!{"%?", key});
self.v.grow_set_elt(key, none, some(val)); self.v.grow_set_elt(key, none, some(val));
} }
@ -49,7 +49,7 @@ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> {
*/ */
pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T { pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T {
alt find(self, key) { alt find(self, key) {
none { #error("smallintmap::get(): key not present"); fail; } none { error!{"smallintmap::get(): key not present"}; fail; }
some(v) { ret v; } some(v) { ret v; }
} }
} }

View file

@ -253,7 +253,7 @@ mod test_qsort {
let pairs = vec::zip(expected, immut_names); let pairs = vec::zip(expected, immut_names);
for vec::each(pairs) |p| { for vec::each(pairs) |p| {
let (a, b) = p; let (a, b) = p;
#debug("%d %d", a, b); debug!{"%d %d", a, b};
assert (a == b); assert (a == b);
} }
} }

View file

@ -109,9 +109,9 @@ fn run_tests_console(opts: test_opts,
te_filtered(filtered_tests) { te_filtered(filtered_tests) {
st.total = vec::len(filtered_tests); st.total = vec::len(filtered_tests);
let noun = if st.total != 1u { ~"tests" } else { ~"test" }; let noun = if st.total != 1u { ~"tests" } else { ~"test" };
st.out.write_line(#fmt["\nrunning %u %s", st.total, noun]); st.out.write_line(fmt!{"\nrunning %u %s", st.total, noun});
} }
te_wait(test) { st.out.write_str(#fmt["test %s ... ", test.name]); } te_wait(test) { st.out.write_str(fmt!{"test %s ... ", test.name}); }
te_result(test, result) { te_result(test, result) {
alt st.log_out { alt st.log_out {
some(f) { some(f) {
@ -146,7 +146,7 @@ fn run_tests_console(opts: test_opts,
alt io::file_writer(path, ~[io::create, io::truncate]) { alt io::file_writer(path, ~[io::create, io::truncate]) {
result::ok(w) { some(w) } result::ok(w) { some(w) }
result::err(s) { result::err(s) {
fail(#fmt("can't open output file: %s", s)) fail(fmt!{"can't open output file: %s", s})
} }
} }
} }
@ -172,23 +172,23 @@ fn run_tests_console(opts: test_opts,
print_failures(st); print_failures(st);
} }
st.out.write_str(#fmt["\nresult: "]); st.out.write_str(fmt!{"\nresult: "});
if success { if success {
// There's no parallelism at this point so it's safe to use color // There's no parallelism at this point so it's safe to use color
write_ok(st.out, true); write_ok(st.out, true);
} else { write_failed(st.out, true); } } else { write_failed(st.out, true); }
st.out.write_str(#fmt[". %u passed; %u failed; %u ignored\n\n", st.passed, st.out.write_str(fmt!{". %u passed; %u failed; %u ignored\n\n", st.passed,
st.failed, st.ignored]); st.failed, st.ignored});
ret success; ret success;
fn write_log(out: io::writer, result: test_result, test: test_desc) { fn write_log(out: io::writer, result: test_result, test: test_desc) {
out.write_line(#fmt("%s %s", out.write_line(fmt!{"%s %s",
alt result { alt result {
tr_ok { ~"ok" } tr_ok { ~"ok" }
tr_failed { ~"failed" } tr_failed { ~"failed" }
tr_ignored { ~"ignored" } tr_ignored { ~"ignored" }
}, test.name)); }, test.name});
} }
fn write_ok(out: io::writer, use_color: bool) { fn write_ok(out: io::writer, use_color: bool) {
@ -220,7 +220,7 @@ fn print_failures(st: console_test_state) {
let failures = vec::map(failures, |test| test.name); let failures = vec::map(failures, |test| test.name);
let failures = sort::merge_sort(str::le, failures); let failures = sort::merge_sort(str::le, failures);
for vec::each(failures) |name| { for vec::each(failures) |name| {
st.out.write_line(#fmt[" %s", name]); st.out.write_line(fmt!{" %s", name});
} }
} }
@ -281,7 +281,7 @@ fn run_tests(opts: test_opts, tests: ~[test_desc],
// It's tempting to just spawn all the tests at once, but since we have // It's tempting to just spawn all the tests at once, but since we have
// many tests that run in other processes we would be making a big mess. // many tests that run in other processes we would be making a big mess.
let concurrency = get_concurrency(); let concurrency = get_concurrency();
#debug("using %u test tasks", concurrency); debug!{"using %u test tasks", concurrency};
let total = vec::len(filtered_tests); let total = vec::len(filtered_tests);
let mut run_idx = 0u; let mut run_idx = 0u;

View file

@ -200,9 +200,9 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
if c == ch { if c == ch {
ok(next) ok(next)
} else { } else {
err(#fmt("Expected %?, found %?", err(fmt!{"Expected %?, found %?",
str::from_char(c), str::from_char(c),
str::from_char(ch))) str::from_char(ch)})
} }
} }
@ -525,7 +525,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
} }
'%' { parse_char(s, pos, '%') } '%' { parse_char(s, pos, '%') }
ch { ch {
err(#fmt("unknown formatting type: %?", str::from_char(ch))) err(fmt!{"unknown formatting type: %?", str::from_char(ch)})
} }
} }
} }
@ -643,70 +643,70 @@ fn strftime(format: ~str, tm: tm) -> ~str {
11 { ~"Dec" } 11 { ~"Dec" }
} }
} }
'C' { #fmt("%02d", (tm.tm_year as int + 1900) / 100) } 'C' { fmt!{"%02d", (tm.tm_year as int + 1900) / 100} }
'c' { 'c' {
#fmt("%s %s %s %s %s", fmt!{"%s %s %s %s %s",
parse_type('a', tm), parse_type('a', tm),
parse_type('b', tm), parse_type('b', tm),
parse_type('e', tm), parse_type('e', tm),
parse_type('T', tm), parse_type('T', tm),
parse_type('Y', tm)) parse_type('Y', tm)}
} }
'D' | 'x' { 'D' | 'x' {
#fmt("%s/%s/%s", fmt!{"%s/%s/%s",
parse_type('m', tm), parse_type('m', tm),
parse_type('d', tm), parse_type('d', tm),
parse_type('y', tm)) parse_type('y', tm)}
} }
'd' { #fmt("%02d", tm.tm_mday as int) } 'd' { fmt!{"%02d", tm.tm_mday as int} }
'e' { #fmt("%2d", tm.tm_mday as int) } 'e' { fmt!{"%2d", tm.tm_mday as int} }
'F' { 'F' {
#fmt("%s-%s-%s", fmt!{"%s-%s-%s",
parse_type('Y', tm), parse_type('Y', tm),
parse_type('m', tm), parse_type('m', tm),
parse_type('d', tm)) parse_type('d', tm)}
} }
//'G' {} //'G' {}
//'g' {} //'g' {}
'H' { #fmt("%02d", tm.tm_hour as int) } 'H' { fmt!{"%02d", tm.tm_hour as int} }
'I' { 'I' {
let mut h = tm.tm_hour as int; let mut h = tm.tm_hour as int;
if h == 0 { h = 12 } if h == 0 { h = 12 }
if h > 12 { h -= 12 } if h > 12 { h -= 12 }
#fmt("%02d", h) fmt!{"%02d", h}
} }
'j' { #fmt("%03d", tm.tm_yday as int + 1) } 'j' { fmt!{"%03d", tm.tm_yday as int + 1} }
'k' { #fmt("%2d", tm.tm_hour as int) } 'k' { fmt!{"%2d", tm.tm_hour as int} }
'l' { 'l' {
let mut h = tm.tm_hour as int; let mut h = tm.tm_hour as int;
if h == 0 { h = 12 } if h == 0 { h = 12 }
if h > 12 { h -= 12 } if h > 12 { h -= 12 }
#fmt("%2d", h) fmt!{"%2d", h}
} }
'M' { #fmt("%02d", tm.tm_min as int) } 'M' { fmt!{"%02d", tm.tm_min as int} }
'm' { #fmt("%02d", tm.tm_mon as int + 1) } 'm' { fmt!{"%02d", tm.tm_mon as int + 1} }
'n' { ~"\n" } 'n' { ~"\n" }
'P' { if tm.tm_hour as int < 12 { ~"am" } else { ~"pm" } } 'P' { if tm.tm_hour as int < 12 { ~"am" } else { ~"pm" } }
'p' { if tm.tm_hour as int < 12 { ~"AM" } else { ~"PM" } } 'p' { if tm.tm_hour as int < 12 { ~"AM" } else { ~"PM" } }
'R' { 'R' {
#fmt("%s:%s", fmt!{"%s:%s",
parse_type('H', tm), parse_type('H', tm),
parse_type('M', tm)) parse_type('M', tm)}
} }
'r' { 'r' {
#fmt("%s:%s:%s %s", fmt!{"%s:%s:%s %s",
parse_type('I', tm), parse_type('I', tm),
parse_type('M', tm), parse_type('M', tm),
parse_type('S', tm), parse_type('S', tm),
parse_type('p', tm)) parse_type('p', tm)}
} }
'S' { #fmt("%02d", tm.tm_sec as int) } 'S' { fmt!{"%02d", tm.tm_sec as int} }
's' { #fmt("%d", tm.to_timespec().sec as int) } 's' { fmt!{"%d", tm.to_timespec().sec as int} }
'T' | 'X' { 'T' | 'X' {
#fmt("%s:%s:%s", fmt!{"%s:%s:%s",
parse_type('H', tm), parse_type('H', tm),
parse_type('M', tm), parse_type('M', tm),
parse_type('S', tm)) parse_type('S', tm)}
} }
't' { ~"\t" } 't' { ~"\t" }
//'U' {} //'U' {}
@ -716,24 +716,24 @@ fn strftime(format: ~str, tm: tm) -> ~str {
} }
//'V' {} //'V' {}
'v' { 'v' {
#fmt("%s-%s-%s", fmt!{"%s-%s-%s",
parse_type('e', tm), parse_type('e', tm),
parse_type('b', tm), parse_type('b', tm),
parse_type('Y', tm)) parse_type('Y', tm)}
} }
//'W' {} //'W' {}
'w' { int::str(tm.tm_wday as int) } 'w' { int::str(tm.tm_wday as int) }
//'X' {} //'X' {}
//'x' {} //'x' {}
'Y' { int::str(tm.tm_year as int + 1900) } 'Y' { int::str(tm.tm_year as int + 1900) }
'y' { #fmt("%02d", (tm.tm_year as int + 1900) % 100) } 'y' { fmt!{"%02d", (tm.tm_year as int + 1900) % 100} }
'Z' { tm.tm_zone } 'Z' { tm.tm_zone }
'z' { 'z' {
let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' }; let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
let mut m = i32::abs(tm.tm_gmtoff) / 60_i32; let mut m = i32::abs(tm.tm_gmtoff) / 60_i32;
let h = m / 60_i32; let h = m / 60_i32;
m -= h * 60_i32; m -= h * 60_i32;
#fmt("%c%02d%02d", sign, h as int, m as int) fmt!{"%c%02d%02d", sign, h as int, m as int}
} }
//'+' {} //'+' {}
'%' { ~"%" } '%' { ~"%" }
@ -824,7 +824,7 @@ impl tm for tm {
let mut m = i32::abs(self.tm_gmtoff) / 60_i32; let mut m = i32::abs(self.tm_gmtoff) / 60_i32;
let h = m / 60_i32; let h = m / 60_i32;
m -= h * 60_i32; m -= h * 60_i32;
s + #fmt("%c%02d:%02d", sign, h as int, m as int) s + fmt!{"%c%02d:%02d", sign, h as int, m as int}
} }
} }
} }
@ -905,7 +905,7 @@ mod tests {
let time = { sec: 1234567890_i64, nsec: 54321_i32 }; let time = { sec: 1234567890_i64, nsec: 54321_i32 };
let local = at(time); let local = at(time);
#error("time_at: %?", local); error!{"time_at: %?", local};
assert local.tm_sec == 30_i32; assert local.tm_sec == 30_i32;
assert local.tm_min == 31_i32; assert local.tm_min == 31_i32;
@ -1111,7 +1111,7 @@ mod tests {
let utc = at_utc(time); let utc = at_utc(time);
let local = at(time); let local = at(time);
#error("test_ctime: %? %?", utc.ctime(), local.ctime()); error!{"test_ctime: %? %?", utc.ctime(), local.ctime()};
assert utc.ctime() == ~"Fri Feb 13 23:31:30 2009"; assert utc.ctime() == ~"Fri Feb 13 23:31:30 2009";
assert local.ctime() == ~"Fri Feb 13 15:31:30 2009"; assert local.ctime() == ~"Fri Feb 13 15:31:30 2009";

View file

@ -106,8 +106,8 @@ fn recv_timeout<T: copy send>(iotask: iotask,
// FIXME: This could be written clearer (#2618) // FIXME: This could be written clearer (#2618)
either::either( either::either(
|left_val| { |left_val| {
log(debug, #fmt("recv_time .. left_val %?", log(debug, fmt!{"recv_time .. left_val %?",
left_val)); left_val});
none none
}, |right_val| { }, |right_val| {
some(right_val) some(right_val)
@ -118,7 +118,7 @@ fn recv_timeout<T: copy send>(iotask: iotask,
// INTERNAL API // INTERNAL API
extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t, extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t,
status: libc::c_int) unsafe { status: libc::c_int) unsafe {
log(debug, #fmt("delayed_send_cb handle %? status %?", handle, status)); log(debug, fmt!{"delayed_send_cb handle %? status %?", handle, status});
let timer_done_ch = let timer_done_ch =
*(uv::ll::get_data_for_uv_handle(handle) as *comm::chan<()>); *(uv::ll::get_data_for_uv_handle(handle) as *comm::chan<()>);
let stop_result = uv::ll::timer_stop(handle); let stop_result = uv::ll::timer_stop(handle);
@ -134,7 +134,7 @@ extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t,
} }
extern fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) unsafe { extern fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) unsafe {
log(debug, #fmt("delayed_send_close_cb handle %?", handle)); log(debug, fmt!{"delayed_send_close_cb handle %?", handle});
let timer_done_ch = let timer_done_ch =
*(uv::ll::get_data_for_uv_handle(handle) as *comm::chan<()>); *(uv::ll::get_data_for_uv_handle(handle) as *comm::chan<()>);
comm::send(timer_done_ch, ()); comm::send(timer_done_ch, ());

View file

@ -36,43 +36,43 @@ fn get_monitor_task_gl() -> iotask unsafe {
let monitor_loop_chan_ptr = rustrt::rust_uv_get_kernel_global_chan_ptr(); let monitor_loop_chan_ptr = rustrt::rust_uv_get_kernel_global_chan_ptr();
#debug("ENTERING global_loop::get() loop chan: %?", debug!{"ENTERING global_loop::get() loop chan: %?",
monitor_loop_chan_ptr); monitor_loop_chan_ptr};
let builder_fn = || { let builder_fn = || {
task::task().sched_mode(task::single_threaded).unlinked() task::task().sched_mode(task::single_threaded).unlinked()
}; };
#debug("before priv::chan_from_global_ptr"); debug!{"before priv::chan_from_global_ptr"};
type monchan = chan<iotask>; type monchan = chan<iotask>;
let monitor_ch = do chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr, let monitor_ch = do chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr,
builder_fn) |msg_po| { builder_fn) |msg_po| {
#debug("global monitor task starting"); debug!{"global monitor task starting"};
// As a weak task the runtime will notify us when to exit // As a weak task the runtime will notify us when to exit
do weaken_task() |weak_exit_po| { do weaken_task() |weak_exit_po| {
#debug("global monitor task is now weak"); debug!{"global monitor task is now weak"};
let hl_loop = spawn_loop(); let hl_loop = spawn_loop();
loop { loop {
#debug("in outer_loop..."); debug!{"in outer_loop..."};
alt select2(weak_exit_po, msg_po) { alt select2(weak_exit_po, msg_po) {
left(weak_exit) { left(weak_exit) {
// all normal tasks have ended, tell the // all normal tasks have ended, tell the
// libuv loop to tear_down, then exit // libuv loop to tear_down, then exit
#debug("weak_exit_po recv'd msg: %?", weak_exit); debug!{"weak_exit_po recv'd msg: %?", weak_exit};
iotask::exit(hl_loop); iotask::exit(hl_loop);
break; break;
} }
right(fetch_ch) { right(fetch_ch) {
#debug("hl_loop req recv'd: %?", fetch_ch); debug!{"hl_loop req recv'd: %?", fetch_ch};
fetch_ch.send(hl_loop); fetch_ch.send(hl_loop);
} }
} }
} }
#debug("global monitor task is leaving weakend state"); debug!{"global monitor task is leaving weakend state"};
}; };
#debug("global monitor task exiting"); debug!{"global monitor task exiting"};
}; };
// once we have a chan to the monitor loop, we ask it for // once we have a chan to the monitor loop, we ask it for
@ -89,14 +89,14 @@ fn spawn_loop() -> iotask unsafe {
// The I/O loop task also needs to be weak so it doesn't keep // The I/O loop task also needs to be weak so it doesn't keep
// the runtime alive // the runtime alive
do weaken_task |weak_exit_po| { do weaken_task |weak_exit_po| {
#debug("global libuv task is now weak %?", weak_exit_po); debug!{"global libuv task is now weak %?", weak_exit_po};
task_body(); task_body();
// We don't wait for the exit message on weak_exit_po // We don't wait for the exit message on weak_exit_po
// because the monitor task will tell the uv loop when to // because the monitor task will tell the uv loop when to
// exit // exit
#debug("global libuv task is leaving weakened state"); debug!{"global libuv task is leaving weakened state"};
} }
} }
}; };
@ -110,8 +110,8 @@ mod test {
timer_ptr as *libc::c_void) as *comm::chan<bool>; timer_ptr as *libc::c_void) as *comm::chan<bool>;
let exit_ch = *exit_ch_ptr; let exit_ch = *exit_ch_ptr;
comm::send(exit_ch, true); comm::send(exit_ch, true);
log(debug, #fmt("EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?", log(debug, fmt!{"EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?",
exit_ch_ptr)); exit_ch_ptr});
} }
extern fn simple_timer_cb(timer_ptr: *ll::uv_timer_t, extern fn simple_timer_cb(timer_ptr: *ll::uv_timer_t,
_status: libc::c_int) unsafe { _status: libc::c_int) unsafe {
@ -131,8 +131,8 @@ mod test {
let exit_po = comm::port::<bool>(); let exit_po = comm::port::<bool>();
let exit_ch = comm::chan(exit_po); let exit_ch = comm::chan(exit_po);
let exit_ch_ptr = ptr::addr_of(exit_ch); let exit_ch_ptr = ptr::addr_of(exit_ch);
log(debug, #fmt("EXIT_CH_PTR newly created exit_ch_ptr: %?", log(debug, fmt!{"EXIT_CH_PTR newly created exit_ch_ptr: %?",
exit_ch_ptr)); exit_ch_ptr});
let timer_handle = ll::timer_t(); let timer_handle = ll::timer_t();
let timer_ptr = ptr::addr_of(timer_handle); let timer_ptr = ptr::addr_of(timer_handle);
do iotask::interact(iotask) |loop_ptr| { do iotask::interact(iotask) |loop_ptr| {

View file

@ -29,9 +29,9 @@ fn spawn_iotask(-task: task::task_builder) -> iotask {
do listen |iotask_ch| { do listen |iotask_ch| {
do task.sched_mode(task::single_threaded).spawn { do task.sched_mode(task::single_threaded).spawn {
#debug("entering libuv task"); debug!{"entering libuv task"};
run_loop(iotask_ch); run_loop(iotask_ch);
#debug("libuv task exiting"); debug!{"libuv task exiting"};
}; };
iotask_ch.recv() iotask_ch.recv()
@ -136,8 +136,8 @@ fn send_msg(iotask: iotask,
extern fn wake_up_cb(async_handle: *ll::uv_async_t, extern fn wake_up_cb(async_handle: *ll::uv_async_t,
status: int) unsafe { status: int) unsafe {
log(debug, #fmt("wake_up_cb extern.. handle: %? status: %?", log(debug, fmt!{"wake_up_cb extern.. handle: %? status: %?",
async_handle, status)); async_handle, status});
let loop_ptr = ll::get_loop_for_uv_handle(async_handle); let loop_ptr = ll::get_loop_for_uv_handle(async_handle);
let data = ll::get_data_for_uv_handle(async_handle) as *iotask_loop_data; let data = ll::get_data_for_uv_handle(async_handle) as *iotask_loop_data;
@ -164,22 +164,22 @@ fn begin_teardown(data: *iotask_loop_data) unsafe {
extern fn tear_down_close_cb(handle: *ll::uv_async_t) unsafe { extern fn tear_down_close_cb(handle: *ll::uv_async_t) unsafe {
let loop_ptr = ll::get_loop_for_uv_handle(handle); let loop_ptr = ll::get_loop_for_uv_handle(handle);
let loop_refs = ll::loop_refcount(loop_ptr); let loop_refs = ll::loop_refcount(loop_ptr);
log(debug, #fmt("tear_down_close_cb called, closing handle at %? refs %?", log(debug, fmt!{"tear_down_close_cb called, closing handle at %? refs %?",
handle, loop_refs)); handle, loop_refs});
assert loop_refs == 1i32; assert loop_refs == 1i32;
} }
#[cfg(test)] #[cfg(test)]
mod test { mod test {
extern fn async_close_cb(handle: *ll::uv_async_t) unsafe { extern fn async_close_cb(handle: *ll::uv_async_t) unsafe {
log(debug, #fmt("async_close_cb handle %?", handle)); log(debug, fmt!{"async_close_cb handle %?", handle});
let exit_ch = (*(ll::get_data_for_uv_handle(handle) let exit_ch = (*(ll::get_data_for_uv_handle(handle)
as *ah_data)).exit_ch; as *ah_data)).exit_ch;
comm::send(exit_ch, ()); comm::send(exit_ch, ());
} }
extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int) extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int)
unsafe { unsafe {
log(debug, #fmt("async_handle_cb handle %? status %?",handle,status)); log(debug, fmt!{"async_handle_cb handle %? status %?",handle,status});
ll::close(handle, async_close_cb); ll::close(handle, async_close_cb);
} }
type ah_data = { type ah_data = {
@ -217,13 +217,13 @@ mod test {
} }
extern fn lifetime_handle_close(handle: *libc::c_void) unsafe { extern fn lifetime_handle_close(handle: *libc::c_void) unsafe {
log(debug, #fmt("lifetime_handle_close ptr %?", handle)); log(debug, fmt!{"lifetime_handle_close ptr %?", handle});
} }
extern fn lifetime_async_callback(handle: *libc::c_void, extern fn lifetime_async_callback(handle: *libc::c_void,
status: libc::c_int) { status: libc::c_int) {
log(debug, #fmt("lifetime_handle_close ptr %? status %?", log(debug, fmt!{"lifetime_handle_close ptr %? status %?",
handle, status)); handle, status});
} }
#[test] #[test]

View file

@ -705,8 +705,8 @@ unsafe fn tcp_connect(connect_ptr: *uv_connect_t,
addr_ptr: *sockaddr_in, addr_ptr: *sockaddr_in,
++after_connect_cb: *u8) ++after_connect_cb: *u8)
-> libc::c_int { -> libc::c_int {
log(debug, #fmt("b4 foreign tcp_connect--addr port: %u cb: %u", log(debug, fmt!{"b4 foreign tcp_connect--addr port: %u cb: %u",
(*addr_ptr).sin_port as uint, after_connect_cb as uint)); (*addr_ptr).sin_port as uint, after_connect_cb as uint});
ret rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr, ret rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr,
after_connect_cb, addr_ptr); after_connect_cb, addr_ptr);
} }
@ -786,10 +786,10 @@ unsafe fn async_send(async_handle: *uv_async_t) {
unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t {
let out_buf = { base: ptr::null(), len: 0 as libc::size_t }; let out_buf = { base: ptr::null(), len: 0 as libc::size_t };
let out_buf_ptr = ptr::addr_of(out_buf); let out_buf_ptr = ptr::addr_of(out_buf);
log(debug, #fmt("buf_init - input %u len %u out_buf: %u", log(debug, fmt!{"buf_init - input %u len %u out_buf: %u",
input as uint, input as uint,
len as uint, len as uint,
out_buf_ptr as uint)); out_buf_ptr as uint});
// yuck :/ // yuck :/
rustrt::rust_uv_buf_init(out_buf_ptr, input, len as size_t); rustrt::rust_uv_buf_init(out_buf_ptr, input, len as size_t);
//let result = rustrt::rust_uv_buf_init_2(input, len as size_t); //let result = rustrt::rust_uv_buf_init_2(input, len as size_t);
@ -797,9 +797,9 @@ unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t {
let res_base = get_base_from_buf(out_buf); let res_base = get_base_from_buf(out_buf);
let res_len = get_len_from_buf(out_buf); let res_len = get_len_from_buf(out_buf);
//let res_base = get_base_from_buf(result); //let res_base = get_base_from_buf(result);
log(debug, #fmt("buf_init - result %u len %u", log(debug, fmt!{"buf_init - result %u len %u",
res_base as uint, res_base as uint,
res_len as uint)); res_len as uint});
ret out_buf; ret out_buf;
//ret result; //ret result;
} }
@ -843,8 +843,8 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str {
0u8,0u8,0u8,0u8,0u8,0u8]; 0u8,0u8,0u8,0u8,0u8,0u8];
do vec::as_buf(dst) |dst_buf, size| { do vec::as_buf(dst) |dst_buf, size| {
let src_unsafe_ptr = src as *sockaddr_in6; let src_unsafe_ptr = src as *sockaddr_in6;
log(debug, #fmt("val of src *sockaddr_in6: %? sockaddr_in6: %?", log(debug, fmt!{"val of src *sockaddr_in6: %? sockaddr_in6: %?",
src_unsafe_ptr, src)); src_unsafe_ptr, src});
let result = rustrt::rust_uv_ip6_name(src_unsafe_ptr, let result = rustrt::rust_uv_ip6_name(src_unsafe_ptr,
dst_buf, size as libc::size_t); dst_buf, size as libc::size_t);
alt result { alt result {
@ -964,8 +964,8 @@ unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str {
let err_ptr = ptr::addr_of(err); let err_ptr = ptr::addr_of(err);
let err_name = str::unsafe::from_c_str(err_name(err_ptr)); let err_name = str::unsafe::from_c_str(err_name(err_ptr));
let err_msg = str::unsafe::from_c_str(strerror(err_ptr)); let err_msg = str::unsafe::from_c_str(strerror(err_ptr));
ret #fmt("LIBUV ERROR: name: %s msg: %s", ret fmt!{"LIBUV ERROR: name: %s msg: %s",
err_name, err_msg); err_name, err_msg};
} }
unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data { unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data {
@ -1015,8 +1015,8 @@ mod test {
}; };
extern fn after_close_cb(handle: *libc::c_void) { extern fn after_close_cb(handle: *libc::c_void) {
log(debug, #fmt("after uv_close! handle ptr: %?", log(debug, fmt!{"after uv_close! handle ptr: %?",
handle)); handle});
} }
extern fn on_alloc_cb(handle: *libc::c_void, extern fn on_alloc_cb(handle: *libc::c_void,
@ -1024,10 +1024,10 @@ mod test {
-> uv_buf_t unsafe { -> uv_buf_t unsafe {
log(debug, ~"on_alloc_cb!"); log(debug, ~"on_alloc_cb!");
let char_ptr = malloc_buf_base_of(suggested_size); let char_ptr = malloc_buf_base_of(suggested_size);
log(debug, #fmt("on_alloc_cb h: %? char_ptr: %u sugsize: %u", log(debug, fmt!{"on_alloc_cb h: %? char_ptr: %u sugsize: %u",
handle, handle,
char_ptr as uint, char_ptr as uint,
suggested_size as uint)); suggested_size as uint});
ret buf_init(char_ptr, suggested_size as uint); ret buf_init(char_ptr, suggested_size as uint);
} }
@ -1035,11 +1035,11 @@ mod test {
nread: libc::ssize_t, nread: libc::ssize_t,
++buf: uv_buf_t) unsafe { ++buf: uv_buf_t) unsafe {
let nread = nread as int; let nread = nread as int;
log(debug, #fmt("CLIENT entering on_read_cb nred: %d", log(debug, fmt!{"CLIENT entering on_read_cb nred: %d",
nread)); nread});
if (nread > 0) { if (nread > 0) {
// we have data // we have data
log(debug, #fmt("CLIENT read: data! nread: %d", nread)); log(debug, fmt!{"CLIENT read: data! nread: %d", nread});
read_stop(stream); read_stop(stream);
let client_data = let client_data =
get_data_for_uv_handle(stream as *libc::c_void) get_data_for_uv_handle(stream as *libc::c_void)
@ -1067,20 +1067,20 @@ mod test {
extern fn on_write_complete_cb(write_req: *uv_write_t, extern fn on_write_complete_cb(write_req: *uv_write_t,
status: libc::c_int) unsafe { status: libc::c_int) unsafe {
log(debug, #fmt("CLIENT beginning on_write_complete_cb status: %d", log(debug, fmt!{"CLIENT beginning on_write_complete_cb status: %d",
status as int)); status as int});
let stream = get_stream_handle_from_write_req(write_req); let stream = get_stream_handle_from_write_req(write_req);
log(debug, #fmt("CLIENT on_write_complete_cb: tcp:%d write_handle:%d", log(debug, fmt!{"CLIENT on_write_complete_cb: tcp:%d write_handle:%d",
stream as int, write_req as int)); stream as int, write_req as int});
let result = read_start(stream, on_alloc_cb, on_read_cb); let result = read_start(stream, on_alloc_cb, on_read_cb);
log(debug, #fmt("CLIENT ending on_write_complete_cb .. status: %d", log(debug, fmt!{"CLIENT ending on_write_complete_cb .. status: %d",
result as int)); result as int});
} }
extern fn on_connect_cb(connect_req_ptr: *uv_connect_t, extern fn on_connect_cb(connect_req_ptr: *uv_connect_t,
status: libc::c_int) unsafe { status: libc::c_int) unsafe {
log(debug, #fmt("beginning on_connect_cb .. status: %d", log(debug, fmt!{"beginning on_connect_cb .. status: %d",
status as int)); status as int});
let stream = let stream =
get_stream_handle_from_connect_req(connect_req_ptr); get_stream_handle_from_connect_req(connect_req_ptr);
if (status == 0i32) { if (status == 0i32) {
@ -1089,14 +1089,14 @@ mod test {
connect_req_ptr as *libc::c_void) connect_req_ptr as *libc::c_void)
as *request_wrapper; as *request_wrapper;
let write_handle = (*client_data).write_req; let write_handle = (*client_data).write_req;
log(debug, #fmt("on_connect_cb: tcp: %d write_hdl: %d", log(debug, fmt!{"on_connect_cb: tcp: %d write_hdl: %d",
stream as int, write_handle as int)); stream as int, write_handle as int});
let write_result = write(write_handle, let write_result = write(write_handle,
stream as *libc::c_void, stream as *libc::c_void,
(*client_data).req_buf, (*client_data).req_buf,
on_write_complete_cb); on_write_complete_cb);
log(debug, #fmt("on_connect_cb: write() status: %d", log(debug, fmt!{"on_connect_cb: write() status: %d",
write_result as int)); write_result as int});
} }
else { else {
let test_loop = get_loop_for_uv_handle( let test_loop = get_loop_for_uv_handle(
@ -1123,7 +1123,7 @@ mod test {
// data field in our uv_connect_t struct // data field in our uv_connect_t struct
let req_str_bytes = str::bytes(req_str); let req_str_bytes = str::bytes(req_str);
let req_msg_ptr: *u8 = vec::unsafe::to_ptr(req_str_bytes); let req_msg_ptr: *u8 = vec::unsafe::to_ptr(req_str_bytes);
log(debug, #fmt("req_msg ptr: %u", req_msg_ptr as uint)); log(debug, fmt!{"req_msg ptr: %u", req_msg_ptr as uint});
let req_msg = ~[ let req_msg = ~[
buf_init(req_msg_ptr, vec::len(req_str_bytes)) buf_init(req_msg_ptr, vec::len(req_str_bytes))
]; ];
@ -1131,9 +1131,9 @@ mod test {
// this to C.. // this to C..
let write_handle = write_t(); let write_handle = write_t();
let write_handle_ptr = ptr::addr_of(write_handle); let write_handle_ptr = ptr::addr_of(write_handle);
log(debug, #fmt("tcp req: tcp stream: %d write_handle: %d", log(debug, fmt!{"tcp req: tcp stream: %d write_handle: %d",
tcp_handle_ptr as int, tcp_handle_ptr as int,
write_handle_ptr as int)); write_handle_ptr as int});
let client_data = { writer_handle: write_handle_ptr, let client_data = { writer_handle: write_handle_ptr,
req_buf: ptr::addr_of(req_msg), req_buf: ptr::addr_of(req_msg),
read_chan: client_chan }; read_chan: client_chan };
@ -1147,12 +1147,12 @@ mod test {
let addr = ip4_addr(ip, port); let addr = ip4_addr(ip, port);
// FIXME ref #2064 // FIXME ref #2064
let addr_ptr = ptr::addr_of(addr); let addr_ptr = ptr::addr_of(addr);
log(debug, #fmt("after build addr in rust. port: %u", log(debug, fmt!{"after build addr in rust. port: %u",
addr.sin_port as uint)); addr.sin_port as uint});
// this should set up the connection request.. // this should set up the connection request..
log(debug, #fmt("b4 call tcp_connect connect cb: %u ", log(debug, fmt!{"b4 call tcp_connect connect cb: %u ",
on_connect_cb as uint)); on_connect_cb as uint});
let tcp_connect_result = tcp_connect( let tcp_connect_result = tcp_connect(
connect_req_ptr, tcp_handle_ptr, connect_req_ptr, tcp_handle_ptr,
addr_ptr, on_connect_cb); addr_ptr, on_connect_cb);
@ -1183,8 +1183,8 @@ mod test {
} }
extern fn server_after_close_cb(handle: *libc::c_void) unsafe { extern fn server_after_close_cb(handle: *libc::c_void) unsafe {
log(debug, #fmt("SERVER server stream closed, should exit.. h: %?", log(debug, fmt!{"SERVER server stream closed, should exit.. h: %?",
handle)); handle});
} }
extern fn client_stream_after_close_cb(handle: *libc::c_void) extern fn client_stream_after_close_cb(handle: *libc::c_void)
@ -1212,15 +1212,15 @@ mod test {
let nread = nread as int; let nread = nread as int;
if (nread > 0) { if (nread > 0) {
// we have data // we have data
log(debug, #fmt("SERVER read: data! nread: %d", nread)); log(debug, fmt!{"SERVER read: data! nread: %d", nread});
// pull out the contents of the write from the client // pull out the contents of the write from the client
let buf_base = get_base_from_buf(buf); let buf_base = get_base_from_buf(buf);
let buf_len = get_len_from_buf(buf) as uint; let buf_len = get_len_from_buf(buf) as uint;
log(debug, #fmt("SERVER buf base: %u, len: %u, nread: %d", log(debug, fmt!{"SERVER buf base: %u, len: %u, nread: %d",
buf_base as uint, buf_base as uint,
buf_len as uint, buf_len as uint,
nread)); nread});
let bytes = vec::unsafe::from_buf(buf_base, buf_len); let bytes = vec::unsafe::from_buf(buf_base, buf_len);
let request_str = str::from_bytes(bytes); let request_str = str::from_bytes(bytes);
@ -1240,8 +1240,8 @@ mod test {
client_stream_ptr as *libc::c_void, client_stream_ptr as *libc::c_void,
(*client_data).server_resp_buf, (*client_data).server_resp_buf,
after_server_resp_write); after_server_resp_write);
log(debug, #fmt("SERVER: resp write result: %d", log(debug, fmt!{"SERVER: resp write result: %d",
write_result as int)); write_result as int});
if (write_result != 0i32) { if (write_result != 0i32) {
log(debug, ~"bad result for server resp write()"); log(debug, ~"bad result for server resp write()");
log(debug, get_last_err_info( log(debug, get_last_err_info(
@ -1275,8 +1275,8 @@ mod test {
server_stream_ptr as *libc::c_void); server_stream_ptr as *libc::c_void);
if status != 0i32 { if status != 0i32 {
let err_msg = get_last_err_info(test_loop); let err_msg = get_last_err_info(test_loop);
log(debug, #fmt("server_connect_cb: non-zero status: %?", log(debug, fmt!{"server_connect_cb: non-zero status: %?",
err_msg)); err_msg});
ret; ret;
} }
let server_data = get_data_for_uv_handle( let server_data = get_data_for_uv_handle(
@ -1303,20 +1303,20 @@ mod test {
log(debug, ~"successful server read start"); log(debug, ~"successful server read start");
} }
else { else {
log(debug, #fmt("server_connection_cb: bad read:%d", log(debug, fmt!{"server_connection_cb: bad read:%d",
read_result as int)); read_result as int});
assert false; assert false;
} }
} }
else { else {
log(debug, #fmt("server_connection_cb: bad accept: %d", log(debug, fmt!{"server_connection_cb: bad accept: %d",
accept_result as int)); accept_result as int});
assert false; assert false;
} }
} }
else { else {
log(debug, #fmt("server_connection_cb: bad client init: %d", log(debug, fmt!{"server_connection_cb: bad client init: %d",
client_init_result as int)); client_init_result as int});
assert false; assert false;
} }
} }
@ -1335,8 +1335,8 @@ mod test {
}; };
extern fn async_close_cb(handle: *libc::c_void) { extern fn async_close_cb(handle: *libc::c_void) {
log(debug, #fmt("SERVER: closing async cb... h: %?", log(debug, fmt!{"SERVER: closing async cb... h: %?",
handle)); handle});
} }
extern fn continue_async_cb(async_handle: *uv_async_t, extern fn continue_async_cb(async_handle: *uv_async_t,
@ -1371,7 +1371,7 @@ mod test {
let resp_str_bytes = str::bytes(server_resp_msg); let resp_str_bytes = str::bytes(server_resp_msg);
let resp_msg_ptr: *u8 = vec::unsafe::to_ptr(resp_str_bytes); let resp_msg_ptr: *u8 = vec::unsafe::to_ptr(resp_str_bytes);
log(debug, #fmt("resp_msg ptr: %u", resp_msg_ptr as uint)); log(debug, fmt!{"resp_msg ptr: %u", resp_msg_ptr as uint});
let resp_msg = ~[ let resp_msg = ~[
buf_init(resp_msg_ptr, vec::len(resp_str_bytes)) buf_init(resp_msg_ptr, vec::len(resp_str_bytes))
]; ];
@ -1430,26 +1430,26 @@ mod test {
log(debug, ~"server uv::run() has returned"); log(debug, ~"server uv::run() has returned");
} }
else { else {
log(debug, #fmt("uv_async_init failure: %d", log(debug, fmt!{"uv_async_init failure: %d",
async_result as int)); async_result as int});
assert false; assert false;
} }
} }
else { else {
log(debug, #fmt("non-zero result on uv_listen: %d", log(debug, fmt!{"non-zero result on uv_listen: %d",
listen_result as int)); listen_result as int});
assert false; assert false;
} }
} }
else { else {
log(debug, #fmt("non-zero result on uv_tcp_bind: %d", log(debug, fmt!{"non-zero result on uv_tcp_bind: %d",
bind_result as int)); bind_result as int});
assert false; assert false;
} }
} }
else { else {
log(debug, #fmt("non-zero result on uv_tcp_init: %d", log(debug, fmt!{"non-zero result on uv_tcp_init: %d",
tcp_init_result as int)); tcp_init_result as int});
assert false; assert false;
} }
loop_delete(test_loop); loop_delete(test_loop);
@ -1526,8 +1526,8 @@ mod test {
fn test_uv_ll_struct_size_uv_tcp_t() { fn test_uv_ll_struct_size_uv_tcp_t() {
let foreign_handle_size = rustrt::rust_uv_helper_uv_tcp_t_size(); let foreign_handle_size = rustrt::rust_uv_helper_uv_tcp_t_size();
let rust_handle_size = sys::size_of::<uv_tcp_t>(); let rust_handle_size = sys::size_of::<uv_tcp_t>();
let output = #fmt("uv_tcp_t -- foreign: %u rust: %u", let output = fmt!{"uv_tcp_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1537,8 +1537,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_uv_connect_t_size(); rustrt::rust_uv_helper_uv_connect_t_size();
let rust_handle_size = sys::size_of::<uv_connect_t>(); let rust_handle_size = sys::size_of::<uv_connect_t>();
let output = #fmt("uv_connect_t -- foreign: %u rust: %u", let output = fmt!{"uv_connect_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1548,8 +1548,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_uv_buf_t_size(); rustrt::rust_uv_helper_uv_buf_t_size();
let rust_handle_size = sys::size_of::<uv_buf_t>(); let rust_handle_size = sys::size_of::<uv_buf_t>();
let output = #fmt("uv_buf_t -- foreign: %u rust: %u", let output = fmt!{"uv_buf_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1559,8 +1559,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_uv_write_t_size(); rustrt::rust_uv_helper_uv_write_t_size();
let rust_handle_size = sys::size_of::<uv_write_t>(); let rust_handle_size = sys::size_of::<uv_write_t>();
let output = #fmt("uv_write_t -- foreign: %u rust: %u", let output = fmt!{"uv_write_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1571,8 +1571,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_sockaddr_in_size(); rustrt::rust_uv_helper_sockaddr_in_size();
let rust_handle_size = sys::size_of::<sockaddr_in>(); let rust_handle_size = sys::size_of::<sockaddr_in>();
let output = #fmt("sockaddr_in -- foreign: %u rust: %u", let output = fmt!{"sockaddr_in -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1582,8 +1582,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_sockaddr_in6_size(); rustrt::rust_uv_helper_sockaddr_in6_size();
let rust_handle_size = sys::size_of::<sockaddr_in6>(); let rust_handle_size = sys::size_of::<sockaddr_in6>();
let output = #fmt("sockaddr_in6 -- foreign: %u rust: %u", let output = fmt!{"sockaddr_in6 -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
// FIXME #1645 .. rust appears to pad structs to the nearest byte..? // FIXME #1645 .. rust appears to pad structs to the nearest byte..?
// .. can't get the uv::ll::sockaddr_in6 to == 28 :/ // .. can't get the uv::ll::sockaddr_in6 to == 28 :/
@ -1597,8 +1597,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_addr_in_size(); rustrt::rust_uv_helper_addr_in_size();
let rust_handle_size = sys::size_of::<addr_in>(); let rust_handle_size = sys::size_of::<addr_in>();
let output = #fmt("addr_in -- foreign: %u rust: %u", let output = fmt!{"addr_in -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
// FIXME #1645 .. see note above about struct padding // FIXME #1645 .. see note above about struct padding
assert (4u+foreign_handle_size as uint) == rust_handle_size; assert (4u+foreign_handle_size as uint) == rust_handle_size;
@ -1610,8 +1610,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_uv_async_t_size(); rustrt::rust_uv_helper_uv_async_t_size();
let rust_handle_size = sys::size_of::<uv_async_t>(); let rust_handle_size = sys::size_of::<uv_async_t>();
let output = #fmt("uv_async_t -- foreign: %u rust: %u", let output = fmt!{"uv_async_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1622,8 +1622,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_uv_timer_t_size(); rustrt::rust_uv_helper_uv_timer_t_size();
let rust_handle_size = sys::size_of::<uv_timer_t>(); let rust_handle_size = sys::size_of::<uv_timer_t>();
let output = #fmt("uv_timer_t -- foreign: %u rust: %u", let output = fmt!{"uv_timer_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1635,8 +1635,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_uv_getaddrinfo_t_size(); rustrt::rust_uv_helper_uv_getaddrinfo_t_size();
let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>(); let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>();
let output = #fmt("uv_getaddrinfo_t -- foreign: %u rust: %u", let output = fmt!{"uv_getaddrinfo_t -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }
@ -1648,8 +1648,8 @@ mod test {
let foreign_handle_size = let foreign_handle_size =
rustrt::rust_uv_helper_addrinfo_size(); rustrt::rust_uv_helper_addrinfo_size();
let rust_handle_size = sys::size_of::<addrinfo>(); let rust_handle_size = sys::size_of::<addrinfo>();
let output = #fmt("addrinfo -- foreign: %u rust: %u", let output = fmt!{"addrinfo -- foreign: %u rust: %u",
foreign_handle_size as uint, rust_handle_size); foreign_handle_size as uint, rust_handle_size};
log(debug, output); log(debug, output);
assert foreign_handle_size as uint == rust_handle_size; assert foreign_handle_size as uint == rust_handle_size;
} }

View file

@ -24,7 +24,7 @@ fn path_ident_to_str(p: path, i: ident) -> ~str {
if vec::is_empty(p) { if vec::is_empty(p) {
/* FIXME (#2543) */ copy *i /* FIXME (#2543) */ copy *i
} else { } else {
#fmt["%s::%s", path_to_str(p), *i] fmt!{"%s::%s", path_to_str(p), *i}
} }
} }
@ -270,46 +270,46 @@ fn map_expr(ex: @expr, cx: ctx, v: vt) {
fn node_id_to_str(map: map, id: node_id) -> ~str { fn node_id_to_str(map: map, id: node_id) -> ~str {
alt map.find(id) { alt map.find(id) {
none { none {
#fmt["unknown node (id=%d)", id] fmt!{"unknown node (id=%d)", id}
} }
some(node_item(item, path)) { some(node_item(item, path)) {
#fmt["item %s (id=%?)", path_ident_to_str(*path, item.ident), id] fmt!{"item %s (id=%?)", path_ident_to_str(*path, item.ident), id}
} }
some(node_foreign_item(item, abi, path)) { some(node_foreign_item(item, abi, path)) {
#fmt["foreign item %s with abi %? (id=%?)", fmt!{"foreign item %s with abi %? (id=%?)",
path_ident_to_str(*path, item.ident), abi, id] path_ident_to_str(*path, item.ident), abi, id}
} }
some(node_method(m, impl_did, path)) { some(node_method(m, impl_did, path)) {
#fmt["method %s in %s (id=%?)", fmt!{"method %s in %s (id=%?)",
*m.ident, path_to_str(*path), id] *m.ident, path_to_str(*path), id}
} }
some(node_variant(variant, def_id, path)) { some(node_variant(variant, def_id, path)) {
#fmt["variant %s in %s (id=%?)", fmt!{"variant %s in %s (id=%?)",
*variant.node.name, path_to_str(*path), id] *variant.node.name, path_to_str(*path), id}
} }
some(node_expr(expr)) { some(node_expr(expr)) {
#fmt["expr %s (id=%?)", fmt!{"expr %s (id=%?)",
pprust::expr_to_str(expr), id] pprust::expr_to_str(expr), id}
} }
// FIXMEs are as per #2410 // FIXMEs are as per #2410
some(node_export(_, path)) { some(node_export(_, path)) {
#fmt["export %s (id=%?)", // add more info here fmt!{"export %s (id=%?)", // add more info here
path_to_str(*path), id] path_to_str(*path), id}
} }
some(node_arg(_, _)) { // add more info here some(node_arg(_, _)) { // add more info here
#fmt["arg (id=%?)", id] fmt!{"arg (id=%?)", id}
} }
some(node_local(_)) { // add more info here some(node_local(_)) { // add more info here
#fmt["local (id=%?)", id] fmt!{"local (id=%?)", id}
} }
some(node_ctor(*)) { // add more info here some(node_ctor(*)) { // add more info here
#fmt["node_ctor (id=%?)", id] fmt!{"node_ctor (id=%?)", id}
} }
some(node_dtor(*)) { // add more info here some(node_dtor(*)) { // add more info here
#fmt["node_dtor (id=%?)", id] fmt!{"node_dtor (id=%?)", id}
} }
some(node_block(_)) { some(node_block(_)) {
#fmt["block"] fmt!{"block"}
} }
} }
} }

View file

@ -197,12 +197,12 @@ fn find_meta_items_by_name(metas: ~[@ast::meta_item], +name: ~str) ->
* comparison is performed structurally. * comparison is performed structurally.
*/ */
fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool { fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool {
#debug("looking for %s", debug!{"looking for %s",
print::pprust::meta_item_to_str(*needle)); print::pprust::meta_item_to_str(*needle)};
for haystack.each |item| { for haystack.each |item| {
#debug("looking in %s", debug!{"looking in %s",
print::pprust::meta_item_to_str(*item)); print::pprust::meta_item_to_str(*item)};
if eq(item, needle) { #debug("found it!"); ret true; } if eq(item, needle) { debug!{"found it!"}; ret true; }
} }
#debug("found it not :("); #debug("found it not :(");
ret false; ret false;
@ -323,7 +323,7 @@ fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] {
for find_attrs_by_name(attrs, ~"link").each |attr| { for find_attrs_by_name(attrs, ~"link").each |attr| {
alt attr.node.value.node { alt attr.node.value.node {
ast::meta_list(_, _) { vec::push(found, attr) } ast::meta_list(_, _) { vec::push(found, attr) }
_ { #debug("ignoring link attribute that has incorrect type"); } _ { debug!{"ignoring link attribute that has incorrect type"}; }
} }
} }
ret found; ret found;
@ -399,7 +399,7 @@ fn require_unique_names(diagnostic: span_handler,
// FIXME: How do I silence the warnings? --pcw (#2619) // FIXME: How do I silence the warnings? --pcw (#2619)
if map.contains_key(*name) { if map.contains_key(*name) {
diagnostic.span_fatal(meta.span, diagnostic.span_fatal(meta.span,
#fmt["duplicate meta item `%s`", *name]); fmt!{"duplicate meta item `%s`", *name});
} }
map.insert(*name, ()); map.insert(*name, ());
} }

View file

@ -73,7 +73,7 @@ fn new_filemap(+filename: filename, src: @~str,
fn mk_substr_filename(cm: codemap, sp: span) -> ~str fn mk_substr_filename(cm: codemap, sp: span) -> ~str
{ {
let pos = lookup_char_pos(cm, sp.lo); let pos = lookup_char_pos(cm, sp.lo);
ret #fmt("<%s:%u:%u>", pos.file.name, pos.line, pos.col); ret fmt!{"<%s:%u:%u>", pos.file.name, pos.line, pos.col};
} }
fn next_line(file: filemap, chpos: uint, byte_pos: uint) { fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
@ -93,7 +93,7 @@ fn lookup_line(map: codemap, pos: uint, lookup: lookup_fn)
if lookup(map.files[m].start_pos) > pos { b = m; } else { a = m; } if lookup(map.files[m].start_pos) > pos { b = m; } else { a = m; }
} }
if (a >= len) { if (a >= len) {
fail #fmt("position %u does not resolve to a source location", pos) fail fmt!{"position %u does not resolve to a source location", pos}
} }
let f = map.files[a]; let f = map.files[a];
a = 0u; a = 0u;
@ -166,15 +166,15 @@ type span = {lo: uint, hi: uint, expn_info: expn_info};
fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str { fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str {
let lo = lookup_char_pos(cm, sp.lo); let lo = lookup_char_pos(cm, sp.lo);
let hi = lookup_char_pos(cm, sp.hi); let hi = lookup_char_pos(cm, sp.hi);
ret #fmt("%s:%u:%u: %u:%u", lo.file.name, ret fmt!{"%s:%u:%u: %u:%u", lo.file.name,
lo.line, lo.col, hi.line, hi.col) lo.line, lo.col, hi.line, hi.col}
} }
fn span_to_str(sp: span, cm: codemap) -> ~str { fn span_to_str(sp: span, cm: codemap) -> ~str {
let lo = lookup_char_pos_adj(cm, sp.lo); let lo = lookup_char_pos_adj(cm, sp.lo);
let hi = lookup_char_pos_adj(cm, sp.hi); let hi = lookup_char_pos_adj(cm, sp.hi);
ret #fmt("%s:%u:%u: %u:%u", lo.filename, ret fmt!{"%s:%u:%u: %u:%u", lo.filename,
lo.line, lo.col, hi.line, hi.col) lo.line, lo.col, hi.line, hi.col}
} }
type file_lines = {file: filemap, lines: ~[uint]}; type file_lines = {file: filemap, lines: ~[uint]};

View file

@ -90,8 +90,8 @@ impl codemap_handler of handler for handler_t {
alt self.err_count { alt self.err_count {
0u { ret; } 0u { ret; }
1u { s = ~"aborting due to previous error"; } 1u { s = ~"aborting due to previous error"; }
_ { s = #fmt["aborting due to %u previous errors", _ { s = fmt!{"aborting due to %u previous errors",
self.err_count]; } self.err_count}; }
} }
self.fatal(s); self.fatal(s);
} }
@ -111,7 +111,7 @@ impl codemap_handler of handler for handler_t {
} }
fn ice_msg(msg: ~str) -> ~str { fn ice_msg(msg: ~str) -> ~str {
#fmt["internal compiler error: %s", msg] fmt!{"internal compiler error: %s", msg}
} }
fn mk_span_handler(handler: handler, cm: codemap::codemap) -> span_handler { fn mk_span_handler(handler: handler, cm: codemap::codemap) -> span_handler {
@ -166,16 +166,16 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: ~str) {
let use_color = term::color_supported() && let use_color = term::color_supported() &&
io::stderr().get_type() == io::screen; io::stderr().get_type() == io::screen;
if str::is_not_empty(topic) { if str::is_not_empty(topic) {
io::stderr().write_str(#fmt["%s ", topic]); io::stderr().write_str(fmt!{"%s ", topic});
} }
if use_color { if use_color {
term::fg(io::stderr(), diagnosticcolor(lvl)); term::fg(io::stderr(), diagnosticcolor(lvl));
} }
io::stderr().write_str(#fmt["%s:", diagnosticstr(lvl)]); io::stderr().write_str(fmt!{"%s:", diagnosticstr(lvl)});
if use_color { if use_color {
term::reset(io::stderr()); term::reset(io::stderr());
} }
io::stderr().write_str(#fmt[" %s\n", msg]); io::stderr().write_str(fmt!{" %s\n", msg});
} }
fn emit(cmsp: option<(codemap::codemap, span)>, fn emit(cmsp: option<(codemap::codemap, span)>,
@ -210,13 +210,13 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
} }
// Print the offending lines // Print the offending lines
for display_lines.each |line| { for display_lines.each |line| {
io::stderr().write_str(#fmt["%s:%u ", fm.name, line + 1u]); io::stderr().write_str(fmt!{"%s:%u ", fm.name, line + 1u});
let s = codemap::get_line(fm, line as int) + ~"\n"; let s = codemap::get_line(fm, line as int) + ~"\n";
io::stderr().write_str(s); io::stderr().write_str(s);
} }
if elided { if elided {
let last_line = display_lines[vec::len(display_lines) - 1u]; let last_line = display_lines[vec::len(display_lines) - 1u];
let s = #fmt["%s:%u ", fm.name, last_line + 1u]; let s = fmt!{"%s:%u ", fm.name, last_line + 1u};
let mut indent = str::len(s); let mut indent = str::len(s);
let mut out = ~""; let mut out = ~"";
while indent > 0u { out += ~" "; indent -= 1u; } while indent > 0u { out += ~" "; indent -= 1u; }
@ -255,7 +255,7 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
let ss = option::map_default(ei.callie.span, @~"", let ss = option::map_default(ei.callie.span, @~"",
|span| @codemap::span_to_str(span, cm)); |span| @codemap::span_to_str(span, cm));
print_diagnostic(*ss, note, print_diagnostic(*ss, note,
#fmt("in expansion of #%s", ei.callie.name)); fmt!{"in expansion of #%s", ei.callie.name});
let ss = codemap::span_to_str(ei.call_site, cm); let ss = codemap::span_to_str(ei.call_site, cm);
print_diagnostic(ss, note, ~"expansion site"); print_diagnostic(ss, note, ~"expansion site");
print_macro_backtrace(cm, ei.call_site); print_macro_backtrace(cm, ei.call_site);

View file

@ -348,7 +348,7 @@ fn ser_variant(cx: ext_ctxt,
argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr) argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr)
-> ast::arm { -> ast::arm {
let vnames = do vec::from_fn(vec::len(tys)) |i| { let vnames = do vec::from_fn(vec::len(tys)) |i| {
@#fmt["__v%u", i] @fmt!{"__v%u", i}
}; };
let pats = do vec::from_fn(vec::len(tys)) |i| { let pats = do vec::from_fn(vec::len(tys)) |i| {
cx.binder_pat(tys[i].span, vnames[i]) cx.binder_pat(tys[i].span, vnames[i])
@ -398,13 +398,13 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
ast::ty_bot { ast::ty_bot {
cx.span_err( cx.span_err(
ty.span, #fmt["Cannot serialize bottom type"]); ty.span, fmt!{"Cannot serialize bottom type"});
~[] ~[]
} }
ast::ty_box(mt) { ast::ty_box(mt) {
let l = ser_lambda(cx, tps, mt.ty, cx.clone(s), #ast{ *$(v) }); let l = ser_lambda(cx, tps, mt.ty, cx.clone(s), #ast{ *$(v) });
~[#ast(stmt){$(s).emit_box($(l));}] ~[#ast[stmt]{$(s).emit_box($(l));}]
} }
// For unique evecs/estrs, just pass through to underlying vec or str // For unique evecs/estrs, just pass through to underlying vec or str
@ -414,7 +414,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
ast::ty_uniq(mt) { ast::ty_uniq(mt) {
let l = ser_lambda(cx, tps, mt.ty, cx.clone(s), #ast{ *$(v) }); let l = ser_lambda(cx, tps, mt.ty, cx.clone(s), #ast{ *$(v) });
~[#ast(stmt){$(s).emit_uniq($(l));}] ~[#ast[stmt]{$(s).emit_uniq($(l));}]
} }
ast::ty_ptr(_) | ast::ty_rptr(_, _) { ast::ty_ptr(_) | ast::ty_rptr(_, _) {
@ -433,10 +433,10 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
let f = cx.lit_str(fld.span, fld.node.ident); let f = cx.lit_str(fld.span, fld.node.ident);
let i = cx.lit_uint(fld.span, fidx); let i = cx.lit_uint(fld.span, fidx);
let l = ser_lambda(cx, tps, fld.node.mt.ty, cx.clone(s), vf); let l = ser_lambda(cx, tps, fld.node.mt.ty, cx.clone(s), vf);
#ast(stmt){$(s).emit_rec_field($(f), $(i), $(l));} #ast[stmt]{$(s).emit_rec_field($(f), $(i), $(l));}
}; };
let fld_lambda = cx.lambda(cx.blk(ty.span, fld_stmts)); let fld_lambda = cx.lambda(cx.blk(ty.span, fld_stmts));
~[#ast(stmt){$(s).emit_rec($(fld_lambda));}] ~[#ast[stmt]{$(s).emit_rec($(fld_lambda));}]
} }
ast::ty_fn(_, _) { ast::ty_fn(_, _) {
@ -514,7 +514,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
cx.clone(s), cx.clone(s),
cx.at(ty.span, #ast{ __e }))))); cx.at(ty.span, #ast{ __e })))));
~[#ast(stmt){ ~[#ast[stmt]{
std::serialization::emit_from_vec($(s), $(v), |__e| $(ser_e)) std::serialization::emit_from_vec($(s), $(v), |__e| $(ser_e))
}] }]
} }
@ -544,7 +544,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
ident: @(~"__s" + *tp.ident), ident: @(~"__s" + *tp.ident),
id: cx.next_id()}); id: cx.next_id()});
#debug["tp_inputs = %?", tp_inputs]; debug!{"tp_inputs = %?", tp_inputs};
let ser_inputs: ~[ast::arg] = let ser_inputs: ~[ast::arg] =
@ -565,8 +565,8 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
*tp.ident, *tp.ident,
fn@(v: @ast::expr) -> ~[@ast::stmt] { fn@(v: @ast::expr) -> ~[@ast::stmt] {
let f = cx.var_ref(span, arg_ident); let f = cx.var_ref(span, arg_ident);
#debug["serializing type arg %s", *arg_ident]; debug!{"serializing type arg %s", *arg_ident};
~[#ast(stmt){$(f)($(v));}] ~[#ast[stmt]{$(f)($(v));}]
}); });
} }
@ -755,7 +755,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
ident: @(~"__d" + *tp.ident), ident: @(~"__d" + *tp.ident),
id: cx.next_id()}); id: cx.next_id()});
#debug["tp_inputs = %?", tp_inputs]; debug!{"tp_inputs = %?", tp_inputs};
let deser_inputs: ~[ast::arg] = let deser_inputs: ~[ast::arg] =
vec::append(~[{mode: ast::expl(ast::by_ref), vec::append(~[{mode: ast::expl(ast::by_ref),
@ -792,7 +792,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
with cloned} with cloned}
})); }));
let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); let deser_blk = cx.expr_blk(f(cx, tps_map, #ast[expr]{__d}));
@{ident: @(~"deserialize_" + *name), @{ident: @(~"deserialize_" + *name),
attrs: ~[], attrs: ~[],
@ -864,7 +864,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident,
}; };
let lam = cx.lambda(cx.blk(e_span, ~[cx.alt_stmt(arms, e_span, v)])); let lam = cx.lambda(cx.blk(e_span, ~[cx.alt_stmt(arms, e_span, v)]));
let e_name = cx.lit_str(e_span, e_name); let e_name = cx.lit_str(e_span, e_name);
~[#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }] ~[#ast[stmt]{ $(s).emit_enum($(e_name), $(lam)) }]
} }
fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident,

View file

@ -243,22 +243,22 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
alt max { alt max {
some(max) if ! (min <= elts_len && elts_len <= max) { some(max) if ! (min <= elts_len && elts_len <= max) {
cx.span_fatal(sp, cx.span_fatal(sp,
#fmt["#%s takes between %u and %u arguments.", fmt!{"#%s takes between %u and %u arguments.",
name, min, max]); name, min, max});
} }
none if ! (min <= elts_len) { none if ! (min <= elts_len) {
cx.span_fatal(sp, #fmt["#%s needs at least %u arguments.", cx.span_fatal(sp, fmt!{"#%s needs at least %u arguments.",
name, min]); name, min});
} }
_ { ret elts; /* we're good */} _ { ret elts; /* we're good */}
} }
} }
_ { _ {
cx.span_fatal(sp, #fmt["#%s: malformed invocation", name]) cx.span_fatal(sp, fmt!{"#%s: malformed invocation", name})
} }
} }
} }
none {cx.span_fatal(sp, #fmt["#%s: missing arguments", name])} none {cx.span_fatal(sp, fmt!{"#%s: missing arguments", name})}
} }
} }

View file

@ -29,12 +29,12 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt,
alt exts.find(*extname) { alt exts.find(*extname) {
none { none {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
#fmt["macro undefined: '%s'", *extname]) fmt!{"macro undefined: '%s'", *extname})
} }
some(item_decorator(_)) { some(item_decorator(_)) {
cx.span_fatal( cx.span_fatal(
pth.span, pth.span,
#fmt["%s can only be used as a decorator", *extname]); fmt!{"%s can only be used as a decorator", *extname});
} }
some(normal({expander: exp, span: exp_sp})) { some(normal({expander: exp, span: exp_sp})) {
let expanded = exp(cx, mac.span, args, body); let expanded = exp(cx, mac.span, args, body);
@ -54,8 +54,8 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt,
} }
some(expr_tt(_)) { some(expr_tt(_)) {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
#fmt["this tt-style macro should be \ fmt!{"this tt-style macro should be \
invoked '%s!{...}'", *extname]) invoked '%s!{...}'", *extname})
} }
some(item_tt(*)) { some(item_tt(*)) {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
@ -72,14 +72,14 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt,
alt exts.find(*extname) { alt exts.find(*extname) {
none { none {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
#fmt["macro undefined: '%s'", *extname]) fmt!{"macro undefined: '%s'", *extname})
} }
some(expr_tt({expander: exp, span: exp_sp})) { some(expr_tt({expander: exp, span: exp_sp})) {
let expanded = alt exp(cx, mac.span, tts) { let expanded = alt exp(cx, mac.span, tts) {
mr_expr(e) { e } mr_expr(e) { e }
_ { cx.span_fatal( _ { cx.span_fatal(
pth.span, #fmt["non-expr macro in expr pos: %s", pth.span, fmt!{"non-expr macro in expr pos: %s",
*extname]) } *extname}) }
}; };
cx.bt_push(expanded_from({call_site: s, cx.bt_push(expanded_from({call_site: s,
@ -106,8 +106,8 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt,
} }
_ { _ {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
#fmt["'%s' is not a tt-style macro", fmt!{"'%s' is not a tt-style macro",
*extname]) *extname})
} }
} }
@ -203,7 +203,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>,
alt exts.find(*extname) { alt exts.find(*extname) {
none { none {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
#fmt("macro undefined: '%s'", *extname)) fmt!{"macro undefined: '%s'", *extname})
} }
some(item_tt(expand)) { some(item_tt(expand)) {
let expanded = expand.expander(cx, it.span, it.ident, tts); let expanded = expand.expander(cx, it.span, it.ident, tts);
@ -224,7 +224,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>,
ret maybe_it ret maybe_it
} }
_ { cx.span_fatal(it.span, _ { cx.span_fatal(it.span,
#fmt("%s is not a legal here", *extname)) } fmt!{"%s is not a legal here", *extname}) }
} }
} }
_ { _ {
@ -246,10 +246,10 @@ fn new_span(cx: ext_ctxt, sp: span) -> span {
fn core_macros() -> ~str { fn core_macros() -> ~str {
ret ret
~"{ ~"{
#macro([#error[f, ...], log(core::error, #fmt[f, ...])]); #macro[[#error[f, ...], log(core::error, #fmt[f, ...])]];
#macro([#warn[f, ...], log(core::warn, #fmt[f, ...])]); #macro[[#warn[f, ...], log(core::warn, #fmt[f, ...])]];
#macro([#info[f, ...], log(core::info, #fmt[f, ...])]); #macro[[#info[f, ...], log(core::info, #fmt[f, ...])]];
#macro([#debug[f, ...], log(core::debug, #fmt[f, ...])]); #macro[[#debug[f, ...], log(core::debug, #fmt[f, ...])]];
}"; }";
} }

View file

@ -18,7 +18,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
expr_to_str(cx, args[0], expr_to_str(cx, args[0],
~"first argument to #fmt must be a string literal."); ~"first argument to #fmt must be a string literal.");
let fmtspan = args[0].span; let fmtspan = args[0].span;
#debug("Format string:"); debug!{"Format string:"};
log(debug, fmt); log(debug, fmt);
fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: ~str) -> ! { fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: ~str) -> ! {
cx.span_fatal(sp, msg); cx.span_fatal(sp, msg);
@ -189,15 +189,15 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
fn log_conv(c: conv) { fn log_conv(c: conv) {
alt c.param { alt c.param {
some(p) { log(debug, ~"param: " + int::to_str(p, 10u)); } some(p) { log(debug, ~"param: " + int::to_str(p, 10u)); }
_ { #debug("param: none"); } _ { debug!{"param: none"}; }
} }
for c.flags.each |f| { for c.flags.each |f| {
alt f { alt f {
flag_left_justify { #debug("flag: left justify"); } flag_left_justify { debug!{"flag: left justify"}; }
flag_left_zero_pad { #debug("flag: left zero pad"); } flag_left_zero_pad { debug!{"flag: left zero pad"}; }
flag_space_for_sign { #debug("flag: left space pad"); } flag_space_for_sign { debug!{"flag: left space pad"}; }
flag_sign_always { #debug("flag: sign always"); } flag_sign_always { debug!{"flag: sign always"}; }
flag_alternate { #debug("flag: alternate"); } flag_alternate { debug!{"flag: alternate"}; }
} }
} }
alt c.width { alt c.width {
@ -207,8 +207,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
log(debug, log(debug,
~"width: count is param " + int::to_str(i, 10u)); ~"width: count is param " + int::to_str(i, 10u));
} }
count_is_next_param { #debug("width: count is next param"); } count_is_next_param { debug!{"width: count is next param"}; }
count_implied { #debug("width: count is implied"); } count_implied { debug!{"width: count is implied"}; }
} }
alt c.precision { alt c.precision {
count_is(i) { log(debug, count_is(i) { log(debug,
@ -217,29 +217,29 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
log(debug, log(debug,
~"prec: count is param " + int::to_str(i, 10u)); ~"prec: count is param " + int::to_str(i, 10u));
} }
count_is_next_param { #debug("prec: count is next param"); } count_is_next_param { debug!{"prec: count is next param"}; }
count_implied { #debug("prec: count is implied"); } count_implied { debug!{"prec: count is implied"}; }
} }
alt c.ty { alt c.ty {
ty_bool { #debug("type: bool"); } ty_bool { debug!{"type: bool"}; }
ty_str { #debug("type: str"); } ty_str { debug!{"type: str"}; }
ty_char { #debug("type: char"); } ty_char { debug!{"type: char"}; }
ty_int(s) { ty_int(s) {
alt s { alt s {
signed { #debug("type: signed"); } signed { debug!{"type: signed"}; }
unsigned { #debug("type: unsigned"); } unsigned { debug!{"type: unsigned"}; }
} }
} }
ty_bits { #debug("type: bits"); } ty_bits { debug!{"type: bits"}; }
ty_hex(cs) { ty_hex(cs) {
alt cs { alt cs {
case_upper { #debug("type: uhex"); } case_upper { debug!{"type: uhex"}; }
case_lower { #debug("type: lhex"); } case_lower { debug!{"type: lhex"}; }
} }
} }
ty_octal { #debug("type: octal"); } ty_octal { debug!{"type: octal"}; }
ty_float { #debug("type: float"); } ty_float { debug!{"type: float"}; }
ty_poly { #debug("type: poly"); } ty_poly { debug!{"type: poly"}; }
} }
} }
let fmt_sp = args[0].span; let fmt_sp = args[0].span;
@ -258,7 +258,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
~"not enough arguments to #fmt " + ~"not enough arguments to #fmt " +
~"for the given format string"); ~"for the given format string");
} }
#debug("Building conversion:"); debug!{"Building conversion:"};
log_conv(conv); log_conv(conv);
let arg_expr = args[n]; let arg_expr = args[n];
let c_expr = make_new_conv(cx, fmt_sp, conv, arg_expr); let c_expr = make_new_conv(cx, fmt_sp, conv, arg_expr);
@ -270,8 +270,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
if expected_nargs < nargs { if expected_nargs < nargs {
cx.span_fatal cx.span_fatal
(sp, #fmt["too many arguments to #fmt. found %u, expected %u", (sp, fmt!{"too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs]); nargs, expected_nargs});
} }
let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs); let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs);

View file

@ -36,9 +36,9 @@ impl proto_check of proto::visitor<(), (), ()> for ext_ctxt {
if state.messages.len() == 0 { if state.messages.len() == 0 {
self.span_warn( self.span_warn(
state.span, // use a real span! state.span, // use a real span!
#fmt("state %s contains no messages, \ fmt!{"state %s contains no messages, \
consider stepping to a terminal state instead", consider stepping to a terminal state instead",
*state.name)) *state.name})
} }
} }
@ -52,8 +52,8 @@ impl proto_check of proto::visitor<(), (), ()> for ext_ctxt {
// track span information. // track span information.
self.span_err( self.span_err(
proto.get_state(next).span, proto.get_state(next).span,
#fmt("message %s steps to undefined state, %s", fmt!{"message %s steps to undefined state, %s",
*name, *next)); *name, *next});
} }
else { else {
let next = proto.get_state(next); let next = proto.get_state(next);
@ -61,11 +61,11 @@ impl proto_check of proto::visitor<(), (), ()> for ext_ctxt {
if next.ty_params.len() != next_tys.len() { if next.ty_params.len() != next_tys.len() {
self.span_err( self.span_err(
next.span, // use a real span next.span, // use a real span
#fmt("message %s target (%s) \ fmt!{"message %s target (%s) \
needs %u type parameters, but got %u", needs %u type parameters, but got %u",
*name, *next.name, *name, *next.name,
next.ty_params.len(), next.ty_params.len(),
next_tys.len())); next_tys.len()});
} }
} }
} }

View file

@ -35,7 +35,7 @@ import proto::methods;
import ast_builder::empty_span; import ast_builder::empty_span;
fn analyze(proto: protocol, _cx: ext_ctxt) { fn analyze(proto: protocol, _cx: ext_ctxt) {
#debug("initializing colive analysis"); debug!{"initializing colive analysis"};
let num_states = proto.num_states(); let num_states = proto.num_states();
let colive = do (copy proto.states).map_to_vec |state| { let colive = do (copy proto.states).map_to_vec |state| {
let bv = ~bitv(num_states, false); let bv = ~bitv(num_states, false);
@ -49,7 +49,7 @@ fn analyze(proto: protocol, _cx: ext_ctxt) {
let mut changed = true; let mut changed = true;
while changed { while changed {
changed = false; changed = false;
#debug("colive iteration %?", i); debug!{"colive iteration %?", i};
for colive.eachi |i, this_colive| { for colive.eachi |i, this_colive| {
let this = proto.get_state_by_id(i); let this = proto.get_state_by_id(i);
for this_colive.ones |j| { for this_colive.ones |j| {
@ -62,7 +62,7 @@ fn analyze(proto: protocol, _cx: ext_ctxt) {
i += 1; i += 1;
} }
#debug("colive analysis complete"); debug!{"colive analysis complete"};
// Determine if we're bounded // Determine if we're bounded
let mut self_live = ~[]; let mut self_live = ~[];
@ -75,20 +75,20 @@ fn analyze(proto: protocol, _cx: ext_ctxt) {
if self_live.len() > 0 { if self_live.len() > 0 {
let states = str::connect(self_live.map(|s| *s.name), ~" "); let states = str::connect(self_live.map(|s| *s.name), ~" ");
#debug("protocol %s is unbounded due to loops involving: %s", debug!{"protocol %s is unbounded due to loops involving: %s",
*proto.name, states); *proto.name, states};
// Someday this will be configurable with a warning // Someday this will be configurable with a warning
//cx.span_warn(empty_span(), //cx.span_warn(empty_span(),
// #fmt("protocol %s is unbounded due to loops \ // fmt!{"protocol %s is unbounded due to loops \
// involving these states: %s", // involving these states: %s",
// *proto.name, // *proto.name,
// states)); // states});
proto.bounded = some(false); proto.bounded = some(false);
} }
else { else {
#debug("protocol %s is bounded. yay!", *proto.name); debug!{"protocol %s is bounded. yay!", *proto.name};
proto.bounded = some(true); proto.bounded = some(true);
} }
} }

View file

@ -46,10 +46,10 @@ trait gen_init {
impl compile of gen_send for message { impl compile of gen_send for message {
fn gen_send(cx: ext_ctxt) -> @ast::item { fn gen_send(cx: ext_ctxt) -> @ast::item {
#debug("pipec: gen_send"); debug!{"pipec: gen_send"};
alt self { alt self {
message(id, span, tys, this, some({state: next, tys: next_tys})) { message(id, span, tys, this, some({state: next, tys: next_tys})) {
#debug("pipec: next state exists"); debug!{"pipec: next state exists"};
let next = this.proto.get_state(next); let next = this.proto.get_state(next);
assert next_tys.len() == next.ty_params.len(); assert next_tys.len() == next.ty_params.len();
let arg_names = tys.mapi(|i, _ty| @(~"x_" + i.to_str())); let arg_names = tys.mapi(|i, _ty| @(~"x_" + i.to_str()));
@ -78,12 +78,12 @@ impl compile of gen_send for message {
}; };
body += "let b = pipe.reuse_buffer();\n"; body += "let b = pipe.reuse_buffer();\n";
body += #fmt("let %s = pipes::send_packet_buffered(\ body += fmt!{"let %s = pipes::send_packet_buffered(\
ptr::addr_of(b.buffer.data.%s));\n", ptr::addr_of(b.buffer.data.%s));\n",
sp, *next.name); sp, *next.name};
body += #fmt("let %s = pipes::recv_packet_buffered(\ body += fmt!{"let %s = pipes::recv_packet_buffered(\
ptr::addr_of(b.buffer.data.%s));\n", ptr::addr_of(b.buffer.data.%s));\n",
rp, *next.name); rp, *next.name};
} }
else { else {
let pat = alt (this.dir, next.dir) { let pat = alt (this.dir, next.dir) {
@ -93,15 +93,15 @@ impl compile of gen_send for message {
(recv, recv) { ~"(c, s)" } (recv, recv) { ~"(c, s)" }
}; };
body += #fmt("let %s = pipes::entangle();\n", pat); body += fmt!{"let %s = pipes::entangle();\n", pat};
} }
body += #fmt("let message = %s::%s(%s);\n", body += fmt!{"let message = %s::%s(%s);\n",
*this.proto.name, *this.proto.name,
*self.name(), *self.name(),
str::connect(vec::append_one(arg_names, @~"s") str::connect(vec::append_one(arg_names, @~"s")
.map(|x| *x), .map(|x| *x),
~", ")); ~", ")};
body += #fmt("pipes::send(pipe, message);\n"); body += fmt!{"pipes::send(pipe, message);\n"};
// return the new channel // return the new channel
body += ~"c }"; body += ~"c }";
@ -117,7 +117,7 @@ impl compile of gen_send for message {
} }
message(id, span, tys, this, none) { message(id, span, tys, this, none) {
#debug("pipec: no next state"); debug!{"pipec: no next state"};
let arg_names = tys.mapi(|i, _ty| @(~"x_" + i.to_str())); let arg_names = tys.mapi(|i, _ty| @(~"x_" + i.to_str()));
let args_ast = (arg_names, tys).map( let args_ast = (arg_names, tys).map(
@ -140,11 +140,11 @@ impl compile of gen_send for message {
}; };
let mut body = ~"{ "; let mut body = ~"{ ";
body += #fmt("let message = %s::%s%s;\n", body += fmt!{"let message = %s::%s%s;\n",
*this.proto.name, *this.proto.name,
*self.name(), *self.name(),
message_args); message_args};
body += #fmt("pipes::send(pipe, message);\n"); body += fmt!{"pipes::send(pipe, message);\n"};
body += ~" }"; body += ~" }";
let body = cx.parse_expr(body); let body = cx.parse_expr(body);
@ -166,7 +166,7 @@ impl compile of gen_send for message {
impl compile of to_type_decls for state { impl compile of to_type_decls for state {
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] { fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] {
#debug("pipec: to_type_decls"); debug!{"pipec: to_type_decls"};
// This compiles into two different type declarations. Say the // This compiles into two different type declarations. Say the
// state is called ping. This will generate both `ping` and // state is called ping. This will generate both `ping` and
// `ping_message`. The first contains data that the user cares // `ping_message`. The first contains data that the user cares
@ -206,7 +206,7 @@ impl compile of to_type_decls for state {
} }
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] { fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] {
#debug("pipec: to_endpoint_decls"); debug!{"pipec: to_endpoint_decls"};
let dir = alt dir { let dir = alt dir {
send { (*self).dir } send { (*self).dir }
recv { (*self).dir.reverse() } recv { (*self).dir.reverse() }
@ -250,7 +250,7 @@ impl compile of gen_init for protocol {
fn gen_init(cx: ext_ctxt) -> @ast::item { fn gen_init(cx: ext_ctxt) -> @ast::item {
let ext_cx = cx; let ext_cx = cx;
#debug("gen_init"); debug!{"gen_init"};
let start_state = self.states[0]; let start_state = self.states[0];
let body = if !self.is_bounded() { let body = if !self.is_bounded() {
@ -277,12 +277,12 @@ impl compile of gen_init for protocol {
} }
}; };
cx.parse_item(#fmt("fn init%s() -> (client::%s, server::%s)\ cx.parse_item(fmt!{"fn init%s() -> (client::%s, server::%s)\
{ import pipes::has_buffer; %s }", { import pipes::has_buffer; %s }",
start_state.ty_params.to_source(), start_state.ty_params.to_source(),
start_state.to_ty(cx).to_source(), start_state.to_ty(cx).to_source(),
start_state.to_ty(cx).to_source(), start_state.to_ty(cx).to_source(),
body.to_source())) body.to_source()})
} }
fn gen_buffer_init(ext_cx: ext_ctxt) -> @ast::expr { fn gen_buffer_init(ext_cx: ext_ctxt) -> @ast::expr {
@ -293,7 +293,7 @@ impl compile of gen_init for protocol {
} }
fn gen_init_bounded(ext_cx: ext_ctxt) -> @ast::expr { fn gen_init_bounded(ext_cx: ext_ctxt) -> @ast::expr {
#debug("gen_init_bounded"); debug!{"gen_init_bounded"};
let buffer_fields = self.gen_buffer_init(ext_cx); let buffer_fields = self.gen_buffer_init(ext_cx);
let buffer = #ast { let buffer = #ast {
@ -305,9 +305,9 @@ impl compile of gen_init for protocol {
ext_cx.block( ext_cx.block(
self.states.map_to_vec( self.states.map_to_vec(
|s| ext_cx.parse_stmt( |s| ext_cx.parse_stmt(
#fmt("data.%s.set_buffer(buffer)", *s.name))), fmt!{"data.%s.set_buffer(buffer)", *s.name})),
ext_cx.parse_expr( ext_cx.parse_expr(
#fmt("ptr::addr_of(data.%s)", *self.states[0].name)))); fmt!{"ptr::addr_of(data.%s)", *self.states[0].name})));
#ast {{ #ast {{
let buffer = $(buffer); let buffer = $(buffer);
@ -442,7 +442,7 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt {
alt res { alt res {
some(ast) { ast } some(ast) { ast }
none { none {
#error("Parse error with ```\n%s\n```", s); error!{"Parse error with ```\n%s\n```", s};
fail fail
} }
} }

View file

@ -158,9 +158,9 @@ class protocol_ {
let bounded = self.bounded.get(); let bounded = self.bounded.get();
bounded bounded
//if bounded && self.has_ty_params() { //if bounded && self.has_ty_params() {
// #debug("protocol %s has is bounded, but type parameters\ // debug!{"protocol %s has is bounded, but type parameters\
// are not yet supported.", // are not yet supported.",
// *self.name); // *self.name};
// false // false
//} //}
//else { bounded } //else { bounded }

View file

@ -185,7 +185,7 @@ fn finish<T: qq_helper>
{ {
let cm = ecx.codemap(); let cm = ecx.codemap();
let str = @codemap::span_to_snippet(body.span, cm); let str = @codemap::span_to_snippet(body.span, cm);
#debug["qquote--str==%?", str]; debug!{"qquote--str==%?", str};
let fname = codemap::mk_substr_filename(cm, body.span); let fname = codemap::mk_substr_filename(cm, body.span);
let node = parse_from_source_str let node = parse_from_source_str
(f, fname, codemap::fss_internal(body.span), str, (f, fname, codemap::fss_internal(body.span), str,
@ -211,7 +211,7 @@ fn finish<T: qq_helper>
do str::chars_iter(*str) |ch| { do str::chars_iter(*str) |ch| {
if (j < g_len && i == cx.gather[j].lo) { if (j < g_len && i == cx.gather[j].lo) {
assert ch == '$'; assert ch == '$';
let repl = #fmt("$%u ", j); let repl = fmt!{"$%u ", j};
state = skip(str::char_len(repl)); state = skip(str::char_len(repl));
str2 += repl; str2 += repl;
} }

View file

@ -289,9 +289,9 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
let len = vec::len(*ms); let len = vec::len(*ms);
if old_len != len { if old_len != len {
let msg = let msg =
#fmt["'%s' occurs %u times, but ", *fv, len] + fmt!{"'%s' occurs %u times, but ", *fv, len} +
#fmt["'%s' occurs %u times", *old_name, fmt!{"'%s' occurs %u times", *old_name,
old_len]; old_len};
cx.span_fatal(repeat_me.span, msg); cx.span_fatal(repeat_me.span, msg);
} }
} }

View file

@ -13,7 +13,7 @@ export expand_include;
export expand_include_str; export expand_include_str;
export expand_include_bin; export expand_include_bin;
/* #line(): expands to the current line number */ /* line!{}: expands to the current line number */
fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"line"); get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"line");
@ -21,7 +21,7 @@ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
ret mk_uint(cx, sp, loc.line); ret mk_uint(cx, sp, loc.line);
} }
/* #col(): expands to the current column number */ /* col!{}: expands to the current column number */
fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"col"); get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"col");
@ -29,7 +29,7 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
ret mk_uint(cx, sp, loc.col); ret mk_uint(cx, sp, loc.col);
} }
/* #file(): expands to the current filename */ /* file!{}: expands to the current filename */
/* The filemap (`loc.file`) contains a bunch more information we could spit /* The filemap (`loc.file`) contains a bunch more information we could spit
* out if we wanted. */ * out if we wanted. */
fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg,

View file

@ -274,13 +274,13 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
let nts = str::connect(vec::map(bb_eis, |ei| { let nts = str::connect(vec::map(bb_eis, |ei| {
alt ei.elts[ei.idx].node { alt ei.elts[ei.idx].node {
match_nonterminal(bind,name,_) { match_nonterminal(bind,name,_) {
#fmt["%s ('%s')", *name, *bind] fmt!{"%s ('%s')", *name, *bind}
} }
_ { fail; } } }), ~" or "); _ { fail; } } }), ~" or ");
ret failure(sp, #fmt[ ret failure(sp, fmt!{
"Local ambiguity: multiple parsing options: \ "Local ambiguity: multiple parsing options: \
built-in NTs %s or %u other options.", built-in NTs %s or %u other options.",
nts, next_eis.len()]); nts, next_eis.len()});
} else if (bb_eis.len() == 0u && next_eis.len() == 0u) { } else if (bb_eis.len() == 0u && next_eis.len() == 0u) {
ret failure(sp, ~"No rules expected the token " ret failure(sp, ~"No rules expected the token "
+ to_str(*rdr.interner(), tok)); + to_str(*rdr.interner(), tok));

View file

@ -111,9 +111,9 @@ fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis {
lis_contradiction(_) { rhs } lis_contradiction(_) { rhs }
lis_constraint(r_len, _) if l_len == r_len { lhs } lis_constraint(r_len, _) if l_len == r_len { lhs }
lis_constraint(r_len, r_id) { lis_constraint(r_len, r_id) {
lis_contradiction(#fmt["Inconsistent lockstep iteration: \ lis_contradiction(fmt!{"Inconsistent lockstep iteration: \
'%s' has %u items, but '%s' has %u", '%s' has %u items, but '%s' has %u",
*l_id, l_len, *r_id, r_len]) *l_id, l_len, *r_id, r_len})
} }
} }
} }
@ -233,8 +233,8 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} {
matched_seq(*) { matched_seq(*) {
r.sp_diag.span_fatal( r.sp_diag.span_fatal(
copy r.cur_span, /* blame the macro writer */ copy r.cur_span, /* blame the macro writer */
#fmt["variable '%s' is still repeating at this depth", fmt!{"variable '%s' is still repeating at this depth",
*ident]); *ident});
} }
} }
} }

View file

@ -119,7 +119,7 @@ fn consume_non_eol_whitespace(rdr: string_reader) {
} }
fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) { fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) {
#debug(">>> blank-line comment"); debug!{">>> blank-line comment"};
let v: ~[~str] = ~[]; let v: ~[~str] = ~[];
vec::push(comments, {style: blank_line, lines: v, pos: rdr.chpos}); vec::push(comments, {style: blank_line, lines: v, pos: rdr.chpos});
} }
@ -137,9 +137,9 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool, fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
&comments: ~[cmnt]) { &comments: ~[cmnt]) {
#debug(">>> shebang comment"); debug!{">>> shebang comment"};
let p = rdr.chpos; let p = rdr.chpos;
#debug("<<< shebang comment"); debug!{"<<< shebang comment"};
vec::push(comments, { vec::push(comments, {
style: if code_to_the_left { trailing } else { isolated }, style: if code_to_the_left { trailing } else { isolated },
lines: ~[read_one_line_comment(rdr)], lines: ~[read_one_line_comment(rdr)],
@ -149,7 +149,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
fn read_line_comments(rdr: string_reader, code_to_the_left: bool, fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
&comments: ~[cmnt]) { &comments: ~[cmnt]) {
#debug(">>> line comments"); debug!{">>> line comments"};
let p = rdr.chpos; let p = rdr.chpos;
let mut lines: ~[~str] = ~[]; let mut lines: ~[~str] = ~[];
while rdr.curr == '/' && nextch(rdr) == '/' { while rdr.curr == '/' && nextch(rdr) == '/' {
@ -161,7 +161,7 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
vec::push(lines, line); vec::push(lines, line);
consume_non_eol_whitespace(rdr); consume_non_eol_whitespace(rdr);
} }
#debug("<<< line comments"); debug!{"<<< line comments"};
if !lines.is_empty() { if !lines.is_empty() {
vec::push(comments, { vec::push(comments, {
style: if code_to_the_left { trailing } else { isolated }, style: if code_to_the_left { trailing } else { isolated },
@ -192,7 +192,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
fn read_block_comment(rdr: string_reader, code_to_the_left: bool, fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
&comments: ~[cmnt]) { &comments: ~[cmnt]) {
#debug(">>> block comment"); debug!{">>> block comment"};
let p = rdr.chpos; let p = rdr.chpos;
let mut lines: ~[~str] = ~[]; let mut lines: ~[~str] = ~[];
let mut col: uint = rdr.col; let mut col: uint = rdr.col;
@ -214,7 +214,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
let mut curr_line = ~"/*"; let mut curr_line = ~"/*";
let mut level: int = 1; let mut level: int = 1;
while level > 0 { while level > 0 {
#debug("=== block comment level %d", level); debug!{"=== block comment level %d", level};
if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");} if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");}
if rdr.curr == '\n' { if rdr.curr == '\n' {
trim_whitespace_prefix_and_push_line(lines, curr_line, col); trim_whitespace_prefix_and_push_line(lines, curr_line, col);
@ -245,7 +245,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
if !is_eof(rdr) && rdr.curr != '\n' && vec::len(lines) == 1u { if !is_eof(rdr) && rdr.curr != '\n' && vec::len(lines) == 1u {
style = mixed; style = mixed;
} }
#debug("<<< block comment"); debug!{"<<< block comment"};
vec::push(comments, {style: style, lines: lines, pos: p}); vec::push(comments, {style: style, lines: lines, pos: p});
} }
@ -257,7 +257,7 @@ fn peeking_at_comment(rdr: string_reader) -> bool {
fn consume_comment(rdr: string_reader, code_to_the_left: bool, fn consume_comment(rdr: string_reader, code_to_the_left: bool,
&comments: ~[cmnt]) { &comments: ~[cmnt]) {
#debug(">>> consume comment"); debug!{">>> consume comment"};
if rdr.curr == '/' && nextch(rdr) == '/' { if rdr.curr == '/' && nextch(rdr) == '/' {
read_line_comments(rdr, code_to_the_left, comments); read_line_comments(rdr, code_to_the_left, comments);
} else if rdr.curr == '/' && nextch(rdr) == '*' { } else if rdr.curr == '/' && nextch(rdr) == '*' {
@ -265,7 +265,7 @@ fn consume_comment(rdr: string_reader, code_to_the_left: bool,
} else if rdr.curr == '#' && nextch(rdr) == '!' { } else if rdr.curr == '#' && nextch(rdr) == '!' {
read_shebang_comment(rdr, code_to_the_left, comments); read_shebang_comment(rdr, code_to_the_left, comments);
} else { fail; } } else { fail; }
#debug("<<< consume comment"); debug!{"<<< consume comment"};
} }
type lit = {lit: ~str, pos: uint}; type lit = {lit: ~str, pos: uint};

View file

@ -113,7 +113,7 @@ impl parser_common of parser_common for parser {
// A sanity check that the word we are asking for is a known keyword // A sanity check that the word we are asking for is a known keyword
fn require_keyword(word: ~str) { fn require_keyword(word: ~str) {
if !self.keywords.contains_key(word) { if !self.keywords.contains_key(word) {
self.bug(#fmt("unknown keyword: %s", word)); self.bug(fmt!{"unknown keyword: %s", word});
} }
} }

View file

@ -20,9 +20,9 @@ fn eval_crate_directives(cx: ctx,
fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive], fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive],
prefix: ~str, suffix: option<~str>) prefix: ~str, suffix: option<~str>)
-> (ast::_mod, ~[ast::attribute]) { -> (ast::_mod, ~[ast::attribute]) {
#debug("eval crate prefix: %s", prefix); debug!{"eval crate prefix: %s", prefix};
#debug("eval crate suffix: %s", debug!{"eval crate suffix: %s",
option::get_default(suffix, ~"none")); option::get_default(suffix, ~"none")};
let (cview_items, citems, cattrs) let (cview_items, citems, cattrs)
= parse_companion_mod(cx, prefix, suffix); = parse_companion_mod(cx, prefix, suffix);
let mut view_items: ~[@ast::view_item] = ~[]; let mut view_items: ~[@ast::view_item] = ~[];
@ -63,9 +63,9 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>)
} }
let modpath = companion_file(prefix, suffix); let modpath = companion_file(prefix, suffix);
#debug("looking for companion mod %s", modpath); debug!{"looking for companion mod %s", modpath};
if file_exists(modpath) { if file_exists(modpath) {
#debug("found companion mod"); debug!{"found companion mod"};
let (p0, r0) = new_parser_etc_from_file(cx.sess, cx.cfg, let (p0, r0) = new_parser_etc_from_file(cx.sess, cx.cfg,
modpath, SOURCE_FILE); modpath, SOURCE_FILE);
let inner_attrs = p0.parse_inner_attrs_and_next(); let inner_attrs = p0.parse_inner_attrs_and_next();

View file

@ -417,8 +417,8 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
} }
let parsed = option::get(u64::from_str_radix(num_str, base as u64)); let parsed = option::get(u64::from_str_radix(num_str, base as u64));
#debug["lexing %s as an unsuffixed integer literal", debug!{"lexing %s as an unsuffixed integer literal",
num_str]; num_str};
ret token::LIT_INT_UNSUFFIXED(parsed as i64); ret token::LIT_INT_UNSUFFIXED(parsed as i64);
} }
} }
@ -429,7 +429,7 @@ fn scan_numeric_escape(rdr: string_reader, n_hex_digits: uint) -> char {
let n = rdr.curr; let n = rdr.curr;
bump(rdr); bump(rdr);
if !is_hex_digit(n) { if !is_hex_digit(n) {
rdr.fatal(#fmt["illegal numeric character escape: %d", n as int]); rdr.fatal(fmt!{"illegal numeric character escape: %d", n as int});
} }
accum_int *= 16; accum_int *= 16;
accum_int += hex_digit_val(n); accum_int += hex_digit_val(n);
@ -572,7 +572,7 @@ fn next_token_inner(rdr: string_reader) -> token::token {
'u' { c2 = scan_numeric_escape(rdr, 4u); } 'u' { c2 = scan_numeric_escape(rdr, 4u); }
'U' { c2 = scan_numeric_escape(rdr, 8u); } 'U' { c2 = scan_numeric_escape(rdr, 8u); }
c2 { c2 {
rdr.fatal(#fmt["unknown character escape: %d", c2 as int]); rdr.fatal(fmt!{"unknown character escape: %d", c2 as int});
} }
} }
} }
@ -587,8 +587,8 @@ fn next_token_inner(rdr: string_reader) -> token::token {
bump(rdr); bump(rdr);
while rdr.curr != '"' { while rdr.curr != '"' {
if is_eof(rdr) { if is_eof(rdr) {
rdr.fatal(#fmt["unterminated double quote string: %s", rdr.fatal(fmt!{"unterminated double quote string: %s",
get_str_from(rdr, n)]); get_str_from(rdr, n)});
} }
let ch = rdr.curr; let ch = rdr.curr;
@ -614,7 +614,7 @@ fn next_token_inner(rdr: string_reader) -> token::token {
str::push_char(accum_str, scan_numeric_escape(rdr, 8u)); str::push_char(accum_str, scan_numeric_escape(rdr, 8u));
} }
c2 { c2 {
rdr.fatal(#fmt["unknown string escape: %d", c2 as int]); rdr.fatal(fmt!{"unknown string escape: %d", c2 as int});
} }
} }
} }
@ -649,7 +649,7 @@ fn next_token_inner(rdr: string_reader) -> token::token {
'/' { ret binop(rdr, token::SLASH); } '/' { ret binop(rdr, token::SLASH); }
'^' { ret binop(rdr, token::CARET); } '^' { ret binop(rdr, token::CARET); }
'%' { ret binop(rdr, token::PERCENT); } '%' { ret binop(rdr, token::PERCENT); }
c { rdr.fatal(#fmt["unknown start of token: %d", c as int]); } c { rdr.fatal(fmt!{"unknown start of token: %d", c as int}); }
} }
} }

View file

@ -273,13 +273,13 @@ class parser {
let tps = p.parse_ty_params(); let tps = p.parse_ty_params();
let d = p.parse_ty_fn_decl(pur); let d = p.parse_ty_fn_decl(pur);
let hi = p.last_span.hi; let hi = p.last_span.hi;
#debug["parse_trait_methods(): trait method signature ends in \ debug!{"parse_trait_methods(): trait method signature ends in \
`%s`", `%s`",
token_to_str(p.reader, p.token)]; token_to_str(p.reader, p.token)};
alt p.token { alt p.token {
token::SEMI { token::SEMI {
p.bump(); p.bump();
#debug["parse_trait_methods(): parsing required method"]; debug!{"parse_trait_methods(): parsing required method"};
// NB: at the moment, visibility annotations on required // NB: at the moment, visibility annotations on required
// methods are ignored; this could change. // methods are ignored; this could change.
required({ident: ident, attrs: attrs, required({ident: ident, attrs: attrs,
@ -287,7 +287,7 @@ class parser {
span: mk_sp(lo, hi)}) span: mk_sp(lo, hi)})
} }
token::LBRACE { token::LBRACE {
#debug["parse_trait_methods(): parsing provided method"]; debug!{"parse_trait_methods(): parsing provided method"};
let (inner_attrs, body) = let (inner_attrs, body) =
p.parse_inner_attrs_and_block(true); p.parse_inner_attrs_and_block(true);
let attrs = vec::append(attrs, inner_attrs); let attrs = vec::append(attrs, inner_attrs);
@ -632,7 +632,7 @@ class parser {
} }
fn parse_path_with_tps(colons: bool) -> @path { fn parse_path_with_tps(colons: bool) -> @path {
#debug["parse_path_with_tps(colons=%b)", colons]; debug!{"parse_path_with_tps(colons=%b)", colons};
let lo = self.span.lo; let lo = self.span.lo;
let path = self.parse_path_without_tps(); let path = self.parse_path_without_tps();
@ -1479,9 +1479,9 @@ class parser {
// There may be other types of expressions that can // There may be other types of expressions that can
// represent the callee in `for` and `do` expressions // represent the callee in `for` and `do` expressions
// but they aren't represented by tests // but they aren't represented by tests
#debug("sugary call on %?", e.node); debug!{"sugary call on %?", e.node};
self.span_fatal( self.span_fatal(
lo, #fmt("`%s` must be followed by a block call", keyword)); lo, fmt!{"`%s` must be followed by a block call", keyword});
} }
} }
} }
@ -2321,7 +2321,7 @@ class parser {
attrs = vec::append(attrs_remaining, attrs); attrs = vec::append(attrs_remaining, attrs);
first = false; first = false;
} }
#debug["parse_mod_items: parse_item(attrs=%?)", attrs]; debug!{"parse_mod_items: parse_item(attrs=%?)", attrs};
let vis = self.parse_visibility(private); let vis = self.parse_visibility(private);
alt self.parse_item(attrs, vis) { alt self.parse_item(attrs, vis) {
some(i) { vec::push(items, i); } some(i) { vec::push(items, i); }
@ -2330,7 +2330,7 @@ class parser {
token_to_str(self.reader, self.token) + ~"`"); token_to_str(self.reader, self.token) + ~"`");
} }
} }
#debug["parse_mod_items: attrs=%?", attrs]; debug!{"parse_mod_items: attrs=%?", attrs};
} }
if first && attrs_remaining.len() > 0u { if first && attrs_remaining.len() > 0u {
@ -2603,7 +2603,7 @@ class parser {
let lo = self.span.lo; let lo = self.span.lo;
let first_ident = self.parse_ident(); let first_ident = self.parse_ident();
let mut path = ~[first_ident]; let mut path = ~[first_ident];
#debug("parsed view_path: %s", *first_ident); debug!{"parsed view_path: %s", *first_ident};
alt self.token { alt self.token {
token::EQ { token::EQ {
// x = foo::bar // x = foo::bar

View file

@ -63,7 +63,7 @@ enum token { STRING(@~str, int), BREAK(break_t), BEGIN(begin_t), END, EOF, }
fn tok_str(++t: token) -> ~str { fn tok_str(++t: token) -> ~str {
alt t { alt t {
STRING(s, len) { ret #fmt["STR(%s,%d)", *s, len]; } STRING(s, len) { ret fmt!{"STR(%s,%d)", *s, len}; }
BREAK(_) { ret ~"BREAK"; } BREAK(_) { ret ~"BREAK"; }
BEGIN(_) { ret ~"BEGIN"; } BEGIN(_) { ret ~"BEGIN"; }
END { ret ~"END"; } END { ret ~"END"; }
@ -81,7 +81,7 @@ fn buf_str(toks: ~[mut token], szs: ~[mut int], left: uint, right: uint,
while i != right && L != 0u { while i != right && L != 0u {
L -= 1u; L -= 1u;
if i != left { s += ~", "; } if i != left { s += ~", "; }
s += #fmt["%d=%s", szs[i], tok_str(toks[i])]; s += fmt!{"%d=%s", szs[i], tok_str(toks[i])};
i += 1u; i += 1u;
i %= n; i %= n;
} }
@ -99,7 +99,7 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
// Yes 3, it makes the ring buffers big enough to never // Yes 3, it makes the ring buffers big enough to never
// fall behind. // fall behind.
let n: uint = 3u * linewidth; let n: uint = 3u * linewidth;
#debug("mk_printer %u", linewidth); debug!{"mk_printer %u", linewidth};
let token: ~[mut token] = vec::to_mut(vec::from_elem(n, EOF)); let token: ~[mut token] = vec::to_mut(vec::from_elem(n, EOF));
let size: ~[mut int] = vec::to_mut(vec::from_elem(n, 0)); let size: ~[mut int] = vec::to_mut(vec::from_elem(n, 0));
let scan_stack: ~[mut uint] = vec::to_mut(vec::from_elem(n, 0u)); let scan_stack: ~[mut uint] = vec::to_mut(vec::from_elem(n, 0u));
@ -235,7 +235,7 @@ impl printer for printer {
// be very careful with this! // be very careful with this!
fn replace_last_token(t: token) { self.token[self.right] = t; } fn replace_last_token(t: token) { self.token[self.right] = t; }
fn pretty_print(t: token) { fn pretty_print(t: token) {
#debug("pp ~[%u,%u]", self.left, self.right); debug!{"pp ~[%u,%u]", self.left, self.right};
alt t { alt t {
EOF { EOF {
if !self.scan_stack_empty { if !self.scan_stack_empty {
@ -252,17 +252,17 @@ impl printer for printer {
self.left = 0u; self.left = 0u;
self.right = 0u; self.right = 0u;
} else { self.advance_right(); } } else { self.advance_right(); }
#debug("pp BEGIN/buffer ~[%u,%u]", self.left, self.right); debug!{"pp BEGIN/buffer ~[%u,%u]", self.left, self.right};
self.token[self.right] = t; self.token[self.right] = t;
self.size[self.right] = -self.right_total; self.size[self.right] = -self.right_total;
self.scan_push(self.right); self.scan_push(self.right);
} }
END { END {
if self.scan_stack_empty { if self.scan_stack_empty {
#debug("pp END/print ~[%u,%u]", self.left, self.right); debug!{"pp END/print ~[%u,%u]", self.left, self.right};
self.print(t, 0); self.print(t, 0);
} else { } else {
#debug("pp END/buffer ~[%u,%u]", self.left, self.right); debug!{"pp END/buffer ~[%u,%u]", self.left, self.right};
self.advance_right(); self.advance_right();
self.token[self.right] = t; self.token[self.right] = t;
self.size[self.right] = -1; self.size[self.right] = -1;
@ -276,7 +276,7 @@ impl printer for printer {
self.left = 0u; self.left = 0u;
self.right = 0u; self.right = 0u;
} else { self.advance_right(); } } else { self.advance_right(); }
#debug("pp BREAK/buffer ~[%u,%u]", self.left, self.right); debug!{"pp BREAK/buffer ~[%u,%u]", self.left, self.right};
self.check_stack(0); self.check_stack(0);
self.scan_push(self.right); self.scan_push(self.right);
self.token[self.right] = t; self.token[self.right] = t;
@ -285,10 +285,10 @@ impl printer for printer {
} }
STRING(s, len) { STRING(s, len) {
if self.scan_stack_empty { if self.scan_stack_empty {
#debug("pp STRING/print ~[%u,%u]", self.left, self.right); debug!{"pp STRING/print ~[%u,%u]", self.left, self.right};
self.print(t, len); self.print(t, len);
} else { } else {
#debug("pp STRING/buffer ~[%u,%u]", self.left, self.right); debug!{"pp STRING/buffer ~[%u,%u]", self.left, self.right};
self.advance_right(); self.advance_right();
self.token[self.right] = t; self.token[self.right] = t;
self.size[self.right] = len; self.size[self.right] = len;
@ -299,14 +299,14 @@ impl printer for printer {
} }
} }
fn check_stream() { fn check_stream() {
#debug("check_stream ~[%u, %u] with left_total=%d, right_total=%d", debug!{"check_stream ~[%u, %u] with left_total=%d, right_total=%d",
self.left, self.right, self.left_total, self.right_total); self.left, self.right, self.left_total, self.right_total};
if self.right_total - self.left_total > self.space { if self.right_total - self.left_total > self.space {
#debug("scan window is %d, longer than space on line (%d)", debug!{"scan window is %d, longer than space on line (%d)",
self.right_total - self.left_total, self.space); self.right_total - self.left_total, self.space};
if !self.scan_stack_empty { if !self.scan_stack_empty {
if self.left == self.scan_stack[self.bottom] { if self.left == self.scan_stack[self.bottom] {
#debug("setting %u to infinity and popping", self.left); debug!{"setting %u to infinity and popping", self.left};
self.size[self.scan_pop_bottom()] = size_infinity; self.size[self.scan_pop_bottom()] = size_infinity;
} }
} }
@ -315,7 +315,7 @@ impl printer for printer {
} }
} }
fn scan_push(x: uint) { fn scan_push(x: uint) {
#debug("scan_push %u", x); debug!{"scan_push %u", x};
if self.scan_stack_empty { if self.scan_stack_empty {
self.scan_stack_empty = false; self.scan_stack_empty = false;
} else { } else {
@ -351,8 +351,8 @@ impl printer for printer {
assert (self.right != self.left); assert (self.right != self.left);
} }
fn advance_left(++x: token, L: int) { fn advance_left(++x: token, L: int) {
#debug("advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right, debug!{"advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right,
self.left, L); self.left, L};
if L >= 0 { if L >= 0 {
self.print(x, L); self.print(x, L);
alt x { alt x {
@ -392,13 +392,13 @@ impl printer for printer {
} }
} }
fn print_newline(amount: int) { fn print_newline(amount: int) {
#debug("NEWLINE %d", amount); debug!{"NEWLINE %d", amount};
self.out.write_str(~"\n"); self.out.write_str(~"\n");
self.pending_indentation = 0; self.pending_indentation = 0;
self.indent(amount); self.indent(amount);
} }
fn indent(amount: int) { fn indent(amount: int) {
#debug("INDENT %d", amount); debug!{"INDENT %d", amount};
self.pending_indentation += amount; self.pending_indentation += amount;
} }
fn get_top() -> print_stack_elt { fn get_top() -> print_stack_elt {
@ -417,24 +417,24 @@ impl printer for printer {
self.out.write_str(s); self.out.write_str(s);
} }
fn print(x: token, L: int) { fn print(x: token, L: int) {
#debug("print %s %d (remaining line space=%d)", tok_str(x), L, debug!{"print %s %d (remaining line space=%d)", tok_str(x), L,
self.space); self.space};
log(debug, buf_str(self.token, self.size, self.left, self.right, 6u)); log(debug, buf_str(self.token, self.size, self.left, self.right, 6u));
alt x { alt x {
BEGIN(b) { BEGIN(b) {
if L > self.space { if L > self.space {
let col = self.margin - self.space + b.offset; let col = self.margin - self.space + b.offset;
#debug("print BEGIN -> push broken block at col %d", col); debug!{"print BEGIN -> push broken block at col %d", col};
self.print_stack.push({offset: col, self.print_stack.push({offset: col,
pbreak: broken(b.breaks)}); pbreak: broken(b.breaks)});
} else { } else {
#debug("print BEGIN -> push fitting block"); debug!{"print BEGIN -> push fitting block"};
self.print_stack.push({offset: 0, self.print_stack.push({offset: 0,
pbreak: fits}); pbreak: fits});
} }
} }
END { END {
#debug("print END -> pop END"); debug!{"print END -> pop END"};
assert (self.print_stack.len() != 0u); assert (self.print_stack.len() != 0u);
self.print_stack.pop(); self.print_stack.pop();
} }
@ -442,22 +442,22 @@ impl printer for printer {
let top = self.get_top(); let top = self.get_top();
alt top.pbreak { alt top.pbreak {
fits { fits {
#debug("print BREAK in fitting block"); debug!{"print BREAK in fitting block"};
self.space -= b.blank_space; self.space -= b.blank_space;
self.indent(b.blank_space); self.indent(b.blank_space);
} }
broken(consistent) { broken(consistent) {
#debug("print BREAK in consistent block"); debug!{"print BREAK in consistent block"};
self.print_newline(top.offset + b.offset); self.print_newline(top.offset + b.offset);
self.space = self.margin - (top.offset + b.offset); self.space = self.margin - (top.offset + b.offset);
} }
broken(inconsistent) { broken(inconsistent) {
if L > self.space { if L > self.space {
#debug("print BREAK w/ newline in inconsistent"); debug!{"print BREAK w/ newline in inconsistent"};
self.print_newline(top.offset + b.offset); self.print_newline(top.offset + b.offset);
self.space = self.margin - (top.offset + b.offset); self.space = self.margin - (top.offset + b.offset);
} else { } else {
#debug("print BREAK w/o newline in inconsistent"); debug!{"print BREAK w/o newline in inconsistent"};
self.indent(b.blank_space); self.indent(b.blank_space);
self.space -= b.blank_space; self.space -= b.blank_space;
} }
@ -465,7 +465,7 @@ impl printer for printer {
} }
} }
STRING(s, len) { STRING(s, len) {
#debug("print STRING"); debug!{"print STRING"};
assert (L == len); assert (L == len);
// assert L <= space; // assert L <= space;
self.space -= len; self.space -= len;

View file

@ -872,14 +872,14 @@ fn print_mac(s: ps, m: ast::mac) {
bclose(s, m.span); bclose(s, m.span);
} }
ast::mac_ellipsis { word(s.s, ~"..."); } ast::mac_ellipsis { word(s.s, ~"..."); }
ast::mac_var(v) { word(s.s, #fmt("$%u", v)); } ast::mac_var(v) { word(s.s, fmt!{"$%u", v}); }
_ { /* fixme */ } _ { /* fixme */ }
} }
} }
fn print_vstore(s: ps, t: ast::vstore) { fn print_vstore(s: ps, t: ast::vstore) {
alt t { alt t {
ast::vstore_fixed(some(i)) { word(s.s, #fmt("%u", i)); } ast::vstore_fixed(some(i)) { word(s.s, fmt!{"%u", i}); }
ast::vstore_fixed(none) { word(s.s, ~"_"); } ast::vstore_fixed(none) { word(s.s, ~"_"); }
ast::vstore_uniq { word(s.s, ~"~"); } ast::vstore_uniq { word(s.s, ~"~"); }
ast::vstore_box { word(s.s, ~"@"); } ast::vstore_box { word(s.s, ~"@"); }

View file

@ -343,7 +343,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
metas: provided_metas, metas: provided_metas,
dep_hashes: ~[@~str]) -> ~str { dep_hashes: ~[@~str]) -> ~str {
fn len_and_str(s: ~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 { 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) { fn warn_missing(sess: session, name: ~str, default: ~str) {
if !sess.building_library { ret; } if !sess.building_library { ret; }
sess.warn(#fmt["missing crate link meta `%s`, using `%s` as default", sess.warn(fmt!{"missing crate link meta `%s`, using `%s` as default",
name, default]); name, default});
} }
fn crate_meta_name(sess: session, _crate: ast::crate, 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 = let mut os =
str::split_char(path::basename(output), '.'); str::split_char(path::basename(output), '.');
if (vec::len(os) < 2u) { if (vec::len(os) < 2u) {
sess.fatal(#fmt("output file name `%s` doesn't\ sess.fatal(fmt!{"output file name `%s` doesn't\
appear to have an extension", output)); appear to have an extension", output});
} }
vec::pop(os); vec::pop(os);
str::connect(os, ~".") str::connect(os, ~".")
@ -505,7 +505,7 @@ fn mangle(ss: path) -> ~str {
for ss.each |s| { for ss.each |s| {
alt s { path_name(s) | path_mod(s) { alt s { path_name(s) | path_mod(s) {
let sani = sanitize(*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. n += ~"E"; // End name-sequence.
@ -576,12 +576,12 @@ fn link_binary(sess: session,
let output = if sess.building_library { let output = if sess.building_library {
let long_libname = let long_libname =
os::dll_filename(#fmt("%s-%s-%s", os::dll_filename(fmt!{"%s-%s-%s",
*lm.name, lm.extras_hash, *lm.vers)); *lm.name, lm.extras_hash, *lm.vers});
#debug("link_meta.name: %s", *lm.name); debug!{"link_meta.name: %s", *lm.name};
#debug("long_libname: %s", long_libname); debug!{"long_libname: %s", long_libname};
#debug("out_filename: %s", out_filename); debug!{"out_filename: %s", out_filename};
#debug("dirname(out_filename): %s", path::dirname(out_filename)); debug!{"dirname(out_filename): %s", path::dirname(out_filename)};
path::connect(path::dirname(out_filename), long_libname) path::connect(path::dirname(out_filename), long_libname)
} else { out_filename }; } else { out_filename };
@ -698,14 +698,14 @@ fn link_binary(sess: session,
// extern libraries might live, based on the addl_lib_search_paths // extern libraries might live, based on the addl_lib_search_paths
vec::push_all(cc_args, rpath::get_rpath_flags(sess, output)); 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 // We run 'cc' here
let prog = run::program_output(cc_prog, cc_args); let prog = run::program_output(cc_prog, cc_args);
if 0 != prog.status { if 0 != prog.status {
sess.err(#fmt["linking with `%s` failed with code %d", sess.err(fmt!{"linking with `%s` failed with code %d",
cc_prog, prog.status]); cc_prog, prog.status});
sess.note(#fmt["%s arguments: %s", sess.note(fmt!{"%s arguments: %s",
cc_prog, str::connect(cc_args, ~" ")]); cc_prog, str::connect(cc_args, ~" ")});
sess.note(prog.err + prog.out); sess.note(prog.err + prog.out);
sess.abort_if_errors(); sess.abort_if_errors();
} }
@ -718,8 +718,8 @@ fn link_binary(sess: session,
// Remove the temporary object file if we aren't saving temps // Remove the temporary object file if we aren't saving temps
if !sess.opts.save_temps { if !sess.opts.save_temps {
if ! os::remove_file(obj_filename) { if ! os::remove_file(obj_filename) {
sess.warn(#fmt["failed to delete object file `%s`", sess.warn(fmt!{"failed to delete object file `%s`",
obj_filename]); obj_filename});
} }
} }
} }

View file

@ -21,7 +21,7 @@ fn get_rpath_flags(sess: session::session, out_filename: ~str) -> ~[~str] {
ret ~[]; ret ~[];
} }
#debug("preparing the RPATH!"); debug!{"preparing the RPATH!"};
let cwd = os::getcwd(); let cwd = os::getcwd();
let sysroot = sess.filesearch.sysroot(); 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] { 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, fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path,
output: path::path, libs: ~[path::path], output: path::path, libs: ~[path::path],
target_triple: ~str) -> ~[~str] { target_triple: ~str) -> ~[~str] {
#debug("cwd: %s", cwd); debug!{"cwd: %s", cwd};
#debug("sysroot: %s", sysroot); debug!{"sysroot: %s", sysroot};
#debug("output: %s", output); debug!{"output: %s", output};
#debug("libs:"); debug!{"libs:"};
for libs.each |libpath| { 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 // Use relative paths to the libraries. Binaries can be moved
// as long as they maintain the relative relationship to the // 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)]; let fallback_rpaths = ~[get_install_prefix_rpath(cwd, target_triple)];
fn log_rpaths(desc: ~str, rpaths: ~[~str]) { fn log_rpaths(desc: ~str, rpaths: ~[~str]) {
#debug("%s rpaths:", desc); debug!{"%s rpaths:", desc};
for rpaths.each |rpath| { 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 { fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
assert path::path_is_absolute(abs1); assert path::path_is_absolute(abs1);
assert path::path_is_absolute(abs2); assert path::path_is_absolute(abs2);
#debug("finding relative path from %s to %s", debug!{"finding relative path from %s to %s",
abs1, abs2); abs1, abs2};
let normal1 = path::normalize(abs1); let normal1 = path::normalize(abs1);
let normal2 = path::normalize(abs2); let normal2 = path::normalize(abs2);
let split1 = path::split(normal1); 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 { 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 == ~"" { if install_prefix == ~"" {
fail ~"rustc compiled without CFG_PREFIX environment variable"; fail ~"rustc compiled without CFG_PREFIX environment variable";
@ -222,7 +222,7 @@ mod test {
#[test] #[test]
fn test_prefix_rpath() { fn test_prefix_rpath() {
let res = get_install_prefix_rpath(~"/usr/lib", ~"triple"); 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); assert str::ends_with(res, d);
} }

View file

@ -115,8 +115,8 @@ fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T {
let start = std::time::precise_time_s(); let start = std::time::precise_time_s();
let rv = thunk(); let rv = thunk();
let end = std::time::precise_time_s(); let end = std::time::precise_time_s();
io::stdout().write_str(#fmt("time: %3.3f s\t%s\n", io::stdout().write_str(fmt!{"time: %3.3f s\t%s\n",
end - start, what)); end - start, what});
ret rv; ret rv;
} }
@ -397,7 +397,7 @@ fn host_triple() -> ~str {
// FIXME (#2400): Instead of grabbing the host triple we really should // FIXME (#2400): Instead of grabbing the host triple we really should
// be grabbing (at compile time) the target triple that this rustc is // be grabbing (at compile time) the target triple that this rustc is
// built with and calling that (at runtime) the host triple. // 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 != ~"" { ret if ht != ~"" {
ht ht
} else { } else {
@ -432,8 +432,8 @@ fn build_session_options(match: getopts::match,
let lint_name = str::replace(lint_name, ~"-", ~"_"); let lint_name = str::replace(lint_name, ~"-", ~"_");
alt lint_dict.find(lint_name) { alt lint_dict.find(lint_name) {
none { none {
early_error(demitter, #fmt("unknown %s flag: %s", early_error(demitter, fmt!{"unknown %s flag: %s",
level_name, lint_name)); level_name, lint_name});
} }
some(lint) { some(lint) {
vec::push(lint_opts, (lint.lint, level)); 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 name == debug_flag { this_bit = bit; break; }
} }
if this_bit == 0u { 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; debugging_opts |= this_bit;
} }

View file

@ -27,14 +27,14 @@ import io::reader_util;
fn version(argv0: ~str) { fn version(argv0: ~str) {
let mut vers = ~"unknown version"; 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; } if str::len(env_vers) != 0u { vers = env_vers; }
io::println(#fmt("%s %s", argv0, vers)); io::println(fmt!{"%s %s", argv0, vers});
io::println(#fmt("host: %s", host_triple())); io::println(fmt!{"host: %s", host_triple()});
} }
fn usage(argv0: ~str) { fn usage(argv0: ~str) {
io::println(#fmt("Usage: %s [options] <input>\n", argv0) + io::println(fmt!{"Usage: %s [options] <input>\n", argv0} +
~" ~"
Options: Options:
@ -91,14 +91,14 @@ fn describe_warnings() {
fn padded(max: uint, s: ~str) -> ~str { fn padded(max: uint, s: ~str) -> ~str {
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
} }
io::println(#fmt("\nAvailable lint checks:\n")); io::println(fmt!{"\nAvailable lint checks:\n"});
io::println(#fmt(" %s %7.7s %s", io::println(fmt!{" %s %7.7s %s",
padded(max_key, ~"name"), ~"default", ~"meaning")); padded(max_key, ~"name"), ~"default", ~"meaning"});
io::println(#fmt(" %s %7.7s %s\n", io::println(fmt!{" %s %7.7s %s\n",
padded(max_key, ~"----"), ~"-------", ~"-------")); padded(max_key, ~"----"), ~"-------", ~"-------"});
for lint_dict.each |k, v| { for lint_dict.each |k, v| {
let k = str::replace(k, ~"_", ~"-"); let k = str::replace(k, ~"_", ~"-");
io::println(#fmt(" %s %7.7s %s", io::println(fmt!{" %s %7.7s %s",
padded(max_key, k), padded(max_key, k),
alt v.default { alt v.default {
lint::allow { ~"allow" } lint::allow { ~"allow" }
@ -106,16 +106,16 @@ fn describe_warnings() {
lint::deny { ~"deny" } lint::deny { ~"deny" }
lint::forbid { ~"forbid" } lint::forbid { ~"forbid" }
}, },
v.desc)); v.desc});
} }
io::println(~""); io::println(~"");
} }
fn describe_debug_flags() { 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| { for session::debugging_opts_map().each |pair| {
let (name, desc, _) = pair; let (name, desc, _) = pair;
io::println(#fmt(" -Z%-20s -- %s", name, desc)); io::println(fmt!{" -Z%-20s -- %s", name, desc});
} }
} }

View file

@ -7,7 +7,7 @@ export inject_intrinsic;
fn inject_intrinsic(sess: session, fn inject_intrinsic(sess: session,
crate: @ast::crate) -> @ast::crate { 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>", let item = parse::parse_item_from_source_str(~"<intrinsic>",
intrinsic_module, intrinsic_module,

View file

@ -99,7 +99,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
option<@ast::item> { option<@ast::item> {
vec::push(cx.path, i.ident); 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) { if is_test_fn(i) {
alt i.node { 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"); ~"unsafe functions cannot be used for tests");
} }
_ { _ {
#debug("this is a test function"); debug!{"this is a test function"};
let test = {span: i.span, let test = {span: i.span,
path: cx.path, ignore: is_ignored(cx, i), path: cx.path, ignore: is_ignored(cx, i),
should_fail: should_fail(i)}; should_fail: should_fail(i)};
cx.testfns.push(test); 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, vis: ast::public,
span: dummy_sp()}; 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; 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 { 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 = ~[]; let mut descs = ~[];
for cx.testfns.each |test| { for cx.testfns.each |test| {
vec::push(descs, mk_test_desc_rec(cx, 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 span = test.span;
let path = test.path; 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 = let name_lit: ast::lit =
nospan(ast::lit_str(@ast_util::path_name_i(path))); nospan(ast::lit_str(@ast_util::path_name_i(path)));

View file

@ -1090,7 +1090,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
if addrspace == 0u { if addrspace == 0u {
~"" ~""
} else { } else {
#fmt("addrspace(%u)", addrspace) fmt!{"addrspace(%u)", addrspace}
} }
}; };
ret addrstr + ~"*" + ret addrstr + ~"*" +

View file

@ -43,16 +43,16 @@ type cache_entry = {
}; };
fn dump_crates(crate_cache: dvec<cache_entry>) { fn dump_crates(crate_cache: dvec<cache_entry>) {
#debug("resolved crates:"); debug!{"resolved crates:"};
for crate_cache.each |entry| { for crate_cache.each |entry| {
#debug("cnum: %?", entry.cnum); debug!{"cnum: %?", entry.cnum};
#debug("span: %?", entry.span); debug!{"span: %?", entry.span};
#debug("hash: %?", entry.hash); debug!{"hash: %?", entry.hash};
let attrs = ~[ let attrs = ~[
attr::mk_attr(attr::mk_list_item(@~"link", *entry.metas)) attr::mk_attr(attr::mk_list_item(@~"link", *entry.metas))
]; ];
for attr::find_linkage_attrs(attrs).each |attr| { 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 { if matches.len() != 1u {
diag.handler().warn( diag.handler().warn(
#fmt("using multiple versions of crate `%s`", *name)); fmt!{"using multiple versions of crate `%s`", *name});
for matches.each |match| { for matches.each |match| {
diag.span_note(match.span, ~"used here"); diag.span_note(match.span, ~"used here");
let attrs = ~[ let attrs = ~[
@ -102,7 +102,7 @@ type env = @{diag: span_handler,
fn visit_view_item(e: env, i: @ast::view_item) { fn visit_view_item(e: env, i: @ast::view_item) {
alt i.node { alt i.node {
ast::view_item_use(ident, meta_items, id) { 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); let cnum = resolve_crate(e, ident, meta_items, ~"", i.span);
cstore::add_use_stmt_cnum(e.cstore, id, cnum); 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 // Go through the crate metadata and load any crates that it references
fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map {
#debug("resolving deps of external crate"); debug!{"resolving deps of external crate"};
// The map from crate numbers in the crate we're resolving to local crate // The map from crate numbers in the crate we're resolving to local crate
// numbers // numbers
let cnum_map = int_hash::<ast::crate_num>(); 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 extrn_cnum = dep.cnum;
let cname = dep.name; let cname = dep.name;
let cmetas = metas_with(dep.vers, @~"vers", ~[]); let cmetas = metas_with(dep.vers, @~"vers", ~[]);
#debug("resolving dep crate %s ver: %s hash: %s", debug!{"resolving dep crate %s ver: %s hash: %s",
*dep.name, *dep.vers, *dep.hash); *dep.name, *dep.vers, *dep.hash};
alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) {
some(local_cnum) { some(local_cnum) {
#debug("already have it"); debug!{"already have it"};
// We've already seen this crate // We've already seen this crate
cnum_map.insert(extrn_cnum, local_cnum); cnum_map.insert(extrn_cnum, local_cnum);
} }
none { none {
#debug("need to load it"); debug!{"need to load it"};
// This is a new one so we've got 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 // FIXME (#2404): Need better error reporting than just a bogus
// span. // span.

View file

@ -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, fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num,
path: ~[ast::ident]) -> ~[ast::def] { path: ~[ast::ident]) -> ~[ast::def] {
let mut result = ~[]; 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| { for resolve_path(cstore, cnum, path).each |elt| {
let (c, data, def) = elt; let (c, data, def) = elt;
vec::push(result, decoder::lookup_def(c, data, def)); 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]) -> path: ~[ast::ident]) ->
~[(ast::crate_num, @~[u8], ast::def_id)] { ~[(ast::crate_num, @~[u8], ast::def_id)] {
let cm = cstore::get_crate_data(cstore, cnum); let cm = cstore::get_crate_data(cstore, cnum);
#debug("resolve_path %s in crates[%d]:%s", debug!{"resolve_path %s in crates[%d]:%s",
ast_util::path_name_i(path), cnum, cm.name); ast_util::path_name_i(path), cnum, cm.name};
let mut result = ~[]; let mut result = ~[];
for decoder::resolve_path(path, cm.data).each |def| { for decoder::resolve_path(path, cm.data).each |def| {
if def.crate == ast::local_crate { 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 cstore = tcx.cstore;
let cdata = cstore::get_crate_data(cstore, class_id.crate); let cdata = cstore::get_crate_data(cstore, class_id.crate);
let all_items = ebml::get_doc(ebml::doc(cdata.data), tag_items); 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, let class_doc = expect(tcx.diag,
decoder::maybe_find_item(class_id.node, all_items), decoder::maybe_find_item(class_id.node, all_items),
|| #fmt("get_field_type: class ID %? not found", || fmt!{"get_field_type: class ID %? not found",
class_id) ); class_id} );
#debug("looking up %? : %?", def, class_doc); debug!{"looking up %? : %?", def, class_doc};
let the_field = expect(tcx.diag, let the_field = expect(tcx.diag,
decoder::maybe_find_item(def.node, class_doc), decoder::maybe_find_item(def.node, class_doc),
|| #fmt("get_field_type: in class %?, field ID %? not found", || fmt!{"get_field_type: in class %?, field ID %? not found",
class_id, def) ); class_id, def} );
#debug("got field data %?", the_field); debug!{"got field data %?", the_field};
let ty = decoder::item_type(def, the_field, tcx, cdata); let ty = decoder::item_type(def, the_field, tcx, cdata);
ret {bounds: @~[], rp: false, ty: ty}; ret {bounds: @~[], rp: false, ty: ty};
} }

View file

@ -160,16 +160,16 @@ fn get_dep_hashes(cstore: cstore) -> ~[@~str] {
for p(cstore).use_crate_map.each_value |cnum| { for p(cstore).use_crate_map.each_value |cnum| {
let cdata = cstore::get_crate_data(cstore, cnum); let cdata = cstore::get_crate_data(cstore, cnum);
let hash = decoder::get_crate_hash(cdata.data); 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}); vec::push(result, {name: @cdata.name, hash: hash});
}; };
fn lteq(a: crate_hash, b: crate_hash) -> bool { fn lteq(a: crate_hash, b: crate_hash) -> bool {
ret *a.name <= *b.name; ret *a.name <= *b.name;
} }
let sorted = std::sort::merge_sort(lteq, result); let sorted = std::sort::merge_sort(lteq, result);
#debug("sorted:"); debug!{"sorted:"};
for sorted.each |x| { 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; } fn mapper(ch: crate_hash) -> @~str { ret ch.hash; }
ret vec::map(sorted, mapper); ret vec::map(sorted, mapper);

View file

@ -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 { fn lookup_item(item_id: int, data: @~[u8]) -> ebml::doc {
let items = ebml::get_doc(ebml::doc(data), tag_items); let items = ebml::get_doc(ebml::doc(data), tag_items);
alt maybe_find_item(item_id, 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 } 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 paths = ebml::get_doc(md, tag_paths);
let eqer = |a| eq_item(a, s); let eqer = |a| eq_item(a, s);
let mut result: ~[ast::def_id] = ~[]; let mut result: ~[ast::def_id] = ~[];
#debug("resolve_path: looking up %s", s); debug!{"resolve_path: looking up %s", s};
for lookup_hash(paths, eqer, hash_path(s)).each |doc| { for lookup_hash(paths, eqer, hash_path(s)).each |doc| {
let did_doc = ebml::get_doc(doc, tag_def_id); let did_doc = ebml::get_doc(doc, tag_def_id);
vec::push(result, ebml::with_doc_data(did_doc, |d| parse_def_id(d))); 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_def(ast::def_ty(did)) }
'i' { dl_impl(did) } 'i' { dl_impl(did) }
'g' | 'j' { dl_field } '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 mut found = none;
let cls_items = alt maybe_find_item(id, items) { let cls_items = alt maybe_find_item(id, items) {
some(it) { it } some(it) { it }
none { fail (#fmt("get_class_method: class id not found \ none { fail (fmt!{"get_class_method: class id not found \
when looking up method %s", *name)) }}; when looking up method %s", *name}) }};
for ebml::tagged_docs(cls_items, tag_item_trait_method) |mid| { for ebml::tagged_docs(cls_items, tag_item_trait_method) |mid| {
let m_did = class_member_id(mid, cdata); let m_did = class_member_id(mid, cdata);
if item_name(mid) == name { if item_name(mid) == name {
@ -361,7 +361,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id,
} }
alt found { alt found {
some(found) { 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 mut found = none;
let cls_items = alt maybe_find_item(id, items) { let cls_items = alt maybe_find_item(id, items) {
some(it) { it } some(it) { it }
none { fail (#fmt("class_dtor: class id not found \ none { fail (fmt!{"class_dtor: class id not found \
when looking up dtor for %d", id)); } when looking up dtor for %d", id}); }
}; };
for ebml::tagged_docs(cls_items, tag_item_dtor) |doc| { for ebml::tagged_docs(cls_items, tag_item_dtor) |doc| {
let doc1 = ebml::get_doc(doc, tag_def_id); 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); let def_id = class_member_id(item_doc, cdata);
// Construct the def for this item. // 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); let def_like = item_to_def_like(item_doc, def_id, cdata.cnum);
// Hand the information off to the iteratee. // Hand the information off to the iteratee.
@ -468,8 +468,8 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) {
// Get the item. // Get the item.
alt maybe_find_item(def_id.node, items) { alt maybe_find_item(def_id.node, items) {
none { none {
#debug("(each_path) ignoring implicit item: %s", debug!{"(each_path) ignoring implicit item: %s",
*path); *path};
} }
some(item_doc) { some(item_doc) {
// Construct the def for this item. // Construct the def for this item.
@ -477,8 +477,8 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) {
cdata.cnum); cdata.cnum);
// Hand the information off to the iteratee. // Hand the information off to the iteratee.
#debug("(each_path) yielding implicit item: %s", debug!{"(each_path) yielding implicit item: %s",
*path); *path};
let this_path_entry = path_entry(*path, def_like); let this_path_entry = path_entry(*path, def_like);
if (!f(this_path_entry)) { if (!f(this_path_entry)) {
broken = true; // XXX: This is awful. broken = true; // XXX: This is awful.
@ -511,7 +511,7 @@ fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
id: ast::node_id, id: ast::node_id,
decode_inlined_item: decode_inlined_item decode_inlined_item: decode_inlined_item
) -> csearch::found_ast { ) -> csearch::found_ast {
#debug("Looking up item: %d", id); debug!{"Looking up item: %d", id};
let item_doc = lookup_item(id, cdata.data); let item_doc = lookup_item(id, cdata.data);
let path = vec::init(item_path(item_doc)); let path = vec::init(item_path(item_doc));
alt decode_inlined_item(cdata, tcx, 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| { for ebml::tagged_docs(mod_item, tag_mod_impl) |doc| {
let did = ebml::with_doc_data(doc, |d| parse_def_id(d)); let did = ebml::with_doc_data(doc, |d| parse_def_id(d));
let local_did = translate_def_id(cdata, did); let local_did = translate_def_id(cdata, did);
#debug("(get impls for mod) getting did %? for '%?'", debug!{"(get impls for mod) getting did %? for '%?'",
local_did, name); local_did, name};
// The impl may be defined in a different crate. Ask the caller // The impl may be defined in a different crate. Ask the caller
// to give us the metadata // to give us the metadata
let impl_cdata = get_cdata(local_did.crate); 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"; } if id.crate != ast::local_crate { ret ~"external"; }
let it = alt maybe_find_item(id.node, items) { let it = alt maybe_find_item(id.node, items) {
some(it) { it } 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)); 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) { fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
for get_meta_items(meta_items).each |mi| { 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) { 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| { 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"); out.write_str(~"\n\n");
@ -843,8 +843,8 @@ fn list_crate_deps(data: @~[u8], out: io::writer) {
out.write_str(~"=External Dependencies=\n"); out.write_str(~"=External Dependencies=\n");
for get_crate_deps(data).each |dep| { for get_crate_deps(data).each |dep| {
out.write_str(#fmt["%d %s-%s-%s\n", out.write_str(fmt!{"%d %s-%s-%s\n",
dep.cnum, *dep.name, *dep.hash, *dep.vers]); dep.cnum, *dep.name, *dep.hash, *dep.vers});
} }
out.write_str(~"\n"); 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| { do iter_crate_items(bytes) |tag, path, did| {
// Don't print out any metadata info about intrinsics // Don't print out any metadata info about intrinsics
if tag != tag_paths_foreign_path { if tag != tag_paths_foreign_path {
out.write_str(#fmt["%s (%s)\n", path, out.write_str(fmt!{"%s (%s)\n", path,
describe_def(items, did)]); describe_def(items, did)});
} }
} }
out.write_str(~"\n"); out.write_str(~"\n");

View file

@ -273,7 +273,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) {
ebml_w.end_tag(); 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, fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
params: ~[ty_param]) { params: ~[ty_param]) {
@ -318,7 +318,7 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) {
some(x) { x } some(x) { x }
none { none {
ecx.diag.handler().bug( 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)); 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_def_id(ebml_w, local_def(id));
encode_family(ebml_w, 'm'); encode_family(ebml_w, 'm');
encode_name(ebml_w, name); 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 // the impl map contains ref_ids
let impls = ecx.impl_map(id); let impls = ecx.impl_map(id);
for impls.each |i| { for impls.each |i| {
let (ident, did) = i; let (ident, did) = i;
#debug("(encoding info for module) ... encoding impl %s (%?/%?), \ debug!{"(encoding info for module) ... encoding impl %s (%?/%?), \
exported? %?", exported? %?",
*ident, *ident,
did, did,
ast_map::node_id_to_str(ecx.tcx.items, did.node), 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); ebml_w.start_tag(tag_mod_impl);
alt ecx.tcx.items.find(did.node) { 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(*index, {val: id, pos: ebml_w.writer.tell()});
vec::push(*global_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); 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_visibility(ebml_w, vis);
encode_name(ebml_w, nm); encode_name(ebml_w, nm);
encode_path(ebml_w, path, ast_map::path_name(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()}); {val: m.id, pos: ebml_w.writer.tell()});
let impl_path = vec::append_one(path, let impl_path = vec::append_one(path,
ast_map::path_name(m.ident)); 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, encode_info_for_method(ecx, ebml_w, impl_path,
should_inline(m.attrs), id, m, should_inline(m.attrs), id, m,
vec::append(class_tps, m.tps)); 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_family(ebml_w, purity_fn_family(decl.purity));
encode_type_param_bounds(ebml_w, ecx, tps); encode_type_param_bounds(ebml_w, ecx, tps);
let its_ty = node_id_to_type(ecx.tcx, id); let its_ty = node_id_to_type(ecx.tcx, id);
#debug("fn name = %s ty = %s its node id = %d", *ident, debug!{"fn name = %s ty = %s its node id = %d", *ident,
util::ppaux::ty_to_str(ecx.tcx, its_ty), id); util::ppaux::ty_to_str(ecx.tcx, its_ty), id};
encode_type(ecx, ebml_w, its_ty); encode_type(ecx, ebml_w, its_ty);
encode_path(ebml_w, path, ast_map::path_name(ident)); encode_path(ebml_w, path, ast_map::path_name(ident));
alt item { 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, impl_path: ast_map::path, should_inline: bool,
parent_id: node_id, parent_id: node_id,
m: @method, all_tps: ~[ty_param]) { m: @method, all_tps: ~[ty_param]) {
#debug("encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len()); debug!{"encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len()};
ebml_w.start_tag(tag_items_data_item); ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(m.id)); encode_def_id(ebml_w, local_def(m.id));
encode_family(ebml_w, purity_fn_family(m.decl.purity)); 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 */ /* encode ctor, then encode items */
alt i.node { alt i.node {
item_class(tps, _, _, some(ctor), m_dtor) { item_class(tps, _, _, some(ctor), m_dtor) {
#debug("encoding info for ctor %s %d", *i.ident, debug!{"encoding info for ctor %s %d", *i.ident,
ctor.node.id); ctor.node.id};
vec::push(*index, { vec::push(*index, {
val: ctor.node.id, val: ctor.node.id,
pos: ebml_w.writer.tell() pos: ebml_w.writer.tell()

View file

@ -62,7 +62,7 @@ fn mk_filesearch(maybe_sysroot: option<path>,
} }
let sysroot = get_sysroot(maybe_sysroot); let sysroot = get_sysroot(maybe_sysroot);
#debug("using sysroot = %s", sysroot); debug!{"using sysroot = %s", sysroot};
{sysroot: sysroot, {sysroot: sysroot,
addl_lib_search_paths: addl_lib_search_paths, addl_lib_search_paths: addl_lib_search_paths,
target_triple: target_triple} as filesearch 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> { fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option<T> {
let mut rslt = none; let mut rslt = none;
for filesearch.lib_search_paths().each |lib_search_path| { 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| { for os::list_dir_path(lib_search_path).each |path| {
#debug("testing %s", path); debug!{"testing %s", path};
let maybe_picked = pick(path); let maybe_picked = pick(path);
if option::is_some(maybe_picked) { if option::is_some(maybe_picked) {
#debug("picked %s", path); debug!{"picked %s", path};
rslt = maybe_picked; rslt = maybe_picked;
break; break;
} else { } else {
#debug("rejected %s", path); debug!{"rejected %s", path};
} }
} }
if option::is_some(rslt) { break; } 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. // The name of the directory rustc expects libraries to be located.
// On Unix should be "lib", on windows "bin" // On Unix should be "lib", on windows "bin"
fn libdir() -> ~str { fn libdir() -> ~str {
let libdir = #env("CFG_LIBDIR"); let libdir = env!{"CFG_LIBDIR"};
if str::is_empty(libdir) { if str::is_empty(libdir) {
fail ~"rustc compiled without CFG_LIBDIR environment variable"; fail ~"rustc compiled without CFG_LIBDIR environment variable";
} }

View file

@ -41,7 +41,7 @@ fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} {
some(t) { ret t; } some(t) { ret t; }
none { none {
cx.diag.span_fatal( 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 = ~[]; let mut matches = ~[];
filesearch::search(filesearch, |path| { filesearch::search(filesearch, |path| {
#debug("inspecting file %s", path); debug!{"inspecting file %s", path};
let f: ~str = path::basename(path); let f: ~str = path::basename(path);
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) { if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
#debug("skipping %s, doesn't look like %s*%s", path, prefix, debug!{"skipping %s, doesn't look like %s*%s", path, prefix,
suffix); suffix};
option::none::<()> option::none::<()>
} else { } else {
#debug("%s is a candidate", path); debug!{"%s is a candidate", path};
alt get_metadata_section(cx.os, path) { alt get_metadata_section(cx.os, path) {
option::some(cvec) { option::some(cvec) {
if !crate_matches(cvec, cx.metas, cx.hash) { 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::<()> option::none::<()>
} else { } else {
#debug("found %s with matching metadata", path); debug!{"found %s with matching metadata", path};
vec::push(matches, {ident: path, data: cvec}); vec::push(matches, {ident: path, data: cvec});
option::none::<()> option::none::<()>
} }
} }
_ { _ {
#debug("could not load metadata for %s", path); debug!{"could not load metadata for %s", path};
option::none::<()> option::none::<()>
} }
} }
@ -104,10 +104,10 @@ fn find_library_crate_aux(cx: ctxt,
some(matches[0]) some(matches[0])
} else { } else {
cx.diag.span_err( 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:"); cx.diag.handler().note(~"candidates:");
for matches.each |match| { 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); let attrs = decoder::get_crate_attributes(match.data);
note_linkage_attrs(cx.diag, attrs); 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]) { fn note_linkage_attrs(diag: span_handler, attrs: ~[ast::attribute]) {
for attr::find_linkage_attrs(attrs).each |attr| { 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], fn metadata_matches(extern_metas: ~[@ast::meta_item],
local_metas: ~[@ast::meta_item]) -> bool { local_metas: ~[@ast::meta_item]) -> bool {
#debug("matching %u metadata requirements against %u items", debug!{"matching %u metadata requirements against %u items",
vec::len(local_metas), vec::len(extern_metas)); vec::len(local_metas), vec::len(extern_metas)};
#debug("crate metadata:"); debug!{"crate metadata:"};
for extern_metas.each |have| { 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| { 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) { 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; ret false;
} }
} }

View file

@ -297,16 +297,16 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
} }
'B' { ty::mk_opaque_box(st.tcx) } 'B' { ty::mk_opaque_box(st.tcx) }
'a' { 'a' {
#debug("saw a class"); debug!{"saw a class"};
assert (next(st) == '['); assert (next(st) == '[');
#debug("saw a ["); debug!{"saw a ["};
let did = parse_def(st, conv); let did = parse_def(st, conv);
#debug("parsed a def_id %?", did); debug!{"parsed a def_id %?", did};
let substs = parse_substs(st, conv); let substs = parse_substs(st, conv);
assert (next(st) == ']'); assert (next(st) == ']');
ret ty::mk_class(st.tcx, did, substs); 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); let len = vec::len(buf);
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; }
if colon_idx == len { if colon_idx == len {
#error("didn't find ':' when parsing def id"); error!{"didn't find ':' when parsing def id"};
fail; fail;
} }
let crate_part = vec::slice(buf, 0u, colon_idx); 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) { let crate_num = alt uint::parse_buf(crate_part, 10u) {
some(cn) { cn as int } some(cn) { cn as int }
none { fail (#fmt("internal error: parse_def_id: crate number \ none { fail (fmt!{"internal error: parse_def_id: crate number \
expected, but found %?", crate_part)); } expected, but found %?", crate_part}); }
}; };
let def_num = alt uint::parse_buf(def_part, 10u) { let def_num = alt uint::parse_buf(def_part, 10u) {
some(dn) { dn as int } some(dn) { dn as int }
none { fail (#fmt("internal error: parse_def_id: id expected, but \ none { fail (fmt!{"internal error: parse_def_id: id expected, but \
found %?", def_part)); } found %?", def_part}); }
}; };
ret {crate: crate_num, node: def_num}; ret {crate: crate_num, node: def_num};
} }

View file

@ -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_closure_ptr(ty::ck_uniq) { w.write_str(&"C~"); }
ty::ty_opaque_box { w.write_char('B'); } ty::ty_opaque_box { w.write_char('B'); }
ty::ty_class(def, substs) { ty::ty_class(def, substs) {
#debug("~~~~ %s", ~"a["); debug!{"~~~~ %s", ~"a["};
w.write_str(&"a["); w.write_str(&"a[");
let s = cx.ds(def); let s = cx.ds(def);
#debug("~~~~ %s", s); debug!{"~~~~ %s", s};
w.write_str(s); w.write_str(s);
#debug("~~~~ %s", ~"|"); debug!{"~~~~ %s", ~"|"};
w.write_char('|'); w.write_char('|');
enc_substs(w, cx, substs); enc_substs(w, cx, substs);
#debug("~~~~ %s", ~"]"); debug!{"~~~~ %s", ~"]"};
w.write_char(']'); w.write_char(']');
} }
} }

View file

@ -89,9 +89,9 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
path: ast_map::path, path: ast_map::path,
ii: ast::inlined_item, ii: ast::inlined_item,
maps: maps) { maps: maps) {
#debug["> Encoding inlined item: %s::%s (%u)", debug!{"> Encoding inlined item: %s::%s (%u)",
ast_map::path_to_str(path), *ii.ident(), 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); let id_range = ast_util::compute_id_range_for_inlined_item(ii);
do ebml_w.wr_tag(c::tag_ast as uint) { 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); 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(), ast_map::path_to_str(path), *ii.ident(),
ebml_w.writer.tell()]; ebml_w.writer.tell()};
} }
fn decode_inlined_item(cdata: cstore::crate_metadata, 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) { alt par_doc.opt_child(c::tag_ast) {
none { none } none { none }
some(ast_doc) { 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 ast_dsr = ebml::ebml_deserializer(ast_doc);
let from_id_range = ast_util::deserialize_id_range(ast_dsr); let from_id_range = ast_util::deserialize_id_range(ast_dsr);
let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); 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); let ii = renumber_ast(xcx, raw_ii);
ast_map::map_decoded_item(tcx.sess.diagnostic(), ast_map::map_decoded_item(tcx.sess.diagnostic(),
dcx.tcx.items, path, ii); dcx.tcx.items, path, ii);
#debug["Fn named: %s", *ii.ident()]; debug!{"Fn named: %s", *ii.ident()};
decode_side_tables(xcx, ast_doc); decode_side_tables(xcx, ast_doc);
#debug["< Decoded inlined fn: %s::%s", debug!{"< Decoded inlined fn: %s::%s",
ast_map::path_to_str(path), *ii.ident()]; ast_map::path_to_str(path), *ii.ident()};
alt ii { alt ii {
ast::ii_item(i) { ast::ii_item(i) {
#debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", debug!{">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<",
syntax::print::pprust::item_to_str(i)); 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) { id: ast::node_id) {
let tcx = ecx.tcx; 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 option::iter(tcx.def_map.find(id)) |def| {
do ebml_w.tag(c::tag_table_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 id0 = entry_doc[c::tag_table_id as uint].as_int();
let id = xcx.tr_id(id0); 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)", found for id %d (orig %d)",
tag, id, id0]; tag, id, id0};
if tag == (c::tag_table_mutbl as uint) { if tag == (c::tag_table_mutbl as uint) {
dcx.maps.mutbl_map.insert(id, ()); dcx.maps.mutbl_map.insert(id, ());
@ -884,11 +884,11 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
dcx.tcx.borrowings.insert(id, borrow); dcx.tcx.borrowings.insert(id, borrow);
} else { } else {
xcx.dcx.tcx.sess.bug( 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)] #[cfg(test)]
fn roundtrip(in_item: @ast::item) { 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 mbuf = io::mem_buffer();
let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf)); let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf));
encode_item_ast(ebml_w, in_item); encode_item_ast(ebml_w, in_item);
let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf)); let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf));
let out_item = decode_item_ast(ebml_doc); 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 = let exp_str =
io::with_str_writer(|w| ast::serialize_item(w, *in_item) ); io::with_str_writer(|w| ast::serialize_item(w, *in_item) );
let out_str = let out_str =
io::with_str_writer(|w| ast::serialize_item(w, *out_item) ); io::with_str_writer(|w| ast::serialize_item(w, *out_item) );
#debug["expected string: %s", exp_str]; debug!{"expected string: %s", exp_str};
#debug["actual string : %s", out_str]; debug!{"actual string : %s", out_str};
assert exp_str == out_str; assert exp_str == out_str;
} }
@ -953,7 +953,7 @@ fn roundtrip(in_item: @ast::item) {
#[test] #[test]
fn test_basic() { fn test_basic() {
let ext_cx = mk_ctxt(); let ext_cx = mk_ctxt();
roundtrip(#ast(item){ roundtrip(#ast[item]{
fn foo() {} fn foo() {}
}); });
} }
@ -961,7 +961,7 @@ fn test_basic() {
#[test] #[test]
fn test_smalltalk() { fn test_smalltalk() {
let ext_cx = mk_ctxt(); let ext_cx = mk_ctxt();
roundtrip(#ast(item){ roundtrip(#ast[item]{
fn foo() -> int { 3 + 4 } // first smalltalk program ever executed. fn foo() -> int { 3 + 4 } // first smalltalk program ever executed.
}); });
} }
@ -969,7 +969,7 @@ fn test_smalltalk() {
#[test] #[test]
fn test_more() { fn test_more() {
let ext_cx = mk_ctxt(); let ext_cx = mk_ctxt();
roundtrip(#ast(item){ roundtrip(#ast[item]{
fn foo(x: uint, y: uint) -> uint { fn foo(x: uint, y: uint) -> uint {
let z = x + y; let z = x + y;
ret z; ret z;
@ -980,14 +980,14 @@ fn test_more() {
#[test] #[test]
fn test_simplification() { fn test_simplification() {
let ext_cx = mk_ctxt(); 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 new_int_alist<B: copy>() -> alist<int, B> {
fn eq_int(&&a: int, &&b: int) -> bool { a == b } fn eq_int(&&a: int, &&b: int) -> bool { a == b }
ret {eq_fn: eq_int, mut data: ~[]}; ret {eq_fn: eq_int, mut data: ~[]};
} }
}); });
let item_out = simplify_ast(item_in); let item_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> { fn new_int_alist<B: copy>() -> alist<int, B> {
ret {eq_fn: eq_int, mut data: ~[]}; ret {eq_fn: eq_int, mut data: ~[]};
} }

View file

@ -255,16 +255,16 @@ fn check_crate(tcx: ty::ctxt,
if tcx.sess.borrowck_stats() { if tcx.sess.borrowck_stats() {
io::println(~"--- borrowck stats ---"); io::println(~"--- borrowck stats ---");
io::println(#fmt["paths requiring guarantees: %u", io::println(fmt!{"paths requiring guarantees: %u",
bccx.guaranteed_paths]); bccx.guaranteed_paths});
io::println(#fmt["paths requiring loans : %s", io::println(fmt!{"paths requiring loans : %s",
make_stat(bccx, bccx.loaned_paths_same)]); make_stat(bccx, bccx.loaned_paths_same)});
io::println(#fmt["paths requiring imm loans : %s", io::println(fmt!{"paths requiring imm loans : %s",
make_stat(bccx, bccx.loaned_paths_imm)]); make_stat(bccx, bccx.loaned_paths_imm)});
io::println(#fmt["stable paths : %s", io::println(fmt!{"stable paths : %s",
make_stat(bccx, bccx.stable_paths)]); make_stat(bccx, bccx.stable_paths)});
io::println(#fmt["paths requiring purity : %s", io::println(fmt!{"paths requiring purity : %s",
make_stat(bccx, bccx.req_pure_paths)]); make_stat(bccx, bccx.req_pure_paths)});
} }
ret (bccx.root_map, bccx.mutbl_map); 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 { fn make_stat(bccx: borrowck_ctxt, stat: uint) -> ~str {
let stat_f = stat as float; let stat_f = stat as float;
let total = bccx.guaranteed_paths 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) { fn report(err: bckerr) {
self.span_err( self.span_err(
err.cmt.span, err.cmt.span,
#fmt["illegal borrow: %s", fmt!{"illegal borrow: %s",
self.bckerr_code_to_str(err.code)]); self.bckerr_code_to_str(err.code)});
} }
fn span_err(s: span, m: ~str) { 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_special(sk_heap_upvar) { ~"heap-upvar" }
cat_stack_upvar(_) { ~"stack-upvar" } cat_stack_upvar(_) { ~"stack-upvar" }
cat_rvalue { ~"rvalue" } cat_rvalue { ~"rvalue" }
cat_local(node_id) { #fmt["local(%d)", node_id] } cat_local(node_id) { fmt!{"local(%d)", node_id} }
cat_binding(node_id) { #fmt["binding(%d)", node_id] } cat_binding(node_id) { fmt!{"binding(%d)", node_id} }
cat_arg(node_id) { #fmt["arg(%d)", node_id] } cat_arg(node_id) { fmt!{"arg(%d)", node_id} }
cat_deref(cmt, derefs, ptr) { cat_deref(cmt, derefs, ptr) {
#fmt["%s->(%s, %u)", self.cat_to_repr(cmt.cat), fmt!{"%s->(%s, %u)", self.cat_to_repr(cmt.cat),
self.ptr_sigil(ptr), derefs] self.ptr_sigil(ptr), derefs}
} }
cat_comp(cmt, comp) { 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) } 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 { fn lp_to_str(lp: @loan_path) -> ~str {
alt *lp { alt *lp {
lp_local(node_id) { lp_local(node_id) {
#fmt["local(%d)", node_id] fmt!{"local(%d)", node_id}
} }
lp_arg(node_id) { lp_arg(node_id) {
#fmt["arg(%d)", node_id] fmt!{"arg(%d)", node_id}
} }
lp_deref(lp, ptr) { lp_deref(lp, ptr) {
#fmt["%s->(%s)", self.lp_to_str(lp), fmt!{"%s->(%s)", self.lp_to_str(lp),
self.ptr_sigil(ptr)] self.ptr_sigil(ptr)}
} }
lp_comp(lp, comp) { lp_comp(lp, comp) {
#fmt["%s.%s", self.lp_to_str(lp), fmt!{"%s.%s", self.lp_to_str(lp),
self.comp_to_repr(comp)] self.comp_to_repr(comp)}
} }
} }
} }
fn cmt_to_repr(cmt: cmt) -> ~str { 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), self.cat_to_repr(cmt.cat),
cmt.id, cmt.id,
self.mut_to_str(cmt.mutbl), self.mut_to_str(cmt.mutbl),
cmt.lp.map_default(~"none", |p| self.lp_to_str(p) ), cmt.lp.map_default(~"none", |p| self.lp_to_str(p) ),
ty_to_str(self.tcx, cmt.ty)] ty_to_str(self.tcx, cmt.ty)}
} }
fn cmt_to_str(cmt: cmt) -> ~str { 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_local(_) { mut_str + ~" local variable" }
cat_binding(_) { ~"pattern binding" } cat_binding(_) { ~"pattern binding" }
cat_arg(_) { ~"argument" } cat_arg(_) { ~"argument" }
cat_deref(_, _, pk) { #fmt["dereference of %s %s pointer", cat_deref(_, _, pk) { fmt!{"dereference of %s %s pointer",
mut_str, self.ptr_sigil(pk)] } mut_str, self.ptr_sigil(pk)} }
cat_stack_upvar(_) { cat_stack_upvar(_) {
~"captured outer " + mut_str + ~" variable in a stack closure" ~"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 { fn bckerr_code_to_str(code: bckerr_code) -> ~str {
alt code { alt code {
err_mutbl(req, act) { err_mutbl(req, act) {
#fmt["creating %s alias to aliasable, %s memory", fmt!{"creating %s alias to aliasable, %s memory",
self.mut_to_str(req), self.mut_to_str(act)] self.mut_to_str(req), self.mut_to_str(act)}
} }
err_mut_uniq { err_mut_uniq {
~"unique value in aliasable, mutable location" ~"unique value in aliasable, mutable location"
@ -626,16 +626,16 @@ impl to_str_methods for borrowck_ctxt {
~"rooting is not permitted" ~"rooting is not permitted"
} }
err_out_of_root_scope(super_scope, sub_scope) { 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", but can only be rooted for lifetime %s",
self.region_to_str(sub_scope), 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) { 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", but the borrowed value only has lifetime %s",
self.region_to_str(sub_scope), self.region_to_str(sub_scope),
self.region_to_str(super_scope)] self.region_to_str(super_scope)}
} }
} }
} }

View file

@ -89,8 +89,8 @@ fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind {
some(k) {k} some(k) {k}
none { none {
tcx.sess.bug( tcx.sess.bug(
#fmt["deref_cat() invoked on non-derefable type %s", fmt!{"deref_cat() invoked on non-derefable type %s",
ty_to_str(tcx, t)]); ty_to_str(tcx, t)});
} }
} }
} }
@ -118,15 +118,15 @@ impl public_methods for borrowck_ctxt {
_ { _ {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
expr.span, expr.span,
#fmt["Borrowing of non-derefable type `%s`", fmt!{"Borrowing of non-derefable type `%s`",
ty_to_str(self.tcx, expr_ty)]); ty_to_str(self.tcx, expr_ty)});
} }
} }
} }
fn cat_expr(expr: @ast::expr) -> cmt { fn cat_expr(expr: @ast::expr) -> cmt {
#debug["cat_expr: id=%d expr=%s", debug!{"cat_expr: id=%d expr=%s",
expr.id, pprust::expr_to_str(expr)]; expr.id, pprust::expr_to_str(expr)};
let tcx = self.tcx; let tcx = self.tcx;
let expr_ty = tcx.ty(expr); let expr_ty = tcx.ty(expr);
@ -142,8 +142,8 @@ impl public_methods for borrowck_ctxt {
none { none {
tcx.sess.span_bug( tcx.sess.span_bug(
e_base.span, e_base.span,
#fmt["Explicit deref of non-derefable type `%s`", fmt!{"Explicit deref of non-derefable type `%s`",
ty_to_str(tcx, tcx.ty(e_base))]); ty_to_str(tcx, tcx.ty(e_base))});
} }
} }
} }
@ -318,8 +318,8 @@ impl public_methods for borrowck_ctxt {
none { none {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
node.span(), node.span(),
#fmt["Cannot find field `%s` in type `%s`", fmt!{"Cannot find field `%s` in type `%s`",
*f_name, ty_to_str(self.tcx, base_cmt.ty)]); *f_name, ty_to_str(self.tcx, base_cmt.ty)});
} }
}; };
let m = self.inherited_mutability(base_cmt.mutbl, f_mutbl); let m = self.inherited_mutability(base_cmt.mutbl, f_mutbl);
@ -382,8 +382,8 @@ impl public_methods for borrowck_ctxt {
none { none {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
expr.span, expr.span,
#fmt["Explicit index of non-index type `%s`", fmt!{"Explicit index of non-index type `%s`",
ty_to_str(self.tcx, base_cmt.ty)]); ty_to_str(self.tcx, base_cmt.ty)});
} }
}; };

View file

@ -157,12 +157,12 @@ impl methods for check_loan_ctxt {
callee_span: span) { callee_span: span) {
let tcx = self.tcx(); 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)", callee_id=%d, ty=%s)",
pc, pc,
opt_expr.map(|e| pprust::expr_to_str(e) ), opt_expr.map(|e| pprust::expr_to_str(e) ),
callee_id, 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 // 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 // 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 { ast::impure_fn | ast::unsafe_fn | ast::extern_fn {
self.report_purity_error( self.report_purity_error(
pc, callee_span, pc, callee_span,
#fmt["access to %s function", fmt!{"access to %s function",
pprust::purity_to_str(fn_ty.purity)]); 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) { (m_mutbl, m_imm) | (m_imm, m_mutbl) {
self.bccx.span_err( self.bccx.span_err(
new_loan.cmt.span, new_loan.cmt.span,
#fmt["loan of %s as %s \ fmt!{"loan of %s as %s \
conflicts with prior loan", conflicts with prior loan",
self.bccx.cmt_to_str(new_loan.cmt), 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( self.bccx.span_note(
old_loan.cmt.span, old_loan.cmt.span,
#fmt["prior loan as %s granted here", fmt!{"prior loan as %s granted here",
self.bccx.mut_to_str(old_loan.mutbl)]); 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) { fn check_assignment(at: assignment_type, ex: @ast::expr) {
let cmt = self.bccx.cat_expr(ex); let cmt = self.bccx.cat_expr(ex);
#debug["check_assignment(cmt=%s)", debug!{"check_assignment(cmt=%s)",
self.bccx.cmt_to_repr(cmt)]; self.bccx.cmt_to_repr(cmt)};
if self.in_ctor && self.is_self_field(cmt) if self.in_ctor && self.is_self_field(cmt)
&& at.checked_by_liveness() { && at.checked_by_liveness() {
@ -354,12 +354,12 @@ impl methods for check_loan_ctxt {
m_imm { m_imm {
self.bccx.span_err( self.bccx.span_err(
ex.span, ex.span,
#fmt["%s prohibited due to outstanding loan", fmt!{"%s prohibited due to outstanding loan",
at.ing_form(self.bccx.cmt_to_str(cmt))]); at.ing_form(self.bccx.cmt_to_str(cmt))});
self.bccx.span_note( self.bccx.span_note(
loan.cmt.span, loan.cmt.span,
#fmt["loan of %s granted here", fmt!{"loan of %s granted here",
self.bccx.cmt_to_str(loan.cmt)]); self.bccx.cmt_to_str(loan.cmt)});
ret; ret;
} }
} }
@ -386,17 +386,17 @@ impl methods for check_loan_ctxt {
pc_pure_fn { pc_pure_fn {
self.tcx().sess.span_err( self.tcx().sess.span_err(
sp, sp,
#fmt["%s prohibited in pure context", msg]); fmt!{"%s prohibited in pure context", msg});
} }
pc_cmt(e) { pc_cmt(e) {
if self.reported.insert(e.cmt.id, ()) { if self.reported.insert(e.cmt.id, ()) {
self.tcx().sess.span_err( self.tcx().sess.span_err(
e.cmt.span, e.cmt.span,
#fmt["illegal borrow unless pure: %s", fmt!{"illegal borrow unless pure: %s",
self.bccx.bckerr_code_to_str(e.code)]); self.bccx.bckerr_code_to_str(e.code)});
self.tcx().sess.span_note( self.tcx().sess.span_note(
sp, 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) { fn check_move_out_from_cmt(cmt: cmt) {
#debug["check_move_out_from_cmt(cmt=%s)", debug!{"check_move_out_from_cmt(cmt=%s)",
self.bccx.cmt_to_repr(cmt)]; self.bccx.cmt_to_repr(cmt)};
alt cmt.cat { alt cmt.cat {
// Rvalues, locals, and arguments can be moved: // Rvalues, locals, and arguments can be moved:
@ -427,7 +427,7 @@ impl methods for check_loan_ctxt {
_ { _ {
self.bccx.span_err( self.bccx.span_err(
cmt.span, 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; ret;
} }
} }
@ -442,12 +442,12 @@ impl methods for check_loan_ctxt {
for self.walk_loans_of(cmt.id, lp) |loan| { for self.walk_loans_of(cmt.id, lp) |loan| {
self.bccx.span_err( self.bccx.span_err(
cmt.span, cmt.span,
#fmt["moving out of %s prohibited due to outstanding loan", fmt!{"moving out of %s prohibited due to outstanding loan",
self.bccx.cmt_to_str(cmt)]); self.bccx.cmt_to_str(cmt)});
self.bccx.span_note( self.bccx.span_note(
loan.cmt.span, loan.cmt.span,
#fmt["loan of %s granted here", fmt!{"loan of %s granted here",
self.bccx.cmt_to_str(loan.cmt)]); self.bccx.cmt_to_str(loan.cmt)});
ret; ret;
} }
} }
@ -462,8 +462,8 @@ impl methods for check_loan_ctxt {
some(lp) { lp } some(lp) { lp }
}; };
for self.walk_loans_of(cmt.id, lp) |_loan| { for self.walk_loans_of(cmt.id, lp) |_loan| {
#debug["Removing last use entry %? due to outstanding loan", debug!{"Removing last use entry %? due to outstanding loan",
expr.id]; expr.id};
self.bccx.last_use_map.remove(expr.id); self.bccx.last_use_map.remove(expr.id);
ret; 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, sp: span, id: ast::node_id, &&self: check_loan_ctxt,
visitor: visit::vt<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.in_ctor) {
do save_and_restore(self.declared_purity) { do save_and_restore(self.declared_purity) {
do save_and_restore(self.fn_args) { 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, fn check_loans_in_local(local: @ast::local,

View file

@ -90,7 +90,7 @@ fn req_loans_in_expr(ex: @ast::expr,
let tcx = bccx.tcx; let tcx = bccx.tcx;
let old_root_ub = self.root_ub; 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: // If this expression is borrowed, have to ensure it remains valid:
for tcx.borrowings.find(ex.id).each |borrow| { for tcx.borrowings.find(ex.id).each |borrow| {
@ -258,10 +258,10 @@ impl methods for gather_loan_ctxt {
self.bccx.guaranteed_paths += 1; 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.cmt_to_repr(cmt),
self.bccx.mut_to_str(req_mutbl), self.bccx.mut_to_str(req_mutbl),
region_to_str(self.tcx(), scope_r)]; region_to_str(self.tcx(), scope_r)};
let _i = indenter(); let _i = indenter();
alt cmt.lp { alt cmt.lp {
@ -290,7 +290,7 @@ impl methods for gather_loan_ctxt {
if self.tcx().sess.borrowck_note_loan() { if self.tcx().sess.borrowck_note_loan() {
self.bccx.span_note( self.bccx.span_note(
cmt.span, cmt.span,
#fmt["immutable loan required"]); fmt!{"immutable loan required"});
} }
} else { } else {
self.bccx.loaned_paths_same += 1; self.bccx.loaned_paths_same += 1;
@ -344,7 +344,7 @@ impl methods for gather_loan_ctxt {
if self.tcx().sess.borrowck_note_pure() { if self.tcx().sess.borrowck_note_pure() {
self.bccx.span_note( self.bccx.span_note(
cmt.span, 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, // 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. // 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), 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 _i = indenter();
let tcx = self.tcx(); let tcx = self.tcx();
@ -463,8 +463,8 @@ impl methods for gather_loan_ctxt {
.find(pat.id) { .find(pat.id) {
some(ast::def_variant(enum_did, _)) {enum_did} some(ast::def_variant(enum_did, _)) {enum_did}
e {tcx.sess.span_bug(pat.span, e {tcx.sess.span_bug(pat.span,
#fmt["resolved to %?, \ fmt!{"resolved to %?, \
not variant", e])} not variant", e})}
}; };
for subpats.each |subpat| { for subpats.each |subpat| {
@ -475,11 +475,11 @@ impl methods for gather_loan_ctxt {
ast::pat_ident(_, none) if self.pat_is_variant(pat) { ast::pat_ident(_, none) if self.pat_is_variant(pat) {
// nullary variant // nullary variant
#debug["nullary variant"]; debug!{"nullary variant"};
} }
ast::pat_ident(id, o_pat) { ast::pat_ident(id, o_pat) {
// x or x @ p --- `x` must remain valid for the scope of the alt // 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 // Note: there is a discussion of the function of
// cat_discr in the method preserve(): // cat_discr in the method preserve():

View file

@ -58,9 +58,9 @@ impl loan_methods for loan_ctxt {
} }
fn loan(cmt: cmt, req_mutbl: ast::mutability) -> bckres<()> { 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.cmt_to_repr(cmt),
self.bccx.mut_to_str(req_mutbl)]; self.bccx.mut_to_str(req_mutbl)};
let _i = indenter(); let _i = indenter();
// see stable() above; should only be called when `cmt` is lendable // see stable() above; should only be called when `cmt` is lendable

View file

@ -58,9 +58,9 @@ impl private_methods for &preserve_ctxt {
fn tcx() -> ty::ctxt { self.bccx.tcx } fn tcx() -> ty::ctxt { self.bccx.tcx }
fn preserve(cmt: cmt) -> bckres<preserve_condition> { 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.bccx.cmt_to_repr(cmt), self.root_ub,
self.root_managed_data]; self.root_managed_data};
let _i = indenter(); let _i = indenter();
alt cmt.cat { alt cmt.cat {
@ -148,7 +148,7 @@ impl private_methods for &preserve_ctxt {
// otherwise we have no guarantee the pointer will stay // otherwise we have no guarantee the pointer will stay
// live, so we must root the pointer (i.e., inc the ref // live, so we must root the pointer (i.e., inc the ref
// count) for the duration of the loan. // 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 { if base.mutbl == m_imm {
let non_rooting_ctxt = let non_rooting_ctxt =
preserve_ctxt({root_managed_data: false with **self}); preserve_ctxt({root_managed_data: false with **self});
@ -157,12 +157,12 @@ impl private_methods for &preserve_ctxt {
ok(pc_ok) ok(pc_ok)
} }
ok(pc_if_pure(_)) { 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) self.attempt_root(cmt, base, derefs)
} }
err(e) => { err(e) => {
#debug["must root @T, err: %s", debug!{"must root @T, err: %s",
self.bccx.bckerr_code_to_str(e.code)]; self.bccx.bckerr_code_to_str(e.code)};
self.attempt_root(cmt, base, derefs) self.attempt_root(cmt, base, derefs)
} }
} }

View file

@ -43,16 +43,16 @@ fn check_capture_clause(tcx: ty::ctxt,
if !vec::any(*freevars, |fv| fv.def == cap_def ) { if !vec::any(*freevars, |fv| fv.def == cap_def ) {
tcx.sess.span_warn( tcx.sess.span_warn(
cap_item.span, cap_item.span,
#fmt("captured variable `%s` not used in closure", fmt!{"captured variable `%s` not used in closure",
*cap_item.name)); *cap_item.name});
} }
let cap_def_id = ast_util::def_id_of_def(cap_def).node; let cap_def_id = ast_util::def_id_of_def(cap_def).node;
if !seen_defs.insert(cap_def_id, ()) { if !seen_defs.insert(cap_def_id, ()) {
tcx.sess.span_err( tcx.sess.span_err(
cap_item.span, cap_item.span,
#fmt("variable `%s` captured more than once", fmt!{"variable `%s` captured more than once",
*cap_item.name)); *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 // first add entries for anything explicitly named in the cap clause
for (*cap_clause).each |cap_item| { for (*cap_clause).each |cap_item| {
#debug("Doing capture var: %s (%?)", debug!{"Doing capture var: %s (%?)",
*cap_item.name, cap_item.id); *cap_item.name, cap_item.id};
let cap_def = tcx.def_map.get(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; let cap_def_id = ast_util::def_id_of_def(cap_def).node;

View file

@ -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>) { 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 { alt e.node {
expr_assign(_, ex) | expr_assign(_, ex) |
expr_unary(box(_), ex) | expr_unary(uniq(_), 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) { if vec::len(ts) != vec::len(*bounds) {
// Fail earlier to make debugging easier // 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 = \ mismatch between actual and declared bounds: actual = \
%s (%u tys), declared = %? (%u tys)", %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| { do vec::iter2(ts, *bounds) |ty, bound| {
check_bounds(cx, e.id, e.span, 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( cx.tcx.sess.span_bug(
sp, 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(*)) => { some(ty::re_bound(*)) | some(ty::re_var(*)) => {
cx.tcx.sess.span_bug( cx.tcx.sess.span_bug(
source.span, source.span,
#fmt["bad region found in kind: %?", target_substs.self_r]); fmt!{"bad region found in kind: %?", target_substs.self_r});
} }
} }

View file

@ -132,8 +132,8 @@ class LanguageItemCollector {
some(original_def_id) some(original_def_id)
if original_def_id != item_def_id => { if original_def_id != item_def_id => {
self.session.err(#fmt("duplicate entry for `%s`", self.session.err(fmt!{"duplicate entry for `%s`",
value)); value});
} }
some(_) | none => { some(_) | none => {
// OK. // OK.
@ -191,7 +191,7 @@ class LanguageItemCollector {
for self.item_refs.each |key, item_ref| { for self.item_refs.each |key, item_ref| {
alt copy *item_ref { alt copy *item_ref {
none => { none => {
self.session.err(#fmt("no item found for `%s`", key)); self.session.err(fmt!{"no item found for `%s`", key});
} }
some(did) => { some(did) => {
// OK. // OK.

View file

@ -253,8 +253,8 @@ impl methods for ctxt {
self.span_lint( self.span_lint(
new_ctxt.get_level(unrecognized_lint), new_ctxt.get_level(unrecognized_lint),
meta.span, meta.span,
#fmt("unknown `%s` attribute: `%s`", fmt!{"unknown `%s` attribute: `%s`",
level_to_str(level), *lintname)); level_to_str(level), *lintname});
} }
some(lint) { some(lint) {
@ -263,9 +263,9 @@ impl methods for ctxt {
self.span_lint( self.span_lint(
forbid, forbid,
meta.span, meta.span,
#fmt("%s(%s) overruled by outer forbid(%s)", fmt!{"%s(%s) overruled by outer forbid(%s)",
level_to_str(level), level_to_str(level),
*lintname, *lintname)); *lintname, *lintname});
} }
// we do multiple unneeded copies of the // 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, fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
_body: ast::blk, span: span, id: ast::node_id) { _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 // don't complain about blocks, since they tend to get their modes
// specified from the outside // 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; let mut counter = 0;
do vec::iter2(fn_ty.inputs, decl.inputs) |arg_ty, arg_ast| { do vec::iter2(fn_ty.inputs, decl.inputs) |arg_ty, arg_ast| {
counter += 1; counter += 1;
#debug["arg %d, ty=%s, mode=%s", debug!{"arg %d, ty=%s, mode=%s",
counter, counter,
ty_to_str(tcx, arg_ty.ty), ty_to_str(tcx, arg_ty.ty),
mode_to_str(arg_ast.mode)]; mode_to_str(arg_ast.mode)};
alt arg_ast.mode { alt arg_ast.mode {
ast::expl(ast::by_copy) => { ast::expl(ast::by_copy) => {
/* always allow 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( tcx.sess.span_lint(
deprecated_mode, id, id, deprecated_mode, id, id,
span, span,
#fmt["argument %d uses an explicit mode", counter]); fmt!{"argument %d uses an explicit mode", counter});
} }
ast::infer(_) { ast::infer(_) {
@ -472,9 +472,9 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
tcx.sess.span_lint( tcx.sess.span_lint(
deprecated_mode, id, id, deprecated_mode, id, id,
span, span,
#fmt["argument %d uses the default mode \ fmt!{"argument %d uses the default mode \
but shouldn't", but shouldn't",
counter]); counter});
} }
} }
} }

View file

@ -153,11 +153,11 @@ fn check_crate(tcx: ty::ctxt,
} }
impl of to_str::to_str for live_node { 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 { 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); vec::push(self.lnks, lnk);
self.num_live_nodes += 1u; self.num_live_nodes += 1u;
#debug["%s is of kind %?", ln.to_str(), lnk]; debug!{"%s is of kind %?", ln.to_str(), lnk};
ln ln
} }
@ -252,7 +252,7 @@ class ir_maps {
let ln = self.add_live_node(lnk); let ln = self.add_live_node(lnk);
self.live_node_map.insert(node_id, ln); 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 { 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 v
} }
@ -281,7 +281,7 @@ class ir_maps {
some(var) {var} some(var) {var}
none { none {
self.tcx.sess.span_bug( 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) { fn add_last_use(expr_id: node_id, var: variable) {
let vk = self.var_kinds[*var]; 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 { alt vk {
vk_arg(id, name, by_move) | vk_arg(id, name, by_move) |
vk_arg(id, name, by_copy) | 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_ref) | vk_arg(_, _, by_mutbl_ref) |
vk_arg(_, _, by_val) | vk_self | vk_field(_) | vk_implicit_ret { 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, fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
sp: span, id: node_id, &&self: @ir_maps, v: vt<@ir_maps>) { 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(); let _i = util::common::indenter();
// swap in a new set of IR maps for this function body: // swap in a new set of IR maps for this function body:
let fn_maps = @ir_maps(self.tcx, self.method_map, let fn_maps = @ir_maps(self.tcx, self.method_map,
self.last_use_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| { 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); let mode = ty::resolved_mode(self.tcx, arg.mode);
(*fn_maps).add_variable(vk_arg(arg.id, arg.ident, 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>) { fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) {
let def_map = self.tcx.def_map; let def_map = self.tcx.def_map;
do pat_util::pat_bindings(def_map, local.node.pat) |p_id, sp, path| { 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); let name = ast_util::path_to_ident(path);
(*self).add_live_node_for_node(p_id, lnk_vdef(sp)); (*self).add_live_node_for_node(p_id, lnk_vdef(sp));
(*self).add_variable(vk_local(p_id, name)); (*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: // live nodes required for uses or definitions of variables:
expr_path(_) { expr_path(_) {
let def = self.tcx.def_map.get(expr.id); 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() { if relevant_def(def).is_some() {
(*self).add_live_node_for_node(expr.id, lnk_expr(expr.span)); (*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 // code have to agree about which AST nodes are worth
// creating liveness nodes for. // creating liveness nodes for.
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
span, #fmt["No live node registered for node %d", span, fmt!{"No live node registered for node %d",
node_id]); node_id});
} }
} }
} }
@ -664,7 +664,7 @@ class liveness {
wr.write_str(~"[ln("); wr.write_str(~"[ln(");
wr.write_uint(*ln); wr.write_uint(*ln);
wr.write_str(~") of kind "); wr.write_str(~") of kind ");
wr.write_str(#fmt["%?", copy self.ir.lnks[*ln]]); wr.write_str(fmt!{"%?", copy self.ir.lnks[*ln]});
wr.write_str(~" reads"); wr.write_str(~" reads");
self.write_vars(wr, ln, |idx| self.users[idx].reader ); self.write_vars(wr, ln, |idx| self.users[idx].reader );
wr.write_str(~" writes"); wr.write_str(~" writes");
@ -695,8 +695,8 @@ class liveness {
self.indices2(ln, succ_ln, |idx, succ_idx| { self.indices2(ln, succ_ln, |idx, succ_idx| {
self.users[idx] = self.users[succ_idx] self.users[idx] = self.users[succ_idx]
}); });
#debug["init_from_succ(ln=%s, succ=%s)", debug!{"init_from_succ(ln=%s, succ=%s)",
self.ln_str(ln), self.ln_str(succ_ln)]; self.ln_str(ln), self.ln_str(succ_ln)};
} }
fn merge_from_succ(ln: live_node, succ_ln: live_node, 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)", debug!{"merge_from_succ(ln=%s, succ=%s, first_merge=%b, changed=%b)",
ln.to_str(), self.ln_str(succ_ln), first_merge, changed]; ln.to_str(), self.ln_str(succ_ln), first_merge, changed};
ret changed; ret changed;
fn copy_if_invalid(src: live_node, &dst: live_node) -> bool { 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].reader = invalid_node();
self.users[idx].writer = invalid_node(); self.users[idx].writer = invalid_node();
#debug["%s defines %s (idx=%u): %s", writer.to_str(), var.to_str(), debug!{"%s defines %s (idx=%u): %s", writer.to_str(), var.to_str(),
idx, self.ln_str(writer)]; idx, self.ln_str(writer)};
} }
// Either read, write, or both depending on the acc bitset // Either read, write, or both depending on the acc bitset
@ -762,8 +762,8 @@ class liveness {
self.users[idx].used = true; self.users[idx].used = true;
} }
#debug["%s accesses[%x] %s: %s", debug!{"%s accesses[%x] %s: %s",
ln.to_str(), acc, var.to_str(), self.ln_str(ln)]; 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: // 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| { for uint::range(0u, self.ir.num_live_nodes) |ln_idx| {
#debug["%s", self.ln_str(live_node(ln_idx))]; #debug["%s", self.ln_str(live_node(ln_idx))];
} }
body.node.id body.node.id
}, },
entry_ln.to_str()]; entry_ln.to_str()};
entry_ln 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 // No initializer: the variable might be unused; if not, it
// should not be live at this point. // 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| { do (*self).pat_bindings(local.node.pat) |ln, var, sp| {
if !self.warn_about_unused(sp, ln, var) { if !self.warn_about_unused(sp, ln, var) {
alt (*self).live_on_exit(ln, var) { alt (*self).live_on_exit(ln, var) {
@ -1487,7 +1487,7 @@ impl check_methods for @liveness {
none { /* ok */ } none { /* ok */ }
some(lnk_exit) { some(lnk_exit) {
self.tcx.sess.span_err( 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) { some(lnk) {
self.report_illegal_read( 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) { fn check_move_from_var(span: span, ln: live_node, var: variable) {
#debug["check_move_from_var(%s, %s)", debug!{"check_move_from_var(%s, %s)",
ln.to_str(), var.to_str()]; ln.to_str(), var.to_str()};
alt (*self).live_on_exit(ln, var) { alt (*self).live_on_exit(ln, var) {
none { } none { }
@ -1546,8 +1546,8 @@ impl check_methods for @liveness {
} }
fn check_move_from_expr(expr: @expr, vt: vt<@liveness>) { fn check_move_from_expr(expr: @expr, vt: vt<@liveness>) {
#debug["check_move_from_expr(node %d: %s)", debug!{"check_move_from_expr(node %d: %s)",
expr.id, expr_to_str(expr)]; expr.id, expr_to_str(expr)};
if self.ir.method_map.contains_key(expr.id) { if self.ir.method_map.contains_key(expr.id) {
// actually an rvalue, since this calls a method // actually an rvalue, since this calls a method
@ -1643,7 +1643,7 @@ impl check_methods for @liveness {
some(lnk) { some(lnk) {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
orig_span, orig_span,
#fmt["illegal writer: %?", lnk]); fmt!{"illegal writer: %?", lnk});
} }
none {} none {}
} }
@ -1662,14 +1662,14 @@ impl check_methods for @liveness {
vk_arg(_, name, _) { vk_arg(_, name, _) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
move_span, move_span,
#fmt["illegal move from argument `%s`, which is not \ fmt!{"illegal move from argument `%s`, which is not \
copy or move mode", *name]); copy or move mode", *name});
ret; ret;
} }
vk_field(name) { vk_field(name) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
move_span, move_span,
#fmt["illegal move from field `%s`", *name]); fmt!{"illegal move from field `%s`", *name});
ret; ret;
} }
vk_self { vk_self {
@ -1682,8 +1682,8 @@ impl check_methods for @liveness {
vk_local(*) | vk_implicit_ret { vk_local(*) | vk_implicit_ret {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
move_span, move_span,
#fmt["illegal reader (%?) for `%?`", fmt!{"illegal reader (%?) for `%?`",
lnk, vk]); lnk, vk});
} }
} }
} }
@ -1708,18 +1708,18 @@ impl check_methods for @liveness {
lnk_freevar(span) { lnk_freevar(span) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
span, span,
#fmt["capture of %s: `%s`", msg, *name]); fmt!{"capture of %s: `%s`", msg, *name});
} }
lnk_expr(span) { lnk_expr(span) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
span, span,
#fmt["use of %s: `%s`", msg, *name]); fmt!{"use of %s: `%s`", msg, *name});
} }
lnk_exit | lnk_exit |
lnk_vdef(_) { lnk_vdef(_) {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
chk_span, chk_span,
#fmt["illegal reader: %?", lnk]); fmt!{"illegal reader: %?", lnk});
} }
} }
} }
@ -1776,11 +1776,11 @@ impl check_methods for @liveness {
if is_assigned { if is_assigned {
self.tcx.sess.span_warn( self.tcx.sess.span_warn(
sp, #fmt["variable `%s` is assigned to, \ sp, fmt!{"variable `%s` is assigned to, \
but never used", *name]); but never used", *name});
} else { } else {
self.tcx.sess.span_warn( self.tcx.sess.span_warn(
sp, #fmt["unused variable: `%s`", *name]); sp, fmt!{"unused variable: `%s`", *name});
} }
} }
ret true; ret true;
@ -1793,7 +1793,7 @@ impl check_methods for @liveness {
for self.should_warn(var).each |name| { for self.should_warn(var).each |name| {
self.tcx.sess.span_warn( self.tcx.sess.span_warn(
sp, sp,
#fmt["value assigned to `%s` is never read", *name]); fmt!{"value assigned to `%s` is never read", *name});
} }
} }
} }

View file

@ -187,7 +187,7 @@ fn record_parent(cx: ctxt, child_id: ast::node_id) {
alt cx.parent { alt cx.parent {
none { /* no-op */ } none { /* no-op */ }
some(parent_id) { 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); 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; let mut new_cx = cx;
alt expr.node { alt expr.node {
ast::expr_call(*) => { 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); new_cx.parent = some(expr.id);
} }
ast::expr_alt(subexpr, _, _) => { 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); new_cx.parent = some(expr.id);
} }
ast::expr_fn(_, _, _, cap_clause) | 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: %?", fn_cx.parent: %?",
body.node.id, cx.parent, fn_cx.parent]; body.node.id, cx.parent, fn_cx.parent};
for decl.inputs.each |input| { for decl.inputs.each |input| {
cx.region_map.insert(input.id, body.node.id); 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) { fn add_rp(id: ast::node_id) {
assert id != 0; assert id != 0;
if self.region_paramd_items.insert(id, ()) { if self.region_paramd_items.insert(id, ()) {
#debug["add region-parameterized item: %d (%s)", debug!{"add region-parameterized item: %d (%s)",
id, ast_map::node_id_to_str(self.ast_map, id)]; id, ast_map::node_id_to_str(self.ast_map, id)};
self.worklist.push(id); self.worklist.push(id);
} else { } 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) { 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, from, to,
ast_map::node_id_to_str(self.ast_map, from), 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) { let vec = alt self.dep_map.find(from) {
some(vec) => {vec} some(vec) => {vec}
none => { none => {
@ -436,7 +436,7 @@ impl methods for determine_rp_ctxt {
let old_anon_implies_rp = self.anon_implies_rp; let old_anon_implies_rp = self.anon_implies_rp;
self.item_id = item_id; self.item_id = item_id;
self.anon_implies_rp = anon_implies_rp; 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(); let _i = util::common::indenter();
f(); f();
self.item_id = old_item_id; self.item_id = old_item_id;
@ -488,7 +488,7 @@ fn determine_rp_in_ty(ty: @ast::ty,
alt ty.node { alt ty.node {
ast::ty_rptr(r, _) | ast::ty_rptr(r, _) |
ast::ty_path(@{rp: some(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) { if cx.region_is_relevant(r) {
cx.add_rp(cx.item_id); cx.add_rp(cx.item_id);
} }
@ -510,8 +510,8 @@ fn determine_rp_in_ty(ty: @ast::ty,
} else { } else {
let cstore = cx.sess.cstore; let cstore = cx.sess.cstore;
if csearch::get_region_param(cstore, did) { if csearch::get_region_param(cstore, did) {
#debug["reference to external, rp'd type %s", debug!{"reference to external, rp'd type %s",
pprust::ty_to_str(ty)]; pprust::ty_to_str(ty)};
cx.add_rp(cx.item_id); cx.add_rp(cx.item_id);
} }
} }
@ -560,7 +560,7 @@ fn determine_rp_in_crate(sess: session,
// propagate indirect dependencies // propagate indirect dependencies
while cx.worklist.len() != 0 { while cx.worklist.len() != 0 {
let id = cx.worklist.pop(); let id = cx.worklist.pop();
#debug["popped %d from worklist", id]; debug!{"popped %d from worklist", id};
alt cx.dep_map.find(id) { alt cx.dep_map.find(id) {
none {} none {}
some(vec) { some(vec) {

File diff suppressed because it is too large Load diff

View file

@ -67,8 +67,8 @@ enum dest {
fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str { fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str {
alt d { alt d {
by_val(v) { #fmt["by_val(%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)] } save_in(v) { fmt!{"save_in(%s)", val_str(ccx.tn, v)} }
ignore { ~"ignore" } ignore { ~"ignore" }
} }
} }
@ -100,7 +100,7 @@ trait get_insn_ctxt {
impl ccx_icx of get_insn_ctxt for @crate_ctxt { impl ccx_icx of get_insn_ctxt for @crate_ctxt {
fn insn_ctxt(s: ~str) -> icx_popper { 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() { if self.sess.count_llvm_insns() {
vec::push(*self.stats.llvm_insn_ctxt, s); 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") mangle_internal_name_by_type_only(ccx, t, @~"tydesc")
} else { mangle_internal_name_by_seq(ccx, @~"tydesc") }; } else { mangle_internal_name_by_seq(ccx, @~"tydesc") };
note_unique_llvm_symbol(ccx, name); 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| { let gvar = str::as_c_str(name, |buf| {
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, 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 { alt ti.take_glue {
some(_) { } some(_) { }
none { none {
#debug("+++ lazily_emit_tydesc_glue TAKE %s", debug!{"+++ lazily_emit_tydesc_glue TAKE %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
let glue_fn = declare_generic_glue let glue_fn = declare_generic_glue
(ccx, ti.ty, T_glue_fn(ccx), ~"take"); (ccx, ti.ty, T_glue_fn(ccx), ~"take");
ti.take_glue = some(glue_fn); ti.take_glue = some(glue_fn);
make_generic_glue(ccx, ti.ty, glue_fn, make_generic_glue(ccx, ti.ty, glue_fn,
make_take_glue, ~"take"); make_take_glue, ~"take");
#debug("--- lazily_emit_tydesc_glue TAKE %s", debug!{"--- lazily_emit_tydesc_glue TAKE %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
} }
} }
} else if field == abi::tydesc_field_drop_glue { } else if field == abi::tydesc_field_drop_glue {
alt ti.drop_glue { alt ti.drop_glue {
some(_) { } some(_) { }
none { none {
#debug("+++ lazily_emit_tydesc_glue DROP %s", debug!{"+++ lazily_emit_tydesc_glue DROP %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
let glue_fn = let glue_fn =
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"drop"); declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"drop");
ti.drop_glue = some(glue_fn); ti.drop_glue = some(glue_fn);
make_generic_glue(ccx, ti.ty, glue_fn, make_generic_glue(ccx, ti.ty, glue_fn,
make_drop_glue, ~"drop"); make_drop_glue, ~"drop");
#debug("--- lazily_emit_tydesc_glue DROP %s", debug!{"--- lazily_emit_tydesc_glue DROP %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
} }
} }
} else if field == abi::tydesc_field_free_glue { } else if field == abi::tydesc_field_free_glue {
alt ti.free_glue { alt ti.free_glue {
some(_) { } some(_) { }
none { none {
#debug("+++ lazily_emit_tydesc_glue FREE %s", debug!{"+++ lazily_emit_tydesc_glue FREE %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
let glue_fn = let glue_fn =
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"free"); declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"free");
ti.free_glue = some(glue_fn); ti.free_glue = some(glue_fn);
make_generic_glue(ccx, ti.ty, glue_fn, make_generic_glue(ccx, ti.ty, glue_fn,
make_free_glue, ~"free"); make_free_glue, ~"free");
#debug("--- lazily_emit_tydesc_glue FREE %s", debug!{"--- lazily_emit_tydesc_glue FREE %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
} }
} }
} else if field == abi::tydesc_field_visit_glue { } else if field == abi::tydesc_field_visit_glue {
alt ti.visit_glue { alt ti.visit_glue {
some(_) { } some(_) { }
none { none {
#debug("+++ lazily_emit_tydesc_glue VISIT %s", debug!{"+++ lazily_emit_tydesc_glue VISIT %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); ppaux::ty_to_str(ccx.tcx, ti.ty)};
let glue_fn = let glue_fn =
declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"visit"); declare_generic_glue(ccx, ti.ty, T_glue_fn(ccx), ~"visit");
ti.visit_glue = some(glue_fn); ti.visit_glue = some(glue_fn);
make_generic_glue(ccx, ti.ty, glue_fn, make_generic_glue(ccx, ti.ty, glue_fn,
make_visit_glue, ~"visit"); make_visit_glue, ~"visit");
#debug("--- lazily_emit_tydesc_glue VISIT %s", debug!{"--- lazily_emit_tydesc_glue VISIT %s",
ppaux::ty_to_str(ccx.tcx, ti.ty)); 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, fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
dst: @ast::expr, src: @ast::expr) -> block { 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 _icx = bcx.insn_ctxt(~"trans_assign_op");
let t = expr_ty(bcx, src); let t = expr_ty(bcx, src);
let lhs_res = trans_lval(bcx, dst); 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) { alt bcx.ccx().maps.method_map.find(ex.id) {
some(origin) { some(origin) {
let bcx = lhs_res.bcx; let bcx = lhs_res.bcx;
#debug["user-defined method callee_id: %s", debug!{"user-defined method callee_id: %s",
ast_map::node_id_to_str(bcx.tcx().items, ex.callee_id)]; ast_map::node_id_to_str(bcx.tcx().items, ex.callee_id)};
let fty = node_id_type(bcx, ex.callee_id); let fty = node_id_type(bcx, ex.callee_id);
let dty = expr_ty(bcx, dst); let dty = expr_ty(bcx, dst);
@ -1745,7 +1745,7 @@ fn root_value(bcx: block, val: ValueRef, ty: ty::t,
if bcx.sess().trace() { if bcx.sess().trace() {
trans_trace( trans_trace(
bcx, none, 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)); 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 ccx = cx.ccx();
let mut derefs = 0u; let mut derefs = 0u;
while derefs < max { 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), e_id, val_str(ccx.tn, v1), ppaux::ty_to_str(ccx.tcx, t1),
derefs]; derefs};
// root the autoderef'd value, if necessary: // root the autoderef'd value, if necessary:
derefs += 1u; derefs += 1u;
@ -2113,8 +2113,8 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
alt ccx.monomorphized.find(hash_id) { alt ccx.monomorphized.find(hash_id) {
some(val) { some(val) {
#debug["leaving monomorphic fn %s", debug!{"leaving monomorphic fn %s",
ty::item_path_str(ccx.tcx, fn_id)]; ty::item_path_str(ccx.tcx, fn_id)};
ret {val: val, must_cast: must_cast}; ret {val: val, must_cast: must_cast};
} }
none {} none {}
@ -2124,9 +2124,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
let mut llitem_ty = tpt.ty; let mut llitem_ty = tpt.ty;
let map_node = session::expect(ccx.sess, ccx.tcx.items.find(fn_id.node), 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 \ (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 // Get the path so that we can create a symbol
let (pt, name, span) = alt map_node { let (pt, name, span) = alt map_node {
ast_map::node_item(i, pt) { (pt, i.ident, i.span) } 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); 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} {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) { alt ccx.external.find(fn_id) {
some(some(node_id)) { some(some(node_id)) {
// Already inline // Already inline
#debug["maybe_instantiate_inline(%s): already inline as node id %d", debug!{"maybe_instantiate_inline(%s): already inline as node id %d",
ty::item_path_str(ccx.tcx, fn_id), node_id]; ty::item_path_str(ccx.tcx, fn_id), node_id};
local_def(node_id) local_def(node_id)
} }
some(none) { fn_id } // Not inlinable 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}; ret {val: slf, kind: lv_owned};
} }
_ { _ {
cx.sess().unimpl(#fmt("unsupported def type in trans_local_def: %?", cx.sess().unimpl(fmt!{"unsupported def type in trans_local_def: %?",
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); 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 /* self is a class with a dtor, which means we
have to select out the object itself 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)); len = Sub(bcx, len, C_uint(bcx.ccx(), 1u));
} }
#debug("trans_index: base %s", val_str(bcx.ccx().tn, base)); 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: len %s", val_str(bcx.ccx().tn, len)};
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len); let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len);
let bcx = do with_cond(bcx, bounds_check) |bcx| { 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); let lv = unrooted(cx, e);
if !cx.sess().no_asm_comments() { if !cx.sess().no_asm_comments() {
add_comment(cx, #fmt["preserving until end of scope %d", add_comment(cx, fmt!{"preserving until end of scope %d",
scope_id]); scope_id});
} }
let _icx = lv.bcx.insn_ctxt(~"root_value_lval"); 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. * wrong address space and thus be the wrong type.
*/ */
fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { 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"); add_comment(cx, ~"non_gc_box_cast");
assert(llvm::LLVMGetPointerAddressSpace(val_ty(val)) as uint == 1u); assert(llvm::LLVMGetPointerAddressSpace(val_ty(val)) as uint == 1u);
let non_gc_t = T_ptr(llvm::LLVMGetElementType(val_ty(val))); 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>, &temp_cleanups: ~[ValueRef], ret_flag: option<ValueRef>,
derefs: uint) derefs: uint)
-> result { -> 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 _icx = cx.insn_ctxt(~"trans_arg_expr");
let ccx = cx.ccx(); let ccx = cx.ccx();
let e_ty = expr_ty(cx, e); 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 // auto-deref value as required (this only applies to method
// call receivers) of 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 { let {lv, e_ty} = if derefs == 0u {
{lv: lv, e_ty: e_ty} {lv: lv, e_ty: e_ty}
} else { } 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) // 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 {lv, ty: e_ty} = adapt_borrowed_value(lv, e, e_ty);
let mut bcx = lv.bcx; let mut bcx = lv.bcx;
let mut val = lv.val; 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 // finally, deal with the various modes
let arg_mode = ty::resolved_mode(ccx.tcx, arg.mode); 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) { 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); 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); 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 (base, len) = tvec::get_base_and_len(bcx, val, e_ty);
let p = alloca(bcx, T_struct(~[T_ptr(llunit_ty), ccx.int_type])); let p = alloca(bcx, T_struct(~[T_ptr(llunit_ty), ccx.int_type]));
#debug("adapt_borrowed_value: adapting %s to %s", debug!{"adapt_borrowed_value: adapting %s to %s",
val_str(bcx.ccx().tn, val), 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, base, GEPi(bcx, p, ~[0u, abi::slice_elt_base]));
Store(bcx, len, GEPi(bcx, p, ~[0u, abi::slice_elt_len])); 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( bcx.tcx().sess.span_bug(
e.span, #fmt["cannot borrow a value of type %s", e.span, fmt!{"cannot borrow a value of type %s",
ppaux::ty_to_str(bcx.tcx(), e_ty)]); 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, fn add_root_cleanup(bcx: block, scope_id: ast::node_id,
root_loc: ValueRef, ty: ty::t) { 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), 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); let bcx_scope = find_bcx_for_scope(bcx, scope_id);
add_clean_temp_mem(bcx_scope, root_loc, ty); 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 { alt bcx_sid.parent {
none { none {
bcx.tcx().sess.bug( 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 } 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}) { ret alt bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) {
none { unrooted(bcx, e, dest) } none { unrooted(bcx, e, dest) }
some(scope_id) { some(scope_id) {
#debug["expression %d found in root map with scope %d", debug!{"expression %d found in root map with scope %d",
e.id, scope_id]; e.id, scope_id};
let ty = expr_ty(bcx, e); let ty = expr_ty(bcx, e);
let root_loc = alloca_zeroed(bcx, type_of(bcx.ccx(), ty)); let root_loc = alloca_zeroed(bcx, type_of(bcx.ccx(), ty));
let bcx = unrooted(bcx, e, save_in(root_loc)); let bcx = unrooted(bcx, e, save_in(root_loc));
if !bcx.sess().no_asm_comments() { if !bcx.sess().no_asm_comments() {
add_comment(bcx, #fmt["preserving until end of scope %d", add_comment(bcx, fmt!{"preserving until end of scope %d",
scope_id]); scope_id});
} }
let _icx = bcx.insn_ctxt(~"root_value_expr"); 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) { ast::expr_fn_block(decl, body, cap_clause) {
alt check ty::get(expr_ty(bcx, e)).struct { alt check ty::get(expr_ty(bcx, e)).struct {
ty::ty_fn({proto, _}) { ty::ty_fn({proto, _}) {
#debug("translating fn_block %s with type %s", debug!{"translating fn_block %s with type %s",
expr_to_str(e), 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, ret closure::trans_expr_fn(bcx, proto, decl, body,
e.id, cap_clause, none, dest); 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_ty = expr_ty(bcx, e);
let ptr_ptr_val = alloc_ty(bcx, ptr_ty); let ptr_ptr_val = alloc_ty(bcx, ptr_ty);
#debug["ptr_ty = %s", ppaux::ty_to_str(tcx, 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_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)};
let void_ty = ty::mk_nil_ptr(tcx); let void_ty = ty::mk_nil_ptr(tcx);
let llvoid_ty = type_of(ccx, void_ty); let llvoid_ty = type_of(ccx, void_ty);
let voidval = PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_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)); let static_ti = get_tydesc(ccx, expr_ty(bcx, val));
lazily_emit_all_tydesc_glue(ccx, static_ti); 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]), arg_vals(~[lltydesc]),
save_in(voidval)); 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); 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)); let bcx = trans_expr(bcx, val, save_in(ptr_val));
store_in_dest(bcx, ptr_val, dest) 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 ty = expr_ty(bcx, e);
let lv = trans_lval(bcx, e); let lv = trans_lval(bcx, e);
let last_use = (lv.kind == lv_owned && last_use_map.contains_key(e.id)); 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, debug!{"is last use (%s) = %b, %d", expr_to_str(e), last_use,
lv.kind as int]; lv.kind as int};
lval_result_to_dps(lv, ty, last_use, dest) 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 { fn trans_stmt(cx: block, s: ast::stmt) -> block {
let _icx = cx.insn_ctxt(~"trans_stmt"); let _icx = cx.insn_ctxt(~"trans_stmt");
#debug["trans_stmt(%s)", stmt_to_str(s)]; debug!{"trans_stmt(%s)", stmt_to_str(s)};
if !cx.sess().no_asm_comments() { if !cx.sess().no_asm_comments() {
add_span_comment(cx, s.span, stmt_to_str(s)); 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 mut cur = bcx, bcx = bcx;
let is_lpad = leave == none; let is_lpad = leave == none;
loop { loop {
#debug["cleanup_and_leave: leaving %s", cur.to_str()]; debug!{"cleanup_and_leave: leaving %s", cur.to_str()};
if bcx.sess().trace() { if bcx.sess().trace() {
trans_trace( trans_trace(
bcx, none, bcx, none,
#fmt["cleanup_and_leave(%s)", cur.to_str()]); fmt!{"cleanup_and_leave(%s)", cur.to_str()});
} }
alt cur.kind { 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); let llfn: ValueRef = decl_fn(ccx.llmod, ps, cc, llfty);
ccx.item_symbols.insert(node_id, ps); ccx.item_symbols.insert(node_id, ps);
#debug["register_fn_fuller created fn %s for item %d with path %s", 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)]; val_str(ccx.tn, llfn), node_id, ast_map::path_to_str(path)};
let is_main = is_main_name(path) && !ccx.sess.building_library; let is_main = is_main_name(path) && !ccx.sess.building_library;
if is_main { create_main_wrapper(ccx, sp, llfn, node_type); } 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) mono_ty)
} }
none { none {
ccx.sess.bug(#fmt("get_dtor_symbol: not monomorphizing and \ ccx.sess.bug(fmt!{"get_dtor_symbol: not monomorphizing and \
couldn't find a symbol for dtor %?", path)); 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) { fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) {
if ccx.rtcalls.contains_key(name) { 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); 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"]; ~[~"exchange_free", ~"exchange_malloc", ~"fail", ~"free", ~"malloc"];
for vec::each(expected_rtcalls) |name| { for vec::each(expected_rtcalls) |name| {
if !ccx.rtcalls.contains_key(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); write_metadata(ccx, crate);
if ccx.sess.trans_stats() { if ccx.sess.trans_stats() {
io::println(~"--- trans stats ---"); io::println(~"--- trans stats ---");
io::println(#fmt("n_static_tydescs: %u", io::println(fmt!{"n_static_tydescs: %u",
ccx.stats.n_static_tydescs)); ccx.stats.n_static_tydescs});
io::println(#fmt("n_glues_created: %u", io::println(fmt!{"n_glues_created: %u",
ccx.stats.n_glues_created)); ccx.stats.n_glues_created});
io::println(#fmt("n_null_glues: %u", ccx.stats.n_null_glues)); 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_real_glues: %u", ccx.stats.n_real_glues});
// FIXME (#2280): this temporary shouldn't be // FIXME (#2280): this temporary shouldn't be
// necessary, but seems to be, for borrowing. // necessary, but seems to be, for borrowing.
let times = copy *ccx.stats.fn_times; let times = copy *ccx.stats.fn_times;
for vec::each(times) |timing| { for vec::each(times) |timing| {
io::println(#fmt("time: %s took %d ms", timing.ident, io::println(fmt!{"time: %s took %d ms", timing.ident,
timing.time)); timing.time});
} }
} }
if ccx.sess.count_llvm_insns() { if ccx.sess.count_llvm_insns() {
for ccx.stats.llvm_insns.each |k, v| { 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); ret (llmod, link_meta);

View file

@ -139,10 +139,10 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
if cx.unreachable { ret; } if cx.unreachable { ret; }
assert (!cx.terminated); assert (!cx.terminated);
cx.terminated = true; cx.terminated = true;
#debug["Invoke(%s with arguments (%s))", debug!{"Invoke(%s with arguments (%s))",
val_str(cx.ccx().tn, Fn), val_str(cx.ccx().tn, Fn),
str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)), str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)),
~", ")]; ~", ")};
unsafe { unsafe {
count_insn(cx, ~"invoke"); count_insn(cx, ~"invoke");
llvm::LLVMBuildInvoke(B(cx), Fn, vec::unsafe::to_ptr(Args), 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) { fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
if cx.unreachable { ret; } if cx.unreachable { ret; }
#debug["Store %s -> %s", debug!{"Store %s -> %s",
val_str(cx.ccx().tn, Val), val_str(cx.ccx().tn, Val),
val_str(cx.ccx().tn, Ptr)]; val_str(cx.ccx().tn, Ptr)};
count_insn(cx, ~"store"); count_insn(cx, ~"store");
llvm::LLVMBuildStore(B(cx), Val, Ptr); llvm::LLVMBuildStore(B(cx), Val, Ptr);
} }
@ -670,9 +670,9 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
unsafe { unsafe {
count_insn(cx, ~"call"); count_insn(cx, ~"call");
#debug["Call(Fn=%s, Args=%?)", debug!{"Call(Fn=%s, Args=%?)",
val_str(cx.ccx().tn, Fn), 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), ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname()); Args.len() as c_uint, noname());

View file

@ -102,12 +102,12 @@ enum environment_value {
fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str { fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str {
alt ev { alt ev {
env_copy(v, t, lk) { #fmt("copy(%s,%s)", val_str(ccx.tn, v), env_copy(v, t, lk) { fmt!{"copy(%s,%s)", val_str(ccx.tn, v),
ty_to_str(ccx.tcx, t)) } ty_to_str(ccx.tcx, t)} }
env_move(v, t, lk) { #fmt("move(%s,%s)", val_str(ccx.tn, v), env_move(v, t, lk) { fmt!{"move(%s,%s)", val_str(ccx.tn, v),
ty_to_str(ccx.tcx, t)) } ty_to_str(ccx.tcx, t)} }
env_ref(v, t, lk) { #fmt("ref(%s,%s)", val_str(ccx.tn, v), env_ref(v, t, lk) { fmt!{"ref(%s,%s)", val_str(ccx.tn, v),
ty_to_str(ccx.tcx, t)) } 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); 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; 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 cboxptr_ty = ty::mk_ptr(tcx, {ty:cbox_ty, mutbl:ast::m_imm});
let llbox = PointerCast(bcx, llbox, type_of(ccx, cboxptr_ty)); 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. // Copy expr values into boxed bindings.
let mut bcx = bcx; let mut bcx = bcx;
do vec::iteri(bound_values) |i, bv| { 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() { if !ccx.sess.no_asm_comments() {
add_comment(bcx, #fmt("Copy %s into closure", add_comment(bcx, fmt!{"Copy %s into closure",
ev_to_str(ccx, bv))); ev_to_str(ccx, bv)});
} }
let bound_data = GEPi(bcx, llbox, let bound_data = GEPi(bcx, llbox,
@ -231,9 +231,9 @@ fn store_environment(bcx: block,
bcx = move_val(bcx, INIT, bound_data, src, ty); bcx = move_val(bcx, INIT, bound_data, src, ty);
} }
env_ref(val, ty, lv_owned) { 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, val),
val_str(bcx.ccx().tn, bound_data)]; val_str(bcx.ccx().tn, bound_data)};
Store(bcx, val, bound_data); Store(bcx, val, bound_data);
} }
env_ref(val, ty, lv_owned_imm) { env_ref(val, ty, lv_owned_imm) {
@ -265,11 +265,11 @@ fn build_closure(bcx0: block,
// Package up the captured upvars // Package up the captured upvars
do vec::iter(cap_vars) |cap_var| { 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 lv = trans_local_var(bcx, cap_var.def);
let nid = ast_util::def_id_of_def(cap_var.def).node; let nid = ast_util::def_id_of_def(cap_var.def).node;
#debug["Node id is %s", debug!{"Node id is %s",
syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)]; syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)};
let mut ty = node_id_type(bcx, nid); let mut ty = node_id_type(bcx, nid);
alt cap_var.mode { alt cap_var.mode {
capture::cap_ref { capture::cap_ref {

View file

@ -248,9 +248,9 @@ fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype {
fn add_clean(cx: block, val: ValueRef, ty: ty::t) { fn add_clean(cx: block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { ret; } 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), 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); let cleanup_type = cleanup_type(cx.tcx(), ty);
do in_scope_cx(cx) |info| { do in_scope_cx(cx) |info| {
vec::push(info.cleanups, clean(|a| base::drop_ty(a, val, ty), 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) { fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { ret; } 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), 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); let cleanup_type = cleanup_type(cx.tcx(), ty);
fn do_drop(bcx: block, val: ValueRef, ty: ty::t) -> fn do_drop(bcx: block, val: ValueRef, ty: ty::t) ->
block { 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) { fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { ret; } 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), 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); let cleanup_type = cleanup_type(cx.tcx(), ty);
do in_scope_cx(cx) |info| { do in_scope_cx(cx) |info| {
vec::push(info.cleanups, vec::push(info.cleanups,
@ -459,8 +459,8 @@ fn in_scope_cx(cx: block, f: fn(scope_info)) {
fn block_parent(cx: block) -> block { fn block_parent(cx: block) -> block {
alt cx.parent { alt cx.parent {
some(b) { b } some(b) { b }
none { cx.sess().bug(#fmt("block_parent called on root block %?", none { cx.sess().bug(fmt!{"block_parent called on root block %?",
cx)); } cx}); }
} }
} }
@ -480,10 +480,10 @@ impl bcx_cxs for block {
fn to_str() -> ~str { fn to_str() -> ~str {
alt self.node_info { alt self.node_info {
some(node_info) { some(node_info) {
#fmt["[block %d]", node_info.id] fmt!{"[block %d]", node_info.id}
} }
none { 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]) fields: ~[ty::field])
-> uint { -> uint {
alt ty::field_idx(ident, fields) { alt ty::field_idx(ident, fields) {
none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \ none { cx.sess.span_bug(sp, fmt!{"base expr doesn't appear to \
have a field named %s", *ident)); } have a field named %s", *ident}); }
some(i) { i } some(i) { i }
} }
} }

View file

@ -178,7 +178,7 @@ fn create_compile_unit(cx: @crate_ctxt)
lli32(DW_LANG_RUST), lli32(DW_LANG_RUST),
llstr(crate_name), llstr(crate_name),
llstr(work_dir), llstr(work_dir),
llstr(#env["CFG_VERSION"]), llstr(env!{"CFG_VERSION"}),
lli1(true), // deprecated: main compile unit lli1(true), // deprecated: main compile unit
lli1(cx.sess.opts.optimize != 0u), lli1(cx.sess.opts.optimize != 0u),
llstr(~""), // flags (???) llstr(~""), // flags (???)
@ -734,7 +734,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let cx = fcx.ccx; let cx = fcx.ccx;
let dbg_cx = option::get(cx.dbg_cx); let dbg_cx = option::get(cx.dbg_cx);
#debug("~~"); debug!{"~~"};
log(debug, fcx.id); log(debug, fcx.id);
let sp = option::get(fcx.span); let sp = option::get(fcx.span);

Some files were not shown because too many files have changed in this diff Show more