From 1542a5b79ecffe4438a8f3e07a65665e7eed3808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 27 Feb 2026 16:12:14 +0100 Subject: [PATCH] chore: Fix some new clippy warnings --- bindings/matrix-sdk-ffi/src/ruma.rs | 8 ++++---- bindings/matrix-sdk-ffi/src/session_verification.rs | 2 +- crates/matrix-sdk-base/src/store/memory_store.rs | 3 ++- crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs | 4 ++-- .../src/session_manager/group_sessions/mod.rs | 4 ++-- crates/matrix-sdk-crypto/src/verification/machine.rs | 2 +- crates/matrix-sdk-indexeddb/src/state_store/mod.rs | 3 ++- crates/matrix-sdk-ui/src/spaces/leave.rs | 2 +- .../oauth/qrcode/rendezvous_channel/msc_4108.rs | 1 + crates/matrix-sdk/src/send_queue/mod.rs | 2 +- examples/timeline/src/main.rs | 2 ++ labs/multiverse/src/widgets/room_view/invited_room.rs | 6 +----- 12 files changed, 20 insertions(+), 19 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/ruma.rs b/bindings/matrix-sdk-ffi/src/ruma.rs index bd167f906..517365a4d 100644 --- a/bindings/matrix-sdk-ffi/src/ruma.rs +++ b/bindings/matrix-sdk-ffi/src/ruma.rs @@ -543,7 +543,7 @@ impl TryFrom for ImageMessageContent { fn try_from(value: RumaImageMessageEventContent) -> Result { Ok(Self { filename: value.filename().to_owned(), - caption: value.caption().map(ToString::to_string), + caption: value.caption().map(str::to_owned), formatted_caption: value.formatted_caption().map(Into::into), source: Arc::new(value.source.try_into()?), info: value.info.as_deref().map(TryInto::try_into).transpose()?, @@ -582,7 +582,7 @@ impl TryFrom for AudioMessageContent { fn try_from(value: RumaAudioMessageEventContent) -> Result { Ok(Self { filename: value.filename().to_owned(), - caption: value.caption().map(ToString::to_string), + caption: value.caption().map(str::to_owned), formatted_caption: value.formatted_caption().map(Into::into), source: Arc::new(value.source.try_into()?), info: value.info.as_deref().map(Into::into), @@ -619,7 +619,7 @@ impl TryFrom for VideoMessageContent { fn try_from(value: RumaVideoMessageEventContent) -> Result { Ok(Self { filename: value.filename().to_owned(), - caption: value.caption().map(ToString::to_string), + caption: value.caption().map(str::to_owned), formatted_caption: value.formatted_caption().map(Into::into), source: Arc::new(value.source.try_into()?), info: value.info.as_deref().map(TryInto::try_into).transpose()?, @@ -654,7 +654,7 @@ impl TryFrom for FileMessageContent { fn try_from(value: RumaFileMessageEventContent) -> Result { Ok(Self { filename: value.filename().to_owned(), - caption: value.caption().map(ToString::to_string), + caption: value.caption().map(str::to_owned), formatted_caption: value.formatted_caption().map(Into::into), source: Arc::new(value.source.try_into()?), info: value.info.as_deref().map(TryInto::try_into).transpose()?, diff --git a/bindings/matrix-sdk-ffi/src/session_verification.rs b/bindings/matrix-sdk-ffi/src/session_verification.rs index 54535fbad..927a8127a 100644 --- a/bindings/matrix-sdk-ffi/src/session_verification.rs +++ b/bindings/matrix-sdk-ffi/src/session_verification.rs @@ -278,7 +278,7 @@ impl SessionVerificationController { sender_profile, flow_id: request.flow_id().into(), device_id: other_device_data.device_id().into(), - device_display_name: other_device_data.display_name().map(str::to_string), + device_display_name: other_device_data.display_name().map(str::to_owned), first_seen_timestamp: other_device_data.first_time_seen_ts().into(), }); } diff --git a/crates/matrix-sdk-base/src/store/memory_store.rs b/crates/matrix-sdk-base/src/store/memory_store.rs index 1b3bb3152..56c83b756 100644 --- a/crates/matrix-sdk-base/src/store/memory_store.rs +++ b/crates/matrix-sdk-base/src/store/memory_store.rs @@ -13,6 +13,7 @@ // limitations under the License. use std::{ + cmp::Reverse, collections::{BTreeMap, BTreeSet, HashMap}, sync::RwLock, }; @@ -878,7 +879,7 @@ impl StateStore for MemoryStore { .or_default() .clone(); // Inverted order of priority, use stable sort to keep insertion order. - ret.sort_by(|lhs, rhs| rhs.priority.cmp(&lhs.priority)); + ret.sort_by_key(|item| Reverse(item.priority)); Ok(ret) } diff --git a/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs b/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs index 072864a78..5a1d50d84 100644 --- a/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs +++ b/crates/matrix-sdk-common/src/linked_chunk/lazy_loader.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::marker::PhantomData; +use std::{cmp::Reverse, marker::PhantomData}; use super::{ Chunk, ChunkContent, ChunkIdentifier, ChunkIdentifierGenerator, Ends, LinkedChunk, @@ -287,7 +287,7 @@ where // Sort by `next` so that the search for the next chunk is faster (it should // come first). The chunk with the biggest next chunk identifier comes first. // Chunk with no next chunk comes last. - chunks.sort_by(|a, b| b.next.cmp(&a.next)); + chunks.sort_by_key(|item| Reverse(item.next)); let last_chunk = chunks .pop() diff --git a/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs b/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs index b2837ec32..b75562c5d 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs @@ -745,8 +745,8 @@ impl GroupSessionManager { // Filter out the devices that already received this room key or have a // to-device message already queued up. let devices: Vec<_> = devices - .into_iter() - .flat_map(|(_, d)| { + .into_values() + .flat_map(|d| { d.into_iter().filter(|d| match outbound.sharing_view().get_share_state(d) { ShareState::NotShared => true, ShareState::Shared { message_index: _, olm_wedging_index } => { diff --git a/crates/matrix-sdk-crypto/src/verification/machine.rs b/crates/matrix-sdk-crypto/src/verification/machine.rs index 4201c2a58..7910563ae 100644 --- a/crates/matrix-sdk-crypto/src/verification/machine.rs +++ b/crates/matrix-sdk-crypto/src/verification/machine.rs @@ -662,7 +662,7 @@ mod tests { } #[cfg(not(target_os = "macos"))] - #[allow(unknown_lints, clippy::unchecked_duration_subtraction)] + #[allow(unknown_lints, clippy::unchecked_time_subtraction)] #[async_test] async fn test_timing_out() { use std::time::Duration; diff --git a/crates/matrix-sdk-indexeddb/src/state_store/mod.rs b/crates/matrix-sdk-indexeddb/src/state_store/mod.rs index e66b83b76..1419a2025 100644 --- a/crates/matrix-sdk-indexeddb/src/state_store/mod.rs +++ b/crates/matrix-sdk-indexeddb/src/state_store/mod.rs @@ -13,6 +13,7 @@ // limitations under the License. use std::{ + cmp::Reverse, collections::{BTreeMap, BTreeSet, HashMap, HashSet}, str::FromStr as _, sync::Arc, @@ -1703,7 +1704,7 @@ impl_state_store!({ )?; // Inverted stable ordering on priority. - prev.sort_by(|lhs, rhs| rhs.priority.unwrap_or(0).cmp(&lhs.priority.unwrap_or(0))); + prev.sort_by_key(|item| Reverse(item.priority.unwrap_or(0))); Ok(prev.into_iter().filter_map(PersistedQueuedRequest::into_queued_request).collect()) } diff --git a/crates/matrix-sdk-ui/src/spaces/leave.rs b/crates/matrix-sdk-ui/src/spaces/leave.rs index a53165d7c..4240a6d50 100644 --- a/crates/matrix-sdk-ui/src/spaces/leave.rs +++ b/crates/matrix-sdk-ui/src/spaces/leave.rs @@ -89,7 +89,7 @@ impl LeaveSpaceHandle { } }) .map(|p: (ruma::OwnedUserId, i64)| p.0) - .chain(privileged_creator_ids.into_iter()); + .chain(privileged_creator_ids); let mut joined_owner_ids = Vec::new(); for owner_id in owner_ids { diff --git a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs index 73c13f209..a566c7eb5 100644 --- a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs +++ b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs @@ -263,6 +263,7 @@ impl Channel { let etag = get_header(headers, &ETAG)?; let expires = get_header(headers, &EXPIRES)?; let last_modified = get_header(headers, &LAST_MODIFIED)?; + #[allow(clippy::result_large_err)] let content_type = headers .get(CONTENT_TYPE) .map(|c| c.to_str().map_err(FromHttpResponseError::::from)) diff --git a/crates/matrix-sdk/src/send_queue/mod.rs b/crates/matrix-sdk/src/send_queue/mod.rs index 4cd956474..06cc04f26 100644 --- a/crates/matrix-sdk/src/send_queue/mod.rs +++ b/crates/matrix-sdk/src/send_queue/mod.rs @@ -2864,7 +2864,7 @@ fn canonicalize_dependent_requests( } } - by_txn.into_iter().flat_map(|(_parent_txn_id, entries)| entries.into_iter().cloned()).collect() + by_txn.into_values().flat_map(|entries| entries.into_iter().cloned()).collect() } #[cfg(all(test, not(target_family = "wasm")))] diff --git a/examples/timeline/src/main.rs b/examples/timeline/src/main.rs index aa2b662fe..3661c2965 100644 --- a/examples/timeline/src/main.rs +++ b/examples/timeline/src/main.rs @@ -1,3 +1,5 @@ +#![recursion_limit = "256"] + use anyhow::Result; use clap::Parser; use futures_util::StreamExt; diff --git a/labs/multiverse/src/widgets/room_view/invited_room.rs b/labs/multiverse/src/widgets/room_view/invited_room.rs index 8cfec5afc..08f3785dd 100644 --- a/labs/multiverse/src/widgets/room_view/invited_room.rs +++ b/labs/multiverse/src/widgets/room_view/invited_room.rs @@ -167,11 +167,7 @@ impl InvitedRoomView { column, row, .. - }) => { - if self.buttons.click(column, row) { - self.join_or_leave() - } - } + }) if self.buttons.click(column, row) => self.join_or_leave(), Event::Mouse(MouseEvent { kind: MouseEventKind::Up(MouseButton::Left), .. }) => { self.buttons.release();