diff --git a/.cargo/config.toml b/.cargo/config.toml index 6433c9841..21f1c4539 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -39,6 +39,7 @@ rustflags = [ "-Wclippy::str_to_string", "-Wclippy::todo", "-Wclippy::unused_async", + "-Wclippy::redundant_clone", ] [target.'cfg(target_arch = "wasm32")'] diff --git a/bindings/matrix-sdk-crypto-ffi/src/lib.rs b/bindings/matrix-sdk-crypto-ffi/src/lib.rs index 1810e127a..2cac969e8 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/lib.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/lib.rs @@ -434,7 +434,7 @@ fn collect_sessions( // the session cache after migration) so we don't need to worry about // signatures. let device_keys = DeviceKeys::new( - user_id.clone(), + user_id, device_id.clone(), Default::default(), BTreeMap::from([ diff --git a/bindings/matrix-sdk-ffi/src/widget.rs b/bindings/matrix-sdk-ffi/src/widget.rs index f20a321af..1e8828832 100644 --- a/bindings/matrix-sdk-ffi/src/widget.rs +++ b/bindings/matrix-sdk-ffi/src/widget.rs @@ -287,7 +287,7 @@ pub fn get_element_call_required_permissions(own_user_id: String) -> WidgetCapab send: vec![ WidgetEventFilter::StateWithTypeAndStateKey { event_type: StateEventType::CallMember.to_string(), - state_key: own_user_id.clone(), + state_key: own_user_id, }, WidgetEventFilter::MessageLikeWithType { event_type: "org.matrix.rageshake_request".to_owned(), diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index c2c5e5423..fa4e910fe 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -1413,7 +1413,7 @@ impl BaseClient { events.get(&StateEventType::RoomMember)?.get(user_id.as_str())?.deserialize().ok() }) { - member.content.displayname.clone().unwrap_or_else(|| user_id.localpart().to_owned()) + member.content.displayname.unwrap_or_else(|| user_id.localpart().to_owned()) } else if let Some(member) = Box::pin(room.get_member(user_id)).await? { member.name().to_owned() } else { diff --git a/crates/matrix-sdk-base/src/sliding_sync.rs b/crates/matrix-sdk-base/src/sliding_sync.rs index 356b7e68d..51238a363 100644 --- a/crates/matrix-sdk-base/src/sliding_sync.rs +++ b/crates/matrix-sdk-base/src/sliding_sync.rs @@ -674,7 +674,7 @@ async fn cache_latest_events( )); // Store it in the return RoomInfo (it will be saved for us in the room later). - room_info.latest_event = Some(latest_event.clone()); + room_info.latest_event = Some(latest_event); // We don't need any of the older encrypted events because we have a new // decrypted one. room.latest_encrypted_events.write().unwrap().clear(); diff --git a/crates/matrix-sdk-crypto/src/identities/user.rs b/crates/matrix-sdk-crypto/src/identities/user.rs index b719f4bfa..61a97c06f 100644 --- a/crates/matrix-sdk-crypto/src/identities/user.rs +++ b/crates/matrix-sdk-crypto/src/identities/user.rs @@ -842,7 +842,7 @@ pub(crate) mod tests { ) .unwrap(); - let mut master_key_updated_signature = master_key.clone(); + let mut master_key_updated_signature = master_key; master_key_updated_signature.signatures = Signatures::new(); let updated_identity = ReadOnlyOwnUserIdentity::new( diff --git a/crates/matrix-sdk-crypto/src/olm/mod.rs b/crates/matrix-sdk-crypto/src/olm/mod.rs index 51396e67c..a111ffc22 100644 --- a/crates/matrix-sdk-crypto/src/olm/mod.rs +++ b/crates/matrix-sdk-crypto/src/olm/mod.rs @@ -152,7 +152,7 @@ pub(crate) mod tests { let message = bob_session.encrypt_helper(plaintext).await; - let prekey_message = match message.clone() { + let prekey_message = match message { OlmMessage::PreKey(m) => m, OlmMessage::Normal(_) => panic!("Incorrect message type"), }; diff --git a/crates/matrix-sdk-crypto/src/secret_storage.rs b/crates/matrix-sdk-crypto/src/secret_storage.rs index 6738eba31..1fbd86815 100644 --- a/crates/matrix-sdk-crypto/src/secret_storage.rs +++ b/crates/matrix-sdk-crypto/src/secret_storage.rs @@ -342,7 +342,7 @@ impl SecretStorageKey { } pub(crate) fn from_bytes(key_id: String, key: Box<[u8; KEY_SIZE]>) -> Self { - let storage_key_info = Self::create_event_content(key_id.to_owned(), &key); + let storage_key_info = Self::create_event_content(key_id, &key); Self { storage_key_info, secret_key: key } } @@ -768,7 +768,7 @@ mod test { content.passphrase = Some(PassPhrase::new("salty goodness".to_owned(), UInt::new_saturating(100))); - SecretStorageKey::from_account_data("It's a secret to nobody", content.to_owned()) + SecretStorageKey::from_account_data("It's a secret to nobody", content) .expect("Should accept any passphrase"); } diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/fuzzy_match_room_name.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/fuzzy_match_room_name.rs index e656ab97d..aa07d4f2b 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/fuzzy_match_room_name.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/fuzzy_match_room_name.rs @@ -50,7 +50,7 @@ pub fn new_filter(pattern: &str) -> impl Filter { move |room| -> bool { let Some(room_name) = room.cached_display_name() else { return false }; - searcher.matches(&room_name.to_string()) + searcher.matches(&room_name) } } diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/normalized_match_room_name.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/normalized_match_room_name.rs index 7f5cec1a0..d6e149b43 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/normalized_match_room_name.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/normalized_match_room_name.rs @@ -49,7 +49,7 @@ pub fn new_filter(pattern: &str) -> impl Filter { move |room| -> bool { let Some(room_name) = room.cached_display_name() else { return false }; - searcher.matches(&room_name.to_string()) + searcher.matches(&room_name) } } diff --git a/crates/matrix-sdk/src/authentication/qrcode/secure_channel.rs b/crates/matrix-sdk/src/authentication/qrcode/secure_channel.rs index 4ff89b66a..bcbe83158 100644 --- a/crates/matrix-sdk/src/authentication/qrcode/secure_channel.rs +++ b/crates/matrix-sdk/src/authentication/qrcode/secure_channel.rs @@ -178,10 +178,7 @@ impl EstablishedSecureChannel { if response == LOGIN_OK_MESSAGE { Ok(ret) } else { - Err(Error::SecureChannelMessage { - expected: LOGIN_OK_MESSAGE, - received: response.to_owned(), - }) + Err(Error::SecureChannelMessage { expected: LOGIN_OK_MESSAGE, received: response }) } } } diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index 34d121077..b71b18e4e 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -347,7 +347,7 @@ impl Client { thumbnail_source, thumbnail_info }); - let content = assign!(ImageMessageEventContent::encrypted(body.to_owned(), file), { + let content = assign!(ImageMessageEventContent::encrypted(body, file), { info: Some(Box::new(info)), formatted: config.formatted_caption, filename @@ -355,8 +355,7 @@ impl Client { MessageType::Image(content) } mime::AUDIO => { - let audio_message_event_content = - AudioMessageEventContent::encrypted(body.to_owned(), file); + let audio_message_event_content = AudioMessageEventContent::encrypted(body, file); MessageType::Audio(crate::media::update_audio_message_event( audio_message_event_content, content_type, @@ -369,7 +368,7 @@ impl Client { thumbnail_source, thumbnail_info }); - let content = assign!(VideoMessageEventContent::encrypted(body.to_owned(), file), { + let content = assign!(VideoMessageEventContent::encrypted(body, file), { info: Some(Box::new(info)), formatted: config.formatted_caption, filename @@ -382,7 +381,7 @@ impl Client { thumbnail_source, thumbnail_info }); - let content = assign!(FileMessageEventContent::encrypted(body.to_owned(), file), { + let content = assign!(FileMessageEventContent::encrypted(body, file), { info: Some(Box::new(info)) }); MessageType::File(content) diff --git a/crates/matrix-sdk/src/event_cache/paginator.rs b/crates/matrix-sdk/src/event_cache/paginator.rs index f80395391..14a896c92 100644 --- a/crates/matrix-sdk/src/event_cache/paginator.rs +++ b/crates/matrix-sdk/src/event_cache/paginator.rs @@ -675,7 +675,7 @@ mod tests { }; return Ok(Messages { - start: opts.from.unwrap().to_owned(), + start: opts.from.unwrap(), end, chunk: events, state: Vec::new(), diff --git a/crates/matrix-sdk/src/media.rs b/crates/matrix-sdk/src/media.rs index cd7cfbd41..1a7a30331 100644 --- a/crates/matrix-sdk/src/media.rs +++ b/crates/matrix-sdk/src/media.rs @@ -507,14 +507,13 @@ impl Media { thumbnail_info, }); let mut image_message_event_content = - ImageMessageEventContent::plain(body.to_owned(), url).info(Box::new(info)); + ImageMessageEventContent::plain(body, url).info(Box::new(info)); image_message_event_content.filename = filename; image_message_event_content.formatted = config.formatted_caption; MessageType::Image(image_message_event_content) } mime::AUDIO => { - let mut audio_message_event_content = - AudioMessageEventContent::plain(body.to_owned(), url); + let mut audio_message_event_content = AudioMessageEventContent::plain(body, url); audio_message_event_content.filename = filename; audio_message_event_content.formatted = config.formatted_caption; MessageType::Audio(update_audio_message_event( @@ -530,7 +529,7 @@ impl Media { thumbnail_info }); let mut video_message_event_content = - VideoMessageEventContent::plain(body.to_owned(), url).info(Box::new(info)); + VideoMessageEventContent::plain(body, url).info(Box::new(info)); video_message_event_content.filename = filename; video_message_event_content.formatted = config.formatted_caption; MessageType::Video(video_message_event_content) @@ -542,7 +541,7 @@ impl Media { thumbnail_info }); let mut file_message_event_content = - FileMessageEventContent::plain(body.to_owned(), url).info(Box::new(info)); + FileMessageEventContent::plain(body, url).info(Box::new(info)); file_message_event_content.filename = filename; file_message_event_content.formatted = config.formatted_caption; MessageType::File(file_message_event_content) diff --git a/crates/matrix-sdk/src/oidc/mod.rs b/crates/matrix-sdk/src/oidc/mod.rs index 2a70e7bfd..97267e7a4 100644 --- a/crates/matrix-sdk/src/oidc/mod.rs +++ b/crates/matrix-sdk/src/oidc/mod.rs @@ -535,8 +535,7 @@ impl Oidc { // The format of the credentials changes according to the client metadata that // was sent. Public clients only get a client ID. - let credentials = - ClientCredentials::None { client_id: registration_response.client_id.clone() }; + let credentials = ClientCredentials::None { client_id: registration_response.client_id }; self.restore_registered_client(issuer, client_metadata, credentials); tracing::info!("Persisting OIDC registration data."); diff --git a/crates/matrix-sdk/src/oidc/tests.rs b/crates/matrix-sdk/src/oidc/tests.rs index 60a6e1c65..5c6a7bc8b 100644 --- a/crates/matrix-sdk/src/oidc/tests.rs +++ b/crates/matrix-sdk/src/oidc/tests.rs @@ -96,10 +96,8 @@ pub async fn mock_environment( }; let oidc = Oidc { - client: client.clone(), - backend: Arc::new( - MockImpl::new().mark_insecure().next_session_tokens(session_tokens.clone()), - ), + client, + backend: Arc::new(MockImpl::new().mark_insecure().next_session_tokens(session_tokens)), }; let (client_credentials, client_metadata) = mock_registered_client_data(); diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 63b19a273..523e35ad4 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -2023,10 +2023,10 @@ mod tests { // partial overlap). already_limited.to_owned(), SlidingSyncRoom::new( - client.clone(), + client, already_limited.to_owned(), None, - vec![event_a.clone(), event_b.clone(), event_c.clone()], + vec![event_a, event_b, event_c.clone()], ), ), ]); @@ -2076,7 +2076,7 @@ mod tests { assign!(v4::SlidingSyncRoom::default(), { initial: Some(true), limited: true, - timeline: vec![event_c.event.clone(), event_d.event.clone()], + timeline: vec![event_c.event, event_d.event], }), ), ]); @@ -2248,7 +2248,7 @@ mod tests { account_data: assign!(v4::AccountData::default(), { rooms: BTreeMap::from([ ( - room_id.clone(), + room_id, vec![ Raw::from_json_string( json!({ diff --git a/crates/matrix-sdk/src/test_utils.rs b/crates/matrix-sdk/src/test_utils.rs index b4cdc5617..7834d42c6 100644 --- a/crates/matrix-sdk/src/test_utils.rs +++ b/crates/matrix-sdk/src/test_utils.rs @@ -80,7 +80,7 @@ pub async fn logged_in_client(homeserver_url: Option) -> Client { #[cfg(not(target_arch = "wasm32"))] pub async fn test_client_builder_with_server() -> (ClientBuilder, wiremock::MockServer) { let server = wiremock::MockServer::start().await; - let builder = test_client_builder(Some(server.uri().to_string())); + let builder = test_client_builder(Some(server.uri())); (builder, server) } diff --git a/crates/matrix-sdk/src/widget/machine/mod.rs b/crates/matrix-sdk/src/widget/machine/mod.rs index c371a2dbb..85979e831 100644 --- a/crates/matrix-sdk/src/widget/machine/mod.rs +++ b/crates/matrix-sdk/src/widget/machine/mod.rs @@ -346,7 +346,7 @@ impl WidgetMachine { let (request, action) = self.send_matrix_driver_request(request); request.then(|mut result, machine| { if let Ok(r) = result.as_mut() { - r.set_room_id(machine.room_id.clone().to_owned()); + r.set_room_id(machine.room_id.clone()); } vec![machine.send_from_widget_result_response(raw_request, result)] }); diff --git a/crates/matrix-sdk/src/widget/machine/tests/openid.rs b/crates/matrix-sdk/src/widget/machine/tests/openid.rs index 5e3b33a9c..f5b248b3c 100644 --- a/crates/matrix-sdk/src/widget/machine/tests/openid.rs +++ b/crates/matrix-sdk/src/widget/machine/tests/openid.rs @@ -80,7 +80,7 @@ fn openid_request_handling_works() { request_openid_token::v3::Response::new( "access_token".to_owned(), TokenType::Bearer, - ServerName::parse("example.org").unwrap().to_owned(), + ServerName::parse("example.org").unwrap(), Duration::from_secs(3600), ), )), diff --git a/crates/matrix-sdk/src/widget/matrix.rs b/crates/matrix-sdk/src/widget/matrix.rs index ce23f2acf..7d6338c70 100644 --- a/crates/matrix-sdk/src/widget/matrix.rs +++ b/crates/matrix-sdk/src/widget/matrix.rs @@ -126,7 +126,7 @@ impl MatrixDriver { (None, Some(future_event_parameters)) => { let r = future::send_future_message_event::unstable::Request::new_raw( self.room.room_id().to_owned(), - TransactionId::new().to_owned(), + TransactionId::new(), MessageLikeEventType::from(type_str), future_event_parameters, Raw::::from_json(content), diff --git a/testing/matrix-sdk-integration-testing/src/tests/nse.rs b/testing/matrix-sdk-integration-testing/src/tests/nse.rs index 40f01139d..4487814c2 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/nse.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/nse.rs @@ -244,8 +244,7 @@ impl ClientWrapper { room.send(RoomMessageEventContent::text_plain(message.to_owned())) .await .expect("Sending message failed") - .event_id - .to_owned(), + .event_id, message.to_owned(), ) }