about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-02-25 14:33:50 +0100
committerGitHub <noreply@github.com>2021-02-25 14:33:50 +0100
commit351d947e548bd9ca3d0147490f5f2ce9161b1246 (patch)
tree972a9b415008d238566874ad06e240df726e3b1c
parentcb2b4ff7142935ebaaec2fe2782d0f53af87be6d (diff)
parent0d6640a5b0c673638b05bba7ddfbb31375f720b2 (diff)
downloadrust-351d947e548bd9ca3d0147490f5f2ce9161b1246.tar.gz
rust-351d947e548bd9ca3d0147490f5f2ce9161b1246.zip
Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Add an impl of Error on `Arc<impl Error>`.

`Display` already exists so this should be a non-controversial change (famous last words).

Would have to be insta-stable.
-rw-r--r--library/std/src/error.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/library/std/src/error.rs b/library/std/src/error.rs
index 605d953f5da..94338c7b04d 100644
--- a/library/std/src/error.rs
+++ b/library/std/src/error.rs
@@ -30,6 +30,7 @@ use crate::mem::transmute;
 use crate::num;
 use crate::str;
 use crate::string;
+use crate::sync::Arc;
 
 /// `Error` is a trait representing the basic expectations for error values,
 /// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
@@ -507,6 +508,27 @@ impl<'a, T: Error + ?Sized> Error for &'a T {
     }
 }
 
+#[stable(feature = "arc_error", since = "1.52.0")]
+impl<T: Error + ?Sized> Error for Arc<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)]