1+ #[ unstable( feature = "macros_internals" , reason = "macros implementation detail" , issue = "none" ) ]
2+ #[ doc( hidden) ]
3+ pub mod internals;
4+
15#[ cfg( bootstrap) ]
26#[ doc( include = "panic.md" ) ]
37#[ macro_export]
@@ -53,6 +57,7 @@ macro_rules! panic {
5357/// ```
5458#[ macro_export]
5559#[ stable( feature = "rust1" , since = "1.0.0" ) ]
60+ #[ allow_internal_unstable( macros_internals) ]
5661macro_rules! assert_eq {
5762 ( $left: expr, $right: expr $( , ) ?) => ( {
5863 match ( & $left, & $right) {
@@ -61,24 +66,19 @@ macro_rules! assert_eq {
6166 // The reborrows below are intentional. Without them, the stack slot for the
6267 // borrow is initialized even before the values are compared, leading to a
6368 // noticeable slow down.
64- $crate:: panic!( r#"assertion failed: `(left == right)`
65- left: `{:?}`,
66- right: `{:?}`"# , & * left_val, & * right_val)
69+ $crate:: macros_internals:: assert_eq_failed( & * left_val, & * right_val) ;
6770 }
6871 }
6972 }
7073 } ) ;
7174 ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
72- match ( & ( $left) , & ( $right) ) {
75+ match ( & $left, & $right) {
7376 ( left_val, right_val) => {
7477 if !( * left_val == * right_val) {
7578 // The reborrows below are intentional. Without them, the stack slot for the
7679 // borrow is initialized even before the values are compared, leading to a
7780 // noticeable slow down.
78- $crate:: panic!( r#"assertion failed: `(left == right)`
79- left: `{:?}`,
80- right: `{:?}`: {}"# , & * left_val, & * right_val,
81- $crate:: format_args!( $( $arg) +) )
81+ $crate:: macros_internals:: assert_eq_failed_args( & * left_val, & * right_val, $crate:: format_args!( $( $arg) +) ) ;
8282 }
8383 }
8484 }
@@ -104,6 +104,7 @@ macro_rules! assert_eq {
104104/// ```
105105#[ macro_export]
106106#[ stable( feature = "assert_ne" , since = "1.13.0" ) ]
107+ #[ allow_internal_unstable( macros_internals) ]
107108macro_rules! assert_ne {
108109 ( $left: expr, $right: expr $( , ) ?) => ( {
109110 match ( & $left, & $right) {
@@ -112,9 +113,7 @@ macro_rules! assert_ne {
112113 // The reborrows below are intentional. Without them, the stack slot for the
113114 // borrow is initialized even before the values are compared, leading to a
114115 // noticeable slow down.
115- $crate:: panic!( r#"assertion failed: `(left != right)`
116- left: `{:?}`,
117- right: `{:?}`"# , & * left_val, & * right_val)
116+ $crate:: macros_internals:: assert_eq_failed( & * left_val, & * right_val) ;
118117 }
119118 }
120119 }
@@ -126,10 +125,7 @@ macro_rules! assert_ne {
126125 // The reborrows below are intentional. Without them, the stack slot for the
127126 // borrow is initialized even before the values are compared, leading to a
128127 // noticeable slow down.
129- $crate:: panic!( r#"assertion failed: `(left != right)`
130- left: `{:?}`,
131- right: `{:?}`: {}"# , & * left_val, & * right_val,
132- $crate:: format_args!( $( $arg) +) )
128+ $crate:: macros_internals:: assert_ne_failed_args( & * left_val, & * right_val, $crate:: format_args!( $( $arg) +) ) ;
133129 }
134130 }
135131 }
0 commit comments