From 9c27441acf2e65f85c106ccff5c6b6c37030ddca Mon Sep 17 00:00:00 2001 From: timedout Date: Fri, 23 Oct 2026 23:37:51 +0200 Subject: [PATCH] style: Reformat with nightly --- src/core/config/mod.rs | 4 +- src/core/matrix/state_res/mod.rs | 4 +- src/service/client/mod.rs | 4 +- src/service/migrations.rs | 50 ++++++++++--------- .../fetch_and_handle_outliers.rs | 4 +- src/service/rooms/summary/mod.rs | 8 +-- src/service/rooms/timeline/create.rs | 3 +- src/service/threepid/mod.rs | 5 +- src/web/mod.rs | 3 +- src/web/pages/components/form.rs | 11 ++-- src/web/pages/mod.rs | 7 +-- 11 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 36baee18d..d5318c9a8 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -65,8 +65,8 @@ use crate::{Result, err, error::Error, utils::sys}; ignore = "config_paths catchall" )] pub struct Config { - // Paths to config file(s). Not supposed to be set manually in the config file, - // only updated dynamically from the --config option given at runtime. + // Paths to config file(s). Not supposed to be set manually in the config + // file, only updated dynamically from the --config option given at runtime. pub config_paths: Option>, /// The server_name is the pretty name of this server. It is used as a diff --git a/src/core/matrix/state_res/mod.rs b/src/core/matrix/state_res/mod.rs index 2a6b2fde1..a48860ac3 100644 --- a/src/core/matrix/state_res/mod.rs +++ b/src/core/matrix/state_res/mod.rs @@ -590,8 +590,8 @@ where .find(|aev| is_type_and_key(*aev, &TimelineEventType::RoomPowerLevels, "")); let content: PowerLevelsContentFields = match pl { - // With no m.room.power_levels in scope the create event's defaults apply, - // under which the room creator holds 100 and everyone else 0. + // With no m.room.power_levels in scope the create event's defaults + // apply, under which the room creator holds 100 and everyone else 0. | None => return Ok(if sender_is_creator { int!(100) } else { int!(0) }), | Some(ev) => from_json_str(ev.content().get())?, }; diff --git a/src/service/client/mod.rs b/src/service/client/mod.rs index fc139a144..234b50956 100644 --- a/src/service/client/mod.rs +++ b/src/service/client/mod.rs @@ -146,8 +146,8 @@ impl crate::Service for Service { .redirect(redirect::Policy::limited(2)) .build()?, - // MSC4174 recommends against following redirects, since the destination - // is only checked before the request is sent. + // MSC4174 recommends against following redirects, since the + // destination is only checked before the request is sent. webpush: base(config)? .connect_timeout(Duration::from_secs(config.pusher_conn_timeout)) .timeout(Duration::from_secs(config.pusher_timeout)) diff --git a/src/service/migrations.rs b/src/service/migrations.rs index 894dd5aa3..3ed2d28a4 100644 --- a/src/service/migrations.rs +++ b/src/service/migrations.rs @@ -109,35 +109,37 @@ migration!(stringify!($name) => $name) migration!(fix_readreceiptid_readreceipt_duplicates), // End pre-fork logic. - // v18: `fix_corrupt_msc4133_fields` will change the `us.cloke.msc4175.tz` field - // in a way that old versions don't understand. + // v18: `fix_corrupt_msc4133_fields` will change the + // `us.cloke.msc4175.tz` field in a way that old versions don't + // understand. VersionBump(18), migration!(fix_corrupt_msc4133_fields), - // v19: `populate_userroomid_leftstate_table` will put data in the values of - // `userroomid_leftstate` that old versions will fail to deserialize because - // they expect the values to be empty. + // v19: `populate_userroomid_leftstate_table` will put data in the + // values of `userroomid_leftstate` that old versions will fail to + // deserialize because they expect the values to be empty. VersionBump(19), migration!(populate_userroomid_leftstate_table), - // This is backwards compatible because it fixes some data that clients care about but we - // don't. + // This is backwards compatible because it fixes some data that clients + // care about but we don't. migration!(fix_local_invite_state), - // v20: Old versions expect remote users to be tracked in `userid_password`. This - // migration moves them to a different keyspace. + // v20: Old versions expect remote users to be tracked in + // `userid_password`. This migration moves them to a different keyspace. VersionBump(20), migration!(split_userid_password), - // This is backwards compatible because old versions will recreate the keyspace if it's - // missing. + // This is backwards compatible because old versions will recreate the + // keyspace if it's missing. migration!("drop_roomsynctoken_shortstatehash" => obliterate_roomsynctoken_shortstatehash_with_extreme_prejudice), - // v21: `unembed_unsigned_info` will remove `unsigned` data from PDUs that old versions - // expect to be embedded. + // v21: `unembed_unsigned_info` will remove `unsigned` data from PDUs + // that old versions expect to be embedded. VersionBump(21), - // This migration can take several hours on old databases, so we run it in the background - // to keep the service manager from killing us for taking too long to start. - // Future maintainers: !!! BE VERY CAREFUL !!! if you need to write more migrations like - // this! This one is fine because it deletes data that we don't check anymore, - // but migrations which replace existing data that we do check should NOT run in - // the background. If they do, the server will finish starting up and might - // access data that the migration hasn't gotten to yet. + // This migration can take several hours on old databases, so we run it + // in the background to keep the service manager from killing us for + // taking too long to start. Future maintainers: !!! BE VERY CAREFUL !!! + // if you need to write more migrations like this! This one is fine + // because it deletes data that we don't check anymore, but migrations + // which replace existing data that we do check should NOT run in + // the background. If they do, the server will finish starting up and + // might access data that the migration hasn't gotten to yet. Migration("unembed_unsigned_info", |services| { Box::pin(async { if services.db["global"] @@ -158,11 +160,11 @@ migration!(stringify!($name) => $name) Ok(()) }) }), - // This is backwards compatible because old versions will recreate the keyspace if it's - // missing. + // This is backwards compatible because old versions will recreate the + // keyspace if it's missing. migration!(drop_server_signingkeys), - // v22: Old versions will fail to deserialize the fixed OAuth scope names, - // preventing users from signing in. + // v22: Old versions will fail to deserialize the fixed OAuth scope + // names, preventing users from signing in. VersionBump(22), migration!(fix_oauth_scope_names), ] diff --git a/src/service/rooms/event_handler/fetch_and_handle_outliers.rs b/src/service/rooms/event_handler/fetch_and_handle_outliers.rs index 3fbe57c30..38a25b914 100644 --- a/src/service/rooms/event_handler/fetch_and_handle_outliers.rs +++ b/src/service/rooms/event_handler/fetch_and_handle_outliers.rs @@ -203,8 +203,8 @@ impl super::Service { "GET_MISSING_EVENTS_MAX_BATCH_SIZE (usize) should fit in u16 (<=65536)", )) .max( - // This max call ensures we fetch *at least* all the prev events the - // head has. + // This max call ensures we fetch *at least* all the prev + // events the head has. u16::try_from(head.prev_events.len()) .expect("cannot have more than 20 prev events, which fits in u16"), ); diff --git a/src/service/rooms/summary/mod.rs b/src/service/rooms/summary/mod.rs index 96f633e93..4c2e21e86 100644 --- a/src/service/rooms/summary/mod.rs +++ b/src/service/rooms/summary/mod.rs @@ -756,11 +756,13 @@ impl Service { let join_rule = self.services.state_accessor.get_join_rules(room_id).await; match (join_rule, querying_user) { - // Anyone can view summaries for `public`, `knock`, and `knock_restricted` rooms. + // Anyone can view summaries for `public`, `knock`, and + // `knock_restricted` rooms. | (JoinRule::Public | JoinRule::Knock | JoinRule::KnockRestricted(_), _) => true, - // The user may be able to view the summary for a `restricted` room, even if they - // aren't invited, provided they fulfill the join rules. + // The user may be able to view the summary for a `restricted` room, + // even if they aren't invited, provided they fulfill the join + // rules. | (JoinRule::Restricted(conditions), Some(querying_user)) => self.services .membership diff --git a/src/service/rooms/timeline/create.rs b/src/service/rooms/timeline/create.rs index 2f33db721..1e7284492 100644 --- a/src/service/rooms/timeline/create.rs +++ b/src/service/rooms/timeline/create.rs @@ -193,7 +193,8 @@ impl super::Service { let redacts = match redacts { // If this isn't a real redaction event, there's no redacts field. | _ if event_type != TimelineEventType::RoomRedaction || state_key.is_some() => None, - // If the redaction is itself in the event content, we don't set the top-level field. + // If the redaction is itself in the event content, we don't set the + // top-level field. | Some(_) if room_version_rules.redaction.content_field_redacts => None, // Otherwise, we do if it's present | other => other, diff --git a/src/service/threepid/mod.rs b/src/service/threepid/mod.rs index db0d08d9f..7e4ffa968 100644 --- a/src/service/threepid/mod.rs +++ b/src/service/threepid/mod.rs @@ -124,8 +124,9 @@ impl Service { let mut sessions = self.sessions.lock().await; let session = match sessions.get_session_by_client_secret(client_secret) { - // If a validation session already exists for this client secret, we can either - // reuse it with a new token or return early because it's already valid. + // If a validation session already exists for this client secret, we + // can either reuse it with a new token or return early because it's + // already valid. | Some(session) => { if session.email != recipient.email { return Err!(Request(InvalidParam("Wrong email for session."))); diff --git a/src/web/mod.rs b/src/web/mod.rs index ac881c26b..43dab6746 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -94,7 +94,8 @@ impl IntoResponse for WebError { error: self, status, context: TemplateContext { - // Statically set false to prevent error pages from being indexed. + // Statically set false to prevent error pages from being + // indexed. allow_indexing: false, csp_nonce: String::new(), }, diff --git a/src/web/pages/components/form.rs b/src/web/pages/components/form.rs index 55b07bda3..4880efd6c 100644 --- a/src/web/pages/components/form.rs +++ b/src/web/pages/components/form.rs @@ -48,11 +48,12 @@ pub(crate) struct FormInput<'a> { pub autocomplete: &'a str, // This is a hack to make the form! macro's support for client-only fields - // work properly. Client-only fields are specified in the macro without a type and aren't - // included in the POST body or as a field in the generated struct. - // To keep the field from being included in the POST body, its `name` property needs not to - // be set in the template. Because of limitations of macro_rules!'s repetition feature, this - // field needs to exist to allow the template to check if the field is client-only. + // work properly. Client-only fields are specified in the macro without a + // type and aren't included in the POST body or as a field in the generated + // struct. To keep the field from being included in the POST body, its + // `name` property needs not to be set in the template. Because of + // limitations of macro_rules!'s repetition feature, this field needs to + // exist to allow the template to check if the field is client-only. #[doc(hidden)] pub type_name: Option<&'static str>, } diff --git a/src/web/pages/mod.rs b/src/web/pages/mod.rs index a9c169810..28a442785 100644 --- a/src/web/pages/mod.rs +++ b/src/web/pages/mod.rs @@ -61,9 +61,10 @@ pub(super) async fn template_context_middleware( response.headers_mut().insert( header::CONTENT_SECURITY_POLICY, HeaderValue::from_str(&format!( - // TODO: `unsafe-inline` for `style-src` defeats the purpose of having it, but - // it's necessary to set CSS variables using the `style` attribute without - // JavaScript. Come back to this once there's a less shitty solution. + // TODO: `unsafe-inline` for `style-src` defeats the purpose of + // having it, but it's necessary to set CSS variables using the + // `style` attribute without JavaScript. Come back to this once + // there's a less shitty solution. "default-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' https: data:; \ script-src 'nonce-{csp_nonce}'; child-src {child_src};" ))