From 4027cbd01ddf11541c84e4029fbb1587d951e784 Mon Sep 17 00:00:00 2001 From: Rudi Floren Date: Thu, 4 Mar 2021 15:27:25 +0100 Subject: [PATCH] Fix various clippy errors --- src/database/sending.rs | 8 +++----- src/ruma_wrapper.rs | 5 +++-- src/server_server.rs | 10 +++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/database/sending.rs b/src/database/sending.rs index 48fe68a..1ae063f 100644 --- a/src/database/sending.rs +++ b/src/database/sending.rs @@ -74,7 +74,7 @@ impl Sending { for ((server, is_appservice), pdus) in current_transactions { // Create new reservation let mut prefix = if is_appservice { - "+".as_bytes().to_vec() + b"+".to_vec() } else { Vec::new() }; @@ -217,11 +217,9 @@ impl Sending { prefix.extend_from_slice(server.as_bytes()); prefix.push(0xff); - if servercurrentpdus + servercurrentpdus .compare_and_swap(prefix, Option::<&[u8]>::None, Some(&[])) // Try to reserve - == Ok(Ok(())) { true } else { - false - } + == Ok(Ok(())) }) { servercurrentpdus.insert(&key, &[]).unwrap(); diff --git a/src/ruma_wrapper.rs b/src/ruma_wrapper.rs index 898561f..188d1b6 100644 --- a/src/ruma_wrapper.rs +++ b/src/ruma_wrapper.rs @@ -1,17 +1,17 @@ use crate::Error; use ruma::{ - api::{AuthScheme, OutgoingRequest}, identifiers::{DeviceId, UserId}, Outgoing, }; use std::{ - convert::{TryFrom, TryInto}, + convert::{TryInto}, ops::Deref, }; #[cfg(feature = "conduit_bin")] use { crate::utils, + ruma::api::{AuthScheme, OutgoingRequest}, log::{debug, warn}, rocket::{ data::{ @@ -25,6 +25,7 @@ use { Request, State, }, std::io::Cursor, + std::convert::TryFrom, }; /// This struct converts rocket requests into ruma structs by converting them into http requests diff --git a/src/server_server.rs b/src/server_server.rs index 00f31ca..a3fac18 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -3,7 +3,7 @@ use get_profile_information::v1::ProfileField; use http::header::{HeaderValue, AUTHORIZATION, HOST}; use log::{info, warn}; use regex::Regex; -use rocket::{get, post, put, response::content::Json, State}; +use rocket::{response::content::Json, State}; use ruma::{ api::{ federation::{ @@ -29,6 +29,10 @@ use std::{ net::{IpAddr, SocketAddr}, time::{Duration, SystemTime}, }; +#[cfg(feature = "conduit_bin")] +use { + rocket::{get, post, put} +}; #[tracing::instrument(skip(globals))] pub async fn send_request( @@ -591,7 +595,7 @@ pub async fn send_transaction_message_route<'a>( .get("users") .and_then(|users| users.as_sequence()) .map_or_else( - || Vec::new(), + Vec::new, |users| { users .iter() @@ -623,7 +627,7 @@ pub async fn send_transaction_message_route<'a>( .and_then(|string| { UserId::parse_with_server_name(string, db.globals.server_name()).ok() }); - + #[allow(clippy::blocks_in_if_conditions)] if bridge_user_id.map_or(false, |bridge_user_id| { db.rooms .is_joined(&bridge_user_id, room_id)