about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/ext/expand.rs53
-rw-r--r--src/test/run-pass/ifmt.rs2
2 files changed, 31 insertions, 24 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 49b8c994dc2..7b493e11ef7 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -758,32 +758,32 @@ pub fn std_macros() -> @str {
         )
     )
 
-    // conditionally define debug!, but keep it type checking even
-    // in non-debug builds.
-    macro_rules! __debug (
+    macro_rules! debug (
         ($arg:expr) => (
-            __log(4u32, fmt!( \"%?\", $arg ))
+            if cfg!(debug) { __log(4u32, fmt!( \"%?\", $arg )) }
         );
         ($( $arg:expr ),+) => (
-            __log(4u32, fmt!( $($arg),+ ))
+            if cfg!(debug) { __log(4u32, fmt!( $($arg),+ )) }
         )
     )
 
-    #[cfg(debug)]
-    #[macro_escape]
-    mod debug_macro {
-        macro_rules! debug (($($arg:expr),*) => {
-            __debug!($($arg),*)
-        })
-    }
+    macro_rules! error2 (
+        ($($arg:tt)*) => ( __log(1u32, format!($($arg)*)))
+    )
 
-    #[cfg(not(debug))]
-    #[macro_escape]
-    mod debug_macro {
-        macro_rules! debug (($($arg:expr),*) => {
-            if false { __debug!($($arg),*) }
-        })
-    }
+    macro_rules! warn2 (
+        ($($arg:tt)*) => ( __log(2u32, format!($($arg)*)))
+    )
+
+    macro_rules! info2 (
+        ($($arg:tt)*) => ( __log(3u32, format!($($arg)*)))
+    )
+
+    macro_rules! debug2 (
+        ($($arg:tt)*) => (
+            if cfg!(debug) { __log(4u32, format!($($arg)*)) }
+        )
+    )
 
     macro_rules! fail(
         () => (
@@ -797,6 +797,15 @@ pub fn std_macros() -> @str {
         )
     )
 
+    macro_rules! fail2(
+        () => (
+            fail!(\"explicit failure\")
+        );
+        ($($arg:tt)+) => (
+            ::std::sys::FailWithCause::fail_with(format!($($arg)+), file!(), line!())
+        )
+    )
+
     macro_rules! assert(
         ($cond:expr) => {
             if !$cond {
@@ -964,15 +973,13 @@ pub fn std_macros() -> @str {
     //              allocation but should rather delegate to an invocation of
     //              write! instead of format!
     macro_rules! print (
-        () => ();
-        ($arg:expr) => ( ::std::io::print(format!(\"{}\", $arg)));
-        ($fmt:expr, $($arg:tt)+) => ( ::std::io::print(format!($fmt, $($arg)+)))
+        ($($arg:tt)+) => ( ::std::io::print(format!($($arg)+)))
     )
 
     // FIXME(#6846) once stdio is redesigned, this shouldn't perform an
     //              allocation but should rather delegate to an io::Writer
     macro_rules! println (
-        ($($arg:tt)*) => ({ print!($($arg)*); ::std::io::println(\"\"); })
+        ($($arg:tt)+) => ({ print!($($arg)+); ::std::io::println(\"\"); })
     )
 
     // NOTE: use this after a snapshot lands to abstract the details
diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs
index e067e16f54b..7bf9d004ee0 100644
--- a/src/test/run-pass/ifmt.rs
+++ b/src/test/run-pass/ifmt.rs
@@ -240,7 +240,7 @@ fn test_write() {
 // Just make sure that the macros are defined, there's not really a lot that we
 // can do with them just yet (to test the output)
 fn test_print() {
-    print!(1);
+    print!("hi");
     print!("{:?}", ~[0u8]);
     println!("hello");
     println!("this is a {}", "test");