3636/// panic!("this is a {} {message}", "fancy", message = "message");
3737/// ```
3838#[ macro_export]
39+ #[ stable]
3940macro_rules! panic {
4041 ( ) => ( {
4142 panic!( "explicit panic" )
4243 } ) ;
4344 ( $msg: expr) => ( {
44- // static requires less code at runtime, more constant data
45- static _FILE_LINE: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
46- :: std:: rt:: begin_unwind( $msg, & _FILE_LINE)
45+ $crate:: rt:: begin_unwind( $msg, {
46+ // static requires less code at runtime, more constant data
47+ static _FILE_LINE: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
48+ & _FILE_LINE
49+ } )
4750 } ) ;
48- ( $fmt: expr, $( $arg: tt) * ) => ( {
49- // The leading _'s are to avoid dead code warnings if this is
50- // used inside a dead function. Just `#[allow(dead_code)]` is
51- // insufficient, since the user may have
52- // `#[forbid(dead_code)]` and which cannot be overridden.
53- static _FILE_LINE: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
54- :: std:: rt:: begin_unwind_fmt( format_args!( $fmt, $( $arg) * ) , & _FILE_LINE)
55-
51+ ( $fmt: expr, $( $arg: tt) +) => ( {
52+ $crate:: rt:: begin_unwind_fmt( format_args!( $fmt, $( $arg) +) , {
53+ // The leading _'s are to avoid dead code warnings if this is
54+ // used inside a dead function. Just `#[allow(dead_code)]` is
55+ // insufficient, since the user may have
56+ // `#[forbid(dead_code)]` and which cannot be overridden.
57+ static _FILE_LINE: ( & ' static str , uint) = ( file!( ) , line!( ) ) ;
58+ & _FILE_LINE
59+ } )
5660 } ) ;
5761}
5862
@@ -77,15 +81,16 @@ macro_rules! panic {
7781/// assert!(a + b == 30, "a = {}, b = {}", a, b);
7882/// ```
7983#[ macro_export]
84+ #[ stable]
8085macro_rules! assert {
8186 ( $cond: expr) => (
8287 if !$cond {
8388 panic!( concat!( "assertion failed: " , stringify!( $cond) ) )
8489 }
8590 ) ;
86- ( $cond: expr, $( $arg: expr ) , +) => (
91+ ( $cond: expr, $( $arg: tt ) +) => (
8792 if !$cond {
88- panic!( $( $arg) , +)
93+ panic!( $( $arg) +)
8994 }
9095 ) ;
9196}
@@ -103,6 +108,7 @@ macro_rules! assert {
103108/// assert_eq!(a, b);
104109/// ```
105110#[ macro_export]
111+ #[ stable]
106112macro_rules! assert_eq {
107113 ( $left: expr , $right: expr) => ( {
108114 match ( & ( $left) , & ( $right) ) {
@@ -144,6 +150,7 @@ macro_rules! assert_eq {
144150/// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
145151/// ```
146152#[ macro_export]
153+ #[ stable]
147154macro_rules! debug_assert {
148155 ( $( $arg: tt) * ) => ( if cfg!( not( ndebug) ) { assert!( $( $arg) * ) ; } )
149156}
@@ -210,6 +217,7 @@ macro_rules! debug_assert_eq {
210217/// }
211218/// ```
212219#[ macro_export]
220+ #[ unstable = "relationship with panic is unclear" ]
213221macro_rules! unreachable {
214222 ( ) => ( {
215223 panic!( "internal error: entered unreachable code" )
@@ -225,6 +233,7 @@ macro_rules! unreachable {
225233/// A standardised placeholder for marking unfinished code. It panics with the
226234/// message `"not yet implemented"` when executed.
227235#[ macro_export]
236+ #[ unstable = "relationship with panic is unclear" ]
228237macro_rules! unimplemented {
229238 ( ) => ( panic!( "not yet implemented" ) )
230239}
@@ -242,15 +251,15 @@ macro_rules! unimplemented {
242251#[ macro_export]
243252#[ stable]
244253macro_rules! format {
245- ( $( $arg: tt) * ) => ( :: std :: fmt:: format( format_args!( $( $arg) * ) ) )
254+ ( $( $arg: tt) * ) => ( $crate :: fmt:: format( format_args!( $( $arg) * ) ) )
246255}
247256
248257/// Equivalent to the `println!` macro except that a newline is not printed at
249258/// the end of the message.
250259#[ macro_export]
251260#[ stable]
252261macro_rules! print {
253- ( $( $arg: tt) * ) => ( :: std :: io:: stdio:: print_args( format_args!( $( $arg) * ) ) )
262+ ( $( $arg: tt) * ) => ( $crate :: io:: stdio:: print_args( format_args!( $( $arg) * ) ) )
254263}
255264
256265/// Macro for printing to a task's stdout handle.
@@ -268,20 +277,19 @@ macro_rules! print {
268277#[ macro_export]
269278#[ stable]
270279macro_rules! println {
271- ( $( $arg: tt) * ) => ( :: std :: io:: stdio:: println_args( format_args!( $( $arg) * ) ) )
280+ ( $( $arg: tt) * ) => ( $crate :: io:: stdio:: println_args( format_args!( $( $arg) * ) ) )
272281}
273282
274283/// Helper macro for unwrapping `Result` values while returning early with an
275284/// error if the value of the expression is `Err`. For more information, see
276285/// `std::io`.
277286#[ macro_export]
287+ #[ stable]
278288macro_rules! try {
279- ( $expr: expr) => ( {
280- use $crate:: result:: Result :: { Ok , Err } ;
281-
282- match $expr {
283- Ok ( val) => val,
284- Err ( err) => return Err ( $crate:: error:: FromError :: from_error( err) ) ,
289+ ( $expr: expr) => ( match $expr {
290+ $crate:: result:: Result :: Ok ( val) => val,
291+ $crate:: result:: Result :: Err ( err) => {
292+ return $crate:: result:: Result :: Err ( $crate:: error:: FromError :: from_error( err) )
285293 }
286294 } )
287295}
@@ -412,26 +420,6 @@ pub mod builtin {
412420 #[ macro_export]
413421 macro_rules! option_env { ( $name: expr) => ( { /* compiler built-in */ } ) }
414422
415- /// Concatenate literals into a static byte slice.
416- ///
417- /// This macro takes any number of comma-separated literal expressions,
418- /// yielding an expression of type `&'static [u8]` which is the
419- /// concatenation (left to right) of all the literals in their byte format.
420- ///
421- /// This extension currently only supports string literals, character
422- /// literals, and integers less than 256. The byte slice returned is the
423- /// utf8-encoding of strings and characters.
424- ///
425- /// # Example
426- ///
427- /// ```
428- /// let rust = bytes!("r", 'u', "st", 255);
429- /// assert_eq!(rust[1], b'u');
430- /// assert_eq!(rust[4], 255);
431- /// ```
432- #[ macro_export]
433- macro_rules! bytes { ( $( $e: expr) ,* ) => ( { /* compiler built-in */ } ) }
434-
435423 /// Concatenate identifiers into one identifier.
436424 ///
437425 /// This macro takes any number of comma-separated identifiers, and
@@ -565,10 +553,6 @@ pub mod builtin {
565553 #[ macro_export]
566554 macro_rules! include_bytes { ( $file: expr) => ( { /* compiler built-in */ } ) }
567555
568- /// Deprecated alias for `include_bytes!()`.
569- #[ macro_export]
570- macro_rules! include_bin { ( $file: expr) => ( { /* compiler built-in */ } ) }
571-
572556 /// Expands to a string that represents the current module path.
573557 ///
574558 /// The current module path can be thought of as the hierarchy of modules
0 commit comments