diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index b43ac0daf5127..1976c77a1e412 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -37,7 +37,6 @@ pub struct Error { repr: Repr, } -#[derive(Debug)] enum Repr { Os(i32), Custom(Box), @@ -240,6 +239,17 @@ impl Error { } } +impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self { + &Repr::Os(ref code) => + fmt.debug_struct("Os").field("code", code) + .field("message", &sys::os::error_string(*code)).finish(), + &Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {