Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

bare_trait_objects for deprecations #265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/error_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ macro_rules! impl_error_chain_cause_or_source {
$( #[$meta_foreign_links:meta] )*; )*
}
) => {
#[allow(unknown_lints, renamed_and_removed_lints)]
#[allow(unknown_lints, renamed_and_removed_lints, bare_trait_objects)]
#[allow(unused_doc_comment, unused_doc_comments)]
fn source(&self) -> Option<&(std::error::Error + 'static)> {
match self.1.next_error {
Expand Down Expand Up @@ -261,6 +261,7 @@ macro_rules! impl_error_chain_processed {
}

/// Construct a chained error from another boxed error and a kind, and generates a backtrace
#[allow(unknown_lints, bare_trait_objects)]
pub fn with_boxed_chain<K>(error: Box<::std::error::Error + Send>, kind: K)
-> $error_name
where K: Into<$error_kind_name>
Expand Down Expand Up @@ -522,7 +523,7 @@ macro_rules! impl_extract_backtrace {
($error_name: ident
$error_kind_name: ident
$([$link_error_path: path, $(#[$meta_links: meta])*])*) => {
#[allow(unknown_lints, renamed_and_removed_lints)]
#[allow(unknown_lints, renamed_and_removed_lints, bare_trait_objects)]
#[allow(unused_doc_comment, unused_doc_comments)]
fn extract_backtrace(e: &(::std::error::Error + Send + 'static))
-> Option<$crate::InternalBacktrace> {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,16 +558,19 @@ pub use backtrace::Backtrace;
pub use backtrace::InternalBacktrace;

#[derive(Debug)]
#[allow(unknown_lints, bare_trait_objects)]
/// Iterator over the error chain using the `Error::cause()` method.
pub struct Iter<'a>(Option<&'a error::Error>);

impl<'a> Iter<'a> {
/// Returns a new iterator over the error chain using `Error::cause()`.
#[allow(unknown_lints, bare_trait_objects)]
pub fn new(err: Option<&'a error::Error>) -> Iter<'a> {
Iter(err)
}
}

#[allow(unknown_lints, bare_trait_objects)]
impl<'a> Iterator for Iter<'a> {
type Item = &'a error::Error;

Expand Down Expand Up @@ -631,6 +634,7 @@ pub trait ChainedError: error::Error + Send + 'static {
/// Returns the first known backtrace, either from its State or from one
/// of the errors from `foreign_links`.
#[doc(hidden)]
#[allow(unknown_lints, bare_trait_objects)]
fn extract_backtrace(e: &(error::Error + Send + 'static)) -> Option<InternalBacktrace>
where Self: Sized;
}
Expand Down Expand Up @@ -661,6 +665,7 @@ impl<'a, T> fmt::Display for DisplayChain<'a, T>
/// Common state between errors.
#[derive(Debug)]
#[doc(hidden)]
#[allow(unknown_lints, bare_trait_objects)]
pub struct State {
/// Next error in the error chain.
pub next_error: Option<Box<error::Error + Send>>,
Expand All @@ -679,6 +684,7 @@ impl Default for State {

impl State {
/// Creates a new State type
#[allow(unknown_lints, bare_trait_objects)]
pub fn new<CE: ChainedError>(e: Box<error::Error + Send>) -> State {
let backtrace = CE::extract_backtrace(&*e)
.unwrap_or_else(InternalBacktrace::new);
Expand Down
1 change: 1 addition & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ mod foreign_link_test {
}

#[test]
#[allow(unknown_lints, bare_trait_objects)]
fn iterates() {
let chained_error = try_foreign_error().err().unwrap();
let mut error_iter = chained_error.iter();
Expand Down