diff --git a/Cargo.toml b/Cargo.toml index 73f16daf..2f9f196b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -772,6 +772,7 @@ unused-qualifications = "warn" #unused-results = "warn" # TODO ## some sadness +elided_named_lifetimes = "allow" # TODO! let_underscore_drop = "allow" missing_docs = "allow" # cfgs cannot be limited to expected cfgs or their de facto non-transitive/opt-in use-case e.g. diff --git a/src/api/client/config.rs b/src/api/client/config.rs index d06cc072..3cf71135 100644 --- a/src/api/client/config.rs +++ b/src/api/client/config.rs @@ -23,7 +23,7 @@ pub(crate) async fn set_global_account_data_route( set_account_data( &services, None, - &body.sender_user, + body.sender_user.as_ref(), &body.event_type.to_string(), body.data.json(), ) @@ -41,7 +41,7 @@ pub(crate) async fn set_room_account_data_route( set_account_data( &services, Some(&body.room_id), - &body.sender_user, + body.sender_user.as_ref(), &body.event_type.to_string(), body.data.json(), ) @@ -89,7 +89,7 @@ pub(crate) async fn get_room_account_data_route( } async fn set_account_data( - services: &Services, room_id: Option<&RoomId>, sender_user: &Option, event_type: &str, + services: &Services, room_id: Option<&RoomId>, sender_user: Option<&OwnedUserId>, event_type: &str, data: &RawJsonValue, ) -> Result<()> { let sender_user = sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client/report.rs b/src/api/client/report.rs index cf789246..143c13e5 100644 --- a/src/api/client/report.rs +++ b/src/api/client/report.rs @@ -101,7 +101,7 @@ pub(crate) async fn report_event_route( &pdu.event_id, &body.room_id, sender_user, - &body.reason, + body.reason.as_ref(), body.score, &pdu, ) @@ -134,7 +134,7 @@ pub(crate) async fn report_event_route( /// check if report reasoning is less than or equal to 750 characters /// check if reporting user is in the reporting room async fn is_event_report_valid( - services: &Services, event_id: &EventId, room_id: &RoomId, sender_user: &UserId, reason: &Option, + services: &Services, event_id: &EventId, room_id: &RoomId, sender_user: &UserId, reason: Option<&String>, score: Option, pdu: &std::sync::Arc, ) -> Result<()> { debug_info!("Checking if report from user {sender_user} for event {event_id} in room {room_id} is valid"); diff --git a/src/api/client/room.rs b/src/api/client/room.rs index daadb724..4224d3fa 100644 --- a/src/api/client/room.rs +++ b/src/api/client/room.rs @@ -126,8 +126,8 @@ pub(crate) async fn create_room_route( .await; let state_lock = services.rooms.state.mutex.lock(&room_id).await; - let alias: Option = if let Some(alias) = &body.room_alias_name { - Some(room_alias_check(&services, alias, &body.appservice_info).await?) + let alias: Option = if let Some(alias) = body.room_alias_name.as_ref() { + Some(room_alias_check(&services, alias, body.appservice_info.as_ref()).await?) } else { None }; @@ -270,7 +270,7 @@ pub(crate) async fn create_room_route( } let power_levels_content = - default_power_levels_content(&body.power_level_content_override, &body.visibility, users)?; + default_power_levels_content(body.power_level_content_override.as_ref(), &body.visibility, users)?; services .rooms @@ -814,7 +814,7 @@ pub(crate) async fn upgrade_room_route( /// creates the power_levels_content for the PDU builder fn default_power_levels_content( - power_level_content_override: &Option>, visibility: &room::Visibility, + power_level_content_override: Option<&Raw>, visibility: &room::Visibility, users: BTreeMap, ) -> Result { let mut power_levels_content = serde_json::to_value(RoomPowerLevelsEventContent { @@ -864,7 +864,7 @@ fn default_power_levels_content( /// if a room is being created with a room alias, run our checks async fn room_alias_check( - services: &Services, room_alias_name: &str, appservice_info: &Option, + services: &Services, room_alias_name: &str, appservice_info: Option<&RegistrationInfo>, ) -> Result { // Basic checks on the room alias validity if room_alias_name.contains(':') { @@ -905,7 +905,7 @@ async fn room_alias_check( return Err(Error::BadRequest(ErrorKind::RoomInUse, "Room alias already exists.")); } - if let Some(ref info) = appservice_info { + if let Some(info) = appservice_info { if !info.aliases.is_match(full_room_alias.as_str()) { return Err(Error::BadRequest(ErrorKind::Exclusive, "Room alias is not in namespace.")); } diff --git a/src/api/client/sync/v4.rs b/src/api/client/sync/v4.rs index 4f8323e6..f8ada81c 100644 --- a/src/api/client/sync/v4.rs +++ b/src/api/client/sync/v4.rs @@ -560,7 +560,7 @@ pub(crate) async fn sync_events_v4_route( for (_, pdu) in timeline_pdus { let ts = MilliSecondsSinceUnixEpoch(pdu.origin_server_ts); - if DEFAULT_BUMP_TYPES.contains(pdu.event_type()) && !timestamp.is_some_and(|time| time > ts) { + if DEFAULT_BUMP_TYPES.contains(pdu.event_type()) && timestamp.is_none_or(|time| time <= ts) { timestamp = Some(ts); } } diff --git a/src/core/utils/future/try_ext_ext.rs b/src/core/utils/future/try_ext_ext.rs index 7c0b36a2..f97ae885 100644 --- a/src/core/utils/future/try_ext_ext.rs +++ b/src/core/utils/future/try_ext_ext.rs @@ -1,4 +1,5 @@ //! Extended external extensions to futures::TryFutureExt +#![allow(clippy::type_complexity)] use futures::{ future::{MapOkOrElse, UnwrapOrElse}, diff --git a/src/core/utils/stream/ready.rs b/src/core/utils/stream/ready.rs index da5aec5a..c16d1246 100644 --- a/src/core/utils/stream/ready.rs +++ b/src/core/utils/stream/ready.rs @@ -1,4 +1,5 @@ //! Synchronous combinator extensions to futures::Stream +#![allow(clippy::type_complexity)] use futures::{ future::{ready, Ready}, diff --git a/src/core/utils/stream/try_ready.rs b/src/core/utils/stream/try_ready.rs index df356456..feb38067 100644 --- a/src/core/utils/stream/try_ready.rs +++ b/src/core/utils/stream/try_ready.rs @@ -1,4 +1,5 @@ //! Synchronous combinator extensions to futures::TryStream +#![allow(clippy::type_complexity)] use futures::{ future::{ready, Ready}, diff --git a/src/macros/config.rs b/src/macros/config.rs index f8616352..6ccdb73c 100644 --- a/src/macros/config.rs +++ b/src/macros/config.rs @@ -164,11 +164,11 @@ fn get_default(field: &Field) -> Option { continue; }; - if !path + if path .segments .iter() .next() - .is_some_and(|s| s.ident == "serde") + .is_none_or(|s| s.ident == "serde") { continue; } @@ -218,12 +218,7 @@ fn get_doc_default(field: &Field) -> Option { continue; }; - if !path - .segments - .iter() - .next() - .is_some_and(|s| s.ident == "doc") - { + if path.segments.iter().next().is_none_or(|s| s.ident == "doc") { continue; } @@ -266,12 +261,7 @@ fn get_doc_comment(field: &Field) -> Option { continue; }; - if !path - .segments - .iter() - .next() - .is_some_and(|s| s.ident == "doc") - { + if path.segments.iter().next().is_none_or(|s| s.ident == "doc") { continue; } diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 58cc012c..2860bd1b 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -370,9 +370,9 @@ impl Service { /// Sets the self-reference to crate::Services which will provide context to /// the admin commands. - pub(super) fn set_services(&self, services: &Option>) { + pub(super) fn set_services(&self, services: Option<&Arc>) { let receiver = &mut *self.services.services.write().expect("locked for writing"); - let weak = services.as_ref().map(Arc::downgrade); + let weak = services.map(Arc::downgrade); *receiver = weak; } } diff --git a/src/service/services.rs b/src/service/services.rs index ea81f434..c0af4249 100644 --- a/src/service/services.rs +++ b/src/service/services.rs @@ -113,7 +113,7 @@ impl Services { pub async fn start(self: &Arc) -> Result> { debug_info!("Starting services..."); - self.admin.set_services(&Some(Arc::clone(self))); + self.admin.set_services(Some(Arc::clone(self)).as_ref()); globals::migrations::migrations(self).await?; self.manager .lock() @@ -151,7 +151,7 @@ impl Services { manager.stop().await; } - self.admin.set_services(&None); + self.admin.set_services(None); debug_info!("Services shutdown complete."); }