Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Dec 1, 2024
1 parent 4f02e4c commit 03d9dab
Show file tree
Hide file tree
Showing 27 changed files with 115 additions and 119 deletions.
130 changes: 65 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/common/src/auth/oauth/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where
{
struct AnyBoolVisitor;

impl<'de> Visitor<'de> for AnyBoolVisitor {
impl Visitor<'_> for AnyBoolVisitor {
type Value = bool;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/scripts/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub trait ApplyString<'x> {
fn transform(&self, f: impl Fn(&'_ str) -> Variable) -> Variable;
}

impl<'x> ApplyString<'x> for Variable {
impl ApplyString<'_> for Variable {
fn transform(&self, f: impl Fn(&'_ str) -> Variable) -> Variable {
match self {
Variable::String(s) => f(s),
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/scripts/plugins/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ async fn exec_remote_(ctx: &PluginContext<'_>) -> trc::Result<Variable> {

// Update expiration
list.expires = Instant::now() + expires;
return Ok(list.entries.contains(item.as_ref()).into());
Ok(list.entries.contains(item.as_ref()).into())
} else {
trc::bail!(trc::SieveEvent::RuntimeError
.into_err()
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/scripts/plugins/pyzor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub trait PyzorCheck {
fn pyzor_check_message(&self) -> String;
}

impl<'x, W: Write> PyzorDigest<W> for Message<'x> {
impl<W: Write> PyzorDigest<W> for Message<'_> {
fn pyzor_digest(&self, writer: W) -> W {
let parts = self
.parts
Expand All @@ -181,7 +181,7 @@ impl<'x, W: Write> PyzorDigest<W> for Message<'x> {
}
}

impl<'x> PyzorCheck for Message<'x> {
impl PyzorCheck for Message<'_> {
fn pyzor_check_message(&self) -> String {
let time = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
Expand Down
2 changes: 1 addition & 1 deletion crates/directory/src/core/principal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ impl<'de> serde::Deserialize<'de> for StringOrU64 {
{
struct StringOrU64Visitor;

impl<'de> Visitor<'de> for StringOrU64Visitor {
impl Visitor<'_> for StringOrU64Visitor {
type Value = StringOrU64;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
4 changes: 1 addition & 3 deletions crates/directory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ pub enum Permission {
// WARNING: add new ids at the end (TODO: use static ids)
}

pub type Permissions = Bitset<
{ (Permission::COUNT + std::mem::size_of::<usize>() - 1) / std::mem::size_of::<usize>() },
>;
pub type Permissions = Bitset<{ Permission::COUNT.div_ceil(std::mem::size_of::<usize>()) }>;

pub const ROLE_ADMIN: u32 = u32::MAX;
pub const ROLE_TENANT_ADMIN: u32 = u32::MAX - 1;
Expand Down
20 changes: 10 additions & 10 deletions crates/imap-proto/src/protocol/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub struct BodyPartExtension<'x> {
pub body_location: Option<Cow<'x, str>>,
}

impl<'x> Address<'x> {
impl Address<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
match self {
Address::Single(addr) => addr.serialize(buf),
Expand All @@ -242,7 +242,7 @@ impl<'x> Address<'x> {
}
}

impl<'x> EmailAddress<'x> {
impl EmailAddress<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
buf.push(b'(');
if let Some(name) = &self.name {
Expand Down Expand Up @@ -280,7 +280,7 @@ impl<'x> EmailAddress<'x> {
}
}

impl<'x> AddressGroup<'x> {
impl AddressGroup<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
buf.extend_from_slice(b"(NIL NIL ");
if let Some(name) = &self.name {
Expand Down Expand Up @@ -482,7 +482,7 @@ impl<'x> BodyPart<'x> {
}
}

impl<'x> BodyPartFields<'x> {
impl BodyPartFields<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
quoted_or_literal_string_or_nil(buf, self.body_subtype.as_deref());
if let Some(body_parameters) = &self.body_parameters {
Expand Down Expand Up @@ -523,7 +523,7 @@ impl<'x> BodyPartFields<'x> {
}
}

impl<'x> BodyPartExtension<'x> {
impl BodyPartExtension<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
if let Some((disposition, parameters)) = &self.body_disposition {
buf.push(b'(');
Expand Down Expand Up @@ -588,7 +588,7 @@ impl<'x> BodyPartExtension<'x> {
}
}

impl<'x> BodyContents<'x> {
impl BodyContents<'_> {
pub fn into_owned<'y>(self) -> BodyContents<'y> {
match self {
BodyContents::Text(text) => BodyContents::Text(text.into_owned().into()),
Expand Down Expand Up @@ -636,7 +636,7 @@ static DUMMY_ADDRESS: [Address; 1] = [Address::Single(EmailAddress {
address: Cow::Borrowed("unknown@localhost"),
})];

impl<'x> Envelope<'x> {
impl Envelope<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
buf.push(b'(');
quoted_rfc2822_or_nil(buf, &self.date);
Expand Down Expand Up @@ -709,7 +709,7 @@ impl<'x> Envelope<'x> {
}
}

impl<'x> DataItem<'x> {
impl DataItem<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
match self {
DataItem::Binary {
Expand Down Expand Up @@ -848,7 +848,7 @@ impl<'x> DataItem<'x> {
}
}

impl<'x> FetchItem<'x> {
impl FetchItem<'_> {
pub fn serialize(&self, buf: &mut Vec<u8>) {
buf.extend_from_slice(b"* ");
buf.extend_from_slice(self.id.to_string().as_bytes());
Expand All @@ -863,7 +863,7 @@ impl<'x> FetchItem<'x> {
}
}

impl<'x> ImapResponse for Response<'x> {
impl ImapResponse for Response<'_> {
fn serialize(self) -> Vec<u8> {
let mut buf = Vec::with_capacity(128);
for item in &self.items {
Expand Down
2 changes: 1 addition & 1 deletion crates/imap-proto/src/protocol/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Response<'x> {
pub items: Vec<FetchItem<'x>>,
}

impl<'x> ImapResponse for Response<'x> {
impl ImapResponse for Response<'_> {
fn serialize(self) -> Vec<u8> {
let mut buf = Vec::with_capacity(64);
for item in &self.items {
Expand Down
4 changes: 2 additions & 2 deletions crates/jmap-proto/src/parser/base32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'x, 'y> JsonBase32Reader<'x, 'y> {
}
}

impl<'x, 'y> Iterator for JsonBase32Reader<'x, 'y> {
impl Iterator for JsonBase32Reader<'_, '_> {
type Item = u8;
fn next(&mut self) -> Option<Self::Item> {
let pos = self.pos % 5;
Expand All @@ -62,4 +62,4 @@ impl<'x, 'y> Iterator for JsonBase32Reader<'x, 'y> {
}
}

impl<'x, 'y> Leb128Iterator<u8> for JsonBase32Reader<'x, 'y> {}
impl Leb128Iterator<u8> for JsonBase32Reader<'_, '_> {}
2 changes: 1 addition & 1 deletion crates/jmap-proto/src/request/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl JsonObjectParser for Capability {
}
}

impl<'x> Parser<'x> {
impl Parser<'_> {
fn error_capability(&mut self) -> trc::Error {
if self.is_eof || self.skip_string() {
trc::JmapEvent::UnknownCapability.into_err().details(
Expand Down
2 changes: 1 addition & 1 deletion crates/jmap-proto/src/types/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ impl JsonObjectParser for ObjectProperty {
}
}

impl<'x> Parser<'x> {
impl Parser<'_> {
fn invalid_property(&mut self) -> trc::Result<Property> {
if self.is_eof || self.skip_string() {
Ok(Property::_T(
Expand Down
2 changes: 1 addition & 1 deletion crates/jmap/src/api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ impl<'x> HttpContext<'x> {
}
}

impl<'x> ResolveVariable for HttpContext<'x> {
impl ResolveVariable for HttpContext<'_> {
fn resolve_variable(&self, variable: u32) -> Variable<'_> {
match variable {
V_REMOTE_IP => self.session.remote_ip.to_string().into(),
Expand Down
2 changes: 1 addition & 1 deletion crates/jmap/src/api/management/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ impl Contains for FailureDetails {
}
}

impl<'x> Contains for Feedback<'x> {
impl Contains for Feedback<'_> {
fn contains(&self, text: &str) -> bool {
// Check if any of the string fields contain the filter
self.authentication_results()
Expand Down
2 changes: 1 addition & 1 deletion crates/jmap/src/email/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl<'x> EmailIndexBuilder<'x> {
}
}

impl<'x> EmailIndexBuilder<'x> {
impl EmailIndexBuilder<'_> {
pub fn build(self, batch: &mut BatchBuilder, account_id: u32, tenant_id: Option<u32>) {
let options = if self.set {
// Serialize metadata
Expand Down
1 change: 1 addition & 0 deletions crates/jmap/src/sieve/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub trait SieveScriptSet: Sync + Send {
fail_if_active: bool,
) -> impl Future<Output = trc::Result<bool>> + Send;

#[allow(clippy::type_complexity)]
fn sieve_set_item(
&self,
changes_: Object<SetValue>,
Expand Down
2 changes: 1 addition & 1 deletion crates/nlp/src/tokenizers/word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct WordTokenizer<'x> {
iterator: CharIndices<'x>,
}

impl<'x> WordTokenizer<'x> {
impl WordTokenizer<'_> {
pub fn new(text: &str, max_token_length: usize) -> WordTokenizer {
WordTokenizer {
max_token_length,
Expand Down
4 changes: 2 additions & 2 deletions crates/smtp/src/outbound/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ pub trait ToNextHop {
&'x self,
domain: &'y str,
max_mx: usize,
) -> Option<Vec<NextHop<'_>>>;
) -> Option<Vec<NextHop<'x>>>;
}

impl ToNextHop for Vec<MX> {
fn to_remote_hosts<'x, 'y: 'x>(
&'x self,
domain: &'y str,
max_mx: usize,
) -> Option<Vec<NextHop<'_>>> {
) -> Option<Vec<NextHop<'x>>> {
if !self.is_empty() {
// Obtain max number of MX hosts to process
let mut remote_hosts = Vec::with_capacity(max_mx);
Expand Down
2 changes: 1 addition & 1 deletion crates/smtp/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ pub enum NextHop<'x> {
MX(&'x str),
}

impl<'x> NextHop<'x> {
impl NextHop<'_> {
#[inline(always)]
fn hostname(&self) -> &str {
match self {
Expand Down
2 changes: 1 addition & 1 deletion crates/store/src/backend/rocksdb/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ enum CommitError {
RocksDB(rocksdb::Error),
}

impl<'x> RocksDBTransaction<'x> {
impl RocksDBTransaction<'_> {
fn commit(&self) -> Result<AssignedIds, CommitError> {
let mut account_id = u32::MAX;
let mut collection = u8::MAX;
Expand Down
16 changes: 8 additions & 8 deletions crates/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ impl<'x> From<&'x str> for Value<'x> {
}
}

impl<'x> From<String> for Value<'x> {
impl From<String> for Value<'_> {
fn from(value: String) -> Self {
Self::Text(value.into())
}
Expand All @@ -557,13 +557,13 @@ impl<'x> From<Cow<'x, str>> for Value<'x> {
}
}

impl<'x> From<bool> for Value<'x> {
impl From<bool> for Value<'_> {
fn from(value: bool) -> Self {
Self::Bool(value)
}
}

impl<'x> From<i64> for Value<'x> {
impl From<i64> for Value<'_> {
fn from(value: i64) -> Self {
Self::Integer(value)
}
Expand All @@ -579,19 +579,19 @@ impl From<Value<'static>> for i64 {
}
}

impl<'x> From<u64> for Value<'x> {
impl From<u64> for Value<'_> {
fn from(value: u64) -> Self {
Self::Integer(value as i64)
}
}

impl<'x> From<u32> for Value<'x> {
impl From<u32> for Value<'_> {
fn from(value: u32) -> Self {
Self::Integer(value as i64)
}
}

impl<'x> From<f64> for Value<'x> {
impl From<f64> for Value<'_> {
fn from(value: f64) -> Self {
Self::Float(value)
}
Expand All @@ -603,13 +603,13 @@ impl<'x> From<&'x [u8]> for Value<'x> {
}
}

impl<'x> From<Vec<u8>> for Value<'x> {
impl From<Vec<u8>> for Value<'_> {
fn from(value: Vec<u8>) -> Self {
Self::Blob(value.into())
}
}

impl<'x> Value<'x> {
impl Value<'_> {
pub fn into_string(self) -> String {
match self {
Value::Text(s) => s.into_owned(),
Expand Down
2 changes: 1 addition & 1 deletion crates/trc/src/atomics/bitset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod tests {
use super::*;

const TEST_SIZE: usize = 1000;
type TestBitset = AtomicBitset<{ (TEST_SIZE + USIZE_BITS - 1) / USIZE_BITS }>;
type TestBitset = AtomicBitset<{ TEST_SIZE.div_ceil(USIZE_BITS) }>;
static BITSET: TestBitset = TestBitset::new();

#[test]
Expand Down
3 changes: 1 addition & 2 deletions crates/trc/src/ipc/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use parking_lot::Mutex;

use crate::*;

pub(crate) type GlobalInterests =
AtomicBitset<{ (TOTAL_EVENT_COUNT + USIZE_BITS - 1) / USIZE_BITS }>;
pub(crate) type GlobalInterests = AtomicBitset<{ TOTAL_EVENT_COUNT.div_ceil(USIZE_BITS) }>;

pub(crate) static TRACE_INTERESTS: GlobalInterests = GlobalInterests::new();
pub(crate) type CollectorThread = JoinHandle<()>;
Expand Down
2 changes: 1 addition & 1 deletion crates/trc/src/ipc/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::{

const MAX_BATCH_SIZE: usize = 32768;

pub type Interests = Box<Bitset<{ (TOTAL_EVENT_COUNT + USIZE_BITS - 1) / USIZE_BITS }>>;
pub type Interests = Box<Bitset<{ TOTAL_EVENT_COUNT.div_ceil(USIZE_BITS) }>>;
pub type EventBatch = Vec<Arc<Event<EventDetails>>>;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/trc/src/serializers/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<T: AsRef<Event<EventDetails>>> Serialize for JsonEventSerializer<T> {
}
}

impl<'x> Serialize for JsonEventSerializer<Keys<'x>> {
impl Serialize for JsonEventSerializer<Keys<'_>> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
Loading

0 comments on commit 03d9dab

Please sign in to comment.