diff --git a/crates/matrix-sdk-base/src/event_cache/store/integration_tests.rs b/crates/matrix-sdk-base/src/event_cache/store/integration_tests.rs index a396f81ac..da7437850 100644 --- a/crates/matrix-sdk-base/src/event_cache/store/integration_tests.rs +++ b/crates/matrix-sdk-base/src/event_cache/store/integration_tests.rs @@ -501,7 +501,7 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore { let previous_chunk = self.load_previous_chunk(room_id, first_chunk).await.unwrap().unwrap(); - let _ = lazy_loader::insert_new_first_chunk(&mut linked_chunk, previous_chunk).unwrap(); + lazy_loader::insert_new_first_chunk(&mut linked_chunk, previous_chunk).unwrap(); let mut rchunks = linked_chunk.rchunks(); @@ -538,7 +538,7 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore { let previous_chunk = self.load_previous_chunk(room_id, first_chunk).await.unwrap().unwrap(); - let _ = lazy_loader::insert_new_first_chunk(&mut linked_chunk, previous_chunk).unwrap(); + lazy_loader::insert_new_first_chunk(&mut linked_chunk, previous_chunk).unwrap(); let mut rchunks = linked_chunk.rchunks(); diff --git a/crates/matrix-sdk-common/src/deserialized_responses.rs b/crates/matrix-sdk-common/src/deserialized_responses.rs index 7e9e12d9c..0fe4d5d5e 100644 --- a/crates/matrix-sdk-common/src/deserialized_responses.rs +++ b/crates/matrix-sdk-common/src/deserialized_responses.rs @@ -208,7 +208,7 @@ impl fmt::Display for VerificationLevel { } VerificationLevel::None(..) => "The sending device is not known", }; - write!(f, "{}", display) + write!(f, "{display}") } } @@ -501,8 +501,7 @@ impl<'de> Deserialize<'de> for TimelineEvent { let v0: SyncTimelineEventDeserializationHelperV0 = serde_json::from_value(Value::Object(value)).map_err(|e| { serde::de::Error::custom(format!( - "Unable to deserialize V0-format TimelineEvent: {}", - e + "Unable to deserialize V0-format TimelineEvent: {e}", )) })?; Ok(v0.into()) @@ -512,8 +511,7 @@ impl<'de> Deserialize<'de> for TimelineEvent { let v1: SyncTimelineEventDeserializationHelperV1 = serde_json::from_value(Value::Object(value)).map_err(|e| { serde::de::Error::custom(format!( - "Unable to deserialize V1-format TimelineEvent: {}", - e + "Unable to deserialize V1-format TimelineEvent: {e}", )) })?; Ok(v1.into()) diff --git a/crates/matrix-sdk-crypto/src/gossiping/machine.rs b/crates/matrix-sdk-crypto/src/gossiping/machine.rs index 6323a32f7..bdebbdd4a 100644 --- a/crates/matrix-sdk-crypto/src/gossiping/machine.rs +++ b/crates/matrix-sdk-crypto/src/gossiping/machine.rs @@ -1265,7 +1265,8 @@ mod tests { second_device.set_trust_state(LocalTrust::Verified); bob_device.set_trust_state(LocalTrust::Verified); alice_machine.inner.store.save_device_data(&[bob_device, second_device]).await.unwrap(); - bob_machine.inner.store.save_device_data(&[alice_device.clone()]).await.unwrap(); + let devices = std::slice::from_ref(&alice_device); + bob_machine.inner.store.save_device_data(devices).await.unwrap(); if create_sessions { // Create Olm sessions for our two accounts. @@ -1486,7 +1487,8 @@ mod tests { // We need a trusted device, otherwise we won't request keys alice_device.set_trust_state(LocalTrust::Verified); - machine.inner.store.save_device_data(&[alice_device.clone()]).await.unwrap(); + let devices = std::slice::from_ref(&alice_device); + machine.inner.store.save_device_data(devices).await.unwrap(); let (outbound, session) = account.create_group_session_pair_with_defaults(room_id()).await; let content = outbound.encrypt("m.dummy", &message_like_event_content!({})).await; @@ -1528,7 +1530,8 @@ mod tests { assert_eq!(first_session.first_known_index(), 10); - machine.inner.store.save_inbound_group_sessions(&[first_session.clone()]).await.unwrap(); + let sessions = std::slice::from_ref(&first_session); + machine.inner.store.save_inbound_group_sessions(sessions).await.unwrap(); // Get the cancel request. let id = machine @@ -1871,7 +1874,8 @@ mod tests { let bob_account = bob_account(); let bob_device = DeviceData::from_account(&bob_account); - alice_machine.inner.store.save_device_data(&[alice_device.clone()]).await.unwrap(); + let devices = std::slice::from_ref(&alice_device); + alice_machine.inner.store.save_device_data(devices).await.unwrap(); // Create Olm sessions for our two accounts. let alice_session = alice_machine @@ -1945,7 +1949,8 @@ mod tests { // We need a trusted device, otherwise we won't serve secrets alice_device.set_trust_state(LocalTrust::Verified); - alice_machine.inner.store.save_device_data(&[alice_device.clone()]).await.unwrap(); + let devices = std::slice::from_ref(&alice_device); + alice_machine.inner.store.save_device_data(devices).await.unwrap(); alice_machine.receive_incoming_secret_request(&event); { diff --git a/crates/matrix-sdk-crypto/src/machine/tests/decryption_verification_state.rs b/crates/matrix-sdk-crypto/src/machine/tests/decryption_verification_state.rs index 2ec499cf9..e402e2bf5 100644 --- a/crates/matrix-sdk-crypto/src/machine/tests/decryption_verification_state.rs +++ b/crates/matrix-sdk-crypto/src/machine/tests/decryption_verification_state.rs @@ -557,7 +557,8 @@ async fn encrypt_message( .unwrap() .inbound_group_session .unwrap(); - recipient.store().save_inbound_group_sessions(&[group_session.clone()]).await.unwrap(); + let sessions = std::slice::from_ref(&group_session); + recipient.store().save_inbound_group_sessions(sessions).await.unwrap(); let content = RoomMessageEventContent::text_plain(plaintext); @@ -596,14 +597,12 @@ async fn check_decryption_trust_requirement( if *is_ok { assert!( bob.decrypt_room_event(event, room_id, &decryption_settings).await.is_ok(), - "Decryption did not succeed with {:?}", - trust_requirement, + "Decryption did not succeed with {trust_requirement:?}", ); } else { assert!( bob.decrypt_room_event(event, room_id, &decryption_settings).await.is_err(), - "Decryption succeeded with {:?}", - trust_requirement, + "Decryption succeeded with {trust_requirement:?}", ); } } diff --git a/crates/matrix-sdk-crypto/src/machine/tests/mod.rs b/crates/matrix-sdk-crypto/src/machine/tests/mod.rs index bfa813ddc..dc4b60bca 100644 --- a/crates/matrix-sdk-crypto/src/machine/tests/mod.rs +++ b/crates/matrix-sdk-crypto/src/machine/tests/mod.rs @@ -637,7 +637,8 @@ async fn test_megolm_encryption() { .unwrap() .inbound_group_session .unwrap(); - bob.store().save_inbound_group_sessions(&[group_session.clone()]).await.unwrap(); + let sessions = std::slice::from_ref(&group_session); + bob.store().save_inbound_group_sessions(sessions).await.unwrap(); // when we decrypt the room key, the // inbound_group_session_streamroom_keys_received_stream should tell us diff --git a/crates/matrix-sdk-crypto/src/session_manager/group_sessions/share_strategy.rs b/crates/matrix-sdk-crypto/src/session_manager/group_sessions/share_strategy.rs index 63d2f6d08..b6de65eec 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/group_sessions/share_strategy.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/group_sessions/share_strategy.rs @@ -1688,7 +1688,7 @@ mod tests { ) { // The share list should be empty for (user, device_list) in recips.devices { - assert_eq!(device_list.len(), 0, "session unexpectedly shared with {}", user); + assert_eq!(device_list.len(), 0, "session unexpectedly shared with {user}"); } // ... and there should be one withheld message diff --git a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs index 94eb006fb..1971a46c1 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs @@ -840,7 +840,8 @@ mod tests { let time = SystemTime::now() - Duration::from_secs(3601); session.creation_time = SecondsSinceUnixEpoch::from_system_time(time).unwrap(); - manager.store.save_device_data(&[bob_device.clone()]).await.unwrap(); + let devices = std::slice::from_ref(&bob_device); + manager.store.save_device_data(devices).await.unwrap(); manager.store.save_sessions(&[session]).await.unwrap(); assert!(manager.get_missing_sessions(iter::once(bob.user_id())).await.unwrap().is_none()); diff --git a/crates/matrix-sdk-crypto/src/verification/machine.rs b/crates/matrix-sdk-crypto/src/verification/machine.rs index cd20a9eb6..3046c351c 100644 --- a/crates/matrix-sdk-crypto/src/verification/machine.rs +++ b/crates/matrix-sdk-crypto/src/verification/machine.rs @@ -155,11 +155,7 @@ impl VerificationMachine { } pub fn get_requests(&self, user_id: &UserId) -> Vec { - self.requests - .read() - .get(user_id) - .map(|v| v.iter().map(|(_, value)| value.clone()).collect()) - .unwrap_or_default() + self.requests.read().get(user_id).map(|v| v.values().cloned().collect()).unwrap_or_default() } /// Add a new `VerificationRequest` object to the cache. diff --git a/crates/matrix-sdk-store-encryption/src/lib.rs b/crates/matrix-sdk-store-encryption/src/lib.rs index dea7e7e44..9827e2db5 100644 --- a/crates/matrix-sdk-store-encryption/src/lib.rs +++ b/crates/matrix-sdk-store-encryption/src/lib.rs @@ -653,7 +653,7 @@ impl std::fmt::Display for EncryptedValueBase64DecodeError { let msg = match self { EncryptedValueBase64DecodeError::DecodeError(e) => e.to_string(), EncryptedValueBase64DecodeError::IncorrectNonceLength(length) => { - format!("Incorrect nonce length {}. Expected length: {}.", length, XNONCE_SIZE) + format!("Incorrect nonce length {length}. Expected length: {XNONCE_SIZE}.") } }; diff --git a/testing/matrix-sdk-test/src/test_json/keys_query.rs b/testing/matrix-sdk-test/src/test_json/keys_query.rs index e9b25c7d4..d842c533a 100644 --- a/testing/matrix-sdk-test/src/test_json/keys_query.rs +++ b/testing/matrix-sdk-test/src/test_json/keys_query.rs @@ -118,11 +118,11 @@ pub fn self_signing_keys(user: &KeysQueryUser) -> serde_json::Value { json!({ user.user_id: { "keys": { - &format!("ed25519:{}", self_signing_key_name): self_signing_key_name + &format!("ed25519:{self_signing_key_name}"): self_signing_key_name }, "signatures": { "@bob:localhost": { - &format!("ed25519:{}", master_key_name): self_signing_key_signature, + &format!("ed25519:{master_key_name}"): self_signing_key_signature, } }, "usage": [ "self_signing" ], @@ -140,10 +140,10 @@ pub fn master_keys(user: &KeysQueryUser) -> serde_json::Value { { json!({ user.user_id: { - "keys": { &format!("ed25519:{}", master_key_name): master_key_name }, + "keys": { &format!("ed25519:{master_key_name}"): master_key_name }, "signatures": { user.user_id: { - &format!("ed25519:{}", master_key_name): master_key_signature, + &format!("ed25519:{master_key_name}"): master_key_signature, &format!("ed25519:{}", user.device_id): master_key_device_signature } }, @@ -164,7 +164,7 @@ pub fn device_keys_payload(user: &KeysQueryUser) -> serde_json::Value { (user.device_signature_2_name, user.device_signature_2_signature) { signatures - .insert(format!("ed25519:{}", device_signature_2_name), device_signature_2_signature); + .insert(format!("ed25519:{device_signature_2_name}"), device_signature_2_signature); } json!({