From dd4d45062d8a9715250e2b912d8fcf4817e3995e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 7 Mar 2013 18:45:22 -0800 Subject: 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)` --- src/libsyntax/ext/expand.rs | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 7b4f92ab3ca..16f087085cc 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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) => ( -- cgit 1.4.1-3-g733a5