From 7febc9e2722f7ca97be91dc4a68c9f6a0502dc27 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 20 Sep 2021 19:26:48 +0300 Subject: Avoid matching on &Foo, when a plain Foo pattern works The extra & in a pattern (match arm or if let) is unnecessary and only makes the code harder to read. In most places it's enough to just remove the & from the pattern, but in a few places a dereference (*) needs to be added where the value captured in the pattern is used, as removing the & changes the type of the captured value to be a reference. Overall, the changes are almost mechanical. Although the diff is huge, it should be easy to read. The clippy lint match_ref_pats warns about this. See: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats --- ffi/src/error.rs | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'ffi') diff --git a/ffi/src/error.rs b/ffi/src/error.rs index dc4ab474..003477dd 100644 --- a/ffi/src/error.rs +++ b/ffi/src/error.rs @@ -28,63 +28,63 @@ impl<'a> FromSequoiaError<'a> for Status { if let Some(e) = e.downcast_ref::() { return match e { - &openpgp::Error::InvalidArgument(_) => + openpgp::Error::InvalidArgument(_) => Status::InvalidArgument, - &openpgp::Error::InvalidOperation(_) => + openpgp::Error::InvalidOperation(_) => Status::InvalidOperation, - &openpgp::Error::MalformedPacket(_) => + openpgp::Error::MalformedPacket(_) => Status::MalformedPacket, - &openpgp::Error::PacketTooLarge(_, _, _) => + openpgp::Error::PacketTooLarge(_, _, _) => Status::PacketTooLarge, - &openpgp::Error::UnsupportedPacketType(_) => + openpgp::Error::UnsupportedPacketType(_) => Status::UnsupportedPacketType, - &openpgp::Error::UnsupportedHashAlgorithm(_) => + openpgp::Error::UnsupportedHashAlgorithm(_) => Status::UnsupportedHashAlgorithm, - &openpgp::Error::UnsupportedPublicKeyAlgorithm(_) => + openpgp::Error::UnsupportedPublicKeyAlgorithm(_) => Status::UnsupportedPublicKeyAlgorithm, - &openpgp::Error::UnsupportedEllipticCurve(_) => + openpgp::Error::UnsupportedEllipticCurve(_) => Status::UnsupportedEllipticCurve, - &openpgp::Error::UnsupportedSymmetricAlgorithm(_) => + openpgp::Error::UnsupportedSymmetricAlgorithm(_) => Status::UnsupportedSymmetricAlgorithm, - &openpgp::Error::UnsupportedAEADAlgorithm(_) => + openpgp::Error::UnsupportedAEADAlgorithm(_) => Status::UnsupportedAEADAlgorithm, - &openpgp::Error::UnsupportedCompressionAlgorithm(_) => + openpgp::Error::UnsupportedCompressionAlgorithm(_) => Status::UnsupportedCompressionAlgorithm, - &openpgp::Error::UnsupportedSignatureType(_) => + openpgp::Error::UnsupportedSignatureType(_) => Status::UnsupportedSignatureType, - &openpgp::Error::InvalidPassword => + openpgp::Error::InvalidPassword => Status::InvalidPassword, - &openpgp::Error::InvalidSessionKey(_) => + openpgp::Error::InvalidSessionKey(_) => Status::InvalidSessionKey, - &openpgp::Error::MissingSessionKey(_) => + openpgp::Error::MissingSessionKey(_) => Status::MissingSessionKey, - &openpgp::Error::MalformedMPI(_) => + openpgp::Error::MalformedMPI(_) => Status::MalformedMPI, - &openpgp::Error::BadSignature(_) => + openpgp::Error::BadSignature(_) => Status::BadSignature, - &openpgp::Error::ManipulatedMessage => + openpgp::Error::ManipulatedMessage => Status::ManipulatedMessage, - &openpgp::Error::MalformedMessage(_) => + openpgp::Error::MalformedMessage(_) => Status::MalformedMessage, - &openpgp::Error::MalformedCert(_) => + openpgp::Error::MalformedCert(_) => Status::MalformedCert, - &openpgp::Error::IndexOutOfRange => + openpgp::Error::IndexOutOfRange => Status::IndexOutOfRange, - &openpgp::Error::UnsupportedCert(_) => + openpgp::Error::UnsupportedCert(_) => Status::UnsupportedCert, - &openpgp::Error::Expired(_) => + openpgp::Error::Expired(_) => Status::Expired, - &openpgp::Error::NotYetLive(_) => + openpgp::Error::NotYetLive(_) => Status::NotYetLive, - &openpgp::Error::NoBindingSignature(_) => + openpgp::Error::NoBindingSignature(_) => Status::NoBindingSignature, - &openpgp::Error::InvalidKey(_) => + openpgp::Error::InvalidKey(_) => Status::InvalidKey, - &openpgp::Error::PolicyViolation(_, _) => + openpgp::Error::PolicyViolation(_, _) => Status::PolicyViolation, // openpgp::Error is non_exhaustive, match on &_ to handle // future additions. - &_ => Status::UnknownError + _ => Status::UnknownError } } -- cgit v1.2.3