Clippy fixes

This commit is contained in:
mdecimus 2024-06-18 15:30:41 +02:00
parent aa4a11baf7
commit ae2a67422f
15 changed files with 459 additions and 148 deletions

535
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -384,8 +384,8 @@ impl ConfigManager {
};
for (key, value) in config.keys {
if key.starts_with("version.") {
external.id = key.clone();
external.version = value.clone();
external.id.clone_from(&key);
external.version.clone_from(&value);
external.keys.push(ConfigKey::from((key, value)));
} else if key.starts_with("queue.quota.")
|| key.starts_with("queue.throttle.")

View file

@ -145,7 +145,9 @@ impl Core {
.or_insert(cert.clone());
}
core.tls.certificates.store(certificates.into());
core.tls.self_signed_cert = self.tls.self_signed_cert.clone();
core.tls
.self_signed_cert
.clone_from(&self.tls.self_signed_cert);
// Parser servers
let mut servers = Servers::parse(&mut config);

View file

@ -96,10 +96,7 @@ pub async fn exec(ctx: PluginContext<'_>) -> Variable {
let span = ctx.span;
let address = ctx.arguments[0].to_string();
let timeout = Duration::from_secs(std::cmp::max(
std::cmp::min(ctx.arguments[1].to_integer() as u64, 60),
5,
));
let timeout = Duration::from_secs((ctx.arguments[1].to_integer() as u64).clamp(5, 60));
// Send message to address
match pyzor_send_message(address.as_ref(), timeout, &request).await {
Ok(response) => response.into(),

View file

@ -405,7 +405,7 @@ impl ManageDirectory for Store {
principal.inner.name.as_bytes().to_vec(),
)));
principal.inner.name = new_name.clone();
principal.inner.name.clone_from(&new_name);
batch.set(
ValueClass::Directory(DirectoryClass::NameToId(new_name.into_bytes())),

View file

@ -104,10 +104,10 @@ impl<T: Hash + Eq> LookupCache<T> {
}
}
pub fn get<Q: ?Sized>(&mut self, name: &Q) -> Option<bool>
pub fn get<Q>(&mut self, name: &Q) -> Option<bool>
where
T: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
// Check positive cache
if let Some(valid_until) = self.cache_pos.get_mut(name) {

View file

@ -1072,13 +1072,9 @@ impl<'x> AsImapDataItem<'x> for Message<'x> {
#[inline(always)]
fn get_partial_bytes(bytes: &[u8], partial: Option<(u32, u32)>) -> &[u8] {
if let Some((start, end)) = partial {
if let Some(bytes) =
bytes.get(start as usize..std::cmp::min((start + end) as usize, bytes.len()))
{
bytes
} else {
&[]
}
bytes
.get(start as usize..std::cmp::min((start + end) as usize, bytes.len()))
.unwrap_or_default()
} else {
bytes
}

View file

@ -21,7 +21,7 @@
* for more details.
*/
use std::{borrow::Borrow, io::Write};
use std::borrow::Borrow;
use store::{
write::{DeserializeFrom, SerializeInto},
@ -145,7 +145,7 @@ impl BlobId {
.into()
}
fn serialize_as(&self, writer: &mut (impl Write + Leb128Writer)) {
fn serialize_as(&self, writer: &mut impl Leb128Writer) {
let marker = self
.section
.as_ref()

View file

@ -109,7 +109,8 @@ impl JMAP {
// Process next call
if let Some(next_call) = next_call {
call = next_call;
call.id = response.method_responses.last().unwrap().id.clone();
call.id
.clone_from(&response.method_responses.last().unwrap().id);
} else {
break;
}

View file

@ -64,8 +64,8 @@ impl<'x> InnerToken<'x> for Cow<'x, str> {
impl<T> Token<T> {
pub fn new(offset: usize, len: usize, word: T) -> Token<T> {
debug_assert!(offset <= u32::max_value() as usize);
debug_assert!(len <= u8::max_value() as usize);
debug_assert!(offset <= u32::MAX as usize);
debug_assert!(len <= u8::MAX as usize);
Token {
from: offset,
to: offset + len,

View file

@ -682,7 +682,7 @@ impl<T: SessionStream> Session<T> {
.unwrap_or_default()
{
if let Some(signer) = self.core.core.get_dkim_signer(&signer) {
match signer.sign_chained(&[headers.as_ref(), &raw_message]) {
match signer.sign_chained(&[headers.as_ref(), raw_message]) {
Ok(signature) => {
signature.write_header(&mut headers);
}

View file

@ -125,14 +125,8 @@ pub enum Action {
Discard,
#[serde(rename = "reject")]
Reject,
#[serde(rename = "tempFail")]
Tempfail,
#[serde(rename = "shutdown")]
Shutdown,
#[serde(rename = "connectionFailure")]
ConnectionFailure,
#[serde(rename = "replyCode")]
ReplyCode,
#[serde(rename = "quarantine")]
Quarantine,
}
#[derive(Serialize, Deserialize)]
@ -174,6 +168,4 @@ pub enum Modification {
index: Option<i32>,
name: String,
},
#[serde(rename = "quarantine")]
Quarantine { value: String },
}

View file

@ -29,10 +29,10 @@ pub type LruCache<K, V> = Mutex<lru_cache::LruCache<K, V, ahash::RandomState>>;
pub trait LruCached<K, V>: Sized {
fn with_capacity(capacity: usize) -> Self;
fn get<Q: ?Sized>(&self, name: &Q) -> Option<V>
fn get<Q>(&self, name: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Hash + Eq;
Q: Hash + Eq + ?Sized;
fn insert(&self, name: K, value: V) -> Option<V>;
}
@ -44,10 +44,10 @@ impl<K: Hash + Eq, V: Clone> LruCached<K, V> for LruCache<K, V> {
))
}
fn get<Q: ?Sized>(&self, name: &Q) -> Option<V>
fn get<Q>(&self, name: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
self.lock().get_mut(name).map(|entry| entry.clone())
}

View file

@ -22,10 +22,10 @@ pub struct LruItem<V> {
pub trait TtlMap<K, V>: Sized {
fn with_capacity(capacity: usize, shard_amount: usize) -> Self;
fn get_with_ttl<Q: ?Sized>(&self, name: &Q) -> Option<V>
fn get_with_ttl<Q>(&self, name: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Hash + Eq;
Q: Hash + Eq + ?Sized;
fn insert_with_ttl(&self, name: K, value: V, valid_until: Instant) -> V;
fn cleanup(&self);
}
@ -39,10 +39,10 @@ impl<K: Hash + Eq, V: Clone> TtlMap<K, V> for TtlDashMap<K, V> {
)
}
fn get_with_ttl<Q: ?Sized>(&self, name: &Q) -> Option<V>
fn get_with_ttl<Q>(&self, name: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
match self.get(name) {
Some(entry) if entry.valid_until >= Instant::now() => entry.item.clone().into(),

View file

@ -159,7 +159,7 @@ async fn report_scheduler() {
}
QueueClass::TlsReportHeader(event) => {
if event.domain != last_domain {
last_domain = event.domain.clone();
last_domain.clone_from(&event.domain);
total_tls += 1;
}
total_tls_policies += 1;