X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibstd%2Ferror.rs;h=5cc7dcdae1fcd5917db45d4210891758b3041df4;hb=760a98fb5e1c964efbe5cb36710fff892b547c51;hp=c8978a94fcda46507e007c3cdf58fc0bfaadc453;hpb=6282fae46f34cdf1700a218120655ce1582c4e07;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)) } }