summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-27 09:04:34 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:07 +0300
commit85362f33d81ebdc1cd355454be2494b9286e80be (patch)
tree6fba218d7f81565e0dd7f00883d8ab908e958af0
parent9fdbbf44d55f99807b2d2736ed3a85b0517be8e7 (diff)
Avoid naming field setting it from variable of the same name
When creating a struct with a field foo, using a variable also named foo, it's not necessary to name the field explicitly. Thus, instead of: Self { foo: foo } use this: Self { foo } The shorter form is more idiomatic and thus less confusing to experienced Rust programmers. This was found by the clippy lint redundant_field_names: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names Sponsored-by: author
-rw-r--r--autocrypt/src/lib.rs8
-rw-r--r--ffi/src/core.rs2
-rw-r--r--net/src/wkd.rs2
-rw-r--r--openpgp-ffi/src/cert.rs2
-rw-r--r--openpgp-ffi/src/io.rs4
-rw-r--r--openpgp-ffi/src/parse/stream.rs2
-rw-r--r--openpgp/src/cert/amalgamation.rs8
-rw-r--r--openpgp/src/cert/amalgamation/key.rs6
-rw-r--r--openpgp/src/packet/signature.rs2
-rw-r--r--openpgp/src/parse.rs12
-rw-r--r--openpgp/src/parse/map.rs4
-rw-r--r--openpgp/src/parse/mpis.rs46
-rw-r--r--openpgp/src/parse/packet_parser_builder.rs2
-rw-r--r--openpgp/src/parse/packet_pile_parser.rs2
-rw-r--r--openpgp/src/parse/stream.rs10
-rw-r--r--sq/src/commands/decrypt.rs2
-rw-r--r--sq/src/commands/dump.rs12
-rw-r--r--sq/src/commands/mod.rs2
-rw-r--r--store/src/backend/log.rs2
-rw-r--r--store/src/backend/mod.rs16
-rw-r--r--store/src/lib.rs32
21 files changed, 89 insertions, 89 deletions
diff --git a/autocrypt/src/lib.rs b/autocrypt/src/lib.rs
index 0da1f053..112f14f4 100644
--- a/autocrypt/src/lib.rs
+++ b/autocrypt/src/lib.rs
@@ -96,7 +96,7 @@ pub struct AutocryptHeader {
impl AutocryptHeader {
fn empty(header_type: AutocryptHeaderType) -> Self {
AutocryptHeader {
- header_type: header_type,
+ header_type,
key: None,
attributes: Vec::new(),
}
@@ -645,8 +645,8 @@ impl AutocryptSetupMessage {
Ok(AutocryptSetupMessageParser {
passcode_format: format,
passcode_begin: begin,
- skesk: skesk,
- pp: pp,
+ skesk,
+ pp,
passcode: None,
})
}
@@ -809,7 +809,7 @@ impl<'a> AutocryptSetupMessageParser<'a> {
// We're done!
Ok(AutocryptSetupMessage {
- prefer_encrypt: prefer_encrypt,
+ prefer_encrypt,
passcode: self.passcode,
passcode_format: self.passcode_format,
passcode_begin: self.passcode_begin,
diff --git a/ffi/src/core.rs b/ffi/src/core.rs
index d9bccd3b..147b9eba 100644
--- a/ffi/src/core.rs
+++ b/ffi/src/core.rs
@@ -52,7 +52,7 @@ pub struct Context {
impl Context {
fn new(c: sequoia_ipc::Context) -> Self {
- Context{c: c, e: ptr::null_mut()}
+ Context{c, e: ptr::null_mut()}
}
pub(crate) fn errp(&mut self) -> &mut *mut crate::error::Error {
diff --git a/net/src/wkd.rs b/net/src/wkd.rs
index dfe9a6e8..6662567a 100644
--- a/net/src/wkd.rs
+++ b/net/src/wkd.rs
@@ -128,7 +128,7 @@ impl Url {
let local_encoded = encode_local_part(&email.local_part);
let url = Url {
domain : email.domain,
- local_encoded : local_encoded,
+ local_encoded,
local_part : email.local_part,
};
Ok(url)
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 03ca1c7d..a39b2e5a 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -863,7 +863,7 @@ fn pgp_cert_parser_from_packet_parser(ppr: *mut PacketParserResult<'static>)
{
let ppr = ffi_param_move!(ppr);
let parser = CertParser::from(*ppr);
- box_raw!(CertParserWrapper { parser: parser })
+ box_raw!(CertParserWrapper { parser })
}
diff --git a/openpgp-ffi/src/io.rs b/openpgp-ffi/src/io.rs
index 3760395f..f888bc21 100644
--- a/openpgp-ffi/src/io.rs
+++ b/openpgp-ffi/src/io.rs
@@ -391,8 +391,8 @@ fn pgp_writer_alloc_with_capacity(buf: *mut *mut c_void, len: *mut size_t,
}
let w = WriterKind::Generic(Box::new(WriterAlloc(Mutex::new(Buffer {
- buf: buf,
- len: len,
+ buf,
+ len,
capacity,
}))));
w.move_into_raw()
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs
index 52932e70..62ba4b1e 100644
--- a/openpgp-ffi/src/parse/stream.rs
+++ b/openpgp-ffi/src/parse/stream.rs
@@ -452,7 +452,7 @@ impl VHelper {
inspect_cb,
get_certs_cb: get_certs,
check_signatures_cb: check_signatures,
- cookie: cookie,
+ cookie,
}))
}
}
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index 620980c4..f7c4e51d 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -887,11 +887,11 @@ macro_rules! impl_with_policy {
Ok(ValidComponentAmalgamation {
ca: self,
cert: ValidCert {
- cert: cert,
- policy: policy,
- time: time,
+ cert,
+ policy,
+ time,
},
- binding_signature: binding_signature,
+ binding_signature,
})
}
}
diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs
index d5c99153..a0614340 100644
--- a/openpgp/src/cert/amalgamation/key.rs
+++ b/openpgp/src/cert/amalgamation/key.rs
@@ -597,9 +597,9 @@ impl<'a, P> ValidateAmalgamation<'a, Key<P, key::UnspecifiedRole>>
// need to check the user's policy. So, it is safe to
// create a ValidCert from scratch.
cert: ValidCert {
- cert: cert,
- policy: policy,
- time: time,
+ cert,
+ policy,
+ time,
},
binding_signature
};
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs
index 3e46e79e..2db99a39 100644
--- a/openpgp/src/packet/signature.rs
+++ b/openpgp/src/packet/signature.rs
@@ -1685,7 +1685,7 @@ impl From<Signature4> for SignatureBuilder {
SignatureBuilder {
overrode_creation_time: false,
original_creation_time: creation_time,
- fields: fields,
+ fields,
}
}
}
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 068bdd6b..cae96fc8 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -452,11 +452,11 @@ impl<'a, T: 'a + BufferedReader<Cookie>> PacketHeaderParser<T> {
};
PacketHeaderParser {
reader: buffered_reader::Dup::with_cookie(inner, cookie),
- header: header,
- header_bytes: header_bytes,
- path: path,
- state: state,
- map: map,
+ header,
+ header_bytes,
+ path,
+ state,
+ map,
}
}
@@ -3050,7 +3050,7 @@ struct PacketParserState {
impl PacketParserState {
fn new(settings: PacketParserSettings) -> Self {
PacketParserState {
- settings: settings,
+ settings,
message_validator: Default::default(),
keyring_validator: Default::default(),
cert_validator: Default::default(),
diff --git a/openpgp/src/parse/map.rs b/openpgp/src/parse/map.rs
index b0c7bbea..d5012e39 100644
--- a/openpgp/src/parse/map.rs
+++ b/openpgp/src/parse/map.rs
@@ -50,7 +50,7 @@ impl Map {
Map {
length: 0,
entries: Vec::new(),
- header: header,
+ header,
data: Vec::new(),
}
}
@@ -235,7 +235,7 @@ struct Iter<'a> {
impl<'a> Iter<'a> {
fn new(map: &'a Map) -> Iter<'a> {
Iter {
- map: map,
+ map,
i: 0,
}
}
diff --git a/openpgp/src/parse/mpis.rs b/openpgp/src/parse/mpis.rs
index 35537c0f..f03eb097 100644
--- a/openpgp/src/parse/mpis.rs
+++ b/openpgp/src/parse/mpis.rs
@@ -48,7 +48,7 @@ impl mpi::PublicKey {
let n = MPI::parse("rsa_public_n_len", "rsa_public_n", php)?;
let e = MPI::parse("rsa_public_e_len", "rsa_public_e", php)?;
- Ok(mpi::PublicKey::RSA { e: e, n: n })
+ Ok(mpi::PublicKey::RSA { e, n })
}
DSA => {
@@ -58,10 +58,10 @@ impl mpi::PublicKey {
let y = MPI::parse("dsa_public_y_len", "dsa_public_y", php)?;
Ok(mpi::PublicKey::DSA {
- p: p,
- q: q,
- g: g,
- y: y,
+ p,
+ q,
+ g,
+ y,
})
}
@@ -74,9 +74,9 @@ impl mpi::PublicKey {
php)?;
Ok(mpi::PublicKey::ElGamal {
- p: p,
- g: g,
- y: y,
+ p,
+ g,
+ y,
})
}
@@ -87,7 +87,7 @@ impl mpi::PublicKey {
Ok(mpi::PublicKey::EdDSA {
curve: Curve::from_oid(&curve),
- q: q
+ q
})
}
@@ -98,7 +98,7 @@ impl mpi::PublicKey {
Ok(mpi::PublicKey::ECDSA {
curve: Curve::from_oid(&curve),
- q: q
+ q
})
}
@@ -332,7 +332,7 @@ impl mpi::Ciphertext {
php)?;
Ok(mpi::Ciphertext::RSA {
- c: c,
+ c,
})
}
@@ -341,8 +341,8 @@ impl mpi::Ciphertext {
let c = MPI::parse("elgamal_c_len", "elgamal_c", php)?;
Ok(mpi::Ciphertext::ElGamal {
- e: e,
- c: c,
+ e,
+ c,
})
}
@@ -353,7 +353,7 @@ impl mpi::Ciphertext {
[..key_len]);
Ok(mpi::Ciphertext::ECDH {
- e: e, key: key.into_boxed_slice()
+ e, key: key.into_boxed_slice()
})
}
@@ -410,7 +410,7 @@ impl mpi::Signature {
let s = MPI::parse("rsa_signature_len", "rsa_signature", php)?;
Ok(mpi::Signature::RSA {
- s: s,
+ s,
})
}
@@ -421,8 +421,8 @@ impl mpi::Signature {
php)?;
Ok(mpi::Signature::DSA {
- r: r,
- s: s,
+ r,
+ s,
})
}
@@ -433,8 +433,8 @@ impl mpi::Signature {
"elgamal_sig_s", php)?;
Ok(mpi::Signature::ElGamal {
- r: r,
- s: s,
+ r,
+ s,
})
}
@@ -445,8 +445,8 @@ impl mpi::Signature {
php)?;
Ok(mpi::Signature::EdDSA {
- r: r,
- s: s,
+ r,
+ s,
})
}
@@ -457,8 +457,8 @@ impl mpi::Signature {
php)?;
Ok(mpi::Signature::ECDSA {
- r: r,
- s: s,
+ r,
+ s,
})
}
diff --git a/openpgp/src/parse/packet_parser_builder.rs b/openpgp/src/parse/packet_parser_builder.rs
index 7459f0be..d94a5d2e 100644
--- a/openpgp/src/parse/packet_parser_builder.rs
+++ b/openpgp/src/parse/packet_parser_builder.rs
@@ -133,7 +133,7 @@ impl<'a> PacketParserBuilder<'a> {
-> Result<Self> {
bio.cookie_mut().level = None;
Ok(PacketParserBuilder {
- bio: bio,
+ bio,
dearmor: Default::default(),
settings: PacketParserSettings::default(),
csf_transformation: false,
diff --git a/openpgp/src/parse/packet_pile_parser.rs b/openpgp/src/parse/packet_pile_parser.rs
index 22b1f82f..8523330a 100644
--- a/openpgp/src/parse/packet_pile_parser.rs
+++ b/openpgp/src/parse/packet_pile_parser.rs
@@ -252,7 +252,7 @@ impl<'a> PacketPileParser<'a> {
{
Ok(PacketPileParser {
pile: Default::default(),
- ppr: ppr,
+ ppr,
})
}
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index f40c3f0d..efb5755e 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -458,8 +458,8 @@ impl<'a> MessageStructure<'a> {
fn new_encryption_layer(&mut self, sym_algo: SymmetricAlgorithm,
aead_algo: Option<AEADAlgorithm>) {
self.0.push(MessageLayer::Encryption {
- sym_algo: sym_algo,
- aead_algo: aead_algo,
+ sym_algo,
+ aead_algo,
})
}
@@ -597,8 +597,8 @@ impl IMessageStructure {
self.layers.push(IMessageLayer::Encryption {
depth,
expect_mdc,
- sym_algo: sym_algo,
- aead_algo: aead_algo,
+ sym_algo,
+ aead_algo,
});
}
@@ -2784,7 +2784,7 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> {
sigid[0], sigid[1], ka.fingerprint());
results.push_verification_result(
Ok(GoodChecksum {
- sig: sig,
+ sig,
ka,
}));
// Continue to the next sig.
diff --git a/sq/src/commands/decrypt.rs b/sq/src/commands/decrypt.rs
index f8102e7e..45e2b4e7 100644
--- a/sq/src/commands/decrypt.rs
+++ b/sq/src/commands/decrypt.rs
@@ -72,7 +72,7 @@ impl<'a> Helper<'a> {
secret_keys: keys,
key_identities: identities,
key_hints: hints,
- dump_session_key: dump_session_key,
+ dump_session_key,
dumper: if dump {
let width = term_size::dimensions_stdout().map(|(w, _)| w)
.unwrap_or(80);
diff --git a/sq/src/commands/dump.rs b/sq/src/commands/dump.rs
index 081760a6..3c1eda31 100644
--- a/sq/src/commands/dump.rs
+++ b/sq/src/commands/dump.rs
@@ -185,10 +185,10 @@ impl Node {
fn new(header: Header, packet: Packet, map: Option<Map>,
additional_fields: Option<Vec<String>>) -> Self {
Node {
- header: header,
- packet: packet,
- map: map,
- additional_fields: additional_fields,
+ header,
+ packet,
+ map,
+ additional_fields,
children: Vec::new(),
}
}
@@ -211,8 +211,8 @@ pub struct PacketDumper {
impl PacketDumper {
pub fn new(width: usize, mpis: bool) -> Self {
PacketDumper {
- width: width,
- mpis: mpis,
+ width,
+ mpis,
root: None,
}
}
diff --git a/sq/src/commands/mod.rs b/sq/src/commands/mod.rs
index ee185be7..61c05133 100644
--- a/sq/src/commands/mod.rs
+++ b/sq/src/commands/mod.rs
@@ -226,7 +226,7 @@ impl<'a> VHelper<'a> {
-> Self {
VHelper {
config: config.clone(),
- signatures: signatures,
+ signatures,
certs: Some(certs),
labels: HashMap::new(),
trusted: HashSet::new(),
diff --git a/store/src/backend/log.rs b/store/src/backend/log.rs
index 722b51c3..10fc2e88 100644
--- a/store/src/backend/log.rs
+++ b/store/src/backend/log.rs
@@ -84,7 +84,7 @@ pub struct IterServer {
impl IterServer {
pub fn new(c: Rc<Connection>, selector: Selector) -> Self {
- IterServer{c: c, selector: selector, n: ID::max()}
+ IterServer{c, selector, n: ID::max()}
}
}
diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs
index 4b2db1be..54bb1708 100644
--- a/store/src/backend/mod.rs
+++ b/store/src/backend/mod.rs
@@ -281,7 +281,7 @@ impl Query for MappingServer {
impl MappingServer {
fn new(c: Rc<Connection>, id: ID) -> MappingServer {
- MappingServer{c: c, id: id}
+ MappingServer{c, id}
}
fn open(c: Rc<Connection>, realm: &str, policy: net::Policy, name: &str)
@@ -423,8 +423,8 @@ struct BindingServer {
impl BindingServer {
fn new(c: Rc<Connection>, id: ID) -> Self {
BindingServer {
- c: c,
- id: id,
+ c,
+ id,
}
}
@@ -691,8 +691,8 @@ struct KeyServer {
impl KeyServer {
fn new(c: Rc<Connection>, id: ID) -> Self {
KeyServer {
- c: c,
- id: id,
+ c,
+ id,
}
}
@@ -1088,7 +1088,7 @@ struct MappingIterServer {
impl MappingIterServer {
fn new(c: Rc<Connection>, prefix: &str) -> Self {
- MappingIterServer{c: c, prefix: String::from(prefix) + "%", n: ID::null()}
+ MappingIterServer{c, prefix: String::from(prefix) + "%", n: ID::null()}
}
}
@@ -1132,7 +1132,7 @@ struct BundleIterServer {
impl BundleIterServer {
fn new(c: Rc<Connection>, mapping_id: ID) -> Self {
- BundleIterServer{c: c, mapping_id: mapping_id, n: ID::null()}
+ BundleIterServer{c, mapping_id, n: ID::null()}
}
}
@@ -1168,7 +1168,7 @@ struct KeyIterServer {
impl KeyIterServer {
fn new(c: Rc<Connection>) -> Self {
- KeyIterServer{c: c, n: ID::null()}
+ KeyIterServer{c, n: ID::null()}
}
}
diff --git a/store/src/lib.rs b/store/src/lib.rs
index b4ce17b3..962bce83 100644
--- a/store/src/lib.rs
+++ b/store/src/lib.rs
@@ -291,7 +291,7 @@ impl Store {
let (mut core, client) = Store::connect(c)?;
let request = client.iter_keys_request();
let iter = make_request!(&mut core, request)?;
- Ok(KeyIter{core: Rc::new(RefCell::new(core)), iter: iter})
+ Ok(KeyIter{core: Rc::new(RefCell::new(core)), iter})
}
/// Lists all log entries.
@@ -299,7 +299,7 @@ impl Store {
let (mut core, client) = Store::connect(c)?;
let request = client.log_request();
let iter = make_request!(&mut core, request)?;
- Ok(LogIter{core: Rc::new(RefCell::new(core)), iter: iter})
+ Ok(LogIter{core: Rc::new(RefCell::new(core)), iter})
}
}
@@ -343,7 +343,7 @@ impl Mapping {
}
fn new(core: Rc<RefCell<RpcRuntime>>, name: &str, mapping: node::mapping::Client) -> Self {
- Mapping{core: core, name: name.into(), mapping: mapping}
+ Mapping{core, name: name.into(), mapping}
}
/// Lists all mappings with the given prefix.
@@ -352,7 +352,7 @@ impl Mapping {
let mut request = client.iter_request();
request.get().set_realm_prefix(realm_prefix);
let iter = make_request!(&mut core, request)?;
- Ok(MappingIter{core: Rc::new(RefCell::new(core)), iter: iter})
+ Ok(MappingIter{core: Rc::new(RefCell::new(core)), iter})
}
/// Adds a key identified by fingerprint to the mapping.
@@ -536,14 +536,14 @@ impl Mapping {
pub fn iter(&self) -> Result<BundleIter> {
let request = self.mapping.iter_request();
let iter = make_request!(self.core.borrow_mut(), request)?;
- Ok(BundleIter{core: