about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-03-07 18:45:22 -0800
committerBrian Anderson <banderson@mozilla.com>2013-03-07 18:45:22 -0800
commitdd4d45062d8a9715250e2b912d8fcf4817e3995e (patch)
tree4558cf30895e7bfcd210afc16351f4f69eeceb2b /src/libsyntax
parent7140d7c52bdf55daf0b978a19706d20c3bf7ee92 (diff)
downloadrust-dd4d45062d8a9715250e2b912d8fcf4817e3995e.tar.gz
rust-dd4d45062d8a9715250e2b912d8fcf4817e3995e.zip
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)`
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/expand.rs40
1 files changed, 32 insertions, 8 deletions
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) => (