diff --git a/Cargo.toml b/Cargo.toml index 34122badb..070b9f2ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,4 @@ example_generated = [] [dependencies] backtrace = { version = "0.3.3", optional = true } +void = "1.0" diff --git a/src/impl_error_chain_kind.rs b/src/impl_error_chain_kind.rs index 69569b64d..0dd66f1d2 100644 --- a/src/impl_error_chain_kind.rs +++ b/src/impl_error_chain_kind.rs @@ -177,7 +177,7 @@ macro_rules! impl_error_chain_kind { )* #[doc(hidden)] - __Nonexhaustive {} + __Nonexhaustive($crate::Void), } }; // Unit variant diff --git a/src/lib.rs b/src/lib.rs index ac185c643..63728a3f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; @@ -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)]