Skip to content

Commit 9cf065a

Browse files
committed
clippy
1 parent a04f7b3 commit 9cf065a

File tree

11 files changed

+53
-89
lines changed

11 files changed

+53
-89
lines changed

src/chat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4894,7 +4894,7 @@ async fn set_contacts_by_fingerprints(
48944894
for (fingerprint, addr) in fingerprint_addrs {
48954895
let contact_addr = ContactAddress::new(addr)?;
48964896
let contact =
4897-
Contact::add_or_lookup_ex(context, "", &contact_addr, &fingerprint, Origin::Hidden)
4897+
Contact::add_or_lookup_ex(context, "", &contact_addr, fingerprint, Origin::Hidden)
48984898
.await?
48994899
.0;
49004900
contacts.insert(contact);

src/chat/chat_tests.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,17 +2654,17 @@ async fn test_chat_get_encryption_info() -> Result<()> {
26542654

26552655
add_contact_to_chat(alice, chat_id, contact_bob).await?;
26562656
assert_eq!(
2657-
chat_id.get_encryption_info(&alice).await?,
2657+
chat_id.get_encryption_info(alice).await?,
26582658
"End-to-end encryption available\n\
26592659
\n\
26602660
26612661
CCCB 5AA9 F6E1 141C 9431\n\
26622662
65F1 DB18 B18C BCF7 0487"
26632663
);
26642664

2665-
add_contact_to_chat(&alice, chat_id, contact_fiona).await?;
2665+
add_contact_to_chat(alice, chat_id, contact_fiona).await?;
26662666
assert_eq!(
2667-
chat_id.get_encryption_info(&alice).await?,
2667+
chat_id.get_encryption_info(alice).await?,
26682668
"End-to-end encryption available\n\
26692669
\n\
26702670
@@ -2678,7 +2678,7 @@ async fn test_chat_get_encryption_info() -> Result<()> {
26782678

26792679
let email_chat = alice.create_email_chat(bob).await;
26802680
assert_eq!(
2681-
email_chat.id.get_encryption_info(&alice).await?,
2681+
email_chat.id.get_encryption_info(alice).await?,
26822682
"No encryption"
26832683
);
26842684

@@ -2892,29 +2892,29 @@ async fn test_sync_blocked() -> Result<()> {
28922892
let sent_msg = bob.send_text(ba_chat.id, "hi").await;
28932893
let a0b_chat_id = alice0.recv_msg(&sent_msg).await.chat_id;
28942894
alice1.recv_msg(&sent_msg).await;
2895-
let a0b_contact_id = alice0.add_or_lookup_contact_id(&bob).await;
2895+
let a0b_contact_id = alice0.add_or_lookup_contact_id(bob).await;
28962896

2897-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Request);
2897+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Request);
28982898
a0b_chat_id.accept(alice0).await?;
28992899
sync(alice0, alice1).await;
2900-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Not);
2900+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Not);
29012901
a0b_chat_id.block(alice0).await?;
29022902
sync(alice0, alice1).await;
2903-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Yes);
2903+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Yes);
29042904
a0b_chat_id.unblock(alice0).await?;
29052905
sync(alice0, alice1).await;
2906-
assert_eq!(alice1.get_pgp_chat(&bob).await.blocked, Blocked::Not);
2906+
assert_eq!(alice1.get_pgp_chat(bob).await.blocked, Blocked::Not);
29072907

29082908
// Unblocking a 1:1 chat doesn't unblock the contact currently.
29092909
Contact::unblock(alice0, a0b_contact_id).await?;
29102910

2911-
assert!(!alice1.add_or_lookup_contact(&bob).await.is_blocked());
2911+
assert!(!alice1.add_or_lookup_contact(bob).await.is_blocked());
29122912
Contact::block(alice0, a0b_contact_id).await?;
29132913
sync(alice0, alice1).await;
2914-
assert!(alice1.add_or_lookup_contact(&bob).await.is_blocked());
2914+
assert!(alice1.add_or_lookup_contact(bob).await.is_blocked());
29152915
Contact::unblock(alice0, a0b_contact_id).await?;
29162916
sync(alice0, alice1).await;
2917-
assert!(!alice1.add_or_lookup_contact(&bob).await.is_blocked());
2917+
assert!(!alice1.add_or_lookup_contact(bob).await.is_blocked());
29182918

29192919
// Test accepting and blocking groups. This way we test:
29202920
// - Group chats synchronisation.
@@ -3221,7 +3221,7 @@ async fn test_sync_broadcast() -> Result<()> {
32213221
a.set_config_bool(Config::SyncMsgs, true).await?;
32223222
}
32233223
let bob = &tcm.bob().await;
3224-
let a0b_contact_id = alice0.add_or_lookup_contact(&bob).await.id;
3224+
let a0b_contact_id = alice0.add_or_lookup_contact(bob).await.id;
32253225

32263226
let a0_broadcast_id = create_broadcast_list(alice0).await?;
32273227
sync(alice0, alice1).await;
@@ -3248,7 +3248,7 @@ async fn test_sync_broadcast() -> Result<()> {
32483248
);
32493249
let sent_msg = alice1.send_text(a1_broadcast_id, "hi").await;
32503250
let msg = bob.recv_msg(&sent_msg).await;
3251-
let chat = Chat::load_from_db(&bob, msg.chat_id).await?;
3251+
let chat = Chat::load_from_db(bob, msg.chat_id).await?;
32523252
assert_eq!(chat.get_type(), Chattype::Mailinglist);
32533253
let msg = alice0.recv_msg(&sent_msg).await;
32543254
assert_eq!(msg.chat_id, a0_broadcast_id);

src/contact/contact_tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -733,20 +733,20 @@ async fn test_contact_get_encrinfo() -> Result<()> {
733733
let bob = &tcm.bob().await;
734734

735735
// Return error for special IDs
736-
let encrinfo = Contact::get_encrinfo(&alice, ContactId::SELF).await;
736+
let encrinfo = Contact::get_encrinfo(alice, ContactId::SELF).await;
737737
assert!(encrinfo.is_err());
738-
let encrinfo = Contact::get_encrinfo(&alice, ContactId::DEVICE).await;
738+
let encrinfo = Contact::get_encrinfo(alice, ContactId::DEVICE).await;
739739
assert!(encrinfo.is_err());
740740

741741
let email_contact_bob_id = alice.add_or_lookup_email_contact_id(bob).await;
742-
let encrinfo = Contact::get_encrinfo(&alice, email_contact_bob_id).await?;
742+
let encrinfo = Contact::get_encrinfo(alice, email_contact_bob_id).await?;
743743
assert_eq!(encrinfo, "No encryption");
744744

745-
let contact = Contact::get_by_id(&alice, email_contact_bob_id).await?;
746-
assert!(!contact.e2ee_avail(&alice).await?);
745+
let contact = Contact::get_by_id(alice, email_contact_bob_id).await?;
746+
assert!(!contact.e2ee_avail(alice).await?);
747747

748748
let contact_bob_id = alice.add_or_lookup_contact_id(bob).await;
749-
let encrinfo = Contact::get_encrinfo(&alice, contact_bob_id).await?;
749+
let encrinfo = Contact::get_encrinfo(alice, contact_bob_id).await?;
750750
assert_eq!(
751751
encrinfo,
752752
"End-to-end encryption available.
@@ -760,8 +760,8 @@ [email protected] ([email protected]):
760760
CCCB 5AA9 F6E1 141C 9431
761761
65F1 DB18 B18C BCF7 0487"
762762
);
763-
let contact = Contact::get_by_id(&alice, contact_bob_id).await?;
764-
assert!(contact.e2ee_avail(&alice).await?);
763+
let contact = Contact::get_by_id(alice, contact_bob_id).await?;
764+
assert!(contact.e2ee_avail(alice).await?);
765765
Ok(())
766766
}
767767

@@ -786,7 +786,7 @@ async fn test_synchronize_status() -> Result<()> {
786786
let chat = alice1.create_email_chat(bob).await;
787787

788788
// Alice sends a message to Bob from the first device.
789-
send_text_msg(&alice1, chat.id, "Hello".to_string()).await?;
789+
send_text_msg(alice1, chat.id, "Hello".to_string()).await?;
790790
let sent_msg = alice1.pop_sent_msg().await;
791791

792792
// Message is not encrypted.
@@ -804,7 +804,7 @@ async fn test_synchronize_status() -> Result<()> {
804804

805805
// Alice sends encrypted message.
806806
let chat = alice1.create_chat(bob).await;
807-
send_text_msg(&alice1, chat.id, "Hello".to_string()).await?;
807+
send_text_msg(alice1, chat.id, "Hello".to_string()).await?;
808808
let sent_msg = alice1.pop_sent_msg().await;
809809

810810
// Second message is encrypted.
@@ -850,7 +850,7 @@ async fn test_selfavatar_changed_event() -> Result<()> {
850850

851851
// Alice sends a message.
852852
let alice1_chat_id = alice1.create_chat(bob).await.id;
853-
send_text_msg(&alice1, alice1_chat_id, "Hello".to_string()).await?;
853+
send_text_msg(alice1, alice1_chat_id, "Hello".to_string()).await?;
854854
let sent_msg = alice1.pop_sent_msg().await;
855855

856856
// The message is encrypted.

src/imex/key_transfer.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,14 @@ mod tests {
313313
alice2.recv_msg(&sent).await;
314314
let msg = alice2.get_last_msg().await;
315315
assert!(msg.is_setupmessage());
316-
assert_eq!(
317-
crate::key::load_self_secret_keyring(&alice2).await?.len(),
318-
0
319-
);
316+
assert_eq!(crate::key::load_self_secret_keyring(alice2).await?.len(), 0);
320317

321318
// Transfer the key.
322319
tcm.section("Alice imports a key from Autocrypt Setup Message");
323320
alice2.set_config(Config::BccSelf, Some("0")).await?;
324-
continue_key_transfer(&alice2, msg.id, &setup_code).await?;
321+
continue_key_transfer(alice2, msg.id, &setup_code).await?;
325322
assert_eq!(alice2.get_config_bool(Config::BccSelf).await?, true);
326-
assert_eq!(
327-
crate::key::load_self_secret_keyring(&alice2).await?.len(),
328-
1
329-
);
323+
assert_eq!(crate::key::load_self_secret_keyring(alice2).await?.len(), 1);
330324

331325
// Alice sends a message to self from the new device.
332326
let sent = alice2.send_text(msg.chat_id, "Test").await;

src/message/message_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ async fn test_unencrypted_quote_encrypted_message() -> Result<()> {
200200

201201
let bob_received_message = bob.recv_msg(&sent).await;
202202
assert_eq!(bob_received_message.get_showpadlock(), true);
203-
let bob_chat_id = bob_received_message.chat_id;
204203

205204
// Bob quotes encrypted message in unencrypted chat.
206205
let bob_email_chat = bob.create_email_chat(alice).await;

src/receive_imf.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub(crate) async fn receive_imf_inner(
324324

325325
let chat_id = if let Some(grpid) = mime_parser.get_chat_group_id() {
326326
if let Some((chat_id, _protected, _blocked)) =
327-
chat::get_chat_id_by_grpid(context, &grpid).await?
327+
chat::get_chat_id_by_grpid(context, grpid).await?
328328
{
329329
Some(chat_id)
330330
} else {
@@ -376,7 +376,7 @@ pub(crate) async fn receive_imf_inner(
376376
past_ids = lookup_pgp_contacts_by_address_list(
377377
context,
378378
&mime_parser.past_members,
379-
&past_member_fingerprints,
379+
past_member_fingerprints,
380380
chat_id,
381381
)
382382
.await?;
@@ -385,15 +385,15 @@ pub(crate) async fn receive_imf_inner(
385385
context,
386386
&mime_parser.past_members,
387387
&mime_parser.gossiped_keys,
388-
&past_member_fingerprints,
388+
past_member_fingerprints,
389389
Origin::Hidden,
390390
)
391391
.await?;
392392
}
393393
} else {
394394
if pgp_to_ids.len() == 1
395395
&& pgp_to_ids
396-
.get(0)
396+
.first()
397397
.is_some_and(|contact_id| contact_id.is_some())
398398
{
399399
// There is a single recipient and we have
@@ -425,18 +425,17 @@ pub(crate) async fn receive_imf_inner(
425425

426426
let received_msg;
427427
if mime_parser.get_header(HeaderDef::SecureJoin).is_some() {
428-
let res;
429-
if mime_parser.incoming {
430-
res = handle_securejoin_handshake(context, &mut mime_parser, from_id)
428+
let res = if mime_parser.incoming {
429+
handle_securejoin_handshake(context, &mut mime_parser, from_id)
431430
.await
432-
.context("error in Secure-Join message handling")?;
431+
.context("error in Secure-Join message handling")?
433432
} else {
434433
let to_id = to_ids.first().copied().flatten().unwrap_or(ContactId::SELF);
435434
// handshake may mark contacts as verified and must be processed before chats are created
436-
res = observe_securejoin_on_other_device(context, &mime_parser, to_id)
435+
observe_securejoin_on_other_device(context, &mime_parser, to_id)
437436
.await
438437
.context("error in Secure-Join watching")?
439-
}
438+
};
440439

441440
match res {
442441
securejoin::HandshakeMessage::Done | securejoin::HandshakeMessage::Ignore => {
@@ -964,7 +963,7 @@ async fn add_parts(
964963
context,
965964
mime_parser,
966965
&parent,
967-
&to_ids,
966+
to_ids,
968967
from_id,
969968
allow_creation || test_normal_chat.is_some(),
970969
create_blocked,
@@ -2622,7 +2621,7 @@ async fn apply_group_changes(
26222621
context,
26232622
chat_id,
26242623
Some(from_id),
2625-
&to_ids,
2624+
to_ids,
26262625
past_ids,
26272626
chat_group_member_timestamps,
26282627
)

src/receive_imf/receive_imf_tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,7 +4722,6 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> {
47224722
let mut tcm = TestContextManager::new();
47234723
let alice = &tcm.alice().await;
47244724
let bob = &tcm.bob().await;
4725-
let bob_addr = bob.get_config(Config::Addr).await?.unwrap();
47264725
mark_as_verified(alice, bob).await;
47274726
let group_id = create_group_chat(alice, ProtectionStatus::Protected, "Group").await?;
47284727
let alice_bob_id = alice.add_or_lookup_contact(bob).await.id;
@@ -4731,7 +4730,6 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> {
47314730
alice.sql.execute("DELETE FROM public_keys", ()).await?;
47324731

47334732
let fiona = &tcm.fiona().await;
4734-
let fiona_addr = fiona.get_config(Config::Addr).await?.unwrap();
47354733
mark_as_verified(alice, fiona).await;
47364734
let alice_fiona_id = alice.add_or_lookup_contact(fiona).await.id;
47374735
add_contact_to_chat(alice, group_id, alice_fiona_id).await?;

src/securejoin.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use crate::mimeparser::{MimeMessage, SystemMessage};
2020
use crate::param::Param;
2121
use crate::qr::check_qr;
2222
use crate::securejoin::bob::JoinerProgress;
23-
use crate::stock_str;
2423
use crate::sync::Sync::*;
2524
use crate::token;
2625

src/securejoin/securejoin_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
350350

351351
tcm.section("Step 1: Generate QR-code");
352352
// `None` indicates setup-contact.
353-
let qr = get_securejoin_qr(&alice, None).await?;
353+
let qr = get_securejoin_qr(alice, None).await?;
354354

355355
tcm.section("Step 2+4: Bob scans QR-code, sends vc-request-with-auth, skipping vc-request");
356-
join_securejoin(&bob, &qr).await.unwrap();
356+
join_securejoin(bob, &qr).await.unwrap();
357357

358358
// Check Bob emitted the JoinerProgress event.
359359
let event = bob
@@ -388,11 +388,11 @@ async fn test_setup_contact_bob_knows_alice() -> Result<()> {
388388

389389
// Alice should not yet have Bob verified
390390
let contact_bob = alice.add_or_lookup_pgp_contact(bob).await;
391-
assert_eq!(contact_bob.is_verified(&alice).await?, false);
391+
assert_eq!(contact_bob.is_verified(alice).await?, false);
392392

393393
tcm.section("Step 5+6: Alice receives vc-request-with-auth, sends vc-contact-confirm");
394394
alice.recv_msg_trash(&sent).await;
395-
assert_eq!(contact_bob.is_verified(&alice).await?, true);
395+
assert_eq!(contact_bob.is_verified(alice).await?, true);
396396

397397
let sent = alice.pop_sent_msg().await;
398398
let msg = bob.parse_msg(&sent).await;

src/stock_str.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,6 @@ pub(crate) async fn msg_grp_img_deleted(context: &Context, by_contact: ContactId
778778
}
779779
}
780780

781-
/// Stock string: `End-to-end encryption preferred.`.
782-
pub(crate) async fn e2e_preferred(context: &Context) -> String {
783-
translated(context, StockMessage::E2ePreferred).await
784-
}
785-
786781
/// Stock string: `%1$s invited you to join this group. Waiting for the device of %2$s to reply…`.
787782
pub(crate) async fn secure_join_started(
788783
context: &Context,

0 commit comments

Comments
 (0)