From 0bb5115bd192adb4cbf34c128c65e11511c32837 Mon Sep 17 00:00:00 2001 From: strawberry Date: Fri, 22 Mar 2024 21:55:05 -0400 Subject: [PATCH] resolve clippy match_bool Signed-off-by: strawberry --- Cargo.toml | 1 + src/api/client_server/account.rs | 3 ++- src/api/server_server.rs | 34 +++++++++++++++++--------------- src/service/admin/mod.rs | 9 +++++---- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 41ff2b40..f250a68f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -496,6 +496,7 @@ cast_possible_wrap = "warn" redundant_closure_for_method_calls = "warn" large_futures = "warn" semicolon_if_nothing_returned = "warn" +match_bool = "warn" # not in rust 1.75.0 (breaks CI) # infinite_loop = "warn" diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index 90d9a2b4..2fbf743e 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -16,7 +16,8 @@ use tracing::{error, info, warn}; use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH}; use crate::{ - api::client_server::{self, join_room_by_id_helper}, service, services, utils, Error, Result, Ruma + api::client_server::{self, join_room_by_id_helper}, + service, services, utils, Error, Result, Ruma, }; const RANDOM_USER_ID_LENGTH: usize = 10; diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 5002ea64..d7ff846e 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -305,26 +305,27 @@ where Err(e) => { // we do not need to log that servers in a room are dead, this is normal in // public rooms and just spams the logs. - match e.is_timeout() { - true => debug!( + if e.is_timeout() { + debug!( "Timed out sending request to {} at {}: {}", destination, actual_destination_str, e - ), - false => match e.is_connect() { - true => debug!("Failed to connect to {} at {}: {}", destination, actual_destination_str, e), - false => match e.is_redirect() { - true => debug!( + ) + } else { + if e.is_connect() { + debug!("Failed to connect to {} at {}: {}", destination, actual_destination_str, e) + } else { + if e.is_redirect() { + debug!( "Redirect loop sending request to {} at {}: {}\nFinal URL: {:?}", destination, actual_destination_str, e, e.url() - ), - false => { - info!("Could not send request to {} at {}: {}", destination, actual_destination_str, e); - }, - }, - }, + ) + } else { + info!("Could not send request to {} at {}: {}", destination, actual_destination_str, e); + } + } } Err(e.into()) }, @@ -1617,9 +1618,10 @@ pub async fn get_devices_route(body: Ruma) -> Result metadata.display_name, - false => Some(device_id_string), + let device_display_name = if services().globals.allow_device_name_federation() { + metadata.display_name + } else { + Some(device_id_string) }; Some(UserDevice { keys: services().users.get_device_keys(&body.user_id, &metadata.device_id).ok()??, diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 3a031ad4..291333df 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -1025,12 +1025,13 @@ impl Service { if !force { user_ids.retain(|&user_id| match services().users.is_admin(user_id) { - Ok(is_admin) => match is_admin { - true => { + Ok(is_admin) => { + if is_admin { admins.push(user_id.localpart()); false - }, - false => true, + } else { + true + } }, Err(_) => false, });