diff --git a/rustfmt.toml b/rustfmt.toml index 6ea1ba64..9538c3d6 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,5 @@ array_width = 80 +attr_fn_like_width = 60 chain_width = 50 comment_width = 80 condense_wildcard_suffixes = true diff --git a/src/core/alloc/mod.rs b/src/core/alloc/mod.rs index 0ed1b1a6..4af6ddb0 100644 --- a/src/core/alloc/mod.rs +++ b/src/core/alloc/mod.rs @@ -6,7 +6,11 @@ pub mod je; #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))] pub use je::{memory_stats, memory_usage, trim}; -#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", not(feature = "jemalloc")))] +#[cfg(all( + not(target_env = "msvc"), + feature = "hardened_malloc", + not(feature = "jemalloc") +))] pub mod hardened; #[cfg(all( not(target_env = "msvc"), diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 0a63105d..f80fb80f 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -606,7 +606,10 @@ pub struct Config { /// spiders. /// /// This is inherently false if `allow_federation` is disabled - #[serde(default = "true_fn", alias = "allow_profile_lookup_federation_requests")] + #[serde( + default = "true_fn", + alias = "allow_profile_lookup_federation_requests" + )] pub allow_inbound_profile_lookup_federation_requests: bool, /// Allow standard users to create rooms. Appservices and admins are always @@ -1827,7 +1830,10 @@ pub struct TlsConfig { #[allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)] #[derive(Clone, Debug, Deserialize, Default)] -#[config_example_generator(filename = "tuwunel-example.toml", section = "global.well_known")] +#[config_example_generator( + filename = "tuwunel-example.toml", + section = "global.well_known" +)] pub struct WellKnownConfig { /// The server URL that the client well-known file will serve. This should /// not contain a port, and should just be a valid HTTPS URL. @@ -1853,7 +1859,10 @@ pub struct WellKnownConfig { #[derive(Clone, Copy, Debug, Deserialize, Default)] #[allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)] -#[config_example_generator(filename = "tuwunel-example.toml", section = "global.blurhashing")] +#[config_example_generator( + filename = "tuwunel-example.toml", + section = "global.blurhashing" +)] pub struct BlurhashConfig { /// blurhashing x component, 4 is recommended by https://blurha.sh/ /// diff --git a/src/core/matrix/pdu/count.rs b/src/core/matrix/pdu/count.rs index b880278f..9397109a 100644 --- a/src/core/matrix/pdu/count.rs +++ b/src/core/matrix/pdu/count.rs @@ -1,4 +1,8 @@ -#![allow(clippy::cast_possible_wrap, clippy::cast_sign_loss, clippy::as_conversions)] +#![allow( + clippy::cast_possible_wrap, + clippy::cast_sign_loss, + clippy::as_conversions +)] use std::{cmp::Ordering, fmt, fmt::Display, str::FromStr}; diff --git a/src/core/matrix/state_res/power_levels.rs b/src/core/matrix/state_res/power_levels.rs index 19ba8fb9..4f8158f6 100644 --- a/src/core/matrix/state_res/power_levels.rs +++ b/src/core/matrix/state_res/power_levels.rs @@ -134,7 +134,10 @@ fn deserialize_legacy_power_levels(content: &str) -> Option, #[serde(default, deserialize_with = "deserialize_v1_powerlevel")] @@ -157,7 +160,10 @@ impl PowerLevelsContentFields { #[derive(Deserialize)] struct IntPowerLevelsContentFields { - #[serde(default, deserialize_with = "vec_deserialize_int_powerlevel_values")] + #[serde( + default, + deserialize_with = "vec_deserialize_int_powerlevel_values" + )] users: Vec<(OwnedUserId, Int)>, #[serde(default)] @@ -227,7 +233,10 @@ pub(crate) fn deserialize_power_levels_content_invite( #[derive(Deserialize)] pub(crate) struct PowerLevelsContentRedact { - #[serde(default = "default_power_level", deserialize_with = "deserialize_v1_powerlevel")] + #[serde( + default = "default_power_level", + deserialize_with = "deserialize_v1_powerlevel" + )] pub(crate) redact: Int, } diff --git a/src/core/utils/sys/storage.rs b/src/core/utils/sys/storage.rs index 3be757e3..4f55a5e9 100644 --- a/src/core/utils/sys/storage.rs +++ b/src/core/utils/sys/storage.rs @@ -123,7 +123,10 @@ pub fn name_from_path(path: &Path) -> Result { } /// Get the (major, minor) of the block device on which Path is mounted. -#[allow(clippy::useless_conversion, clippy::unnecessary_fallible_conversions)] +#[allow( + clippy::useless_conversion, + clippy::unnecessary_fallible_conversions +)] fn dev_from_path(path: &Path) -> Result<(dev_t, dev_t)> { #[cfg(target_family = "unix")] use std::os::unix::fs::MetadataExt; diff --git a/src/core/utils/time.rs b/src/core/utils/time.rs index 73f73971..9ba67207 100644 --- a/src/core/utils/time.rs +++ b/src/core/utils/time.rs @@ -57,7 +57,11 @@ pub fn format(ts: SystemTime, str: &str) -> String { } #[must_use] -#[allow(clippy::as_conversions, clippy::cast_possible_truncation, clippy::cast_sign_loss)] +#[allow( + clippy::as_conversions, + clippy::cast_possible_truncation, + clippy::cast_sign_loss +)] pub fn pretty(d: Duration) -> String { use Unit::*; diff --git a/src/database/de.rs b/src/database/de.rs index f6f2ab0f..1d4f7b53 100644 --- a/src/database/de.rs +++ b/src/database/de.rs @@ -183,7 +183,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { visitor.visit_seq(self) } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, visitor)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, visitor)) + )] fn deserialize_tuple(self, _len: usize, visitor: V) -> Result where V: Visitor<'de>, @@ -192,7 +195,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { visitor.visit_seq(self) } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, visitor)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, visitor)) + )] fn deserialize_tuple_struct( self, _name: &'static str, @@ -216,7 +222,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { d.deserialize_map(visitor).map_err(Into::into) } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, visitor)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, visitor)) + )] fn deserialize_struct( self, name: &'static str, @@ -232,7 +241,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { .map_err(Into::into) } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, visitor)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, visitor)) + )] fn deserialize_unit_struct(self, name: &'static str, visitor: V) -> Result where V: Visitor<'de>, @@ -246,7 +258,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { visitor.visit_unit() } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, visitor)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, visitor)) + )] fn deserialize_newtype_struct(self, name: &'static str, visitor: V) -> Result where V: Visitor<'de>, @@ -261,7 +276,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { } } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, _visitor)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, _visitor)) + )] fn deserialize_enum( self, _name: &'static str, @@ -436,7 +454,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { impl<'a, 'de: 'a> de::SeqAccess<'de> for &'a mut Deserializer<'de> { type Error = Error; - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, seed)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, seed)) + )] fn next_element_seed(&mut self, seed: T) -> Result> where T: DeserializeSeed<'de>, @@ -455,7 +476,10 @@ impl<'a, 'de: 'a> de::SeqAccess<'de> for &'a mut Deserializer<'de> { impl<'a, 'de: 'a> de::MapAccess<'de> for &'a mut Deserializer<'de> { type Error = Error; - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, seed)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, seed)) + )] fn next_key_seed(&mut self, seed: K) -> Result> where K: DeserializeSeed<'de>, @@ -463,7 +487,10 @@ impl<'a, 'de: 'a> de::MapAccess<'de> for &'a mut Deserializer<'de> { seed.deserialize(&mut **self).map(Some) } - #[cfg_attr(unabridged, tracing::instrument(level = "trace", skip(self, seed)))] + #[cfg_attr( + unabridged, + tracing::instrument(level = "trace", skip(self, seed)) + )] fn next_value_seed(&mut self, seed: V) -> Result where V: DeserializeSeed<'de>, diff --git a/src/database/engine.rs b/src/database/engine.rs index a01525bd..306b6d80 100644 --- a/src/database/engine.rs +++ b/src/database/engine.rs @@ -124,7 +124,12 @@ impl Engine { #[inline] #[must_use] - #[tracing::instrument(name = "sequence", level = "debug", skip_all, fields(sequence))] + #[tracing::instrument( + name = "sequence", + level = "debug", + skip_all, + fields(sequence) + )] pub fn current_sequence(&self) -> u64 { let sequence = self.db.latest_sequence_number(); diff --git a/src/database/engine/cf_opts.rs b/src/database/engine/cf_opts.rs index e1947a7b..e625dc18 100644 --- a/src/database/engine/cf_opts.rs +++ b/src/database/engine/cf_opts.rs @@ -268,7 +268,11 @@ pub(crate) fn cache_size(config: &Config, base_size: u32, entity_size: usize) -> cache_size_f64(config, f64::from(base_size), entity_size) } -#[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)] +#[allow( + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_truncation +)] pub(crate) fn cache_size_f64(config: &Config, base_size: f64, entity_size: usize) -> usize { let ents = base_size * config.cache_capacity_modifier; diff --git a/src/database/tests.rs b/src/database/tests.rs index 6fe53060..c59ec9b9 100644 --- a/src/database/tests.rs +++ b/src/database/tests.rs @@ -14,7 +14,10 @@ use crate::{ }; #[test] -#[cfg_attr(debug_assertions, should_panic(expected = "serializing string at the top-level"))] +#[cfg_attr( + debug_assertions, + should_panic(expected = "serializing string at the top-level") +)] fn ser_str() { let user_id: &UserId = "@user:example.com".try_into().unwrap(); let s = serialize_to_vec(&user_id).expect("failed to serialize user_id"); @@ -162,7 +165,10 @@ fn ser_json_macro() { } #[test] -#[cfg_attr(debug_assertions, should_panic(expected = "serializing string at the top-level"))] +#[cfg_attr( + debug_assertions, + should_panic(expected = "serializing string at the top-level") +)] fn ser_json_raw() { use tuwunel_core::ruma::api::client::filter::FilterDefinition; @@ -179,7 +185,10 @@ fn ser_json_raw() { } #[test] -#[cfg_attr(debug_assertions, should_panic(expected = "you can skip serialization instead"))] +#[cfg_attr( + debug_assertions, + should_panic(expected = "you can skip serialization instead") +)] fn ser_json_raw_json() { use tuwunel_core::ruma::api::client::filter::FilterDefinition; diff --git a/src/main/clap.rs b/src/main/clap.rs index bd012f56..01602e24 100644 --- a/src/main/clap.rs +++ b/src/main/clap.rs @@ -58,15 +58,30 @@ pub(crate) struct Args { pub(crate) worker_threads: usize, /// Override the tokio global_queue_interval. - #[arg(long, hide(true), env = "TOKIO_GLOBAL_QUEUE_INTERVAL", default_value = "192")] + #[arg( + long, + hide(true), + env = "TOKIO_GLOBAL_QUEUE_INTERVAL", + default_value = "192" + )] pub(crate) global_event_interval: u32, /// Override the tokio event_interval. - #[arg(long, hide(true), env = "TOKIO_EVENT_INTERVAL", default_value = "512")] + #[arg( + long, + hide(true), + env = "TOKIO_EVENT_INTERVAL", + default_value = "512" + )] pub(crate) kernel_event_interval: u32, /// Override the tokio max_io_events_per_tick. - #[arg(long, hide(true), env = "TOKIO_MAX_IO_EVENTS_PER_TICK", default_value = "512")] + #[arg( + long, + hide(true), + env = "TOKIO_MAX_IO_EVENTS_PER_TICK", + default_value = "512" + )] pub(crate) kernel_events_per_tick: usize, /// Set the histogram bucket size, in microseconds (tokio_unstable). Default @@ -74,11 +89,21 @@ pub(crate) struct Args { /// with the exception of the last bucket, try increasing this value to e.g. /// 50 or 100. Inversely, decrease to 10 etc if the histogram lacks /// resolution. - #[arg(long, hide(true), env = "TUWUNEL_RUNTIME_HISTOGRAM_INTERVAL", default_value = "25")] + #[arg( + long, + hide(true), + env = "TUWUNEL_RUNTIME_HISTOGRAM_INTERVAL", + default_value = "25" + )] pub(crate) worker_histogram_interval: u64, /// Set the histogram bucket count (tokio_unstable). Default is 20. - #[arg(long, hide(true), env = "TUWUNEL_RUNTIME_HISTOGRAM_BUCKETS", default_value = "20")] + #[arg( + long, + hide(true), + env = "TUWUNEL_RUNTIME_HISTOGRAM_BUCKETS", + default_value = "20" + )] pub(crate) worker_histogram_buckets: usize, /// Toggles worker affinity feature. diff --git a/src/main/logging.rs b/src/main/logging.rs index 13453566..2334ad2b 100644 --- a/src/main/logging.rs +++ b/src/main/logging.rs @@ -92,7 +92,10 @@ pub(crate) fn init( }; #[cfg(not(feature = "perf_measurements"))] - #[cfg_attr(not(feature = "perf_measurements"), allow(clippy::let_unit_value))] + #[cfg_attr( + not(feature = "perf_measurements"), + allow(clippy::let_unit_value) + )] let flame_guard = (); let ret = (reload_handles, flame_guard, cap_state); diff --git a/src/service/client/mod.rs b/src/service/client/mod.rs index 4a129078..65905776 100644 --- a/src/service/client/mod.rs +++ b/src/service/client/mod.rs @@ -179,7 +179,11 @@ fn base(config: &Config) -> Result { } } -#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] +#[cfg(any( + target_os = "android", + target_os = "fuchsia", + target_os = "linux" +))] fn builder_interface( builder: reqwest::ClientBuilder, config: Option<&str>, @@ -191,7 +195,11 @@ fn builder_interface( } } -#[cfg(not(any(target_os = "android", target_os = "fuchsia", target_os = "linux")))] +#[cfg(not(any( + target_os = "android", + target_os = "fuchsia", + target_os = "linux" +)))] fn builder_interface( builder: reqwest::ClientBuilder, config: Option<&str>, diff --git a/src/service/media/preview.rs b/src/service/media/preview.rs index e97a9d35..f5921ec1 100644 --- a/src/service/media/preview.rs +++ b/src/service/media/preview.rs @@ -16,17 +16,35 @@ use super::Service; #[derive(Serialize, Default)] pub struct UrlPreviewData { - #[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:title"))] + #[serde( + skip_serializing_if = "Option::is_none", + rename(serialize = "og:title") + )] pub title: Option, - #[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:description"))] + #[serde( + skip_serializing_if = "Option::is_none", + rename(serialize = "og:description") + )] pub description: Option, - #[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image"))] + #[serde( + skip_serializing_if = "Option::is_none", + rename(serialize = "og:image") + )] pub image: Option, - #[serde(skip_serializing_if = "Option::is_none", rename(serialize = "matrix:image:size"))] + #[serde( + skip_serializing_if = "Option::is_none", + rename(serialize = "matrix:image:size") + )] pub image_size: Option, - #[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:width"))] + #[serde( + skip_serializing_if = "Option::is_none", + rename(serialize = "og:image:width") + )] pub image_width: Option, - #[serde(skip_serializing_if = "Option::is_none", rename(serialize = "og:image:height"))] + #[serde( + skip_serializing_if = "Option::is_none", + rename(serialize = "og:image:height") + )] pub image_height: Option, } diff --git a/src/service/resolver/dns.rs b/src/service/resolver/dns.rs index edd6417d..7ad997cc 100644 --- a/src/service/resolver/dns.rs +++ b/src/service/resolver/dns.rs @@ -22,7 +22,11 @@ pub(crate) struct Hooked { type ResolvingResult = Result>; impl Resolver { - #[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)] + #[allow( + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_truncation + )] pub(super) fn build(server: &Arc, cache: Arc) -> Result> { let config = &server.config; let (sys_conf, mut opts) = hickory_resolver::system_conf::read_system_conf() diff --git a/src/service/resolver/mod.rs b/src/service/resolver/mod.rs index bbf63f24..ec1a60dd 100644 --- a/src/service/resolver/mod.rs +++ b/src/service/resolver/mod.rs @@ -31,7 +31,11 @@ type NameBuf = ArrayString<256>; #[async_trait] impl crate::Service for Service { - #[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)] + #[allow( + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_truncation + )] fn build(args: crate::Args<'_>) -> Result> { let cache = Cache::new(&args); Ok(Arc::new(Self { diff --git a/src/service/sending/sender.rs b/src/service/sending/sender.rs index f3613a82..99dd3861 100644 --- a/src/service/sending/sender.rs +++ b/src/service/sending/sender.rs @@ -519,7 +519,11 @@ impl Service { } /// Look for read receipts in this room - #[tracing::instrument(name = "receipts", level = "trace", skip(self, since, max_edu_count))] + #[tracing::instrument( + name = "receipts", + level = "trace", + skip(self, since, max_edu_count) + )] async fn select_edus_receipts_room( &self, room_id: &RoomId, diff --git a/src/service/users/mod.rs b/src/service/users/mod.rs index 82ed9990..d7fd2f0f 100644 --- a/src/service/users/mod.rs +++ b/src/service/users/mod.rs @@ -184,7 +184,10 @@ impl Service { /// Returns an iterator over all users on this homeserver (offered for /// compatibility) - #[allow(clippy::iter_without_into_iter, clippy::iter_not_returning_iterator)] + #[allow( + clippy::iter_without_into_iter, + clippy::iter_not_returning_iterator + )] pub fn iter(&self) -> impl Stream + Send + '_ { self.stream().map(ToOwned::to_owned) }