chore: Fix clippy lints

This commit is contained in:
Jonas Platte
2025-05-29 00:10:16 +02:00
committed by Damir Jelić
parent ed245a0cf0
commit 3c20ee41d6
10 changed files with 31 additions and 31 deletions

View File

@@ -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();

View File

@@ -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())

View File

@@ -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);
{

View File

@@ -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:?}",
);
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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());

View File

@@ -155,11 +155,7 @@ impl VerificationMachine {
}
pub fn get_requests(&self, user_id: &UserId) -> Vec<VerificationRequest> {
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.

View File

@@ -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}.")
}
};

View File

@@ -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!({