]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/error.rs
error: remove StringError from Debug output
[rust.git] / src / libstd / error.rs
index 7cb830e751a77653295b4bcb0f6f6e8d9bb8d48c..9424e059a14fd5d314cd2a1bc64242183053d8d9 100644 (file)
@@ -300,7 +300,6 @@ impl From<String> for Box<dyn Error + Send + Sync> {
     ///     mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
     /// ```
     fn from(err: String) -> Box<dyn Error + Send + Sync> {
-        #[derive(Debug)]
         struct StringError(String);
 
         impl Error for StringError {
@@ -313,6 +312,13 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             }
         }
 
+        // Purposefully skip printing "StringError(..)"
+        impl Debug for StringError {
+            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+                Debug::fmt(&self.0, f)
+            }
+        }
+
         Box::new(StringError(err))
     }
 }