@@ -758,32 +758,32 @@ pub fn std_macros() -> @str {
758
758
)
759
759
)
760
760
761
- // conditionally define debug!, but keep it type checking even
762
- // in non-debug builds.
763
- macro_rules! __debug (
761
+ macro_rules! debug (
764
762
( $arg: expr) => (
765
- __log( 4u32 , fmt!( \"%?\" , $arg ) )
763
+ if cfg! ( debug ) { __log( 4u32 , fmt!( \"%?\" , $arg ) ) }
766
764
) ;
767
765
( $( $arg: expr ) ,+) => (
768
- __log( 4u32 , fmt!( $( $arg) ,+ ) )
766
+ if cfg! ( debug ) { __log( 4u32 , fmt!( $( $arg) ,+ ) ) }
769
767
)
770
768
)
771
769
772
- #[ cfg( debug) ]
773
- #[ macro_escape]
774
- mod debug_macro {
775
- macro_rules! debug ( ( $( $arg: expr) ,* ) => {
776
- __debug!( $( $arg) ,* )
777
- } )
778
- }
770
+ macro_rules! error2 (
771
+ ( $( $arg: tt) * ) => ( __log( 1u32 , format!( $( $arg) * ) ) )
772
+ )
779
773
780
- #[ cfg( not( debug) ) ]
781
- #[ macro_escape]
782
- mod debug_macro {
783
- macro_rules! debug ( ( $( $arg: expr) ,* ) => {
784
- if false { __debug!( $( $arg) ,* ) }
785
- } )
786
- }
774
+ macro_rules! warn2 (
775
+ ( $( $arg: tt) * ) => ( __log( 2u32 , format!( $( $arg) * ) ) )
776
+ )
777
+
778
+ macro_rules! info2 (
779
+ ( $( $arg: tt) * ) => ( __log( 3u32 , format!( $( $arg) * ) ) )
780
+ )
781
+
782
+ macro_rules! debug2 (
783
+ ( $( $arg: tt) * ) => (
784
+ if cfg!( debug) { __log( 4u32 , format!( $( $arg) * ) ) }
785
+ )
786
+ )
787
787
788
788
macro_rules! fail(
789
789
( ) => (
@@ -797,6 +797,15 @@ pub fn std_macros() -> @str {
797
797
)
798
798
)
799
799
800
+ macro_rules! fail2(
801
+ ( ) => (
802
+ fail!( \" explicit failure\" )
803
+ ) ;
804
+ ( $( $arg: tt) +) => (
805
+ :: std:: sys:: FailWithCause :: fail_with( format!( $( $arg) +) , file!( ) , line!( ) )
806
+ )
807
+ )
808
+
800
809
macro_rules! assert(
801
810
( $cond: expr) => {
802
811
if !$cond {
@@ -964,15 +973,13 @@ pub fn std_macros() -> @str {
964
973
// allocation but should rather delegate to an invocation of
965
974
// write! instead of format!
966
975
macro_rules! print (
967
- ( ) => ( ) ;
968
- ( $arg: expr) => ( :: std:: io:: print( format!( \" { } \" , $arg) ) ) ;
969
- ( $fmt: expr, $( $arg: tt) +) => ( :: std:: io:: print( format!( $fmt, $( $arg) +) ) )
976
+ ( $( $arg: tt) +) => ( :: std:: io:: print( format!( $( $arg) +) ) )
970
977
)
971
978
972
979
// FIXME(#6846) once stdio is redesigned, this shouldn't perform an
973
980
// allocation but should rather delegate to an io::Writer
974
981
macro_rules! println (
975
- ( $( $arg: tt) * ) => ( { print!( $( $arg) * ) ; :: std:: io:: println( \" \" ) ; } )
982
+ ( $( $arg: tt) + ) => ( { print!( $( $arg) + ) ; :: std:: io:: println( \" \" ) ; } )
976
983
)
977
984
978
985
// NOTE: use this after a snapshot lands to abstract the details
0 commit comments