diff --git a/Cargo.toml b/Cargo.toml index ebdabcd9..2ea00cab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ repository = "https://gitlab.com/famedly/conduit" version = "0.11.0-alpha" # See also `rust-toolchain.toml` -rust-version = "1.83.0" +rust-version = "1.85.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/flake.nix b/flake.nix index ddf9d526..d9653c8f 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,7 @@ file = ./rust-toolchain.toml; # See also `rust-toolchain.toml` - sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM="; + sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU="; }; }); in diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c5259d2a..2d003223 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -9,7 +9,7 @@ # If you're having trouble making the relevant changes, bug a maintainer. [toolchain] -channel = "1.83.0" +channel = "1.85.0" components = [ # For rust-analyzer "rust-src", diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index 84bd0a69..78584c22 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -656,7 +656,7 @@ pub async fn joined_members_route( Ok(joined_members::v3::Response { joined }) } -pub(crate) async fn invite_helper<'a>( +pub(crate) async fn invite_helper( sender_user: &UserId, user_id: &UserId, room_id: &RoomId, diff --git a/src/api/client_server/session.rs b/src/api/client_server/session.rs index 07078328..581867dc 100644 --- a/src/api/client_server/session.rs +++ b/src/api/client_server/session.rs @@ -182,11 +182,11 @@ pub async fn login_route(body: Ruma) -> Result(&'a self, server: &ServerName, room_id: &RoomId) -> Result { + fn server_in_room(&self, server: &ServerName, room_id: &RoomId) -> Result { let mut key = server.as_bytes().to_vec(); key.push(0xff); key.extend_from_slice(room_id.as_bytes()); diff --git a/src/database/mod.rs b/src/database/mod.rs index d2fb3267..ae477856 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -491,7 +491,7 @@ impl KeyValueDatabase { for (userid, password) in db.userid_password.iter() { let password = utils::string_from_bytes(&password); - let empty_hashed_password = password.map_or(false, |password| { + let empty_hashed_password = password.is_ok_and(|password| { argon2::verify_encoded(&password, b"").unwrap_or(false) }); diff --git a/src/service/rooms/pdu_metadata/mod.rs b/src/service/rooms/pdu_metadata/mod.rs index 5ffe8846..13fe7c3f 100644 --- a/src/service/rooms/pdu_metadata/mod.rs +++ b/src/service/rooms/pdu_metadata/mod.rs @@ -87,13 +87,13 @@ impl Service { let events_after: Vec<_> = relations_until // TODO: should be relations_after .iter() .filter(|(_, pdu)| { - filter_event_type.as_ref().map_or(true, |t| &pdu.kind == t) + filter_event_type.as_ref().is_none_or(|t| &pdu.kind == t) && if let Ok(content) = serde_json::from_str::(pdu.content.get()) { filter_rel_type .as_ref() - .map_or(true, |r| &content.relates_to.rel_type == r) + .is_none_or(|r| &content.relates_to.rel_type == r) } else { false } @@ -135,13 +135,13 @@ impl Service { let events_before: Vec<_> = relations_until .iter() .filter(|(_, pdu)| { - filter_event_type.as_ref().map_or(true, |t| &pdu.kind == t) + filter_event_type.as_ref().is_none_or(|t| &pdu.kind == t) && if let Ok(content) = serde_json::from_str::(pdu.content.get()) { filter_rel_type .as_ref() - .map_or(true, |r| &content.relates_to.rel_type == r) + .is_none_or(|r| &content.relates_to.rel_type == r) } else { false } diff --git a/src/service/rooms/search/mod.rs b/src/service/rooms/search/mod.rs index 3b9de19f..aff9a31c 100644 --- a/src/service/rooms/search/mod.rs +++ b/src/service/rooms/search/mod.rs @@ -11,17 +11,12 @@ pub struct Service { impl Service { #[tracing::instrument(skip(self))] - pub fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> { + pub fn index_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> { self.db.index_pdu(shortroomid, pdu_id, message_body) } #[tracing::instrument(skip(self))] - pub fn deindex_pdu<'a>( - &self, - shortroomid: u64, - pdu_id: &[u8], - message_body: &str, - ) -> Result<()> { + pub fn deindex_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> { self.db.deindex_pdu(shortroomid, pdu_id, message_body) } diff --git a/src/service/rooms/spaces/mod.rs b/src/service/rooms/spaces/mod.rs index abd8f950..f8e294da 100644 --- a/src/service/rooms/spaces/mod.rs +++ b/src/service/rooms/spaces/mod.rs @@ -629,7 +629,7 @@ fn next_room_to_traverse( stack: &mut Vec)>>, parents: &mut VecDeque, ) -> Option<(OwnedRoomId, Vec)> { - while stack.last().map_or(false, |s| s.is_empty()) { + while stack.last().is_some_and(|s| s.is_empty()) { stack.pop(); parents.pop_back(); } @@ -663,7 +663,7 @@ async fn get_stripped_space_child_events( if serde_json::from_str::(pdu.content.get()) .ok() .map(|c| c.via) - .map_or(true, |v| v.is_empty()) + .is_none_or(|v| v.is_empty()) { continue; } diff --git a/src/service/rooms/state_cache/mod.rs b/src/service/rooms/state_cache/mod.rs index 5cfd9738..b24d5b33 100644 --- a/src/service/rooms/state_cache/mod.rs +++ b/src/service/rooms/state_cache/mod.rs @@ -171,7 +171,7 @@ impl Service { }) }) .transpose()? - .map_or(false, |ignored| { + .is_some_and(|ignored| { ignored .content .ignored_users @@ -236,7 +236,7 @@ impl Service { } #[tracing::instrument(skip(self))] - pub fn server_in_room<'a>(&'a self, server: &ServerName, room_id: &RoomId) -> Result { + pub fn server_in_room(&self, server: &ServerName, room_id: &RoomId) -> Result { self.db.server_in_room(server, room_id) } diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index cc30d2c9..32144f7d 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -199,7 +199,7 @@ impl Service { /// /// Returns pdu id #[tracing::instrument(skip(self, pdu, pdu_json, leaves))] - pub async fn append_pdu<'a>( + pub async fn append_pdu( &self, pdu: &PduEvent, mut pdu_json: CanonicalJsonObject, @@ -612,8 +612,8 @@ impl Service { services().globals.server_name() == pdu.sender.server_name() && appservice.is_user_match(&pdu.sender) || pdu.kind == TimelineEventType::RoomMember - && pdu.state_key.as_ref().map_or(false, |state_key| { - UserId::parse(state_key).map_or(false, |user_id| { + && pdu.state_key.as_ref().is_some_and(|state_key| { + UserId::parse(state_key).is_ok_and(|user_id| { services().globals.server_name() == user_id.server_name() && appservice.is_user_match(&user_id) }) @@ -633,8 +633,8 @@ impl Service { "", ) { serde_json::from_str::(pdu.content.get()) - .map_or(false, |content| { - content.alias.map_or(false, |alias| { + .is_ok_and(|content| { + content.alias.is_some_and(|alias| { appservice.aliases.is_match(alias.as_str()) }) || content .alt_aliases @@ -1044,7 +1044,7 @@ impl Service { /// Append the incoming event setting the state snapshot to the state from the /// server that sent the event. #[tracing::instrument(skip_all)] - pub async fn append_incoming_pdu<'a>( + pub async fn append_incoming_pdu( &self, pdu: &PduEvent, pdu_json: CanonicalJsonObject,