From 39466bc58b15cca644afcdf79a152625fc75987e Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Wed, 5 Aug 2020 16:49:48 +1000 Subject: [PATCH 1/3] implement Error for &(impl Error) --- library/std/src/error.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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)] From 573ec314b635178533f68160f2dab3dd345d5df2 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Sat, 31 Oct 2020 20:16:15 +1000 Subject: [PATCH 2/3] update stabilization to 1.49.0 --- library/std/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/error.rs b/library/std/src/error.rs index cb70b38850cbe..8fd9f09b9de75 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -506,7 +506,7 @@ impl Error for Box { } } -#[stable(feature = "error_by_ref", since = "1.47.0")] +#[stable(feature = "error_by_ref", since = "1.49.0")] impl<'a, T: Error + ?Sized> Error for &'a T { #[allow(deprecated, deprecated_in_future)] fn description(&self) -> &str { From bbf5001b9428bbf5b4ac93f42dc7017b27c9002f Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Mon, 21 Dec 2020 18:40:34 +1000 Subject: [PATCH 3/3] bump stabilization to 1.51.0 --- library/std/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/error.rs b/library/std/src/error.rs index 8fd9f09b9de75..4ff60709b2079 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -506,7 +506,7 @@ impl Error for Box { } } -#[stable(feature = "error_by_ref", since = "1.49.0")] +#[stable(feature = "error_by_ref", since = "1.51.0")] impl<'a, T: Error + ?Sized> Error for &'a T { #[allow(deprecated, deprecated_in_future)] fn description(&self) -> &str {