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

@ -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));
}

View file

@ -17,6 +17,6 @@ use cci_borrow_lib::foo;
pub fn main() {
let p = @22u;
let r = foo(p);
debug!("r=%u", r);
info!("r=%u", r);
assert_eq!(r, 22u);
}

View file

@ -16,13 +16,13 @@ use cci_impl_lib::uint_helpers;
pub fn main() {
//let bt0 = sys::frame_address();
//debug!("%?", bt0);
//info!("%?", bt0);
do 3u.to(10u) |i| {
print(fmt!("%u\n", i));
//let bt1 = sys::frame_address();
//debug!("%?", bt1);
//info!("%?", bt1);
//assert!(bt0 == bt1);
}
}

View file

@ -15,7 +15,7 @@ extern mod cci_iter_lib;
pub fn main() {
//let bt0 = sys::rusti::frame_address(1u32);
//debug!("%?", bt0);
//info!("%?", bt0);
do cci_iter_lib::iter(~[1, 2, 3]) |i| {
print(fmt!("%d", *i));
//assert!(bt0 == sys::rusti::frame_address(2u32));

View file

@ -21,12 +21,12 @@ pub fn main() {
// sys::frame_address() to determine if we are inlining is
// actually working.
//let bt0 = sys::frame_address();
//debug!("%?", bt0);
//info!("%?", bt0);
do iter(~[1u, 2u, 3u]) |i| {
print(fmt!("%u\n", i));
//let bt1 = sys::frame_address();
//debug!("%?", bt1);
//info!("%?", bt1);
//assert!(bt0 != bt1);
}

View file

@ -16,7 +16,7 @@ use cci_class_cast::kitty::*;
fn print_out(thing: @ToStr, expected: ~str) {
let actual = thing.to_str();
debug!("%s", actual);
info!("%s", actual);
assert_eq!(actual, expected);
}

View file

@ -22,7 +22,7 @@ struct dog {
impl dog {
priv fn bark(&self) -> int {
debug!("Woof %u %d", *self.barks, *self.volume);
info!("Woof %u %d", *self.barks, *self.volume);
*self.barks += 1u;
if *self.barks % 3u == 0u {
*self.volume += 1;
@ -30,7 +30,7 @@ impl dog {
if *self.barks % 10u == 0u {
*self.volume -= 2;
}
debug!("Grrr %u %d", *self.barks, *self.volume);
info!("Grrr %u %d", *self.barks, *self.volume);
*self.volume
}
}
@ -63,7 +63,7 @@ impl cat {
impl cat {
fn meow(&self) -> uint {
debug!("Meow");
info!("Meow");
*self.meows += 1u;
if *self.meows % 5u == 0u {
*self.how_hungry += 1;

View file

@ -43,7 +43,7 @@ class cat : noisy, scratchy, bitey {
let bite_counts : hashmap<body_part, uint>;
fn meow() -> uint {
debug!("Meow: %u", *self.meows);
info!("Meow: %u", *self.meows);
*self.meows += 1u;
if *self.meows % 5u == 0u {
*self.how_hungry += 1;
@ -84,12 +84,12 @@ class cat : noisy, scratchy, bitey {
let all = ~[toe, nose, ear];
let mut min = finger;
do iter(all) |next| {
debug!("min = %?", min);
info!("min = %?", min);
if self.bite_counts.get(next) < self.bite_counts.get(min) {
min = next;
}};
self.bite_counts.insert(min, self.bite_counts.get(min) + 1u);
debug!("Bit %?", min);
info!("Bit %?", min);
min
}
}
@ -97,7 +97,7 @@ class cat : noisy, scratchy, bitey {
fn annoy_neighbors<T:noisy>(critter: T) {
for uint::range(0u, 10u) |i| {
let what = critter.speak();
debug!("%u %d", i, what);
info!("%u %d", i, what);
}
}
@ -105,7 +105,7 @@ fn bite_everything<T:bitey>(critter: T) -> bool {
let mut left : ~[body_part] = ~[finger, toe, nose, ear];
while left.len() > 0u {
let part = critter.bite();
debug!("%? %?", left, part);
info!("%? %?", left, part);
if vec_includes(left, part) {
left = vec::filter(left, |p| p != part );
}

View file

@ -61,7 +61,7 @@ impl ToStr for cat {
fn print_out(thing: @ToStr, expected: ~str) {
let actual = thing.to_str();
debug!("%s", actual);
info!("%s", actual);
assert_eq!(actual, expected);
}

View file

@ -23,7 +23,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

@ -37,7 +37,7 @@ fn foo(x: int) -> int {
pub fn main() {
let x: int = 2 + 2;
debug!("%?", x);
debug!("hello, world");
debug!("%?", 10);
info!("%?", x);
info!("hello, world");
info!("%?", 10);
}

View file

@ -0,0 +1,17 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-fast exec-env directive doesn't work for check-fast
// exec-env:RUST_LOG=conditional-debug-macro-off=4
fn main() {
// only fails if debug! evaluates its argument.
debug!({ if true { fail!() } });
}

View file

@ -0,0 +1,21 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-fast compile-flags directive doesn't work for check-fast
// compile-flags: --cfg debug
// exec-env:RUST_LOG=conditional-debug-macro-on=4
fn main() {
// exits early if debug! evaluates its arguments, otherwise it
// will hit the fail.
debug!({ if true { return; } });
fail!();
}

View file

@ -12,4 +12,4 @@
static i: int = 10;
pub fn main() { debug!("%i", i); }
pub fn main() { info!("%i", i); }

View file

@ -15,6 +15,6 @@
#[start]
fn start(argc: int, argv: **u8, crate_map: *u8) -> int {
do std::rt::start(argc, argv, crate_map) {
debug!("creating my own runtime is joy");
info!("creating my own runtime is joy");
}
}

View file

@ -12,4 +12,4 @@
// -*- rust -*-
pub fn main() { if 1 == 1 { return; } debug!("Paul is dead"); }
pub fn main() { if 1 == 1 { return; } info!("Paul is dead"); }

View file

@ -10,4 +10,4 @@
pub fn main() { let x = @mut 5; *x = 1000; debug!("%?", *x); }
pub fn main() { let x = @mut 5; *x = 1000; info!("%?", *x); }

View file

@ -14,8 +14,8 @@ pub fn main() {
let v = &"hello";
let mut y : &str = &"there";
debug!(x);
debug!(y);
info!(x);
info!(y);
assert_eq!(x[0], 'h' as u8);
assert_eq!(x[4], 'o' as u8);
@ -30,7 +30,7 @@ pub fn main() {
let c = &"cccc";
let cc = &"ccccc";
debug!(a);
info!(a);
assert!(a < b);
assert!(a <= b);
@ -38,7 +38,7 @@ pub fn main() {
assert!(b >= a);
assert!(b > a);
debug!(b);
info!(b);
assert!(a < c);
assert!(a <= c);
@ -46,7 +46,7 @@ pub fn main() {
assert!(c >= a);
assert!(c > a);
debug!(c);
info!(c);
assert!(c < cc);
assert!(c <= cc);
@ -54,5 +54,5 @@ pub fn main() {
assert!(cc >= c);
assert!(cc > c);
debug!(cc);
info!(cc);
}

View file

@ -20,7 +20,7 @@ pub fn main() {
let c : &[int] = &[2,2,2,2,3];
let cc : &[int] = &[2,2,2,2,2,2];
debug!(a);
info!(a);
assert!(a < b);
assert!(a <= b);
@ -28,7 +28,7 @@ pub fn main() {
assert!(b >= a);
assert!(b > a);
debug!(b);
info!(b);
assert!(b < c);
assert!(b <= c);
@ -42,7 +42,7 @@ pub fn main() {
assert!(c >= a);
assert!(c > a);
debug!(c);
info!(c);
assert!(a < cc);
assert!(a <= cc);
@ -50,5 +50,5 @@ pub fn main() {
assert!(cc >= a);
assert!(cc > a);
debug!(cc);
info!(cc);
}

View file

@ -13,7 +13,7 @@ mod foo {
pub fn y() { super::super::foo::x(); }
}
pub fn x() { debug!("x"); }
pub fn x() { info!("x"); }
}
pub fn main() { self::foo::bar::y(); }

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