diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 7cb830e751a77..9424e059a14fd 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -300,7 +300,6 @@ impl From for Box { /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(err: String) -> Box { - #[derive(Debug)] struct StringError(String); impl Error for StringError { @@ -313,6 +312,13 @@ impl From for Box { } } + // 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)) } }