about summary refs log tree commit diff
path: root/library/core/src/array
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-23 19:48:55 +0000
committerbors <bors@rust-lang.org>2022-08-23 19:48:55 +0000
commit060e47f74a91b28c3db28d80a6a9d6841ca51026 (patch)
tree79655bdb6dd437f2773196bcfdda18b9f6bc2896 /library/core/src/array
parenta1bea1551b8312b6abfbbf7d49bafac2e6ce8ee4 (diff)
parentbf7611d55ee6e24647aefc4d1c82b1dba0164536 (diff)
downloadrust-060e47f74a91b28c3db28d80a6a9d6841ca51026.tar.gz
rust-060e47f74a91b28c3db28d80a6a9d6841ca51026.zip
Auto merge of #99917 - yaahc:error-in-core-move, r=thomcc
Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of https://github.com/rust-lang/rust/pull/90328 using new compiler features that have been added to support error in core.
Diffstat (limited to 'library/core/src/array')
-rw-r--r--library/core/src/array/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs
index db5bfcab9d2..9effb379016 100644
--- a/library/core/src/array/mod.rs
+++ b/library/core/src/array/mod.rs
@@ -7,6 +7,8 @@
 use crate::borrow::{Borrow, BorrowMut};
 use crate::cmp::Ordering;
 use crate::convert::{Infallible, TryFrom};
+#[cfg(not(bootstrap))]
+use crate::error::Error;
 use crate::fmt;
 use crate::hash::{self, Hash};
 use crate::iter::TrustedLen;
@@ -119,6 +121,15 @@ impl fmt::Display for TryFromSliceError {
     }
 }
 
+#[cfg(not(bootstrap))]
+#[stable(feature = "try_from", since = "1.34.0")]
+impl Error for TryFromSliceError {
+    #[allow(deprecated)]
+    fn description(&self) -> &str {
+        self.__description()
+    }
+}
+
 impl TryFromSliceError {
     #[unstable(
         feature = "array_error_internals",