summaryrefslogtreecommitdiffstats
path: root/openpgp/src/keyid.rs
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2020-09-22 00:45:53 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2020-11-06 09:46:53 +0100
commitcdc9e16fb2aef0156d6af4abe3e519c22efa230e (patch)
treef4f5e10029ed7816bcb0931c53d27ed0e21c598c /openpgp/src/keyid.rs
parent327a987e2c95ea9d05fcadd6fa7a8c249372affd (diff)
openpgp: Use non_exhaustive attribute.
- Fixes #563 - With an MSRV >= 1.40.0, we can use #[non_exhaustive], as mentioned in #406. - This is also a clippy lint: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
Diffstat (limited to 'openpgp/src/keyid.rs')
-rw-r--r--openpgp/src/keyid.rs11
1 files changed, 1 insertions, 10 deletions
diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs
index 7b545165..a507527f 100644
--- a/openpgp/src/keyid.rs
+++ b/openpgp/src/keyid.rs
@@ -17,6 +17,7 @@ use crate::Result;
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
pub enum KeyID {
/// Lower 8 byte SHA-1 hash.
@@ -25,10 +26,6 @@ pub enum KeyID {
/// instance, we don't grok v3 keyids. And, it is possible that
/// the Issuer subpacket contains the wrong number of bytes.
Invalid(Box<[u8]>),
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl fmt::Display for KeyID {
@@ -82,7 +79,6 @@ impl From<KeyID> for Vec<u8> {
match id {
KeyID::V4(ref b) => r.extend_from_slice(b),
KeyID::Invalid(ref b) => r.extend_from_slice(b),
- KeyID::__Nonexhaustive => unreachable!(),
}
r
}
@@ -108,7 +104,6 @@ impl From<&Fingerprint> for KeyID {
Fingerprint::Invalid(fp) => {
KeyID::Invalid(fp.clone())
}
- Fingerprint::__Nonexhaustive => unreachable!(),
}
}
}
@@ -121,7 +116,6 @@ impl From<Fingerprint> for KeyID {
Fingerprint::Invalid(fp) => {
KeyID::Invalid(fp)
}
- Fingerprint::__Nonexhaustive => unreachable!(),
}
}
}
@@ -140,7 +134,6 @@ impl KeyID {
Ok(u64::from_be_bytes(*b)),
KeyID::Invalid(_) =>
Err(Error::InvalidArgument("Invalid KeyID".into()).into()),
- KeyID::__Nonexhaustive => unreachable!(),
}
}
@@ -160,7 +153,6 @@ impl KeyID {
match self {
&KeyID::V4(ref id) => id,
&KeyID::Invalid(ref id) => id,
- KeyID::__Nonexhaustive => unreachable!(),
}
}
@@ -218,7 +210,6 @@ impl KeyID {
let raw = match self {
&KeyID::V4(ref fp) => &fp[..],
&KeyID::Invalid(ref fp) => &fp[..],
- KeyID::__Nonexhaustive => unreachable!(),
};
// We currently only handle V4 key IDs, which look like: