about summary refs log tree commit diff
path: root/src/libstd/error.rs
diff options
context:
space:
mode:
authorSean McArthur <sean@seanmonstar.com>2019-05-16 17:09:04 -0700
committerSean McArthur <sean@seanmonstar.com>2019-05-16 17:37:43 -0700
commitd2d89b10de394b4a1d5e2491dfffd3d65d1741b3 (patch)
tree3ce404ef8ca9023a6301f7f93be8e17fd0501481 /src/libstd/error.rs
parent7d5aa43325ad7629766b1183011f5bf5b2a1ea26 (diff)
downloadrust-d2d89b10de394b4a1d5e2491dfffd3d65d1741b3.tar.gz
rust-d2d89b10de394b4a1d5e2491dfffd3d65d1741b3.zip
error: remove StringError from Debug output
Seeing `StringError("something something")` in debug output can cause
 someone to think there was an error dealing with `String`s, not that the
error type is just a string. So, remove that noise.
Diffstat (limited to 'src/libstd/error.rs')
-rw-r--r--src/libstd/error.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 7cb830e751a..9424e059a14 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -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 @@ impl From<String> for Box<dyn Error + Send + Sync> {
             }
         }
 
+        // 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))
     }
 }