From 12741c1d0e8b0801f6dfb5963efabef069236ffd Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 8 Dec 2020 17:40:11 +0100 Subject: openpgp: Tweak the assert_send_and_sync macro. - Declare trait bounds using a where clause. It looks a bit odd if there is no bound, but not worse than before. --- openpgp/src/armor.rs | 2 +- openpgp/src/cert/amalgamation.rs | 4 ++-- openpgp/src/cert/amalgamation/iter.rs | 4 ++-- openpgp/src/cert/amalgamation/key.rs | 16 ++++++++-------- openpgp/src/cert/amalgamation/key/iter.rs | 12 ++++++------ openpgp/src/cert/bundle.rs | 2 +- openpgp/src/crypto/aead.rs | 2 +- openpgp/src/crypto/symmetric.rs | 4 ++-- openpgp/src/fmt.rs | 2 +- openpgp/src/macros.rs | 3 +-- openpgp/src/packet/key.rs | 2 +- openpgp/src/packet/mod.rs | 2 +- openpgp/src/serialize/stream/partial_body.rs | 2 +- openpgp/src/serialize/stream/writer/mod.rs | 10 +++++----- openpgp/src/serialize/stream/writer/writer_bzip2.rs | 2 +- openpgp/src/serialize/stream/writer/writer_deflate.rs | 4 ++-- 16 files changed, 36 insertions(+), 37 deletions(-) diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index c3002e7f..686ea939 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -172,7 +172,7 @@ pub struct Writer { header: Vec, dirty: bool, } -assert_send_and_sync!(Writer, W: Write); +assert_send_and_sync!(Writer where W: Write); impl Writer { /// Constructs a new filter for the given type of data. diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 91328528..78efb4cc 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -647,7 +647,7 @@ pub struct ComponentAmalgamation<'a, C> { cert: &'a Cert, bundle: &'a ComponentBundle, } -assert_send_and_sync!(ComponentAmalgamation<'_, C>, C); +assert_send_and_sync!(ComponentAmalgamation<'_, C> where C); /// A User ID and its associated data. /// @@ -1078,7 +1078,7 @@ pub struct ValidComponentAmalgamation<'a, C> { // The binding signature at time `time`. (This is just a cache.) binding_signature: &'a Signature, } -assert_send_and_sync!(ValidComponentAmalgamation<'_, C>, C); +assert_send_and_sync!(ValidComponentAmalgamation<'_, C> where C); /// A Valid User ID and its associated data. /// diff --git a/openpgp/src/cert/amalgamation/iter.rs b/openpgp/src/cert/amalgamation/iter.rs index 60ac9495..bf940845 100644 --- a/openpgp/src/cert/amalgamation/iter.rs +++ b/openpgp/src/cert/amalgamation/iter.rs @@ -90,7 +90,7 @@ pub struct ComponentAmalgamationIter<'a, C> { cert: &'a Cert, iter: slice::Iter<'a, ComponentBundle>, } -assert_send_and_sync!(ComponentAmalgamationIter<'_, C>, C); +assert_send_and_sync!(ComponentAmalgamationIter<'_, C> where C); /// An iterator over `UserIDAmalgamtion`s. /// @@ -246,7 +246,7 @@ pub struct ValidComponentAmalgamationIter<'a, C> { // at time `t`. revoked: Option, } -assert_send_and_sync!(ValidComponentAmalgamationIter<'_, C>, C); +assert_send_and_sync!(ValidComponentAmalgamationIter<'_, C> where C); /// An iterator over `ValidUserIDAmalgamtion`s. /// diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs index d3dc085f..543da96f 100644 --- a/openpgp/src/cert/amalgamation/key.rs +++ b/openpgp/src/cert/amalgamation/key.rs @@ -449,10 +449,10 @@ pub struct KeyAmalgamation<'a, P, R, R2> ca: ComponentAmalgamation<'a, Key>, primary: R2, } -assert_send_and_sync!(KeyAmalgamation<'_, P, R, R2>, - P: key::KeyParts, - R: key::KeyRole, - R2 +assert_send_and_sync!(KeyAmalgamation<'_, P, R, R2> + where P: key::KeyParts, + R: key::KeyRole, + R2, ); // derive(Clone) doesn't work with generic parameters that don't @@ -947,10 +947,10 @@ pub struct ValidKeyAmalgamation<'a, P, R, R2> // The binding signature at time `time`. (This is just a cache.) binding_signature: &'a Signature, } -assert_send_and_sync!(ValidKeyAmalgamation<'_, P, R, R2>, - P: key::KeyParts, - R: key::KeyRole, - R2: Copy +assert_send_and_sync!(ValidKeyAmalgamation<'_, P, R, R2> + where P: key::KeyParts, + R: key::KeyRole, + R2: Copy, ); /// A Valid primary Key, and its associated data. diff --git a/openpgp/src/cert/amalgamation/key/iter.rs b/openpgp/src/cert/amalgamation/key/iter.rs index 45d3c618..9d4d6ce7 100644 --- a/openpgp/src/cert/amalgamation/key/iter.rs +++ b/openpgp/src/cert/amalgamation/key/iter.rs @@ -82,9 +82,9 @@ pub struct KeyAmalgamationIter<'a, P, R> _p: std::marker::PhantomData

, _r: std::marker::PhantomData, } -assert_send_and_sync!(KeyAmalgamationIter<'_, P, R>, - P: key::KeyParts, - R: key::KeyRole +assert_send_and_sync!(KeyAmalgamationIter<'_, P, R> + where P: key::KeyParts, + R: key::KeyRole, ); impl<'a, P, R> fmt::Debug for KeyAmalgamationIter<'a, P, R> @@ -684,9 +684,9 @@ pub struct ValidKeyAmalgamationIter<'a, P, R> _p: std::marker::PhantomData

, _r: std::marker::PhantomData, } -assert_send_and_sync!(ValidKeyAmalgamationIter<'_, P, R>, - P: key::KeyParts, - R: key::KeyRole +assert_send_and_sync!(ValidKeyAmalgamationIter<'_, P, R> + where P: key::KeyParts, + R: key::KeyRole, ); impl<'a, P, R> fmt::Debug for ValidKeyAmalgamationIter<'a, P, R> diff --git a/openpgp/src/cert/bundle.rs b/openpgp/src/cert/bundle.rs index d755fe80..3693ef1e 100644 --- a/openpgp/src/cert/bundle.rs +++ b/openpgp/src/cert/bundle.rs @@ -125,7 +125,7 @@ pub struct ComponentBundle { // Third-party revocations (e.g., designated revokers). pub(crate) other_revocations: Vec, } -assert_send_and_sync!(ComponentBundle, C); +assert_send_and_sync!(ComponentBundle where C); /// A key (primary or subkey, public or private) and any associated /// signatures. diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index 2544f6c8..fb95b087 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -544,7 +544,7 @@ pub struct Encryptor { // A place to write encrypted data into. scratch: Vec, } -assert_send_and_sync!(Encryptor, W: io::Write); +assert_send_and_sync!(Encryptor where W: io::Write); impl Encryptor { /// Instantiate a new AEAD encryptor. diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs index 0030b2d4..0a022cc3 100644 --- a/openpgp/src/crypto/symmetric.rs +++ b/openpgp/src/crypto/symmetric.rs @@ -51,7 +51,7 @@ pub struct Decryptor { // Up to a block of unread data. buffer: Vec, } -assert_send_and_sync!(Decryptor, R: io::Read); +assert_send_and_sync!(Decryptor where R: io::Read); impl Decryptor { /// Instantiate a new symmetric decryptor. `reader` is the source @@ -318,7 +318,7 @@ pub struct Encryptor { // A place to write encrypted data into. scratch: Vec, } -assert_send_and_sync!(Encryptor, W: io::Write); +assert_send_and_sync!(Encryptor where W: io::Write); impl Encryptor { /// Instantiate a new symmetric encryptor. diff --git a/openpgp/src/fmt.rs b/openpgp/src/fmt.rs index b748f8a2..783c1885 100644 --- a/openpgp/src/fmt.rs +++ b/openpgp/src/fmt.rs @@ -61,7 +61,7 @@ pub mod hex { offset: usize, } - assert_send_and_sync!(Dumper, W: io::Write); + assert_send_and_sync!(Dumper where W: io::Write); impl Dumper { /// Creates a new dumper. diff --git a/openpgp/src/macros.rs b/openpgp/src/macros.rs index 7810a69b..d350a09b 100644 --- a/openpgp/src/macros.rs +++ b/openpgp/src/macros.rs @@ -145,7 +145,7 @@ macro_rules! time_it { /// ``` /// macro_rules! assert_send_and_sync { - ( $x:ty, $( $g:ident$( : $b:path )? $(,)?)*) => { + ( $x:ty where $( $g:ident$( : $b:path )? $(,)?)*) => { impl<$( $g ),*> crate::types::Sendable for $x where $( $g: Send + Sync $(+ $b)? ),* {} @@ -158,4 +158,3 @@ macro_rules! assert_send_and_sync { impl crate::types::Syncable for $x {} }; } - diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 99584a6e..4003e507 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -782,7 +782,7 @@ pub struct Key4 r: std::marker::PhantomData, } -assert_send_and_sync!(Key4, P: KeyParts, R: KeyRole); +assert_send_and_sync!(Key4 where P: KeyParts, R: KeyRole); impl PartialEq for Key4 { fn eq(&self, other: &Key4) -> bool { diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index 45ef3d3c..d426cc35 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -1440,7 +1440,7 @@ pub enum Key { /// A version 4 `Key` packet. V4(Key4), } -assert_send_and_sync!(Key, P: key::KeyParts, R: key::KeyRole); +assert_send_and_sync!(Key where P: key::KeyParts, R: key::KeyRole); impl fmt::Display for Key { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/openpgp/src/serialize/stream/partial_body.rs b/openpgp/src/serialize/stream/partial_body.rs index cc9afa89..d85ca96e 100644 --- a/openpgp/src/serialize/stream/partial_body.rs +++ b/openpgp/src/serialize/stream/partial_body.rs @@ -45,7 +45,7 @@ pub struct PartialBodyFilter<'a, C: 'a> { // The number of bytes written to this filter. position: u64, } -assert_send_and_sync!(PartialBodyFilter<'_, C>, C); +assert_send_and_sync!(PartialBodyFilter<'_, C> where C); const PARTIAL_BODY_FILTER_MAX_CHUNK_SIZE : usize = 1 << 30; diff --git a/openpgp/src/serialize/stream/writer/mod.rs b/openpgp/src/serialize/stream/writer/mod.rs index c2f9f518..bc011429 100644 --- a/openpgp/src/serialize/stream/writer/mod.rs +++ b/openpgp/src/serialize/stream/writer/mod.rs @@ -189,7 +189,7 @@ pub struct Identity<'a, C> { inner: Option>, cookie: C, } -assert_send_and_sync!(Identity<'_, C>, C); +assert_send_and_sync!(Identity<'_, C> where C); impl<'a> Identity<'a, Cookie> { /// Makes an identity writer. @@ -270,7 +270,7 @@ pub struct Generic { cookie: C, position: u64, } -assert_send_and_sync!(Generic, W: io::Write, C); +assert_send_and_sync!(Generic where W: io::Write, C); impl<'a, W: 'a + io::Write + Send + Sync> Generic { /// Wraps an `io::Write`r. @@ -355,7 +355,7 @@ impl<'a, W: io::Write + Send + Sync, C> Stackable<'a, C> for Generic { pub struct Armorer<'a, C: 'a> { inner: Generic>, C>, } -assert_send_and_sync!(Armorer<'_, C>, C); +assert_send_and_sync!(Armorer<'_, C> where C); impl<'a> Armorer<'a, Cookie> { /// Makes an armoring writer. @@ -428,7 +428,7 @@ impl<'a, C: 'a> Stackable<'a, C> for Armorer<'a, C> { pub struct Encryptor<'a, C: 'a> { inner: Generic + Send + Sync + 'a>>, C>, } -assert_send_and_sync!(Encryptor<'_, C>, C); +assert_send_and_sync!(Encryptor<'_, C> where C); impl<'a> Encryptor<'a, Cookie> { /// Makes an encrypting writer. @@ -500,7 +500,7 @@ impl<'a, C: 'a> Stackable<'a, C> for Encryptor<'a, C> { pub struct AEADEncryptor<'a, C: 'a> { inner: Generic>, C>, } -assert_send_and_sync!(AEADEncryptor<'_, C>, C); +assert_send_and_sync!(AEADEncryptor<'_, C> where C); impl<'a> AEADEncryptor<'a, Cookie> { /// Makes an encrypting writer. diff --git a/openpgp/src/serialize/stream/writer/writer_bzip2.rs b/openpgp/src/serialize/stream/writer/writer_bzip2.rs index b38d8f7e..7db8cf89 100644 --- a/openpgp/src/serialize/stream/writer/writer_bzip2.rs +++ b/openpgp/src/serialize/stream/writer/writer_bzip2.rs @@ -10,7 +10,7 @@ use super::{Generic, Message, BoxStack, Stackable, Cookie}; pub struct BZ<'a, C: 'a> { inner: Generic>, C>, } -assert_send_and_sync!(BZ<'_, C>, C); +assert_send_and_sync!(BZ<'_, C> where C); impl<'a> BZ<'a, Cookie> { /// Makes a BZ compressing writer. diff --git a/openpgp/src/serialize/stream/writer/writer_deflate.rs b/openpgp/src/serialize/stream/writer/writer_deflate.rs index 27b4bd6b..e254e49c 100644 --- a/openpgp/src/serialize/stream/writer/writer_deflate.rs +++ b/openpgp/src/serialize/stream/writer/writer_deflate.rs @@ -10,7 +10,7 @@ use super::{Generic, Message, BoxStack, Stackable, Cookie}; pub struct ZIP<'a, C: 'a> { inner: Generic>, C>, } -assert_send_and_sync!(ZIP<'_, C>, C); +assert_send_and_sync!(ZIP<'_, C> where C); impl<'a> ZIP<'a, Cookie> { /// Makes a ZIP compressing writer. @@ -79,7 +79,7 @@ impl<'a, C: 'a> Stackable<'a, C> for ZIP<'a, C> { pub struct ZLIB<'a, C: 'a> { inner: Generic>, C>, } -assert_send_and_sync!(ZLIB<'_, C>, C); +assert_send_and_sync!(ZLIB<'_, C> where C); impl<'a> ZLIB<'a, Cookie> { /// Makes a ZLIB compressing writer. -- cgit v1.2.3