Skip to content

Commit

Permalink
Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dylan-DPC authored Feb 25, 2021
2 parents cb2b4ff 0d6640a commit 351d947
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 351d947

Please sign in to comment.