Skip to content

Commit 389329e

Browse files
committed
Merge all 3 log syntaxes, tidy up residual misuses.
1 parent f816d8c commit 389329e

File tree

26 files changed

+117
-133
lines changed

26 files changed

+117
-133
lines changed

src/comp/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ fn get_rpath_relative_to_output(os: session::os,
117117
fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path {
118118
assert fs::path_is_absolute(abs1);
119119
assert fs::path_is_absolute(abs2);
120-
log #fmt("finding relative path from %s to %s",
121-
abs1, abs2);
120+
#debug("finding relative path from %s to %s",
121+
abs1, abs2);
122122
let normal1 = fs::normalize(abs1);
123123
let normal2 = fs::normalize(abs2);
124124
let split1 = str::split(normal1, os_fs::path_sep as u8);

src/comp/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
105105
let start = std::time::precise_time_s();
106106
let rv = thunk();
107107
let end = std::time::precise_time_s();
108-
log_err #fmt["time: %s took %s s", what,
109-
float::to_str(end - start, 3u)];
108+
#error("time: %s took %s s", what,
109+
float::to_str(end - start, 3u));
110110
ret rv;
111111
}
112112

src/comp/front/attr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
135135
}
136136

137137
fn contains(haystack: [@ast::meta_item], needle: @ast::meta_item) -> bool {
138-
log #fmt["looking for %s",
139-
syntax::print::pprust::meta_item_to_str(*needle)];
138+
#debug("looking for %s",
139+
syntax::print::pprust::meta_item_to_str(*needle));
140140
for item: @ast::meta_item in haystack {
141-
log #fmt["looking in %s",
142-
syntax::print::pprust::meta_item_to_str(*item)];
141+
#debug("looking in %s",
142+
syntax::print::pprust::meta_item_to_str(*item));
143143
if eq(item, needle) { #debug("found it!"); ret true; }
144144
}
145145
#debug("found it not :(");

src/comp/metadata/creader.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ fn metadata_matches(crate_data: @[u8], metas: [@ast::meta_item]) -> bool {
104104
let attrs = decoder::get_crate_attributes(crate_data);
105105
let linkage_metas = attr::find_linkage_metas(attrs);
106106

107-
log #fmt["matching %u metadata requirements against %u items",
108-
vec::len(metas), vec::len(linkage_metas)];
107+
#debug("matching %u metadata requirements against %u items",
108+
vec::len(metas), vec::len(linkage_metas));
109109

110110
#debug("crate metadata:");
111111
for have: @ast::meta_item in linkage_metas {
@@ -178,8 +178,8 @@ fn find_library_crate_aux(sess: session::session,
178178
#debug("inspecting file %s", path);
179179
let f: str = fs::basename(path);
180180
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
181-
log #fmt["skipping %s, doesn't look like %s*%s", path, prefix,
182-
suffix];
181+
#debug("skipping %s, doesn't look like %s*%s", path, prefix,
182+
suffix);
183183
option::none
184184
} else {
185185
#debug("%s is a candidate", path);

src/comp/metadata/csearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
3737
path: [ast::ident]) ->
3838
[(ast::crate_num, @[u8], ast::def_id)] {
3939
let cm = cstore::get_crate_data(cstore, cnum);
40-
log #fmt("resolve_path %s in crates[%d]:%s",
41-
str::connect(path, "::"), cnum, cm.name);
40+
#debug("resolve_path %s in crates[%d]:%s",
41+
str::connect(path, "::"), cnum, cm.name);
4242
let result = [];
4343
for def in decoder::resolve_path(path, cm.data) {
4444
if def.crate == ast::local_crate {

src/comp/middle/resolve.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,9 +1393,8 @@ fn lookup_external(e: env, cnum: int, ids: [ident], ns: namespace) ->
13931393
let cname = cstore::get_crate_data(e.cstore, did.crate).name;
13941394
let name =
13951395
csearch::get_item_name(e.cstore, did.crate, did.node);
1396-
log #fmt("lookup_external: %s %d, %d, %s, %s", cname,
1397-
did.crate, did.node,
1398-
str::connect(ids, "::"), name);
1396+
#debug("lookup_external: %s %d, %d, %s, %s", cname,
1397+
did.crate, did.node, str::connect(ids, "::"), name);
13991398
e.ext_map.insert(did, vec::init(ids) + [name]);
14001399
} else {
14011400
e.ext_map.insert(did, ids);

src/comp/middle/trans.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
205205
T_opaque_closure(cx)
206206
}
207207
_ {
208-
log_err ("type_of_inner not implemented for ",
209-
ty::struct(cx.tcx, t));
210208
fail "type_of_inner not implemented for this kind of type";
211209
}
212210
};
@@ -1759,8 +1757,8 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
17591757
alt ti.take_glue {
17601758
some(_) { }
17611759
none. {
1762-
log #fmt["+++ lazily_emit_tydesc_glue TAKE %s",
1763-
ty_to_str(bcx_tcx(cx), ti.ty)];
1760+
#debug("+++ lazily_emit_tydesc_glue TAKE %s",
1761+
ty_to_str(bcx_tcx(cx), ti.ty));
17641762
let lcx = cx.fcx.lcx;
17651763
let glue_fn =
17661764
declare_generic_glue(lcx, ti.ty, T_glue_fn(lcx.ccx),
@@ -1769,16 +1767,16 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
17691767
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
17701768
make_take_glue,
17711769
ti.ty_params, "take");
1772-
log #fmt["--- lazily_emit_tydesc_glue TAKE %s",
1773-
ty_to_str(bcx_tcx(cx), ti.ty)];
1770+
#debug("--- lazily_emit_tydesc_glue TAKE %s",
1771+
ty_to_str(bcx_tcx(cx), ti.ty));
17741772
}
17751773
}
17761774
} else if field == abi::tydesc_field_drop_glue {
17771775
alt ti.drop_glue {
17781776
some(_) { }
17791777
none. {
1780-
log #fmt["+++ lazily_emit_tydesc_glue DROP %s",
1781-
ty_to_str(bcx_tcx(cx), ti.ty)];
1778+
#debug("+++ lazily_emit_tydesc_glue DROP %s",
1779+
ty_to_str(bcx_tcx(cx), ti.ty));
17821780
let lcx = cx.fcx.lcx;
17831781
let glue_fn =
17841782
declare_generic_glue(lcx, ti.ty, T_glue_fn(lcx.ccx),
@@ -1787,16 +1785,16 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
17871785
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
17881786
make_drop_glue,
17891787
ti.ty_params, "drop");
1790-
log #fmt["--- lazily_emit_tydesc_glue DROP %s",
1791-
ty_to_str(bcx_tcx(cx), ti.ty)];
1788+
#debug("--- lazily_emit_tydesc_glue DROP %s",
1789+
ty_to_str(bcx_tcx(cx), ti.ty));
17921790
}
17931791
}
17941792
} else if field == abi::tydesc_field_free_glue {
17951793
alt ti.free_glue {
17961794
some(_) { }
17971795
none. {
1798-
log #fmt["+++ lazily_emit_tydesc_glue FREE %s",
1799-
ty_to_str(bcx_tcx(cx), ti.ty)];
1796+
#debug("+++ lazily_emit_tydesc_glue FREE %s",
1797+
ty_to_str(bcx_tcx(cx), ti.ty));
18001798
let lcx = cx.fcx.lcx;
18011799
let glue_fn =
18021800
declare_generic_glue(lcx, ti.ty, T_glue_fn(lcx.ccx),
@@ -1805,19 +1803,19 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
18051803
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
18061804
make_free_glue,
18071805
ti.ty_params, "free");
1808-
log #fmt["--- lazily_emit_tydesc_glue FREE %s",
1809-
ty_to_str(bcx_tcx(cx), ti.ty)];
1806+
#debug("--- lazily_emit_tydesc_glue FREE %s",
1807+
ty_to_str(bcx_tcx(cx), ti.ty));
18101808
}
18111809
}
18121810
} else if field == abi::tydesc_field_cmp_glue {
18131811
alt ti.cmp_glue {
18141812
some(_) { }
18151813
none. {
1816-
log #fmt["+++ lazily_emit_tydesc_glue CMP %s",
1817-
ty_to_str(bcx_tcx(cx), ti.ty)];
1814+
#debug("+++ lazily_emit_tydesc_glue CMP %s",
1815+
ty_to_str(bcx_tcx(cx), ti.ty));
18181816
ti.cmp_glue = some(bcx_ccx(cx).upcalls.cmp_type);
1819-
log #fmt["--- lazily_emit_tydesc_glue CMP %s",
1820-
ty_to_str(bcx_tcx(cx), ti.ty)];
1817+
#debug("--- lazily_emit_tydesc_glue CMP %s",
1818+
ty_to_str(bcx_tcx(cx), ti.ty));
18211819
}
18221820
}
18231821
}

src/comp/middle/tstate/auxiliary.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
547547
// should freeze it at some earlier point.
548548
fn match_args(fcx: fn_ctxt, occs: @mutable [pred_args],
549549
occ: [@constr_arg_use]) -> uint {
550-
log "match_args: looking at " +
551-
constr_args_to_str(fn (i: inst) -> str { ret i.ident; }, occ);
550+
#debug("match_args: looking at %s",
551+
constr_args_to_str(fn (i: inst) -> str { ret i.ident; }, occ));
552552
for pd: pred_args in *occs {
553553
log_full(core::debug,
554554
"match_args: candidate " + pred_args_to_str(pd));
@@ -879,9 +879,9 @@ fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
879879
some(d_id) {
880880
for c: norm_constraint in constraints(fcx) {
881881
if constraint_mentions(fcx, c, d_id) {
882-
log ("clearing constraint ",
883-
c.bit_num,
884-
constraint_to_str(fcx.ccx.tcx, c.c));
882+
#debug("clearing constraint %u %s",
883+
c.bit_num,
884+
constraint_to_str(fcx.ccx.tcx, c.c));
885885
clear_in_postcond(c.bit_num,
886886
node_id_to_ts_ann(fcx.ccx,
887887
parent_exp).conditions);

src/comp/middle/tstate/ck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt<fn_ctxt>) {
7171
let pres: prestate = ann_prestate(a);
7272

7373

74-
log("check_states_stmt:");
74+
#debug("check_states_stmt:");
7575
log_full(core::debug, print::pprust::stmt_to_str(*s));
76-
log("prec = ");
76+
#debug("prec = ");
7777
log_tritv(fcx, prec);
78-
log("pres = ");
78+
#debug("pres = ");
7979
log_tritv(fcx, pres);
8080

8181
if !implies(pres, prec) {

src/comp/middle/tstate/collect_locals.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ fn mk_fn_info(ccx: crate_ctxt,
154154
i_diverge: ninit(diverges_id, diverges_name),
155155
used_vars: v};
156156
ccx.fm.insert(id, rslt);
157-
log name + " has " + uint::str(num_constraints(rslt)) +
158-
" constraints";
157+
#debug("%s has %u constraints", name, num_constraints(rslt));
159158
}
160159

161160

src/comp/middle/typeck.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,9 +1502,9 @@ fn check_expr_fn_with_unifier(fcx: @fn_ctxt,
15021502

15031503
let fty = ty_of_fn_decl(tcx, m_check_tyvar(fcx), decl);
15041504

1505-
log #fmt("check_expr_fn_with_unifier %s fty=%s",
1506-
expr_to_str(expr),
1507-
ty_to_str(tcx, fty));
1505+
#debug("check_expr_fn_with_unifier %s fty=%s",
1506+
expr_to_str(expr),
1507+
ty_to_str(tcx, fty));
15081508

15091509
write::ty_only_fixup(fcx, expr.id, fty);
15101510

@@ -1965,9 +1965,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
19651965
ast::proto_block
19661966
}
19671967
};
1968-
log #fmt("checking expr_fn_block %s expected=%s",
1969-
expr_to_str(expr),
1970-
ty_to_str(tcx, expected));
1968+
#debug("checking expr_fn_block %s expected=%s",
1969+
expr_to_str(expr),
1970+
ty_to_str(tcx, expected));
19711971
check_expr_fn_with_unifier(fcx, expr, {proto: proto with decl}, body,
19721972
unify, expected);
19731973
write::ty_only_fixup(fcx, id, expected);

src/comp/syntax/parse/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive],
3030
prefix: str, suffix: option::t<str>)
3131
-> (ast::_mod, [ast::attribute]) {
3232
#debug("eval crate prefix: %s", prefix);
33-
log #fmt("eval crate suffix: %s",
34-
option::from_maybe("none", suffix));
33+
#debug("eval crate suffix: %s",
34+
option::from_maybe("none", suffix));
3535
let (cview_items, citems, cattrs)
3636
= parse_companion_mod(cx, prefix, suffix);
3737
let view_items: [@ast::view_item] = [];

src/comp/syntax/parse/parser.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -910,22 +910,17 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
910910
hi = e.span.hi;
911911
ex = ast::expr_fail(some(e));
912912
} else { ex = ast::expr_fail(none); }
913-
} else if eat_word(p, "log_full") {
913+
} else if
914+
(eat_word(p, "log_full")
915+
|| eat_word(p, "log")
916+
|| eat_word(p, "log_err")) {
914917
expect(p, token::LPAREN);
915918
let lvl = parse_expr(p);
916919
expect(p, token::COMMA);
917920
let e = parse_expr(p);
918921
ex = ast::expr_log(2, lvl, e);
919922
hi = p.get_hi_pos();
920923
expect(p, token::RPAREN);
921-
} else if eat_word(p, "log") {
922-
let e = parse_expr(p);
923-
ex = ast::expr_log(1, mk_lit_u32(p, 1u32), e);
924-
hi = e.span.hi;
925-
} else if eat_word(p, "log_err") {
926-
let e = parse_expr(p);
927-
ex = ast::expr_log(0, mk_lit_u32(p, 0u32), e);
928-
hi = e.span.hi;
929924
} else if eat_word(p, "assert") {
930925
let e = parse_expr(p);
931926
ex = ast::expr_assert(e);

src/comp/syntax/print/pp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ obj printer(out: io::writer,
304304
}
305305
}
306306
fn check_stream() {
307-
log #fmt["check_stream [%u, %u] with left_total=%d, right_total=%d",
308-
left, right, left_total, right_total];
307+
#debug("check_stream [%u, %u] with left_total=%d, right_total=%d",
308+
left, right, left_total, right_total);
309309
if right_total - left_total > space {
310-
log #fmt["scan window is %d, longer than space on line (%d)",
311-
right_total - left_total, space];
310+
#debug("scan window is %d, longer than space on line (%d)",
311+
right_total - left_total, space);
312312
if !scan_stack_empty {
313313
if left == scan_stack[bottom] {
314314
#debug("setting %u to infinity and popping", left);
@@ -411,8 +411,8 @@ obj printer(out: io::writer,
411411
out.write_str(s);
412412
}
413413
fn print(x: token, L: int) {
414-
log #fmt["print %s %d (remaining line space=%d)", tok_str(x), L,
415-
space];
414+
#debug("print %s %d (remaining line space=%d)", tok_str(x), L,
415+
space);
416416
log_full(core::debug, buf_str(token, size, left, right, 6u));
417417
alt x {
418418
BEGIN(b) {

src/compiletest/header.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ fn parse_name_value_directive(line: str,
110110
let value =
111111
str::slice(line, colon + str::byte_len(keycolon),
112112
str::byte_len(line));
113-
log #fmt("%s: %s", directive,
114-
value);
113+
#debug("%s: %s", directive, value);
115114
option::some(value)
116115
} else { option::none }
117116
}

src/fuzzer/fuzzer.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,11 @@ fn check_variants(files: [str], cx: context) {
549549
parser::parse_crate_from_source_str(
550550
file,
551551
s, [], sess);
552-
log_err as_str(bind pprust::print_crate(sess.cm, crate,
553-
file,
554-
io::string_reader(s), _,
555-
pprust::no_ann()));
552+
#error("%s",
553+
as_str(bind pprust::print_crate(sess.cm, crate,
554+
file,
555+
io::string_reader(s), _,
556+
pprust::no_ann())));
556557
check_variants_of_ast(*crate, sess.cm, file, cx);
557558
}
558559
}

src/libstd/map.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,16 @@ mod chained {
143143
while true {
144144
alt e0.next {
145145
absent. {
146-
log("search_tbl", "absent", "comparisons", comp,
147-
"hash", h, "idx", idx);
148-
146+
#debug("search_tbl: absent, comp %u, hash %u, idx %u",
147+
comp, h, idx);
149148
ret not_found;
150149
}
151150
present(e1) {
152151
comp += 1u;
153152
let e1_key = e1.key; // Satisfy alias checker.
154153
if e1.hash == h && tbl.eqer(e1_key, k) {
155-
log("search_tbl", "present", "comparisons", comp,
156-
"hash", h, "idx", idx);
154+
#debug("search_tbl: present, comp %u, hash %u, idx %u",
155+
comp, h, idx);
157156
ret found_after(e0, e1);
158157
} else {
159158
e0 = e1;
@@ -169,15 +168,15 @@ mod chained {
169168
let idx = h % vec::len(tbl.chains);
170169
alt tbl.chains[idx] {
171170
absent. {
172-
log("search_tbl", "absent", "comparisons", 0u,
173-
"hash", h, "idx", idx);
171+
#debug("search_tbl: absent, comp %u, hash %u, idx %u",
172+
0u, h, idx);
174173
ret not_found;
175174
}
176175
present(e) {
177176
let e_key = e.key; // Satisfy alias checker.
178177
if e.hash == h && tbl.eqer(e_key, k) {
179-
log("search_tbl", "present", "comparisons", 1u,
180-
"hash", h, "idx", idx);
178+
#debug("search_tbl: present, comp %u, hash %u, idx %u",
179+
1u, h, idx);
181180
ret found_first(idx, e);
182181
} else {
183182
ret search_rem(tbl, k, h, idx, e);

0 commit comments

Comments
 (0)