X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibstd%2Ferror.rs;h=5cc7dcdae1fcd5917db45d4210891758b3041df4;hb=eebe62aaa1e31151269d19ec71248215a40f6417;hp=c8978a94fcda46507e007c3cdf58fc0bfaadc453;hpb=040af62a5a780b55912f331ec1b576ccd680a109;p=rust.git diff --git a/src/libstd/error.rs b/src/libstd/error.rs index c8978a94fcd..5cc7dcdae1f 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -314,7 +314,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 { @@ -327,6 +326,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)) } }