diff --git a/library/std/src/error.rs b/library/std/src/error.rs index 3b4cb859dd425..cb70b38850cbe 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -506,6 +506,27 @@ impl Error for Box { } } +#[stable(feature = "error_by_ref", since = "1.47.0")] +impl<'a, T: Error + ?Sized> Error for &'a T { + #[allow(deprecated, deprecated_in_future)] + fn description(&self) -> &str { + Error::description(&**self) + } + + #[allow(deprecated)] + fn cause(&self) -> Option<&dyn Error> { + Error::cause(&**self) + } + + fn source(&self) -> Option<&(dyn Error + 'static)> { + Error::source(&**self) + } + + fn backtrace(&self) -> Option<&Backtrace> { + Error::backtrace(&**self) + } +} + #[stable(feature = "fmt_error", since = "1.11.0")] impl Error for fmt::Error { #[allow(deprecated)]