diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-06 21:24:59 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-09 13:13:58 +0200 |
commit | 5d029cbf42621452666bd084f7beecb7d3d885a4 (patch) | |
tree | 21219c5864beac97ff5c55c78b436918034adcd6 /openpgp/src/packet | |
parent | 9424cd350f32a97479a74d919c646f9e26c2ebce (diff) |
Lint: Remove unnecessary conversions.
- https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
Diffstat (limited to 'openpgp/src/packet')
-rw-r--r-- | openpgp/src/packet/key.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/mod.rs | 8 | ||||
-rw-r--r-- | openpgp/src/packet/signature.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/userid.rs | 22 |
5 files changed, 20 insertions, 24 deletions
diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 40f22a23..084ec50c 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -595,13 +595,13 @@ impl KeyParts for UnspecifiedParts { fn convert_key_amalgamation<'a, R: KeyRole>( ka: ComponentAmalgamation<'a, Key<UnspecifiedParts, R>>) -> Result<ComponentAmalgamation<'a, Key<UnspecifiedParts, R>>> { - Ok(ka.into()) + Ok(ka) } fn convert_key_amalgamation_ref<'a, R: KeyRole>( ka: &'a ComponentAmalgamation<'a, Key<UnspecifiedParts, R>>) -> Result<&'a ComponentAmalgamation<'a, Key<Self, R>>> { - Ok(ka.into()) + Ok(ka) } fn significant_secrets() -> bool { @@ -1367,7 +1367,7 @@ impl SecretKeyMaterial { match self { SecretKeyMaterial::Unencrypted(ref u) => { *self = SecretKeyMaterial::Encrypted( - u.encrypt(password)?.into()); + u.encrypt(password)?); Ok(()) } SecretKeyMaterial::Encrypted(_) => diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index da4c621c..ae92462a 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -1516,28 +1516,28 @@ impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { impl From<Key<key::PublicParts, key::PrimaryRole>> for Packet { /// Convert the `Key` struct to a `Packet`. fn from(k: Key<key::PublicParts, key::PrimaryRole>) -> Self { - Packet::PublicKey(k.into()) + Packet::PublicKey(k) } } impl From<Key<key::PublicParts, key::SubordinateRole>> for Packet { /// Convert the `Key` struct to a `Packet`. fn from(k: Key<key::PublicParts, key::SubordinateRole>) -> Self { - Packet::PublicSubkey(k.into()) + Packet::PublicSubkey(k) } } impl From<Key<key::SecretParts, key::PrimaryRole>> for Packet { /// Convert the `Key` struct to a `Packet`. fn from(k: Key<key::SecretParts, key::PrimaryRole>) -> Self { - Packet::SecretKey(k.into()) + Packet::SecretKey(k) } } impl From<Key<key::SecretParts, key::SubordinateRole>> for Packet { /// Convert the `Key` struct to a `Packet`. fn from(k: Key<key::SecretParts, key::SubordinateRole>) -> Self { - Packet::SecretSubkey(k.into()) + Packet::SecretSubkey(k) } } diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs index 14fadbe9..eaa0c4a4 100644 --- a/openpgp/src/packet/signature.rs +++ b/openpgp/src/packet/signature.rs @@ -3410,8 +3410,8 @@ mod test { let embedded_sig = SignatureBuilder::new(SignatureType::PrimaryKeyBinding) .sign_hash(&mut pair, hash.clone()).unwrap(); builder.unhashed_area_mut().add(Subpacket::new( - SubpacketValue::EmbeddedSignature(embedded_sig.into()), false) - .unwrap()).unwrap(); + SubpacketValue::EmbeddedSignature(embedded_sig), false).unwrap()) + .unwrap(); let sig = builder.sign_hash(&mut pair, hash.clone()).unwrap().normalize(); assert_eq!(sig.unhashed_area().iter().count(), 3); diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 3885375c..fc619848 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -7089,8 +7089,8 @@ fn accessors() { sig = sig.set_signature_target(pk_algo, hash_algo, &digest).unwrap(); let sig_ = sig.clone().sign_hash(&mut keypair, hash.clone()).unwrap(); - assert_eq!(sig_.signature_target(), Some((pk_algo.into(), - hash_algo.into(), + assert_eq!(sig_.signature_target(), Some((pk_algo, + hash_algo, &digest[..]))); let embedded_sig = sig_.clone(); diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index 4037f078..f9f3c1a4 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -595,14 +595,13 @@ impl UserID { Err(err) => return Err(err.context(format!( "Validating name ({:?})", - name)).into()), + name))), Ok(p) => { if !(p.name().is_some() && p.comment().is_none() && p.email().is_none()) { return Err(Error::InvalidArgument( - format!("Invalid name ({:?})", name) - .into()).into()); + format!("Invalid name ({:?})", name)).into()); } } } @@ -617,14 +616,13 @@ impl UserID { Err(err) => return Err(err.context(format!( "Validating comment ({:?})", - comment)).into()), + comment))), Ok(p) => { if !(p.name().is_none() && p.comment().is_some() && p.email().is_none()) { return Err(Error::InvalidArgument( - format!("Invalid comment ({:?})", comment) - .into()).into()); + format!("Invalid comment ({:?})", comment)).into()); } } } @@ -644,14 +642,14 @@ impl UserID { Err(err) => return Err(err.context(format!( "Validating address ({:?})", - address)).into()), + address))), Ok(p) => { if !(p.name().is_none() && p.comment().is_none() && p.email().is_some()) { return Err(Error::InvalidArgument( - format!("Invalid address address ({:?})", address) - .into()).into()); + format!("Invalid address address ({:?})", address)) + .into()); } } } @@ -673,14 +671,13 @@ impl UserID { Err(err) => return Err(err.context(format!( "Validating User ID ({:?})", - value)).into()), + value))), Ok(p) => { if !(p.name().is_none() == name.is_none() && p.comment().is_none() == comment.is_none() && p.email().is_some()) { return Err(Error::InvalidArgument( - format!("Invalid User ID ({:?})", value) - .into()).into()); + format!("Invalid User ID ({:?})", value)).into()); } } } @@ -857,7 +854,6 @@ impl UserID { Ok(puid) => puid, Err(err) => { // Return the error from the NameAddrOrOther parser. - let err : anyhow::Error = err.into(); return Err(err).context(format!( "Failed to parse User ID: {:?}", s))?; } |