diff --git a/src/util/errors.rs b/src/util/errors.rs index 2db744b2a00..30377993c71 100644 --- a/src/util/errors.rs +++ b/src/util/errors.rs @@ -65,20 +65,6 @@ impl CargoError for Box { (**self).response() } } -impl CargoError for Box { - fn description(&self) -> &str { - (**self).description() - } - fn cause(&self) -> Option<&dyn CargoError> { - (**self).cause() - } - fn human(&self) -> bool { - (**self).human() - } - fn response(&self) -> Option { - (**self).response() - } -} pub type CargoResult = Result>; @@ -163,42 +149,21 @@ impl fmt::Display for ChainedError { // ============================================================================= // Error impls -impl From for Box { - fn from(err: E) -> Box { - if let Some(err) = Any::downcast_ref::(&err) { - if let DieselError::NotFound = *err { - return Box::new(NotFound); - } - } - - #[derive(Debug)] - struct Shim(E); - impl CargoError for Shim { - fn description(&self) -> &str { - Error::description(&self.0) - } - } - impl fmt::Display for Shim { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) - } - } - Box::new(Shim(err)) - } -} - -impl CargoError for ::serde_json::Error { +impl CargoError for E { fn description(&self) -> &str { Error::description(self) } } -impl CargoError for ::std::io::Error { - fn description(&self) -> &str { - Error::description(self) +impl From for Box { + fn from(err: E) -> Box { + if let Some(DieselError::NotFound) = Any::downcast_ref::(&err) { + Box::new(NotFound) + } else { + Box::new(err) + } } } - // ============================================================================= // Concrete errors