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

Use Void in __Nonexhaustive #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ example_generated = []

[dependencies]
backtrace = { version = "0.3.3", optional = true }
void = "1.0"
2 changes: 1 addition & 1 deletion src/impl_error_chain_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ macro_rules! impl_error_chain_kind {
)*

#[doc(hidden)]
__Nonexhaustive {}
__Nonexhaustive($crate::Void),
}
};
// Unit variant
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@
//! [`map_err`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err
//! [`BacktraceFrame`]: https://docs.rs/backtrace/0.3.2/backtrace/struct.BacktraceFrame.html

extern crate void;

use std::error;
use std::iter::Iterator;
use std::fmt;
Expand Down Expand Up @@ -650,6 +652,13 @@ impl<'a, T> fmt::Display for DisplayChain<'a, T>
}
}

/// Wrapper over void::Void, provided for 2 reasons:
/// * Users shouldn't need to specify a void dependency in Cargo.toml to use error-chain
/// * We can reuse whatever trait impls defined for void::Void
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
#[doc(hidden)]
pub struct Void(::void::Void);

/// Common state between errors.
#[derive(Debug)]
#[doc(hidden)]
Expand Down