diff --git a/matrix_qrcode/src/types.rs b/matrix_qrcode/src/types.rs index 76c9804f..915c901a 100644 --- a/matrix_qrcode/src/types.rs +++ b/matrix_qrcode/src/types.rs @@ -333,7 +333,7 @@ impl QrVerification { /// This represents the ID as a string even if it is a `EventId`. pub fn flow_id(&self) -> &str { match self { - QrVerification::Verification(v) => &v.event_id.as_str(), + QrVerification::Verification(v) => v.event_id.as_str(), QrVerification::SelfVerification(v) => &v.transaction_id, QrVerification::SelfVerificationNoMasterKey(v) => &v.transaction_id, } @@ -434,7 +434,7 @@ impl VerificationData { pub fn to_bytes(&self) -> Result, EncodingError> { to_bytes( Self::QR_MODE, - &self.event_id.as_str(), + self.event_id.as_str(), &self.first_master_key, &self.second_master_key, &self.shared_secret, diff --git a/matrix_sdk/examples/emoji_verification.rs b/matrix_sdk/examples/emoji_verification.rs index d954dcc9..72e8b7cd 100644 --- a/matrix_sdk/examples/emoji_verification.rs +++ b/matrix_sdk/examples/emoji_verification.rs @@ -89,7 +89,7 @@ async fn login( &sas.other_device().user_id(), &sas.other_device().device_id() ); - print_devices(&e.sender, &client).await; + print_devices(&e.sender, client).await; sas.accept().await.unwrap(); } @@ -110,7 +110,7 @@ async fn login( if sas.is_done() { print_result(&sas); - print_devices(&e.sender, &client).await; + print_devices(&e.sender, client).await; } } @@ -141,7 +141,7 @@ async fn login( } AnySyncMessageEvent::KeyVerificationKey(e) => { let sas = client - .get_verification(&e.content.relation.event_id.as_str()) + .get_verification(e.content.relation.event_id.as_str()) .await .expect("Sas object wasn't created"); @@ -149,13 +149,13 @@ async fn login( } AnySyncMessageEvent::KeyVerificationMac(e) => { let sas = client - .get_verification(&e.content.relation.event_id.as_str()) + .get_verification(e.content.relation.event_id.as_str()) .await .expect("Sas object wasn't created"); if sas.is_done() { print_result(&sas); - print_devices(&e.sender, &client).await; + print_devices(&e.sender, client).await; } } _ => (), diff --git a/matrix_sdk/examples/login.rs b/matrix_sdk/examples/login.rs index 428a198a..31a71acd 100644 --- a/matrix_sdk/examples/login.rs +++ b/matrix_sdk/examples/login.rs @@ -27,7 +27,7 @@ impl EventHandler for EventCallback { .. } = event { - let member = room.get_member(&sender).await.unwrap().unwrap(); + let member = room.get_member(sender).await.unwrap().unwrap(); let name = member.display_name().unwrap_or_else(|| member.user_id().as_str()); println!("{}: {}", name, msg_body); } diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 09ba72f4..45a17a30 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -2033,15 +2033,15 @@ impl Client { } } OutgoingRequests::KeysUpload(request) => { - if let Err(e) = self.keys_upload(&r.request_id(), request).await { + if let Err(e) = self.keys_upload(r.request_id(), request).await { warn!("Error while querying device keys {:?}", e); } } OutgoingRequests::ToDeviceRequest(request) => { // TODO remove this unwrap - if let Ok(resp) = self.send_to_device(&request).await { + if let Ok(resp) = self.send_to_device(request).await { self.base_client - .mark_request_as_sent(&r.request_id(), &resp) + .mark_request_as_sent(r.request_id(), &resp) .await .unwrap(); } @@ -2050,7 +2050,7 @@ impl Client { // TODO remove this unwrap. if let Ok(resp) = self.send(request.clone(), None).await { self.base_client - .mark_request_as_sent(&r.request_id(), &resp) + .mark_request_as_sent(r.request_id(), &resp) .await .unwrap(); } @@ -2058,7 +2058,7 @@ impl Client { OutgoingRequests::RoomMessage(request) => { if let Ok(resp) = self.room_send_helper(request).await { self.base_client - .mark_request_as_sent(&r.request_id(), &resp) + .mark_request_as_sent(r.request_id(), &resp) .await .unwrap(); } @@ -2523,17 +2523,13 @@ impl Client { MediaType::Uri(uri) => { if let MediaFormat::Thumbnail(size) = &request.format { self.send( - get_content_thumbnail::Request::from_url( - &uri, - size.width, - size.height, - )?, + get_content_thumbnail::Request::from_url(uri, size.width, size.height)?, None, ) .await? .file } else { - self.send(get_content::Request::from_url(&uri)?, None).await?.file + self.send(get_content::Request::from_url(uri)?, None).await?.file } } }; @@ -2562,7 +2558,7 @@ impl Client { /// /// * `uri` - The `MxcUri` of the files. pub async fn remove_media_content_for_uri(&self, uri: &MxcUri) -> Result<()> { - Ok(self.base_client.store().remove_media_content_for_uri(&uri).await?) + Ok(self.base_client.store().remove_media_content_for_uri(uri).await?) } /// Get the file of the given media event content. diff --git a/matrix_sdk/src/event_handler/mod.rs b/matrix_sdk/src/event_handler/mod.rs index 7a8b3ab1..37d8b8e7 100644 --- a/matrix_sdk/src/event_handler/mod.rs +++ b/matrix_sdk/src/event_handler/mod.rs @@ -141,7 +141,7 @@ impl Handler { } for (room_id, notifications) in &response.notifications { - if let Some(room) = self.get_room(&room_id) { + if let Some(room) = self.get_room(room_id) { for notification in notifications { self.on_room_notification(room.clone(), notification.clone()).await; } @@ -191,20 +191,20 @@ impl Handler { async fn handle_state_event(&self, room: Room, event: &AnySyncStateEvent) { match event { - AnySyncStateEvent::RoomMember(member) => self.on_state_member(room, &member).await, - AnySyncStateEvent::RoomName(name) => self.on_state_name(room, &name).await, + AnySyncStateEvent::RoomMember(member) => self.on_state_member(room, member).await, + AnySyncStateEvent::RoomName(name) => self.on_state_name(room, name).await, AnySyncStateEvent::RoomCanonicalAlias(canonical) => { - self.on_state_canonical_alias(room, &canonical).await + self.on_state_canonical_alias(room, canonical).await } - AnySyncStateEvent::RoomAliases(aliases) => self.on_state_aliases(room, &aliases).await, - AnySyncStateEvent::RoomAvatar(avatar) => self.on_state_avatar(room, &avatar).await, + AnySyncStateEvent::RoomAliases(aliases) => self.on_state_aliases(room, aliases).await, + AnySyncStateEvent::RoomAvatar(avatar) => self.on_state_avatar(room, avatar).await, AnySyncStateEvent::RoomPowerLevels(power) => { - self.on_state_power_levels(room, &power).await + self.on_state_power_levels(room, power).await } - AnySyncStateEvent::RoomJoinRules(rules) => self.on_state_join_rules(room, &rules).await, + AnySyncStateEvent::RoomJoinRules(rules) => self.on_state_join_rules(room, rules).await, AnySyncStateEvent::RoomTombstone(tomb) => { // TODO make `on_state_tombstone` method - self.on_room_tombstone(room, &tomb).await + self.on_room_tombstone(room, tomb).await } AnySyncStateEvent::Custom(custom) => { self.on_custom_event(room, &CustomEvent::State(custom)).await @@ -221,23 +221,23 @@ impl Handler { ) { match event { AnyStrippedStateEvent::RoomMember(member) => { - self.on_stripped_state_member(room, &member, None).await + self.on_stripped_state_member(room, member, None).await } - AnyStrippedStateEvent::RoomName(name) => self.on_stripped_state_name(room, &name).await, + AnyStrippedStateEvent::RoomName(name) => self.on_stripped_state_name(room, name).await, AnyStrippedStateEvent::RoomCanonicalAlias(canonical) => { - self.on_stripped_state_canonical_alias(room, &canonical).await + self.on_stripped_state_canonical_alias(room, canonical).await } AnyStrippedStateEvent::RoomAliases(aliases) => { - self.on_stripped_state_aliases(room, &aliases).await + self.on_stripped_state_aliases(room, aliases).await } AnyStrippedStateEvent::RoomAvatar(avatar) => { - self.on_stripped_state_avatar(room, &avatar).await + self.on_stripped_state_avatar(room, avatar).await } AnyStrippedStateEvent::RoomPowerLevels(power) => { - self.on_stripped_state_power_levels(room, &power).await + self.on_stripped_state_power_levels(room, power).await } AnyStrippedStateEvent::RoomJoinRules(rules) => { - self.on_stripped_state_join_rules(room, &rules).await + self.on_stripped_state_join_rules(room, rules).await } _ => {} } @@ -249,18 +249,16 @@ impl Handler { event: &AnyRoomAccountDataEvent, ) { if let AnyRoomAccountDataEvent::FullyRead(event) = event { - self.on_non_room_fully_read(room, &event).await + self.on_non_room_fully_read(room, event).await } } pub(crate) async fn handle_account_data_event(&self, event: &AnyGlobalAccountDataEvent) { match event { AnyGlobalAccountDataEvent::IgnoredUserList(ignored) => { - self.on_non_room_ignored_users(&ignored).await - } - AnyGlobalAccountDataEvent::PushRules(rules) => { - self.on_non_room_push_rules(&rules).await + self.on_non_room_ignored_users(ignored).await } + AnyGlobalAccountDataEvent::PushRules(rules) => self.on_non_room_push_rules(rules).await, _ => {} } } diff --git a/matrix_sdk/src/http_client.rs b/matrix_sdk/src/http_client.rs index 63c83e60..a6f54137 100644 --- a/matrix_sdk/src/http_client.rs +++ b/matrix_sdk/src/http_client.rs @@ -368,6 +368,6 @@ impl HttpSend for Client { request: http::Request, config: RequestConfig, ) -> Result, HttpError> { - send_request(&self, request, config).await + send_request(self, request, config).await } } diff --git a/matrix_sdk/src/room/joined.rs b/matrix_sdk/src/room/joined.rs index 3adb477a..f9216d9a 100644 --- a/matrix_sdk/src/room/joined.rs +++ b/matrix_sdk/src/room/joined.rs @@ -392,7 +392,7 @@ impl Joined { }; let txn_id = txn_id.unwrap_or_else(Uuid::new_v4).to_string(); - let request = send_message_event::Request::new(&self.inner.room_id(), &txn_id, &content); + let request = send_message_event::Request::new(self.inner.room_id(), &txn_id, &content); let response = self.client.send(request, None).await?; Ok(response) @@ -480,7 +480,7 @@ impl Joined { (response, keys) } else { - let response = self.client.upload(&content_type, &mut reader).await?; + let response = self.client.upload(content_type, &mut reader).await?; (response, None) }; diff --git a/matrix_sdk/src/room_member.rs b/matrix_sdk/src/room_member.rs index 0514480e..035cdb5e 100644 --- a/matrix_sdk/src/room_member.rs +++ b/matrix_sdk/src/room_member.rs @@ -63,7 +63,7 @@ impl RoomMember { if let Some(url) = self.avatar_url() { if let (Some(width), Some(height)) = (width, height) { let request = - get_content_thumbnail::Request::from_url(&url, width.into(), height.into())?; + get_content_thumbnail::Request::from_url(url, width.into(), height.into())?; let response = self.client.send(request, None).await?; Ok(Some(response.file)) } else { diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 79c45ea7..55cee12d 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -504,7 +504,7 @@ impl BaseClient { } if let Some(context) = &push_context { - let actions = push_rules.get_actions(&event.event, &context).to_vec(); + let actions = push_rules.get_actions(&event.event, context).to_vec(); if actions.iter().any(|a| matches!(a, Action::Notify)) { changes.add_notification( @@ -941,7 +941,7 @@ impl BaseClient { async fn apply_changes(&self, changes: &StateChanges) { for (room_id, room_info) in &changes.room_infos { - if let Some(room) = self.store.get_room(&room_id) { + if let Some(room) = self.store.get_room(room_id) { room.update_summary(room_info.clone()) } } @@ -978,7 +978,7 @@ impl BaseClient { let mut user_ids = BTreeSet::new(); for member in &members { - if self.store.get_member_event(&room_id, &member.state_key).await?.is_none() { + if self.store.get_member_event(room_id, &member.state_key).await?.is_none() { #[cfg(feature = "encryption")] match member.content.membership { MembershipState::Join | MembershipState::Invite => { @@ -987,7 +987,7 @@ impl BaseClient { _ => (), } - ambiguity_cache.handle_event(&changes, room_id, &member).await?; + ambiguity_cache.handle_event(&changes, room_id, member).await?; if member.state_key == member.sender { changes diff --git a/matrix_sdk_base/src/rooms/members.rs b/matrix_sdk_base/src/rooms/members.rs index 5f9d8c3a..ee35ebbc 100644 --- a/matrix_sdk_base/src/rooms/members.rs +++ b/matrix_sdk_base/src/rooms/members.rs @@ -92,7 +92,7 @@ impl RoomMember { .map(|e| { e.content .users - .get(&self.user_id()) + .get(self.user_id()) .map(|p| (*p).into()) .unwrap_or_else(|| e.content.users_default.into()) }) diff --git a/matrix_sdk_base/src/rooms/normal.rs b/matrix_sdk_base/src/rooms/normal.rs index e6d8b55e..e0f415de 100644 --- a/matrix_sdk_base/src/rooms/normal.rs +++ b/matrix_sdk_base/src/rooms/normal.rs @@ -335,12 +335,7 @@ impl Room { let is_own_user_id = |u: &str| u == self.own_user_id().as_str(); let members: Vec = if summary.heroes.is_empty() { - self.active_members() - .await? - .into_iter() - .filter(|u| !is_own_member(&u)) - .take(5) - .collect() + self.active_members().await?.into_iter().filter(|u| !is_own_member(u)).take(5).collect() } else { let members: Vec<_> = stream::iter(summary.heroes.iter()) .filter(|u| future::ready(!is_own_user_id(u))) @@ -528,7 +523,7 @@ impl RoomInfo { } pub(crate) fn handle_state_event(&mut self, event: &AnyStateEventContent) -> bool { - self.base_info.handle_state_event(&event) + self.base_info.handle_state_event(event) } pub(crate) fn update_notification_count( diff --git a/matrix_sdk_base/src/store/ambiguity_map.rs b/matrix_sdk_base/src/store/ambiguity_map.rs index dd0238ac..6d14c664 100644 --- a/matrix_sdk_base/src/store/ambiguity_map.rs +++ b/matrix_sdk_base/src/store/ambiguity_map.rs @@ -197,7 +197,7 @@ impl AmbiguityCache { { u.clone() } else { - self.store.get_users_with_display_name(&room_id, &old_name).await? + self.store.get_users_with_display_name(room_id, old_name).await? }; Some(AmbiguityMap { display_name: old_name.to_string(), users: old_display_name_map }) @@ -231,7 +231,7 @@ impl AmbiguityCache { { u.clone() } else { - self.store.get_users_with_display_name(&room_id, &new_display_name).await? + self.store.get_users_with_display_name(room_id, new_display_name).await? }; Some(AmbiguityMap { diff --git a/matrix_sdk_base/src/store/sled_store/mod.rs b/matrix_sdk_base/src/store/sled_store/mod.rs index 13d35184..37343c0d 100644 --- a/matrix_sdk_base/src/store/sled_store/mod.rs +++ b/matrix_sdk_base/src/store/sled_store/mod.rs @@ -304,7 +304,7 @@ impl SledStore { event: &[u8], ) -> Result { if let Some(key) = &*self.store_key { - let encrypted: EncryptedEvent = serde_json::from_slice(&event)?; + let encrypted: EncryptedEvent = serde_json::from_slice(event)?; Ok(key.decrypt(encrypted)?) } else { Ok(serde_json::from_slice(event)?) diff --git a/matrix_sdk_base/src/store/sled_store/store_key.rs b/matrix_sdk_base/src/store/sled_store/store_key.rs index 734a8d31..cadb7f26 100644 --- a/matrix_sdk_base/src/store/sled_store/store_key.rs +++ b/matrix_sdk_base/src/store/sled_store/store_key.rs @@ -139,7 +139,7 @@ impl StoreKey { /// Expand the given passphrase into a KEY_SIZE long key. fn expand_key(passphrase: &str, salt: &[u8], rounds: u32) -> Zeroizing> { let mut key = Zeroizing::from(vec![0u8; KEY_SIZE]); - pbkdf2::>(passphrase.as_bytes(), &salt, rounds, &mut *key); + pbkdf2::>(passphrase.as_bytes(), salt, rounds, &mut *key); key } @@ -162,7 +162,7 @@ impl StoreKey { let key = StoreKey::expand_key(passphrase, &salt, KDF_ROUNDS); let key = Key::from_slice(key.as_ref()); - let cipher = ChaCha20Poly1305::new(&key); + let cipher = ChaCha20Poly1305::new(key); let mut nonce = vec![0u8; NONCE_SIZE]; nonce.try_fill(&mut rng)?; @@ -230,7 +230,7 @@ impl StoreKey { let decrypted = match encrypted.ciphertext_info { CipherTextInfo::ChaCha20Poly1305 { nonce, ciphertext } => { - let cipher = ChaCha20Poly1305::new(&key); + let cipher = ChaCha20Poly1305::new(key); let nonce = Nonce::from_slice(&nonce); cipher.decrypt(nonce, ciphertext.as_ref())? } diff --git a/matrix_sdk_crypto/src/file_encryption/key_export.rs b/matrix_sdk_crypto/src/file_encryption/key_export.rs index 957238b2..a761d11d 100644 --- a/matrix_sdk_crypto/src/file_encryption/key_export.rs +++ b/matrix_sdk_crypto/src/file_encryption/key_export.rs @@ -161,7 +161,7 @@ fn encrypt_helper(mut plaintext: &mut [u8], passphrase: &str, rounds: u32) -> St pbkdf2::>(passphrase.as_bytes(), &salt, rounds, &mut derived_keys); let (key, hmac_key) = derived_keys.split_at(KEY_SIZE); - let mut aes = Aes256Ctr::new_var(&key, &iv.to_be_bytes()).expect("Can't create AES object"); + let mut aes = Aes256Ctr::new_var(key, &iv.to_be_bytes()).expect("Can't create AES object"); aes.apply_keystream(&mut plaintext); @@ -171,7 +171,7 @@ fn encrypt_helper(mut plaintext: &mut [u8], passphrase: &str, rounds: u32) -> St payload.extend(&salt); payload.extend(&iv.to_be_bytes()); payload.extend(&rounds.to_be_bytes()); - payload.extend_from_slice(&plaintext); + payload.extend_from_slice(plaintext); let mut hmac = Hmac::::new_varkey(hmac_key).expect("Can't create HMAC object"); hmac.update(&payload); @@ -218,7 +218,7 @@ fn decrypt_helper(ciphertext: &str, passphrase: &str) -> Result { - own_identity.is_device_signed(&self).map_or(false, |_| true) + own_identity.is_device_signed(self).map_or(false, |_| true) } // If it's a device from someone else, first check @@ -406,10 +406,10 @@ impl ReadOnlyDevice { // check if the other user has signed this device. UserIdentities::Other(device_identity) => { own_identity - .is_identity_signed(&device_identity) + .is_identity_signed(device_identity) .map_or(false, |_| true) && device_identity - .is_device_signed(&self) + .is_device_signed(self) .map_or(false, |_| true) } }) @@ -455,7 +455,7 @@ impl ReadOnlyDevice { return Err(OlmError::MissingSession); }; - let message = session.encrypt(&self, event_type, content).await?; + let message = session.encrypt(self, event_type, content).await?; Ok((session, message)) } diff --git a/matrix_sdk_crypto/src/key_request.rs b/matrix_sdk_crypto/src/key_request.rs index 296eaea9..19876ce1 100644 --- a/matrix_sdk_crypto/src/key_request.rs +++ b/matrix_sdk_crypto/src/key_request.rs @@ -540,7 +540,7 @@ impl KeyRequestMachine { &self, key_info: &RequestedKeyInfo, ) -> Result { - let request = self.store.get_key_request_by_info(&key_info).await?; + let request = self.store.get_key_request_by_info(key_info).await?; // Don't send out duplicate requests, users can re-request them if they // think a second request might succeed. @@ -1244,7 +1244,7 @@ mod test { .store .get_inbound_group_session( &room_id(), - &bob_account.identity_keys().curve25519(), + bob_account.identity_keys().curve25519(), group_session.session_id() ) .await @@ -1393,7 +1393,7 @@ mod test { .store .get_inbound_group_session( &room_id(), - &bob_account.identity_keys().curve25519(), + bob_account.identity_keys().curve25519(), group_session.session_id() ) .await diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 6f6b0b80..9f00046b 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -123,7 +123,7 @@ impl OlmMachine { pub fn new(user_id: &UserId, device_id: &DeviceId) -> Self { let store: Box = Box::new(MemoryStore::new()); let device_id: DeviceIdBox = device_id.into(); - let account = ReadOnlyAccount::new(&user_id, &device_id); + let account = ReadOnlyAccount::new(user_id, &device_id); OlmMachine::new_helper( user_id, @@ -334,7 +334,7 @@ impl OlmMachine { self.receive_keys_claim_response(response).await?; } IncomingResponse::ToDevice(_) => { - self.mark_to_device_request_as_sent(&request_id).await?; + self.mark_to_device_request_as_sent(request_id).await?; } IncomingResponse::SigningKeysUpload(_) => { self.receive_cross_signing_upload_response().await?; @@ -738,7 +738,7 @@ impl OlmMachine { async fn handle_to_device_event(&self, event: &AnyToDeviceEvent) { match event { AnyToDeviceEvent::RoomKeyRequest(e) => { - self.key_request_machine.receive_incoming_key_request(&e) + self.key_request_machine.receive_incoming_key_request(e) } AnyToDeviceEvent::KeyVerificationAccept(..) | AnyToDeviceEvent::KeyVerificationCancel(..) @@ -748,7 +748,7 @@ impl OlmMachine { | AnyToDeviceEvent::KeyVerificationReady(..) | AnyToDeviceEvent::KeyVerificationDone(..) | AnyToDeviceEvent::KeyVerificationStart(..) => { - self.handle_verification_event(&event).await; + self.handle_verification_event(event).await; } AnyToDeviceEvent::Dummy(_) => {} AnyToDeviceEvent::RoomKey(_) => {} @@ -794,7 +794,7 @@ impl OlmMachine { self.update_one_time_key_count(one_time_keys_counts).await; for user_id in &changed_devices.changed { - if let Err(e) = self.identity_manager.mark_user_as_changed(&user_id).await { + if let Err(e) = self.identity_manager.mark_user_as_changed(user_id).await { error!("Error marking a tracked user as changed {:?}", e); } } @@ -1200,7 +1200,7 @@ impl OlmMachine { .get_inbound_group_sessions() .await? .drain(..) - .filter(|s| predicate(&s)) + .filter(|s| predicate(s)) .collect(); for session in sessions.drain(..) { diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index e665710e..ddd527b9 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -376,7 +376,7 @@ impl Account { plaintext: &str, ) -> OlmResult<(Raw, String)> { // TODO make the errors a bit more specific. - let decrypted_json: Value = serde_json::from_str(&plaintext)?; + let decrypted_json: Value = serde_json::from_str(plaintext)?; let encrypted_sender = decrypted_json .get("sender") @@ -874,7 +874,7 @@ impl ReadOnlyAccount { } }; - device.verify_one_time_key(&one_time_key).map_err(|e| { + device.verify_one_time_key(one_time_key).map_err(|e| { SessionCreationError::InvalidSignature( device.user_id().to_owned(), device.device_id().into(), @@ -889,7 +889,7 @@ impl ReadOnlyAccount { ) })?; - self.create_outbound_session_helper(curve_key, &one_time_key).await.map_err(|e| { + self.create_outbound_session_helper(curve_key, one_time_key).await.map_err(|e| { SessionCreationError::OlmError( device.user_id().to_owned(), device.device_id().into(), @@ -974,7 +974,7 @@ impl ReadOnlyAccount { let inbound = InboundGroupSession::new( sender_key, signing_key, - &room_id, + room_id, outbound.session_key().await, Some(visibility), ) diff --git a/matrix_sdk_crypto/src/olm/signing/mod.rs b/matrix_sdk_crypto/src/olm/signing/mod.rs index 82024ce2..bbeacff6 100644 --- a/matrix_sdk_crypto/src/olm/signing/mod.rs +++ b/matrix_sdk_crypto/src/olm/signing/mod.rs @@ -144,7 +144,7 @@ impl PrivateCrossSigningIdentity { .await .as_ref() .ok_or(SignatureError::MissingSigningKey)? - .sign_user(&user_identity) + .sign_user(user_identity) .await?; Ok(SignatureUploadRequest::new(signed_keys)) diff --git a/matrix_sdk_crypto/src/olm/signing/pk_signing.rs b/matrix_sdk_crypto/src/olm/signing/pk_signing.rs index 0d583212..419fccd9 100644 --- a/matrix_sdk_crypto/src/olm/signing/pk_signing.rs +++ b/matrix_sdk_crypto/src/olm/signing/pk_signing.rs @@ -320,7 +320,7 @@ impl Signing { let ciphertext = &decode(pickled.ciphertext)?; let seed = cipher - .decrypt(&nonce, ciphertext.as_slice()) + .decrypt(nonce, ciphertext.as_slice()) .map_err(|e| SigningError::Decryption(e.to_string()))?; Ok(Self::from_seed(seed)) diff --git a/matrix_sdk_crypto/src/olm/utility.rs b/matrix_sdk_crypto/src/olm/utility.rs index 4393a41d..95bd4d99 100644 --- a/matrix_sdk_crypto/src/olm/utility.rs +++ b/matrix_sdk_crypto/src/olm/utility.rs @@ -133,7 +133,7 @@ mod test { .verify_json( &user_id!("@example:localhost"), &DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, "GBEWHQOYGS".into()), - &signing_key, + signing_key, &mut device_keys, ) .expect("Can't verify device keys"); diff --git a/matrix_sdk_crypto/src/session_manager/group_sessions.rs b/matrix_sdk_crypto/src/session_manager/group_sessions.rs index 08498ad0..b1d2ce6c 100644 --- a/matrix_sdk_crypto/src/session_manager/group_sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/group_sessions.rs @@ -210,7 +210,7 @@ impl GroupSessionManager { room_id: &RoomId, settings: EncryptionSettings, ) -> OlmResult<(OutboundGroupSession, Option)> { - let outbound_session = self.sessions.get_or_load(&room_id).await?; + let outbound_session = self.sessions.get_or_load(room_id).await?; // If there is no session or the session has expired or is invalid, // create a new one. @@ -331,7 +331,7 @@ impl GroupSessionManager { let mut should_rotate = user_left || visibility_changed; for user_id in users { - let user_devices = self.store.get_user_devices(&user_id).await?; + let user_devices = self.store.get_user_devices(user_id).await?; let non_blacklisted_devices: Vec = user_devices.devices().filter(|d| !d.is_blacklisted()).collect(); diff --git a/matrix_sdk_crypto/src/session_manager/sessions.rs b/matrix_sdk_crypto/src/session_manager/sessions.rs index 099e2ffd..e0634051 100644 --- a/matrix_sdk_crypto/src/session_manager/sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/sessions.rs @@ -246,7 +246,7 @@ impl SessionManager { for (user_id, user_devices) in &response.one_time_keys { for (device_id, key_map) in user_devices { - let device = match self.store.get_readonly_device(&user_id, device_id).await { + let device = match self.store.get_readonly_device(user_id, device_id).await { Ok(Some(d)) => d, Ok(None) => { warn!( @@ -267,7 +267,7 @@ impl SessionManager { info!("Creating outbound Session for {} {}", user_id, device_id); - let session = match self.account.create_outbound_session(device, &key_map).await { + let session = match self.account.create_outbound_session(device, key_map).await { Ok(s) => s, Err(e) => { warn!("Error creating new outbound session {:?}", e); @@ -277,9 +277,9 @@ impl SessionManager { changes.sessions.push(session); - self.key_request_machine.retry_keyshare(&user_id, device_id); + self.key_request_machine.retry_keyshare(user_id, device_id); - if let Err(e) = self.check_if_unwedged(&user_id, device_id).await { + if let Err(e) = self.check_if_unwedged(user_id, device_id).await { error!( "Error while treating an unwedged device {} {} {:?}", user_id, device_id, e @@ -426,7 +426,7 @@ mod test { assert!(!manager.users_for_key_claim.contains_key(bob.user_id())); assert!(!manager.is_device_wedged(&bob_device)); - manager.mark_device_as_wedged(bob_device.user_id(), &curve_key).await.unwrap(); + manager.mark_device_as_wedged(bob_device.user_id(), curve_key).await.unwrap(); assert!(manager.is_device_wedged(&bob_device)); assert!(manager.users_for_key_claim.contains_key(bob.user_id())); diff --git a/matrix_sdk_crypto/src/store/pickle_key.rs b/matrix_sdk_crypto/src/store/pickle_key.rs index 6a30836e..03d85f5e 100644 --- a/matrix_sdk_crypto/src/store/pickle_key.rs +++ b/matrix_sdk_crypto/src/store/pickle_key.rs @@ -107,7 +107,7 @@ impl PickleKey { fn expand_key(passphrase: &str, salt: &[u8], rounds: u32) -> Zeroizing> { let mut key = Zeroizing::from(vec![0u8; KEY_SIZE]); - pbkdf2::>(passphrase.as_bytes(), &salt, rounds, &mut *key); + pbkdf2::>(passphrase.as_bytes(), salt, rounds, &mut *key); key } @@ -133,13 +133,13 @@ impl PickleKey { let key = PickleKey::expand_key(passphrase, &salt, KDF_ROUNDS); let key = GenericArray::from_slice(key.as_ref()); - let cipher = Aes256Gcm::new(&key); + let cipher = Aes256Gcm::new(key); let mut nonce = vec![0u8; NONCE_SIZE]; getrandom(&mut nonce).expect("Can't generate new random nonce for the pickle key"); let ciphertext = cipher - .encrypt(&GenericArray::from_slice(nonce.as_ref()), self.aes256_key.as_slice()) + .encrypt(GenericArray::from_slice(nonce.as_ref()), self.aes256_key.as_slice()) .expect("Can't encrypt pickle key"); EncryptedPickleKey { @@ -169,7 +169,7 @@ impl PickleKey { let decrypted = match encrypted.ciphertext_info { CipherTextInfo::Aes256Gcm { nonce, ciphertext } => { - let cipher = Aes256Gcm::new(&key); + let cipher = Aes256Gcm::new(key); let nonce = GenericArray::from_slice(&nonce); cipher.decrypt(nonce, ciphertext.as_ref())? } diff --git a/matrix_sdk_crypto/src/store/sled.rs b/matrix_sdk_crypto/src/store/sled.rs index d1dc9920..90117cfd 100644 --- a/matrix_sdk_crypto/src/store/sled.rs +++ b/matrix_sdk_crypto/src/store/sled.rs @@ -213,7 +213,7 @@ impl SledStore { let session_cache = SessionStore::new(); let pickle_key = if let Some(passphrase) = passphrase { - Self::get_or_create_pickle_key(&passphrase, &db)? + Self::get_or_create_pickle_key(passphrase, &db)? } else { PickleKey::try_from(DEFAULT_PICKLE.as_bytes().to_vec()) .expect("Can't create default pickle key") @@ -1111,7 +1111,7 @@ mod test { let store = SledStore::open_with_passphrase(tmpdir_path, None).expect("Can't create store"); - let account = ReadOnlyAccount::new(&user_id, &device_id); + let account = ReadOnlyAccount::new(&user_id, device_id); store.save_account(account.clone()).await.expect("Can't save account"); diff --git a/matrix_sdk_crypto/src/verification/event_enums.rs b/matrix_sdk_crypto/src/verification/event_enums.rs index b99c123f..f787b00f 100644 --- a/matrix_sdk_crypto/src/verification/event_enums.rs +++ b/matrix_sdk_crypto/src/verification/event_enums.rs @@ -48,8 +48,8 @@ pub enum AnyEvent<'a> { impl AnyEvent<'_> { pub fn sender(&self) -> &UserId { match self { - Self::Room(e) => &e.sender(), - Self::ToDevice(e) => &e.sender(), + Self::Room(e) => e.sender(), + Self::ToDevice(e) => e.sender(), } } @@ -382,7 +382,7 @@ impl<'a> StartContent<'a> { pub fn flow_id(&self) -> &str { match self { Self::ToDevice(c) => &c.transaction_id, - Self::Room(c) => &c.relation.event_id.as_str(), + Self::Room(c) => c.relation.event_id.as_str(), } } @@ -434,7 +434,7 @@ impl<'a> DoneContent<'a> { pub fn flow_id(&self) -> &str { match self { Self::ToDevice(c) => &c.transaction_id, - Self::Room(c) => &c.relation.event_id.as_str(), + Self::Room(c) => c.relation.event_id.as_str(), } } } diff --git a/matrix_sdk_crypto/src/verification/machine.rs b/matrix_sdk_crypto/src/verification/machine.rs index 63ad139e..f474e220 100644 --- a/matrix_sdk_crypto/src/verification/machine.rs +++ b/matrix_sdk_crypto/src/verification/machine.rs @@ -222,7 +222,7 @@ impl VerificationMachine { AnyVerificationContent::Start(c) => { if let Some(request) = self.requests.get(flow_id.as_str()) { if request.flow_id() == &flow_id { - request.receive_start(event.sender(), &c).await? + request.receive_start(event.sender(), c).await? } else { flow_id_mismatch(); } diff --git a/matrix_sdk_crypto/src/verification/mod.rs b/matrix_sdk_crypto/src/verification/mod.rs index d792d053..b237fec2 100644 --- a/matrix_sdk_crypto/src/verification/mod.rs +++ b/matrix_sdk_crypto/src/verification/mod.rs @@ -275,7 +275,7 @@ impl IdentitiesBeingVerified { // We only sign other users here. let request = if let Some(i) = i.other() { // Signing can fail if the user signing key is missing. - match self.private_identity.sign_user(&i).await { + match self.private_identity.sign_user(i).await { Ok(r) => Some(r), Err(SignatureError::MissingSigningKey) => { warn!( diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index 94d1ed98..ea41d749 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -582,7 +582,7 @@ impl RequestState { "Received a new verification start event", ); - let device = if let Some(d) = self.store.get_device(&sender, content.from_device()).await? { + let device = if let Some(d) = self.store.get_device(sender, content.from_device()).await? { d } else { warn!( @@ -594,7 +594,7 @@ impl RequestState { return Ok(()); }; - let identity = self.store.get_user_identity(&sender).await?; + let identity = self.store.get_user_identity(sender).await?; match content.method() { StartMethod::SasV1(_) => match self.to_started_sas(content, device.clone(), identity) { diff --git a/matrix_sdk_crypto/src/verification/sas/helpers.rs b/matrix_sdk_crypto/src/verification/sas/helpers.rs index 9cc1b454..fd365037 100644 --- a/matrix_sdk_crypto/src/verification/sas/helpers.rs +++ b/matrix_sdk_crypto/src/verification/sas/helpers.rs @@ -188,7 +188,7 @@ pub fn receive_mac_event( let mut verified_devices = Vec::new(); let mut verified_identities = Vec::new(); - let info = extra_mac_info_receive(&ids, flow_id); + let info = extra_mac_info_receive(ids, flow_id); trace!( "Received a key.verification.mac event from {} {}", @@ -395,7 +395,7 @@ pub fn get_emoji( ) -> [(&'static str, &'static str); 7] { let bytes = sas .generate_bytes( - &extra_info_sas(&ids, &sas.public_key(), their_pubkey, &flow_id, we_started), + &extra_info_sas(ids, &sas.public_key(), their_pubkey, flow_id, we_started), 6, ) .expect("Can't generate bytes"); @@ -432,7 +432,7 @@ pub fn get_emoji_index( ) -> [u8; 7] { let bytes = sas .generate_bytes( - &extra_info_sas(&ids, &sas.public_key(), their_pubkey, &flow_id, we_started), + &extra_info_sas(ids, &sas.public_key(), their_pubkey, flow_id, we_started), 6, ) .expect("Can't generate bytes"); @@ -507,7 +507,7 @@ pub fn get_decimal( ) -> (u16, u16, u16) { let bytes = sas .generate_bytes( - &extra_info_sas(&ids, &sas.public_key(), their_pubkey, &flow_id, we_started), + &extra_info_sas(ids, &sas.public_key(), their_pubkey, flow_id, we_started), 5, ) .expect("Can't generate bytes"); diff --git a/matrix_sdk_crypto/src/verification/sas/mod.rs b/matrix_sdk_crypto/src/verification/sas/mod.rs index eb8be8d1..827c62dc 100644 --- a/matrix_sdk_crypto/src/verification/sas/mod.rs +++ b/matrix_sdk_crypto/src/verification/sas/mod.rs @@ -584,7 +584,7 @@ mod test { let content = MacContent::try_from(&content).unwrap(); alice.receive_any_event(bob.user_id(), &content.into()); - assert!(alice.verified_devices().unwrap().contains(&alice.other_device())); - assert!(bob.verified_devices().unwrap().contains(&bob.other_device())); + assert!(alice.verified_devices().unwrap().contains(alice.other_device())); + assert!(bob.verified_devices().unwrap().contains(bob.other_device())); } } diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index 78200f52..ac571309 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -285,12 +285,12 @@ impl SasState { /// Get our own user id. #[cfg(test)] pub fn user_id(&self) -> &UserId { - &self.ids.account.user_id() + self.ids.account.user_id() } /// Get our own device id. pub fn device_id(&self) -> &DeviceId { - &self.ids.account.device_id() + self.ids.account.device_id() } #[cfg(test)] @@ -448,7 +448,7 @@ impl SasState { sender: &UserId, content: &AcceptContent, ) -> Result, SasState> { - self.check_event(&sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; + self.check_event(sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; if let AcceptMethod::MSasV1(content) = content.method() { let accepted_protocols = @@ -604,7 +604,7 @@ impl SasState { sender: &UserId, content: &KeyContent, ) -> Result, SasState> { - self.check_event(&sender, &content.flow_id()).map_err(|c| self.clone().cancel(c))?; + self.check_event(sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; let their_pubkey = content.public_key().to_owned(); @@ -644,7 +644,7 @@ impl SasState { sender: &UserId, content: &KeyContent, ) -> Result, SasState> { - self.check_event(&sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; + self.check_event(sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; let commitment = calculate_commitment( content.public_key(), @@ -781,14 +781,14 @@ impl SasState { sender: &UserId, content: &MacContent, ) -> Result, SasState> { - self.check_event(&sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; + self.check_event(sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; let (devices, master_keys) = receive_mac_event( &self.inner.lock().unwrap(), &self.ids, self.verification_flow_id.as_str(), sender, - &content, + content, ) .map_err(|c| self.clone().cancel(c))?; @@ -846,9 +846,9 @@ impl SasState { let (devices, master_keys) = receive_mac_event( &self.inner.lock().unwrap(), &self.ids, - &self.verification_flow_id.as_str(), + self.verification_flow_id.as_str(), sender, - &content, + content, ) .map_err(|c| self.clone().cancel(c))?; @@ -881,14 +881,14 @@ impl SasState { sender: &UserId, content: &MacContent, ) -> Result, SasState> { - self.check_event(&sender, &content.flow_id()).map_err(|c| self.clone().cancel(c))?; + self.check_event(sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; let (devices, master_keys) = receive_mac_event( &self.inner.lock().unwrap(), &self.ids, - &self.verification_flow_id.as_str(), + self.verification_flow_id.as_str(), sender, - &content, + content, ) .map_err(|c| self.clone().cancel(c))?; @@ -965,7 +965,7 @@ impl SasState { &self.inner.lock().unwrap(), &self.ids, &self.state.their_pubkey, - &self.verification_flow_id.as_str(), + self.verification_flow_id.as_str(), self.state.we_started, ) } @@ -993,7 +993,7 @@ impl SasState { &self.inner.lock().unwrap(), &self.ids, &self.state.their_pubkey, - &self.verification_flow_id.as_str(), + self.verification_flow_id.as_str(), self.state.we_started, ) } @@ -1036,7 +1036,7 @@ impl SasState { sender: &UserId, content: &DoneContent, ) -> Result, SasState> { - self.check_event(&sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; + self.check_event(sender, content.flow_id()).map_err(|c| self.clone().cancel(c))?; Ok(SasState { inner: self.inner,