Merge branch 'clippy_again' into 'master'

Fix more clippy errors in master

See merge request famedly/conduit!34
This commit is contained in:
Timo Kösters 2021-03-04 14:30:28 +00:00
commit 79c910efdf
5 changed files with 15 additions and 10 deletions

View File

@ -74,7 +74,7 @@ impl Sending {
for ((server, is_appservice), pdus) in current_transactions { for ((server, is_appservice), pdus) in current_transactions {
// Create new reservation // Create new reservation
let mut prefix = if is_appservice { let mut prefix = if is_appservice {
"+".as_bytes().to_vec() b"+".to_vec()
} else { } else {
Vec::new() Vec::new()
}; };
@ -217,11 +217,9 @@ impl Sending {
prefix.extend_from_slice(server.as_bytes()); prefix.extend_from_slice(server.as_bytes());
prefix.push(0xff); prefix.push(0xff);
if servercurrentpdus servercurrentpdus
.compare_and_swap(prefix, Option::<&[u8]>::None, Some(&[])) // Try to reserve .compare_and_swap(prefix, Option::<&[u8]>::None, Some(&[])) // Try to reserve
== Ok(Ok(())) { true } else { == Ok(Ok(()))
false
}
}) })
{ {
servercurrentpdus.insert(&key, &[]).unwrap(); servercurrentpdus.insert(&key, &[]).unwrap();

View File

@ -1,3 +1,4 @@
#![allow(clippy::suspicious_else_formatting)]
pub mod appservice_server; pub mod appservice_server;
pub mod client_server; pub mod client_server;
mod database; mod database;

View File

@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)] #![warn(rust_2018_idioms)]
#![allow(clippy::suspicious_else_formatting)]
pub mod appservice_server; pub mod appservice_server;
pub mod client_server; pub mod client_server;

View File

@ -1,17 +1,17 @@
use crate::Error; use crate::Error;
use ruma::{ use ruma::{
api::{AuthScheme, OutgoingRequest},
identifiers::{DeviceId, UserId}, identifiers::{DeviceId, UserId},
Outgoing, Outgoing,
}; };
use std::{ use std::{
convert::{TryFrom, TryInto}, convert::{TryInto},
ops::Deref, ops::Deref,
}; };
#[cfg(feature = "conduit_bin")] #[cfg(feature = "conduit_bin")]
use { use {
crate::utils, crate::utils,
ruma::api::{AuthScheme, OutgoingRequest},
log::{debug, warn}, log::{debug, warn},
rocket::{ rocket::{
data::{ data::{
@ -25,6 +25,7 @@ use {
Request, State, Request, State,
}, },
std::io::Cursor, std::io::Cursor,
std::convert::TryFrom,
}; };
/// This struct converts rocket requests into ruma structs by converting them into http requests /// This struct converts rocket requests into ruma structs by converting them into http requests

View File

@ -3,7 +3,7 @@ use get_profile_information::v1::ProfileField;
use http::header::{HeaderValue, AUTHORIZATION, HOST}; use http::header::{HeaderValue, AUTHORIZATION, HOST};
use log::{info, warn}; use log::{info, warn};
use regex::Regex; use regex::Regex;
use rocket::{get, post, put, response::content::Json, State}; use rocket::{response::content::Json, State};
use ruma::{ use ruma::{
api::{ api::{
federation::{ federation::{
@ -29,6 +29,10 @@ use std::{
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
time::{Duration, SystemTime}, time::{Duration, SystemTime},
}; };
#[cfg(feature = "conduit_bin")]
use {
rocket::{get, post, put}
};
#[tracing::instrument(skip(globals))] #[tracing::instrument(skip(globals))]
pub async fn send_request<T: OutgoingRequest>( pub async fn send_request<T: OutgoingRequest>(
@ -591,7 +595,7 @@ pub async fn send_transaction_message_route<'a>(
.get("users") .get("users")
.and_then(|users| users.as_sequence()) .and_then(|users| users.as_sequence())
.map_or_else( .map_or_else(
|| Vec::new(), Vec::new,
|users| { |users| {
users users
.iter() .iter()
@ -623,7 +627,7 @@ pub async fn send_transaction_message_route<'a>(
.and_then(|string| { .and_then(|string| {
UserId::parse_with_server_name(string, db.globals.server_name()).ok() 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| { if bridge_user_id.map_or(false, |bridge_user_id| {
db.rooms db.rooms
.is_joined(&bridge_user_id, room_id) .is_joined(&bridge_user_id, room_id)