auto merge of #7822 : huonw/rust/cond-debug, r=graydon

As per @pcwalton's request, `debug!(..)` is only activated when the `debug` cfg is set; that is, for `RUST_LOG=some_module=4 ./some_program` to work, it needs to be compiled with `rustc --cfg debug some_program.rs`. (Although, there is the sneaky `__debug!(..)` macro that is always active, if you *really* need it.)

It functions by making `debug!` expand to `if false { __debug!(..) }` (expanding to an `if` like this is required to make sure `debug!` statements are typechecked and to avoid unused variable warnings), and adjusting trans to skip the pointless branches in `if true ...` and `if false ...`.

The conditional expansion change also required moving the inject-std-macros step into a new pass, and makes it actually insert them at the top of the crate; this means that the cfg stripping traverses over the macros and so filters out the unused ones.

This appears to takes an unoptimised build of `librustc` from 65s to 59s; and the full bootstrap from 18m41s to 18m26s on my computer (with general background use).

`./configure --enable-debug` will enable `debug!` statements in the bootstrap build.
This commit is contained in:
bors 2013-07-16 11:19:20 -07:00
commit ad212ecee4
226 changed files with 838 additions and 682 deletions

View File

@ -194,6 +194,10 @@ pub fn compile_rest(sess: Session,
// mod bar { macro_rules! baz!(() => {{}}) }
//
// baz! should not use this definition unless foo is enabled.
crate = time(time_passes, ~"std macros injection", ||
syntax::ext::expand::inject_std_macros(sess.parse_sess, copy cfg,
crate));
crate = time(time_passes, ~"configuration 1", ||
front::config::strip_unconfigured_items(crate));
@ -214,7 +218,7 @@ pub fn compile_rest(sess: Session,
assert!(phases.from != cu_no_trans);
let (llcx, llmod, link_meta) = {
crate = time(time_passes, ~"extra injection", ||
crate = time(time_passes, ~"std injection", ||
front::std_inject::maybe_inject_libstd_ref(sess, crate));
let ast_map = time(time_passes, ~"ast indexing", ||

View File

@ -1530,7 +1530,7 @@ pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> Value
let _icx = push_ctxt("alloca");
if cx.unreachable {
unsafe {
return llvm::LLVMGetUndef(ty.to_ref());
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
}
}
let initcx = base::raw_block(cx.fcx, false, cx.fcx.get_llstaticallocas());

View File

@ -569,15 +569,17 @@ pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
let value = Load(cx, PointerVal);
unsafe {
let t = llvm::LLVMGetElementType(llvm::LLVMTypeOf(PointerVal));
let min = llvm::LLVMConstInt(t, lo, signed);
let max = llvm::LLVMConstInt(t, hi, signed);
if !cx.unreachable {
unsafe {
let t = llvm::LLVMGetElementType(llvm::LLVMTypeOf(PointerVal));
let min = llvm::LLVMConstInt(t, lo, signed);
let max = llvm::LLVMConstInt(t, hi, signed);
do [min, max].as_imm_buf |ptr, len| {
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
llvm::LLVMMDNodeInContext(cx.fcx.ccx.llcx,
ptr, len as c_uint));
do [min, max].as_imm_buf |ptr, len| {
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
llvm::LLVMMDNodeInContext(cx.fcx.ccx.llcx,
ptr, len as c_uint));
}
}
}

View File

@ -63,6 +63,38 @@ pub fn trans_if(bcx: block,
let _indenter = indenter();
let _icx = push_ctxt("trans_if");
match cond.node {
// `if true` and `if false` can be trans'd more efficiently,
// by dropping branches that are known to be impossible.
ast::expr_lit(@ref l) => match l.node {
ast::lit_bool(true) => {
// if true { .. } [else { .. }]
let then_bcx_in = scope_block(bcx, thn.info(), "if_true_then");
let then_bcx_out = trans_block(then_bcx_in, thn, dest);
let then_bcx_out = trans_block_cleanups(then_bcx_out,
block_cleanups(then_bcx_in));
Br(bcx, then_bcx_in.llbb);
return then_bcx_out;
}
ast::lit_bool(false) => {
match els {
// if false { .. } else { .. }
Some(elexpr) => {
let (else_bcx_in, else_bcx_out) =
trans_if_else(bcx, elexpr, dest, "if_false_else");
Br(bcx, else_bcx_in.llbb);
return else_bcx_out;
}
// if false { .. }
None => return bcx,
}
}
_ => {}
},
_ => {}
}
let Result {bcx, val: cond_val} =
expr::trans_to_datum(bcx, cond).to_result();
@ -80,22 +112,8 @@ pub fn trans_if(bcx: block,
// 'else' context
let (else_bcx_in, next_bcx) = match els {
Some(elexpr) => {
let else_bcx_in = scope_block(bcx, els.info(), "else");
let else_bcx_out = match elexpr.node {
ast::expr_if(_, _, _) => {
let elseif_blk = ast_util::block_from_expr(elexpr);
trans_block(else_bcx_in, &elseif_blk, dest)
}
ast::expr_block(ref blk) => {
trans_block(else_bcx_in, blk, dest)
}
// would be nice to have a constraint on ifs
_ => bcx.tcx().sess.bug("strange alternative in if")
};
let else_bcx_out = trans_block_cleanups(else_bcx_out,
block_cleanups(else_bcx_in));
(else_bcx_in, join_blocks(bcx, [then_bcx_out, else_bcx_out]))
let (else_bcx_in, else_bcx_out) = trans_if_else(bcx, elexpr, dest, "else");
(else_bcx_in, join_blocks(bcx, [then_bcx_out, else_bcx_out]))
}
_ => {
let next_bcx = sub_block(bcx, "next");
@ -109,7 +127,27 @@ pub fn trans_if(bcx: block,
then_bcx_in.to_str(), else_bcx_in.to_str());
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
next_bcx
return next_bcx;
// trans `else [ if { .. } ... | { .. } ]`
fn trans_if_else(bcx: block, elexpr: @ast::expr,
dest: expr::Dest, scope_name: &str) -> (block, block) {
let else_bcx_in = scope_block(bcx, elexpr.info(), scope_name);
let else_bcx_out = match elexpr.node {
ast::expr_if(_, _, _) => {
let elseif_blk = ast_util::block_from_expr(elexpr);
trans_block(else_bcx_in, &elseif_blk, dest)
}
ast::expr_block(ref blk) => {
trans_block(else_bcx_in, blk, dest)
}
// would be nice to have a constraint on ifs
_ => bcx.tcx().sess.bug("strange alternative in if")
};
let else_bcx_out = trans_block_cleanups(else_bcx_out,
block_cleanups(else_bcx_in));
(else_bcx_in, else_bcx_out)
}
}
pub fn join_blocks(parent_bcx: block, in_cxs: &[block]) -> block {

View File

@ -413,7 +413,7 @@ impl Datum {
pub fn to_value_datum(&self, bcx: block) -> Datum {
/*!
*
* Yields a by-ref form of this datum. This may involve
* Yields a by-value form of this datum. This may involve
* creation of a temporary stack slot. The value returned by
* this function is not separately rooted from this datum, so
* it will not live longer than the current datum. */

View File

@ -113,6 +113,8 @@ fn build_ctxt(sess: Session,
use rustc::front::config;
let ast = syntax::ext::expand::inject_std_macros(sess.parse_sess,
copy sess.opts.cfg, ast);
let ast = config::strip_unconfigured_items(ast);
let ast = syntax::ext::expand::expand_crate(sess.parse_sess,
copy sess.opts.cfg, ast);
@ -138,7 +140,8 @@ fn should_prune_unconfigured_items() {
let source = ~"#[cfg(shut_up_and_leave_me_alone)]fn a() { }";
do from_str(source) |srv| {
do exec(srv) |ctxt| {
assert!(ctxt.ast.node.module.items.is_empty());
// one item: the __std_macros secret module
assert_eq!(ctxt.ast.node.module.items.len(), 1);
}
}
}

View File

@ -255,7 +255,8 @@ mod test {
#[test]
fn should_should_extract_mod_attributes() {
let doc = mk_doc(~"#[doc = \"test\"] mod a { }");
assert!(doc.cratemod().mods()[0].desc() == Some(~"test"));
// hidden __std_macros module at the start.
assert!(doc.cratemod().mods()[1].desc() == Some(~"test"));
}
#[test]

View File

@ -190,7 +190,8 @@ mod test {
#[test]
fn should_promote_desc() {
let doc = mk_doc(~"#[doc = \"desc\"] mod m { }");
assert_eq!(doc.cratemod().mods()[0].brief(), Some(~"desc"));
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().mods()[1].brief(), Some(~"desc"));
}
#[test]

View File

@ -172,6 +172,7 @@ mod test {
use extract;
use markdown_index_pass::run;
use path_pass;
use prune_hidden_pass;
use super::pandoc_header_id;
fn mk_doc(output_style: config::OutputStyle, source: ~str)
@ -183,8 +184,10 @@ mod test {
};
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (attr_pass::mk_pass().f)(srv.clone(), doc);
let doc = (prune_hidden_pass::mk_pass().f)(srv.clone(), doc);
let doc = (desc_to_brief_pass::mk_pass().f)(srv.clone(), doc);
let doc = (path_pass::mk_pass().f)(srv.clone(), doc);
run(srv.clone(), doc, config)
}
}
@ -240,13 +243,13 @@ mod test {
config::DocPerMod,
~"mod a { } fn b() { }"
);
assert!(doc.cratemod().index.get().entries[0] == doc::IndexEntry {
assert_eq!(doc.cratemod().index.get().entries[0], doc::IndexEntry {
kind: ~"Module",
name: ~"a",
brief: None,
link: ~"a.html"
});
assert!(doc.cratemod().index.get().entries[1] == doc::IndexEntry {
assert_eq!(doc.cratemod().index.get().entries[1], doc::IndexEntry {
kind: ~"Function",
name: ~"b",
brief: None,
@ -260,8 +263,7 @@ mod test {
config::DocPerMod,
~"#[doc = \"test\"] mod a { }"
);
assert!(doc.cratemod().index.get().entries[0].brief
== Some(~"test"));
assert_eq!(doc.cratemod().index.get().entries[0].brief, Some(~"test"));
}
#[test]
@ -270,12 +272,13 @@ mod test {
config::DocPerCrate,
~"extern { fn b(); }"
);
assert!(doc.cratemod().nmods()[0].index.get().entries[0]
== doc::IndexEntry {
kind: ~"Function",
name: ~"b",
brief: None,
link: ~"#function-b"
});
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().nmods()[0].index.get().entries[0],
doc::IndexEntry {
kind: ~"Function",
name: ~"b",
brief: None,
link: ~"#function-b"
});
}
}

View File

@ -529,6 +529,7 @@ mod test {
use markdown_writer;
use path_pass;
use page_pass;
use prune_hidden_pass;
use sectionalize_pass;
use trim_pass;
use tystr_pass;
@ -557,6 +558,8 @@ mod test {
debug!("doc (path): %?", doc);
let doc = (attr_pass::mk_pass().f)(srv.clone(), doc);
debug!("doc (attr): %?", doc);
let doc = (prune_hidden_pass::mk_pass().f)(srv.clone(), doc);
debug!("doc (prune_hidden): %?", doc);
let doc = (desc_to_brief_pass::mk_pass().f)(srv.clone(), doc);
debug!("doc (desc_to_brief): %?", doc);
let doc = (unindent_pass::mk_pass().f)(srv.clone(), doc);

View File

@ -277,7 +277,8 @@ mod test {
.. config::default_config(&Path("input/test.rc"))
};
let doc = mk_doc(~"", ~"mod a { mod b { } }");
let modb = copy doc.cratemod().mods()[0].mods()[0];
// hidden __std_macros module at the start.
let modb = copy doc.cratemod().mods()[1].mods()[0];
let page = doc::ItemPage(doc::ModTag(modb));
let filename = make_local_filename(&config, page);
assert_eq!(filename, Path("output/dir/a_b.html"));

View File

@ -152,8 +152,10 @@ fn fold_nmod(
mod test {
use astsrv;
use config;
use attr_pass;
use doc;
use extract;
use prune_hidden_pass;
use page_pass::run;
fn mk_doc_(
@ -162,6 +164,8 @@ mod test {
) -> doc::Doc {
do astsrv::from_str(copy source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (attr_pass::mk_pass().f)(srv.clone(), doc);
let doc = (prune_hidden_pass::mk_pass().f)(srv.clone(), doc);
run(srv.clone(), doc, output_style)
}
}
@ -182,6 +186,7 @@ mod test {
#[test]
fn should_make_a_page_for_every_mod() {
let doc = mk_doc(~"mod a { }");
// hidden __std_macros module at the start.
assert_eq!(doc.pages.mods()[0].name(), ~"a");
}

View File

@ -97,10 +97,11 @@ fn should_record_mod_paths() {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = run(srv.clone(), doc);
assert!(doc.cratemod().mods()[0].mods()[0].mods()[0].path()
== ~[~"a", ~"b"]);
assert!(doc.cratemod().mods()[0].mods()[1].mods()[0].path()
== ~[~"a", ~"d"]);
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().mods()[1].mods()[0].mods()[0].path(),
~[~"a", ~"b"]);
assert_eq!(doc.cratemod().mods()[1].mods()[1].mods()[0].path(),
~[~"a", ~"d"]);
}
}
@ -110,6 +111,7 @@ fn should_record_fn_paths() {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = run(srv.clone(), doc);
assert_eq!(doc.cratemod().mods()[0].fns()[0].path(), ~[~"a"]);
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().mods()[1].fns()[0].path(), ~[~"a"]);
}
}

View File

@ -166,12 +166,14 @@ mod test {
use attr_pass;
use doc;
use extract;
use prune_hidden_pass;
use sectionalize_pass::run;
fn mk_doc(source: ~str) -> doc::Doc {
do astsrv::from_str(copy source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (attr_pass::mk_pass().f)(srv.clone(), doc);
let doc = (prune_hidden_pass::mk_pass().f)(srv.clone(), doc);
run(srv.clone(), doc)
}
}

View File

@ -31,7 +31,8 @@ fn test() {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (mk_pass().f)(srv.clone(), doc);
assert_eq!(doc.cratemod().items[0].name(), ~"y");
assert_eq!(doc.cratemod().items[1].name(), ~"z");
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().items[1].name(), ~"y");
assert_eq!(doc.cratemod().items[2].name(), ~"z");
}
}

View File

@ -53,6 +53,7 @@ fn test() {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (mk_pass().f)(srv.clone(), doc);
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().items[0].name(), ~"iconst");
assert_eq!(doc.cratemod().items[1].name(), ~"itype");
assert_eq!(doc.cratemod().items[2].name(), ~"ienum");
@ -60,6 +61,7 @@ fn test() {
assert_eq!(doc.cratemod().items[4].name(), ~"itrait");
assert_eq!(doc.cratemod().items[5].name(), ~"__extensions__");
assert_eq!(doc.cratemod().items[6].name(), ~"ifn");
assert_eq!(doc.cratemod().items[7].name(), ~"imod");
// hidden __std_macros module fits here.
assert_eq!(doc.cratemod().items[8].name(), ~"imod");
}
}

View File

@ -67,10 +67,11 @@ fn test() {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (mk_pass(~"", name_lteq).f)(srv.clone(), doc);
assert_eq!(doc.cratemod().mods()[0].name(), ~"w");
assert_eq!(doc.cratemod().mods()[1].items[0].name(), ~"x");
assert_eq!(doc.cratemod().mods()[1].items[1].name(), ~"y");
assert_eq!(doc.cratemod().mods()[1].name(), ~"z");
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().mods()[1].name(), ~"w");
assert_eq!(doc.cratemod().mods()[2].items[0].name(), ~"x");
assert_eq!(doc.cratemod().mods()[2].items[1].name(), ~"y");
assert_eq!(doc.cratemod().mods()[2].name(), ~"z");
}
}
@ -84,10 +85,11 @@ fn should_be_stable() {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (mk_pass(~"", always_eq).f)(srv.clone(), doc);
assert_eq!(doc.cratemod().mods()[0].items[0].name(), ~"b");
assert_eq!(doc.cratemod().mods()[1].items[0].name(), ~"d");
// hidden __std_macros module at the start.
assert_eq!(doc.cratemod().mods()[1].items[0].name(), ~"b");
assert_eq!(doc.cratemod().mods()[2].items[0].name(), ~"d");
let doc = (mk_pass(~"", always_eq).f)(srv.clone(), doc);
assert_eq!(doc.cratemod().mods()[0].items[0].name(), ~"b");
assert_eq!(doc.cratemod().mods()[1].items[0].name(), ~"d");
assert_eq!(doc.cratemod().mods()[1].items[0].name(), ~"b");
assert_eq!(doc.cratemod().mods()[2].items[0].name(), ~"d");
}
}

View File

@ -28,12 +28,14 @@ mod test {
use attr_pass;
use doc;
use extract;
use prune_hidden_pass;
use trim_pass::mk_pass;
fn mk_doc(source: ~str) -> doc::Doc {
do astsrv::from_str(copy source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
let doc = (attr_pass::mk_pass().f)(srv.clone(), doc);
let doc = (prune_hidden_pass::mk_pass().f)(srv.clone(), doc);
(mk_pass().f)(srv.clone(), doc)
}
}

View File

@ -8,15 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{blk_, attribute_, attr_outer, meta_word};
use ast::{crate, expr_, expr_mac, mac_invoc_tt};
use ast::{blk_, crate, expr_, expr_mac, mac_invoc_tt};
use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
use ast::{illegal_ctxt};
use ast;
use ast_util::{new_rename, new_mark, resolve};
use attr;
use codemap;
use codemap::{span, ExpnInfo, NameAndSpan, spanned};
use codemap::{span, ExpnInfo, NameAndSpan};
use ext::base::*;
use fold::*;
use parse;
@ -452,9 +451,12 @@ pub fn new_span(cx: @ExtCtxt, sp: span) -> span {
// the default compilation environment. It would be much nicer to use
// a mechanism like syntax_quote to ensure hygiene.
pub fn core_macros() -> @str {
pub fn std_macros() -> @str {
return
@"pub mod macros {
@"mod __std_macros {
#[macro_escape];
#[doc(hidden)];
macro_rules! ignore (($($x:tt)*) => (()))
macro_rules! error (
@ -484,7 +486,9 @@ pub fn core_macros() -> @str {
)
)
macro_rules! debug (
// conditionally define debug!, but keep it type checking even
// in non-debug builds.
macro_rules! __debug (
($arg:expr) => (
__log(4u32, fmt!( \"%?\", $arg ))
);
@ -493,6 +497,22 @@ pub fn core_macros() -> @str {
)
)
#[cfg(debug)]
#[macro_escape]
mod debug_macro {
macro_rules! debug (($($arg:expr),*) => {
__debug!($($arg),*)
})
}
#[cfg(not(debug))]
#[macro_escape]
mod debug_macro {
macro_rules! debug (($($arg:expr),*) => {
if false { __debug!($($arg),*) }
})
}
macro_rules! fail(
() => (
fail!(\"explicit failure\")
@ -668,6 +688,35 @@ pub fn core_macros() -> @str {
}";
}
// add a bunch of macros as though they were placed at the head of the
// program (ick). This should run before cfg stripping.
pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg, c: &crate) -> @crate {
let sm = match parse_item_from_source_str(@"<std-macros>",
std_macros(),
copy cfg,
~[],
parse_sess) {
Some(item) => item,
None => fail!("expected core macros to parse correctly")
};
let injecter = @AstFoldFns {
fold_mod: |modd, _| {
// just inject the std macros at the start of the first
// module in the crate (i.e the crate file itself.)
let items = vec::append(~[sm], modd.items);
ast::_mod {
items: items,
// FIXME #2543: Bad copy.
.. copy *modd
}
},
.. *default_ast_fold()
};
@make_fold(injecter).fold_crate(c)
}
pub fn expand_crate(parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg, c: &crate) -> @crate {
// adding *another* layer of indirection here so that the block
@ -692,33 +741,6 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
new_span: |a| new_span(cx, a),
.. *afp};
let f = make_fold(f_pre);
// add a bunch of macros as though they were placed at the
// head of the program (ick).
let attrs = ~[
spanned {
span: codemap::dummy_sp(),
node: attribute_ {
style: attr_outer,
value: @spanned {
node: meta_word(@"macro_escape"),
span: codemap::dummy_sp(),
},
is_sugared_doc: false,
}
}
];
let cm = match parse_item_from_source_str(@"<core-macros>",
core_macros(),
copy cfg,
attrs,
parse_sess) {
Some(item) => item,
None => cx.bug("expected core macros to parse correctly")
};
// This is run for its side-effects on the expander env,
// as it registers all the core macros as expanders.
f.fold_item(cm);
@f.fold_crate(c)
}
@ -789,6 +811,8 @@ mod test {
@"<test>",
src,
~[],sess);
let crate_ast = inject_std_macros(sess, ~[], crate_ast);
// don't bother with striping, doesn't affect fail!.
expand_crate(sess,~[],crate_ast);
}
@ -836,20 +860,14 @@ mod test {
expand_crate(sess,~[],crate_ast);
}
#[test] fn core_macros_must_parse () {
let src = @"
pub mod macros {
macro_rules! ignore (($($x:tt)*) => (()))
macro_rules! error ( ($( $arg:expr ),+) => (
log(::core::error, fmt!( $($arg),+ )) ))
}";
#[test] fn std_macros_must_parse () {
let src = super::std_macros();
let sess = parse::new_parse_sess(None);
let cfg = ~[];
let item_ast = parse::parse_item_from_source_str(
@"<test>",
src,
cfg,~[make_dummy_attr (@"macro_escape")],sess);
cfg,~[],sess);
match item_ast {
Some(_) => (), // success
None => fail!("expected this to parse")

View File

@ -26,7 +26,7 @@ pub mod rustrt {
pub fn fact(n: uint) -> uint {
unsafe {
debug!("n = %?", n);
info!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}

View File

@ -25,6 +25,6 @@ fn main() {
for uint::range(0u, n) |i| {
let x = uint::to_str(i);
debug!(x);
info!(x);
}
}

View File

@ -110,6 +110,6 @@ fn main() {
copy args
};
debug!("%?", args);
info!("%?", args);
run(args);
}

View File

@ -106,6 +106,6 @@ fn main() {
copy args
};
debug!("%?", args);
info!("%?", args);
run(args);
}

View File

@ -44,7 +44,7 @@ fn roundtrip(id: int, n_tasks: int, p: &Port<int>, ch: &Chan<int>) {
return;
}
token => {
debug!("thread: %d got token: %d", id, token);
info!("thread: %d got token: %d", id, token);
ch.send(token - 1);
if token <= n_tasks {
return;

View File

@ -33,11 +33,11 @@ fn main() {
fn run(repeat: int, depth: int) {
for (repeat as uint).times {
debug!("starting %.4f", precise_time_s());
info!("starting %.4f", precise_time_s());
do task::try {
recurse_or_fail(depth, None)
};
debug!("stopping %.4f", precise_time_s());
info!("stopping %.4f", precise_time_s());
}
}
@ -71,7 +71,7 @@ fn r(l: @nillist) -> r {
fn recurse_or_fail(depth: int, st: Option<State>) {
if depth == 0 {
debug!("unwinding %.4f", precise_time_s());
info!("unwinding %.4f", precise_time_s());
fail!();
} else {
let depth = depth - 1;

View File

@ -11,9 +11,9 @@
fn test() {
let v: int;
v = 1; //~ NOTE prior assignment occurs here
debug!("v=%d", v);
info!("v=%d", v);
v = 2; //~ ERROR re-assignment of immutable variable
debug!("v=%d", v);
info!("v=%d", v);
}
fn main() {

View File

@ -27,5 +27,5 @@ fn cat(in_x : uint, in_y : int) -> cat {
fn main() {
let nyan : cat = cat(52u, 99);
nyan.speak = || debug!("meow"); //~ ERROR attempted to take value of method
nyan.speak = || info!("meow"); //~ ERROR attempted to take value of method
}

View File

@ -10,5 +10,5 @@
fn main() {
#[attr] //~ ERROR expected item after attributes
debug!("hi");
info!("hi");
}

View File

@ -21,11 +21,11 @@ fn main() {
let a: clam = clam{x: @1, y: @2};
let b: clam = clam{x: @10, y: @20};
let z: int = a.x + b.y; //~ ERROR binary operation + cannot be applied to type `@int`
debug!(z);
info!(z);
assert_eq!(z, 21);
let forty: fish = fish{a: @40};
let two: fish = fish{a: @2};
let answer: int = forty.a + two.a; //~ ERROR binary operation + cannot be applied to type `@int`
debug!(answer);
info!(answer);
assert_eq!(answer, 42);
}

View File

@ -11,4 +11,4 @@
// error-pattern:expected `~str` but found `int`
static i: ~str = 10i;
fn main() { debug!(i); }
fn main() { info!(i); }

View File

@ -17,6 +17,6 @@ fn compute1() -> float {
fn main() {
let x = compute1();
debug!(x);
info!(x);
assert_eq!(x, -4f);
}

View File

@ -17,7 +17,7 @@ enum color { rgb(int, int, int), rgba(int, int, int, int), }
fn main() {
let red: color = rgb(255, 0, 0);
match red {
rgb(r, g, b) => { debug!("rgb"); }
hsl(h, s, l) => { debug!("hsl"); }
rgb(r, g, b) => { info!("rgb"); }
hsl(h, s, l) => { info!("hsl"); }
}
}

View File

@ -21,7 +21,7 @@ fn a() {
p[0] = 5; //~ ERROR cannot assign
debug!("%d", *q);
info!("%d", *q);
}
fn borrow(_x: &[int], _f: &fn()) {}

View File

@ -18,14 +18,14 @@ fn box_imm() {
let v = ~3;
let _w = &v;
do task::spawn {
debug!("v=%d", *v);
info!("v=%d", *v);
//~^ ERROR cannot move `v` into closure
}
let v = ~3;
let _w = &v;
task::spawn(|| {
debug!("v=%d", *v);
info!("v=%d", *v);
//~^ ERROR cannot move
});
}

View File

@ -22,7 +22,7 @@ pub fn main() {
}
}
let z = copy tail[0];
debug!(fmt!("%?", z));
info!(fmt!("%?", z));
}
_ => {
::std::util::unreachable();

View File

@ -12,5 +12,5 @@ fn main() {
let x: int = 3;
let y: &mut int = &mut x; //~ ERROR cannot borrow
*y = 5;
debug!(*y);
info!(*y);
}

View File

@ -13,5 +13,5 @@
fn main() {
return;
debug!("Paul is dead"); //~ ERROR: unreachable
info!("Paul is dead"); //~ ERROR: unreachable
}

View File

@ -1,2 +1,2 @@
// error-pattern: unresolved name `this_does_nothing_what_the`.
fn main() { debug!("doing"); this_does_nothing_what_the; debug!("boing"); }
fn main() { info!("doing"); this_does_nothing_what_the; info!("boing"); }

View File

@ -15,7 +15,7 @@ mod foo {
}
mod bar {
fn x() { debug!("x"); }
fn x() { info!("x"); }
pub fn y() { }
}

View File

@ -12,5 +12,5 @@
fn main() {
let a = if true { true };
debug!(a);
info!(a);
}

View File

@ -13,10 +13,10 @@
use module_of_many_things::*;
mod module_of_many_things {
pub fn f1() { debug!("f1"); }
pub fn f2() { debug!("f2"); }
fn f3() { debug!("f3"); }
pub fn f4() { debug!("f4"); }
pub fn f1() { info!("f1"); }
pub fn f2() { info!("f2"); }
fn f3() { info!("f3"); }
pub fn f4() { info!("f4"); }
}

View File

@ -12,13 +12,13 @@
mod circ1 {
pub use circ2::f2;
pub fn f1() { debug!("f1"); }
pub fn f1() { info!("f1"); }
pub fn common() -> uint { return 0u; }
}
mod circ2 {
pub use circ1::f1;
pub fn f2() { debug!("f2"); }
pub fn f2() { info!("f2"); }
pub fn common() -> uint { return 1u; }
}

View File

@ -12,6 +12,6 @@
use zed::bar;
use zed::baz;
mod zed {
pub fn bar() { debug!("bar"); }
pub fn bar() { info!("bar"); }
}
fn main(args: ~[str]) { bar(); }

View File

@ -13,6 +13,6 @@ use baz::zed::bar; //~ ERROR unresolved import
mod baz {}
mod zed {
pub fn bar() { debug!("bar3"); }
pub fn bar() { info!("bar3"); }
}
fn main(args: ~[str]) { bar(); }

View File

@ -11,4 +11,4 @@
// error-pattern: unresolved
use main::bar;
fn main(args: ~[str]) { debug!("foo"); }
fn main(args: ~[str]) { info!("foo"); }

View File

@ -13,4 +13,4 @@
mod a { pub use b::foo; }
mod b { pub use a::foo; }
fn main(args: ~[str]) { debug!("loop"); }
fn main(args: ~[str]) { info!("loop"); }

View File

@ -11,5 +11,5 @@
// Regression test for issue #1448 and #1386
fn main() {
debug!("%u", 10i); //~ ERROR mismatched types
info!("%u", 10i); //~ ERROR mismatched types
}

View File

@ -10,4 +10,4 @@
// error-pattern: unresolved name `foobar`.
fn main(args: ~[str]) { debug!(foobar); }
fn main(args: ~[str]) { info!(foobar); }

View File

@ -19,7 +19,7 @@ fn main()
{
let _z = match g(1, 2) {
g(x, x) => { debug!(x + x); }
g(x, x) => { info!(x + x); }
//~^ ERROR Identifier `x` is bound more than once in the same pattern
};

View File

@ -11,6 +11,6 @@
fn main() {
let i: int;
debug!(false && { i = 5; true });
debug!(i); //~ ERROR use of possibly uninitialized variable: `i`
info!(false && { i = 5; true });
info!(i); //~ ERROR use of possibly uninitialized variable: `i`
}

View File

@ -12,6 +12,6 @@
// Tests that a function with a ! annotation always actually fails
// error-pattern: some control paths may return
fn bad_bang(i: uint) -> ! { debug!(3); }
fn bad_bang(i: uint) -> ! { info!(3); }
fn main() { bad_bang(5u); }

View File

@ -12,6 +12,6 @@ fn force(f: &fn()) { f(); }
fn main() {
let x: int;
force(|| {
debug!(x); //~ ERROR capture of possibly uninitialized variable: `x`
info!(x); //~ ERROR capture of possibly uninitialized variable: `x`
});
}

View File

@ -16,9 +16,9 @@ fn foo() -> int {
x = 0;
}
debug!(x); //~ ERROR use of possibly uninitialized variable: `x`
info!(x); //~ ERROR use of possibly uninitialized variable: `x`
return 17;
}
fn main() { debug!(foo()); }
fn main() { info!(foo()); }

View File

@ -16,9 +16,9 @@ fn foo() -> int {
x = 0;
}
debug!(x); //~ ERROR use of possibly uninitialized variable: `x`
info!(x); //~ ERROR use of possibly uninitialized variable: `x`
return 17;
}
fn main() { debug!(foo()); }
fn main() { info!(foo()); }

View File

@ -9,4 +9,4 @@
// except according to those terms.
fn force(f: &fn() -> int) -> int { f() }
fn main() { debug!(force(|| {})); } //~ ERROR mismatched types
fn main() { info!(force(|| {})); } //~ ERROR mismatched types

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x: int) { debug!(x); }
fn foo(x: int) { info!(x); }
fn main() {
let x: int; if 1 > 2 { x = 10; }

View File

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x: int) { debug!(x); }
fn foo(x: int) { info!(x); }
fn main() {
let x: int;
if 1 > 2 {
debug!("whoops");
info!("whoops");
} else {
x = 10;
}

View File

@ -12,7 +12,7 @@ fn main() {
let y: ~int = ~42;
let mut x: ~int;
loop {
debug!(y);
info!(y);
loop {
loop {
loop {

View File

@ -13,7 +13,7 @@ fn main() {
let y: ~int = ~42;
let mut x: ~int;
loop {
debug!(y); //~ ERROR use of moved value: `y`
info!(y); //~ ERROR use of moved value: `y`
while true { while true { while true { x = y; copy x; } } }
//~^ ERROR use of moved value: `y`
}

View File

@ -11,6 +11,6 @@
fn main() {
let i: int;
debug!(false || { i = 5; true });
debug!(i); //~ ERROR use of possibly uninitialized variable: `i`
info!(false || { i = 5; true });
info!(i); //~ ERROR use of possibly uninitialized variable: `i`
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x: int) { debug!(x); }
fn foo(x: int) { info!(x); }
fn main() {
let x: int;

View File

@ -11,6 +11,6 @@
fn main() {
let x = ~5;
let y = x;
debug!(*x); //~ ERROR use of moved value: `x`
info!(*x); //~ ERROR use of moved value: `x`
copy y;
}

View File

@ -9,8 +9,8 @@
// except according to those terms.
fn send<T:Send>(ch: _chan<T>, data: T) {
debug!(ch);
debug!(data);
info!(ch);
info!(data);
fail!();
}
@ -20,7 +20,7 @@ struct _chan<T>(int);
// message after the send deinitializes it
fn test00_start(ch: _chan<~int>, message: ~int, _count: ~int) {
send(ch, message);
debug!(message); //~ ERROR use of moved value: `message`
info!(message); //~ ERROR use of moved value: `message`
}
fn main() { fail!(); }

View File

@ -14,7 +14,7 @@ fn test(cond: bool) {
v = 3;
break;
}
debug!("%d", v); //~ ERROR use of possibly uninitialized variable: `v`
info!("%d", v); //~ ERROR use of possibly uninitialized variable: `v`
}
fn main() {

View File

@ -16,6 +16,6 @@ fn my_fail() -> ! { fail!(); }
fn main() {
match true { false => { my_fail(); } true => { } }
debug!(x); //~ ERROR unresolved name `x`.
info!(x); //~ ERROR unresolved name `x`.
let x: int;
}

View File

@ -15,5 +15,5 @@ struct foo {
}
fn main() {
debug!(foo{ x: 1 } as int);
info!(foo{ x: 1 } as int);
}

View File

@ -10,4 +10,4 @@
// error-pattern:literal out of range
fn main() { debug!(300u8); }
fn main() { info!(300u8); }

View File

@ -32,6 +32,6 @@ fn main() {
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
unsafe {
let oof: Oof<[u8, .. 5], i32> = cast::transmute(foo);
debug!(oof);
info!(oof);
}
}

View File

@ -32,6 +32,6 @@ fn main() {
let foo = Foo { bar: 1, baz: 10 };
unsafe {
let oof: Oof = cast::transmute(foo);
debug!(oof);
info!(oof);
}
}

View File

@ -18,7 +18,7 @@ enum bar { t1((), Option<~[int]>), t2, }
fn foo(t: bar) {
match t {
t1(_, Some::<int>(x)) => {
debug!(x);
info!(x);
}
_ => { fail!(); }
}

View File

@ -34,7 +34,7 @@ fn main() {
// Can't do this copy
let x = ~~~A {y: r(i)};
let _z = copy x; //~ ERROR copying a value of non-copyable type
debug!(x);
info!(x);
}
error!(*i);
}

View File

@ -33,5 +33,5 @@ fn dog() -> dog {
fn main() {
let mut d = dog();
d.chase_cat();
debug!("cats_chased: %u", d.cats_chased);
info!("cats_chased: %u", d.cats_chased);
}

View File

@ -13,6 +13,6 @@ fn wants_static_fn(_x: &'static fn()) {}
fn main() {
let i = 3;
do wants_static_fn { //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
debug!("i=%d", i);
info!("i=%d", i);
}
}

View File

@ -24,5 +24,5 @@ fn return_it<'a>() -> &'a int {
fn main() {
let x = return_it();
debug!("foo=%d", *x);
info!("foo=%d", *x);
}

View File

@ -27,5 +27,5 @@ fn return_it() -> &int {
fn main() {
let x = return_it();
debug!("foo=%d", *x);
info!("foo=%d", *x);
}

View File

@ -14,5 +14,5 @@ fn test(f: @fn(uint) -> uint) -> uint {
fn main() {
let f: ~fn(x: uint) -> uint = |x| 4u;
debug!(test(f)); //~ ERROR expected @ closure, found ~ closure
info!(test(f)); //~ ERROR expected @ closure, found ~ closure
}

View File

@ -19,5 +19,5 @@ impl Drop for r {
fn main() {
let i = ~r { b: true };
let _j = copy i; //~ ERROR copying a value of non-copyable type
debug!(i);
info!(i);
}

View File

@ -32,6 +32,6 @@ fn main() {
f(copy r1, copy r2);
//~^ ERROR copying a value of non-copyable type
//~^^ ERROR copying a value of non-copyable type
debug!((r2, *i1));
debug!((r1, *i2));
info!((r2, *i1));
info!((r1, *i2));
}

View File

@ -13,5 +13,5 @@
use std::libc;
fn main() {
debug!(1.0 as *libc::FILE); // Can't cast float to foreign.
info!(1.0 as *libc::FILE); // Can't cast float to foreign.
}

View File

@ -13,7 +13,7 @@
fn f() {
let v = ~[1i];
debug!(v.some_field_name); //type error
info!(v.some_field_name); //type error
}
fn main() { }

View File

@ -25,5 +25,5 @@ fn main() {
let i = ~[r(0)];
let j = ~[r(1)];
let k = i + j;
debug!(j);
info!(j);
}

View File

@ -9,4 +9,4 @@
// except according to those terms.
fn blk1(b: &fn()) -> @fn() { return || { }; }
fn test1() { (do blk1 { debug!("hi"); })(); }
fn test1() { (do blk1 { info!("hi"); })(); }

View File

@ -43,7 +43,7 @@ fn main() {
for 10u.times {
do task::spawn {
let result = count(5u);
debug!("result = %?", result);
info!("result = %?", result);
fail!();
};
}

View File

@ -9,6 +9,6 @@
// except according to those terms.
// error-pattern:woe
fn f(a: int) { debug!(a); }
fn f(a: int) { info!(a); }
fn main() { f(fail!("woe")); }

View File

@ -17,7 +17,7 @@ fn even(x: uint) -> bool {
fn foo(x: uint) {
if even(x) {
debug!(x);
info!(x);
} else {
fail!("Number is odd");
}

View File

@ -19,7 +19,7 @@ fn f<A:Copy + 'static>(a: A, b: u16) -> @fn() -> (A, u16) {
pub fn main() {
let (a, b) = f(22_u64, 44u16)();
debug!("a=%? b=%?", a, b);
info!("a=%? b=%?", a, b);
assert_eq!(a, 22u64);
assert_eq!(b, 44u16);
}

View File

@ -34,7 +34,7 @@ pub fn main() {
let z = f(~x, y);
make_cycle(z);
let (a, b) = z();
debug!("a=%u b=%u", *a as uint, b as uint);
info!("a=%u b=%u", *a as uint, b as uint);
assert_eq!(*a, x);
assert_eq!(b, y);
}

View File

@ -12,6 +12,6 @@
pub fn main() {
let a: int = 10;
debug!(a);
info!(a);
assert_eq!(a * (a - 1), 90);
}

View File

@ -28,6 +28,6 @@ pub fn main() {
assert_eq!(i32_b << 1, i32_b << 1);
assert_eq!(i32_b >> 1, i32_b >> 1);
assert_eq!(i32_b & i32_b << 1, 0);
debug!(i32_b | i32_b << 1);
info!(i32_b | i32_b << 1);
assert_eq!(i32_b | i32_b << 1, 0x30303030);
}

View File

@ -19,6 +19,6 @@ struct Triple { x: int, y: int, z: int }
fn f<T:Copy,U:Copy>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; }
pub fn main() {
debug!("%?", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
debug!("%?", f(5, 6).a);
info!("%?", f(Triple {x: 3, y: 4, z: 5}, 4).a.x);
info!("%?", f(5, 6).a);
}

View File

@ -27,8 +27,8 @@ fn general() {
a ^= b;
b ^= a;
a = a ^ b;
debug!(a);
debug!(b);
info!(a);
info!(b);
assert_eq!(b, 1);
assert_eq!(a, 2);
assert_eq!(!0xf0 & 0xff, 0xf);

View File

@ -23,7 +23,7 @@ pub fn main() {
x = @F {f: ~4};
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
info!("ptr::to_unsafe_ptr(*b_x) = %x",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
assert_eq!(**b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));

View File

@ -28,7 +28,7 @@ pub fn main() {
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
x = @F {f: ~4};
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
info!("ptr::to_unsafe_ptr(*b_x) = %x",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));

View File

@ -23,7 +23,7 @@ pub fn main() {
*x = @F {f: ~4};
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
info!("ptr::to_unsafe_ptr(*b_x) = %x",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
assert_eq!(**b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));

View File

@ -28,7 +28,7 @@ pub fn main() {
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
*x = @F{f: ~4};
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
info!("ptr::to_unsafe_ptr(*b_x) = %x",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));

View File

@ -26,7 +26,7 @@ pub fn main() {
assert_eq!(ptr::to_unsafe_ptr(&(*x)), ptr::to_unsafe_ptr(&(*b_x)));
x = @22;
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
info!("ptr::to_unsafe_ptr(*b_x) = %x",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x)));

View File

@ -25,13 +25,13 @@ fn testfn(cond: bool) {
exp = 4;
}
debug!("*r = %d, exp = %d", *r, exp);
info!("*r = %d, exp = %d", *r, exp);
assert_eq!(*r, exp);
x = @5;
y = @6;
debug!("*r = %d, exp = %d", *r, exp);
info!("*r = %d, exp = %d", *r, exp);
assert_eq!(*r, exp);
}

View File

@ -28,7 +28,7 @@ pub fn main() {
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
x = @F {f: ~4};
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
info!("ptr::to_unsafe_ptr(*b_x) = %x",
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));

View File

@ -17,6 +17,6 @@ fn unbox<T:Copy>(b: Box<T>) -> T { return copy *b.c; }
pub fn main() {
let foo: int = 17;
let bfoo: Box<int> = Box {c: @foo};
debug!("see what's in our box");
info!("see what's in our box");
assert_eq!(unbox::<int>(bfoo), foo);
}

View File

@ -12,5 +12,5 @@ use std::borrow;
pub fn main() {
let x = 3;
debug!("&x=%x", borrow::to_uint(&x));
info!("&x=%x", borrow::to_uint(&x));
}

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