@@ -44,12 +44,20 @@ macro_rules! assert_eq {
4444 match ( & $left, & $right) {
4545 ( left_val, right_val) => {
4646 if !( * left_val == * right_val) {
47+ let left = stringify!( $left) ;
48+ let right = stringify!( $right) ;
49+ let width = if left. len( ) > right. len( ) {
50+ left. len( )
51+ } else {
52+ right. len( )
53+ } ;
54+
4755 // The reborrows below are intentional. Without them, the stack slot for the
4856 // borrow is initialized even before the values are compared, leading to a
4957 // noticeable slow down.
50- panic!( r#"assertion failed: `(left == right)`
51- left: `{:?}`,
52- right: `{:?}`"#, & * left_val, & * right_val)
58+ panic!( r#"assertion failed: `({ left}) == ({ right} )`
59+ { left:>width$} : `{:?}`,
60+ { right:>width$}: `{:?}`"#, & * left_val, & * right_val, left=left , right=right , width=width )
5361 }
5462 }
5563 }
@@ -61,13 +69,22 @@ macro_rules! assert_eq {
6169 match ( & ( $left) , & ( $right) ) {
6270 ( left_val, right_val) => {
6371 if !( * left_val == * right_val) {
72+ let left = stringify!( $left) ;
73+ let right = stringify!( $right) ;
74+ let width = if left. len( ) > right. len( ) {
75+ left. len( )
76+ } else {
77+ right. len( )
78+ } ;
79+
6480 // The reborrows below are intentional. Without them, the stack slot for the
6581 // borrow is initialized even before the values are compared, leading to a
6682 // noticeable slow down.
67- panic!( r#"assertion failed: `(left == right)`
68- left: `{:?}`,
69- right: `{:?}`: {}"# , & * left_val, & * right_val,
70- $crate:: format_args!( $( $arg) +) )
83+ panic!( r#"assertion failed: `({left}) == ({right})`
84+ {left:>width$}: `{:?}`,
85+ {right:>width$}: `{:?}`: {}"# , & * left_val, & * right_val,
86+ $crate:: format_args!( $( $arg) +) ,
87+ left=left, right=right, width=width)
7188 }
7289 }
7390 }
@@ -101,12 +118,20 @@ macro_rules! assert_ne {
101118 match ( & $left, & $right) {
102119 ( left_val, right_val) => {
103120 if * left_val == * right_val {
121+ let left = stringify!( $left) ;
122+ let right = stringify!( $right) ;
123+ let width = if left. len( ) > right. len( ) {
124+ left. len( )
125+ } else {
126+ right. len( )
127+ } ;
128+
104129 // The reborrows below are intentional. Without them, the stack slot for the
105130 // borrow is initialized even before the values are compared, leading to a
106131 // noticeable slow down.
107- panic!( r#"assertion failed: `(left != right)`
108- left: `{:?}`,
109- right: `{:?}`"#, & * left_val, & * right_val)
132+ panic!( r#"assertion failed: `({ left}) != ({ right} )`
133+ { left:>width$} : `{:?}`,
134+ { right:>width$}: `{:?}`"#, & * left_val, & * right_val, left=left , right=right , width=width )
110135 }
111136 }
112137 }
@@ -118,13 +143,22 @@ macro_rules! assert_ne {
118143 match ( & ( $left) , & ( $right) ) {
119144 ( left_val, right_val) => {
120145 if * left_val == * right_val {
146+ let left = stringify!( $left) ;
147+ let right = stringify!( $right) ;
148+ let width = if left. len( ) > right. len( ) {
149+ left. len( )
150+ } else {
151+ right. len( )
152+ } ;
153+
121154 // The reborrows below are intentional. Without them, the stack slot for the
122155 // borrow is initialized even before the values are compared, leading to a
123156 // noticeable slow down.
124- panic!( r#"assertion failed: `(left != right)`
125- left: `{:?}`,
126- right: `{:?}`: {}"# , & * left_val, & * right_val,
127- $crate:: format_args!( $( $arg) +) )
157+ panic!( r#"assertion failed: `({left}) != ({right})`
158+ {left:>width$}: `{:?}`,
159+ {right:>width$}: `{:?}`: {}"# , & * left_val, & * right_val,
160+ $crate:: format_args!( $( $arg) +) ,
161+ left=left, right=right, width=width)
128162 }
129163 }
130164 }
0 commit comments