From 31a033b7d19644c1e96512b9f8983b2fd5704503 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Fri, 25 Sep 2020 15:44:20 +0200 Subject: ipc: Handle matching on non_exhaustive enums. --- ipc/src/keygrip.rs | 6 +++--- ipc/src/sexp.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ipc/src/keygrip.rs b/ipc/src/keygrip.rs index 148c11d7..6d08f70f 100644 --- a/ipc/src/keygrip.rs +++ b/ipc/src/keygrip.rs @@ -169,12 +169,12 @@ impl Keygrip { &ECDSA { ref curve, ref q } => hash_ecc(&mut hash, curve, q), &ECDH { ref curve, ref q, .. } => hash_ecc(&mut hash, curve, q), - &Unknown { .. } => + // crypto::mpi::PublicKey is non_exhaustive, match on &_ to handle + // future additions. + &Unknown { .. } | &_ => return Err(Error::InvalidOperation( "Keygrip not defined for this kind of public key".into()) .into()), - - &_ => unreachable!(), // Ciphertext is non-exhaustive. } let mut digest = [0; 20]; diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs index 1ca36a04..14d3e4c8 100644 --- a/ipc/src/sexp.rs +++ b/ipc/src/sexp.rs @@ -289,12 +289,12 @@ impl TryFrom<&mpi::Ciphertext> for Sexp { Sexp::String("e".into()), Sexp::String(e.value().into())])])])), - &Unknown { .. } => + // crypto::mpi::Ciphertext is non_exhaustive, match on &_ to handle + // future additions. + &Unknown { .. } | &_ => Err(Error::InvalidArgument( format!("Don't know how to convert {:?}", ciphertext)) .into()), - - &_ => unreachable!(), // Ciphertext is non-exhaustive. } } } -- cgit v1.2.3