diff options
| author | Sean McArthur <sean@seanmonstar.com> | 2019-05-16 17:09:04 -0700 |
|---|---|---|
| committer | Sean McArthur <sean@seanmonstar.com> | 2019-05-16 17:37:43 -0700 |
| commit | d2d89b10de394b4a1d5e2491dfffd3d65d1741b3 (patch) | |
| tree | 3ce404ef8ca9023a6301f7f93be8e17fd0501481 /src/libstd | |
| parent | 7d5aa43325ad7629766b1183011f5bf5b2a1ea26 (diff) | |
| download | rust-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')
| -rw-r--r-- | src/libstd/error.rs | 8 |
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)) } } |
