diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-02 11:59:14 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-02 13:32:02 +0100 |
commit | 984d3645cbb68437475316fda35a2726f5cc21c1 (patch) | |
tree | 1708bae47a103e08e50251eaaef7b57ca61b9062 | |
parent | 75c1d18d7a7eb3e6889c651cfaf8e6c4da00b647 (diff) |
openpgp: Mark enum Error non-exhaustive.
- See #405.
-rw-r--r-- | ffi/src/error.rs | 1 | ||||
-rw-r--r-- | openpgp-ffi/src/error.rs | 1 | ||||
-rw-r--r-- | openpgp/src/lib.rs | 7 |
3 files changed, 9 insertions, 0 deletions
diff --git a/ffi/src/error.rs b/ffi/src/error.rs index 0e867cb3..1bcf051c 100644 --- a/ffi/src/error.rs +++ b/ffi/src/error.rs @@ -74,6 +74,7 @@ impl<'a> FromSequoiaError<'a> for Status { Status::Expired, &openpgp::Error::NotYetLive(_) => Status::NotYetLive, + openpgp::Error::__Nonexhaustive => unreachable!(), } } diff --git a/openpgp-ffi/src/error.rs b/openpgp-ffi/src/error.rs index 14c79187..2277d9a2 100644 --- a/openpgp-ffi/src/error.rs +++ b/openpgp-ffi/src/error.rs @@ -250,6 +250,7 @@ impl<'a> From<&'a failure::Error> for Status { Status::Expired, &openpgp::Error::NotYetLive(_) => Status::NotYetLive, + openpgp::Error::__Nonexhaustive => unreachable!(), } } diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index a351c789..56d88528 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -167,6 +167,9 @@ pub type Result<T> = ::std::result::Result<T, failure::Error>; #[derive(Fail, Debug, Clone)] /// Errors returned by this module. +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. pub enum Error { /// Invalid argument. #[fail(display = "Invalid argument: {}", _0)] @@ -268,6 +271,10 @@ pub enum Error { /// Not yet live. #[fail(display = "Not live until {:?}", _0)] NotYetLive(std::time::SystemTime), + + /// This marks this enum as non-exhaustive. Do not use this + /// variant. + #[doc(hidden)] #[fail(display = "__Nonexhaustive")] __Nonexhaustive, } /// The OpenPGP packets that Sequoia understands. |