mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 21:23:20 +00:00
Make debug!, etc. macros not require a format string
The one thing `log` can still do is polymorphically log anything, but debug!, etc. require a format string. With this patch you can equivalently write `debug!(foo)` or `debug!("%?", foo)`
This commit is contained in:
parent
7140d7c52b
commit
dd4d45062d
@ -409,14 +409,38 @@ pub fn core_macros() -> ~str {
|
||||
~"pub mod macros {
|
||||
macro_rules! ignore (($($x:tt)*) => (()))
|
||||
|
||||
macro_rules! error ( ($( $arg:expr ),+) => (
|
||||
log(::core::error, fmt!( $($arg),+ )) ))
|
||||
macro_rules! warn ( ($( $arg:expr ),+) => (
|
||||
log(::core::warn, fmt!( $($arg),+ )) ))
|
||||
macro_rules! info ( ($( $arg:expr ),+) => (
|
||||
log(::core::info, fmt!( $($arg),+ )) ))
|
||||
macro_rules! debug ( ($( $arg:expr ),+) => (
|
||||
log(::core::debug, fmt!( $($arg),+ )) ))
|
||||
macro_rules! error (
|
||||
($arg:expr) => (
|
||||
log(::core::error, fmt!( \"%?\", $arg ))
|
||||
);
|
||||
($( $arg:expr ),+) => (
|
||||
log(::core::error, fmt!( $($arg),+ ))
|
||||
)
|
||||
)
|
||||
macro_rules! warn (
|
||||
($arg:expr) => (
|
||||
log(::core::warn, fmt!( \"%?\", $arg ))
|
||||
);
|
||||
($( $arg:expr ),+) => (
|
||||
log(::core::warn, fmt!( $($arg),+ ))
|
||||
)
|
||||
)
|
||||
macro_rules! info (
|
||||
($arg:expr) => (
|
||||
log(::core::info, fmt!( \"%?\", $arg ))
|
||||
);
|
||||
($( $arg:expr ),+) => (
|
||||
log(::core::info, fmt!( $($arg),+ ))
|
||||
)
|
||||
)
|
||||
macro_rules! debug (
|
||||
($arg:expr) => (
|
||||
log(::core::debug, fmt!( \"%?\", $arg ))
|
||||
);
|
||||
($( $arg:expr ),+) => (
|
||||
log(::core::debug, fmt!( $($arg),+ ))
|
||||
)
|
||||
)
|
||||
|
||||
macro_rules! fail(
|
||||
($msg: expr) => (
|
||||
|
10
src/test/run-pass/log-poly.rs
Normal file
10
src/test/run-pass/log-poly.rs
Normal file
@ -0,0 +1,10 @@
|
||||
enum Numbers {
|
||||
Three
|
||||
}
|
||||
|
||||
fn main() {
|
||||
debug!(1);
|
||||
info!(2.0);
|
||||
warn!(Three);
|
||||
error!(~[4]);
|
||||
}
|
Loading…
Reference in New Issue
Block a user