1
+ #[ unstable( feature = "macros_internals" , reason = "macros implementation detail" , issue = "none" ) ]
2
+ #[ doc( hidden) ]
3
+ pub mod internals;
4
+
1
5
#[ cfg( bootstrap) ]
2
6
#[ doc( include = "panic.md" ) ]
3
7
#[ macro_export]
@@ -53,6 +57,7 @@ macro_rules! panic {
53
57
/// ```
54
58
#[ macro_export]
55
59
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
60
+ #[ allow_internal_unstable( macros_internals) ]
56
61
macro_rules! assert_eq {
57
62
( $left: expr, $right: expr $( , ) ?) => ( {
58
63
match ( & $left, & $right) {
@@ -61,24 +66,19 @@ macro_rules! assert_eq {
61
66
// The reborrows below are intentional. Without them, the stack slot for the
62
67
// borrow is initialized even before the values are compared, leading to a
63
68
// 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) ;
67
70
}
68
71
}
69
72
}
70
73
} ) ;
71
74
( $left: expr, $right: expr, $( $arg: tt) +) => ( {
72
- match ( & ( $left) , & ( $right) ) {
75
+ match ( & $left, & $right) {
73
76
( left_val, right_val) => {
74
77
if !( * left_val == * right_val) {
75
78
// The reborrows below are intentional. Without them, the stack slot for the
76
79
// borrow is initialized even before the values are compared, leading to a
77
80
// 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) +) ) ;
82
82
}
83
83
}
84
84
}
@@ -104,6 +104,7 @@ macro_rules! assert_eq {
104
104
/// ```
105
105
#[ macro_export]
106
106
#[ stable( feature = "assert_ne" , since = "1.13.0" ) ]
107
+ #[ allow_internal_unstable( macros_internals) ]
107
108
macro_rules! assert_ne {
108
109
( $left: expr, $right: expr $( , ) ?) => ( {
109
110
match ( & $left, & $right) {
@@ -112,9 +113,7 @@ macro_rules! assert_ne {
112
113
// The reborrows below are intentional. Without them, the stack slot for the
113
114
// borrow is initialized even before the values are compared, leading to a
114
115
// 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) ;
118
117
}
119
118
}
120
119
}
@@ -126,10 +125,7 @@ macro_rules! assert_ne {
126
125
// The reborrows below are intentional. Without them, the stack slot for the
127
126
// borrow is initialized even before the values are compared, leading to a
128
127
// 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) +) ) ;
133
129
}
134
130
}
135
131
}
0 commit comments