@@ -97,7 +97,6 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
9797pub enum AssertKind {
9898 Eq ,
9999 Ne ,
100- Match ,
101100}
102101
103102/// Internal function for `assert_eq!` and `assert_ne!` macros
@@ -114,54 +113,32 @@ where
114113 T : fmt:: Debug + ?Sized ,
115114 U : fmt:: Debug + ?Sized ,
116115{
117- assert_failed_inner ( kind, & left, & right, args)
118- }
119-
120- /// Internal function for `assert_match!`
121- #[ cold]
122- #[ track_caller]
123- #[ doc( hidden) ]
124- pub fn assert_matches_failed < T : fmt:: Debug + ?Sized > (
125- left : & T ,
126- right : & str ,
127- args : Option < fmt:: Arguments < ' _ > > ,
128- ) -> ! {
129- // Use the Display implementation to display the pattern.
130- struct Pattern < ' a > ( & ' a str ) ;
131- impl fmt:: Debug for Pattern < ' _ > {
132- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
133- fmt:: Display :: fmt ( self . 0 , f)
134- }
135- }
136- assert_failed_inner ( AssertKind :: Match , & left, & Pattern ( right) , args) ;
137- }
138-
139- /// Non-generic version of the above functions, to avoid code bloat.
140- #[ track_caller]
141- fn assert_failed_inner (
142- kind : AssertKind ,
143- left : & dyn fmt:: Debug ,
144- right : & dyn fmt:: Debug ,
145- args : Option < fmt:: Arguments < ' _ > > ,
146- ) -> ! {
147- let op = match kind {
148- AssertKind :: Eq => "==" ,
149- AssertKind :: Ne => "!=" ,
150- AssertKind :: Match => "matches" ,
151- } ;
152-
153- match args {
154- Some ( args) => panic ! (
155- r#"assertion failed: `(left {} right)`
116+ #[ track_caller]
117+ fn inner (
118+ kind : AssertKind ,
119+ left : & dyn fmt:: Debug ,
120+ right : & dyn fmt:: Debug ,
121+ args : Option < fmt:: Arguments < ' _ > > ,
122+ ) -> ! {
123+ let op = match kind {
124+ AssertKind :: Eq => "==" ,
125+ AssertKind :: Ne => "!=" ,
126+ } ;
127+
128+ match args {
129+ Some ( args) => panic ! (
130+ r#"assertion failed: `(left {} right)`
156131 left: `{:?}`,
157132 right: `{:?}`: {}"# ,
158- op, left, right, args
159- ) ,
160- None => panic ! (
161- r#"assertion failed: `(left {} right)`
133+ op, left, right, args
134+ ) ,
135+ None => panic ! (
136+ r#"assertion failed: `(left {} right)`
162137 left: `{:?}`,
163138 right: `{:?}`"# ,
164- op, left, right,
165- ) ,
139+ op, left, right,
140+ ) ,
141+ }
166142 }
143+ inner ( kind, & left, & right, args)
167144}
0 commit comments