diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-08-24 12:46:55 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-08-24 17:07:30 -0700 |
| commit | a3e39b945402475dbe0eae91833981dad4622cb7 (patch) | |
| tree | 589de0a006aef2fcec4c186b3455d6a90cb4b0e1 /src/libsyntax | |
| parent | eb836dd61ed2d780ca9639f73876c3d3e05ef079 (diff) | |
| download | rust-a3e39b945402475dbe0eae91833981dad4622cb7.tar.gz rust-a3e39b945402475dbe0eae91833981dad4622cb7.zip | |
Introduce alternate forms of logging
These new macros are all based on format! instead of fmt! and purely exist for bootstrapping purposes. After the next snapshot, all uses of logging will be migrated to these macros, and then after the next snapshot after that we can drop the `2` suffix on everything
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 53 |
1 files changed, 30 insertions, 23 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 |
