about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBenoît du Garreau <bdgdlm@outlook.com>2022-08-24 00:53:09 +0200
committerBenoît du Garreau <bdgdlm@outlook.com>2022-08-24 00:56:04 +0200
commit289d7cca1dff4b142b1c208fd1dd5eb2ce0a628f (patch)
tree5b97e67995324a05db1b0cc89f2bedc670334fec
parenta1bea1551b8312b6abfbbf7d49bafac2e6ce8ee4 (diff)
downloadrust-289d7cca1dff4b142b1c208fd1dd5eb2ce0a628f.tar.gz
rust-289d7cca1dff4b142b1c208fd1dd5eb2ce0a628f.zip
Reduce code size of `assert_matches_failed`
-rw-r--r--library/core/src/panicking.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs
index 7a575a88e52..d4afe0f5326 100644
--- a/library/core/src/panicking.rs
+++ b/library/core/src/panicking.rs
@@ -190,11 +190,11 @@ pub fn assert_matches_failed<T: fmt::Debug + ?Sized>(
     right: &str,
     args: Option<fmt::Arguments<'_>>,
 ) -> ! {
-    // Use the Display implementation to display the pattern.
+    // The pattern is a string so it can be displayed directly.
     struct Pattern<'a>(&'a str);
     impl fmt::Debug for Pattern<'_> {
         fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-            fmt::Display::fmt(self.0, f)
+            f.write_str(self.0)
         }
     }
     assert_failed_inner(AssertKind::Match, &left, &Pattern(right), args);