Package: wnpp Followup-For: Bug #1109537 Hi,
I tried to "cargo deb" it, here are a few notes: - cargo-deb isn't in Debian (?), so `cargo install cargo-deb` was needed - the sources target rust 1.88 (2024). However Debian has rust 1.86 (and 1.87 in experimental). See attached trivial patch - which is done *after* dependencies are downloaded, so one has to run `cargo deb` once before applying it. Jérémy
Description: Chained if not supported in rust 1.86 Forwarded: https://github.com/rust-lang/rust/issues/53667 Author: Jérémy Lal <[email protected]> Last-Update: 2025-09-13 --- a/crates/utils/src/json/pointer.rs +++ b/crates/utils/src/json/pointer.rs @@ -71,10 +71,10 @@ ) { match pointer.next() { Some(JsonPointerItem::String(n)) => { - if let serde_json::Value::Object(map) = self - && let Some(v) = map.get(n) - { - v.eval_pointer(pointer, results); + if let serde_json::Value::Object(map) = self { + if let Some(v) = map.get(n) { + v.eval_pointer(pointer, results); + } } } Some(JsonPointerItem::Number(n)) => match self { --- a/crates/nlp/src/tokenizers/types.rs +++ b/crates/nlp/src/tokenizers/types.rs @@ -88,14 +88,14 @@ } // Try parsing currencies and floating point numbers - if self.tokenize_numbers - && !last_is_dot - && let Some(num) = self.try_parse_number() - { - self.peek_advance(); - return Some(num); + if self.tokenize_numbers && !last_is_dot { + if let Some(num) = self.try_parse_number() { + self.peek_advance(); + return Some(num); + } } + self.peek_rewind(); self.next_() } --- a/crates/store/src/config.rs +++ b/crates/store/src/config.rs @@ -431,11 +431,12 @@ "tracing.history.store", "metrics.history.store", ] { - if let Some(store_id) = self.value(key) - && store_id == id - { - return true; + if let Some(store_id) = self.value(key) { + if store_id == id { + return true; + } } + } false --- a/crates/jmap-proto/src/response/references.rs +++ b/crates/jmap-proto/src/response/references.rs @@ -144,8 +144,8 @@ let mut graph = HashMap::with_capacity(request.create.len()); for (create_id, object) in request.create.iter_mut() { for data in &mut object.data { - if let DataSourceObject::Id { id, .. } = data - && let MaybeReference::Reference(parent_id) = id + if let DataSourceObject::Id { id, .. } = data { + if let MaybeReference::Reference(parent_id) = id { match self.created_ids.get(parent_id) { Some(AnyId::Blob(blob_id)) => { @@ -166,6 +166,7 @@ } } } + } } } --- a/crates/jmap-proto/src/types/value.rs +++ b/crates/jmap-proto/src/types/value.rs @@ -580,21 +580,21 @@ ) { match pointer.next() { Some(JsonPointerItem::String(n)) => { - if let Value::Object(map) = self - && let Some(v) = map + if let Value::Object(map) = self { + if let Some(v) = map .0 .iter() .find_map(|(k, v)| if k.as_str() == n { Some(v) } else { None }) { v.eval_pointer(pointer, results); - } + }} } Some(JsonPointerItem::Number(n)) => { - if let Value::List(values) = self - && let Some(v) = values.get(*n as usize) + if let Value::List(values) = self { + if let Some(v) = values.get(*n as usize) { v.eval_pointer(pointer, results); - } + }} } Some(JsonPointerItem::Wildcard) => match self { Value::List(values) => { --- a/crates/directory/src/backend/internal/lookup.rs +++ b/crates/directory/src/backend/internal/lookup.rs @@ -45,14 +45,14 @@ }, }; - if let Some(account_id) = account_id - && let Some(mut principal) = self.get_principal(account_id).await? + if let Some(account_id) = account_id { + if let Some(mut principal) = self.get_principal(account_id).await? { - if let Some(secret) = secret - && !principal.verify_secret(secret, by.only_app_pass).await? + if let Some(secret) = secret { + if !principal.verify_secret(secret, by.only_app_pass).await? { return Ok(None); - } + }} if by.return_member_of { let mut roles = vec![]; @@ -78,7 +78,7 @@ } } return Ok(Some(principal)); - } + }} Ok(None) } --- a/crates/directory/src/backend/internal/manage.rs +++ b/crates/directory/src/backend/internal/manage.rs @@ -354,8 +354,8 @@ principal_create.tenant = tenant_id.into(); if !matches!(principal_create.typ, Type::Tenant | Type::Domain) { - if let Some(domain) = name.split('@').nth(1) - && self + if let Some(domain) = name.split('@').nth(1) { + if self .get_principal_info(domain) .await .caused_by(trc::location!())? @@ -363,7 +363,7 @@ .is_some() { valid_domains.insert(domain.into()); - } + }} if valid_domains.is_empty() { return Err(error( @@ -523,15 +523,15 @@ if self.rcpt(&email).await.caused_by(trc::location!())? != RcptType::Invalid { return Err(err_exists(PrincipalField::Emails, email.to_string())); } - if let Some(domain) = email.split('@').nth(1) - && valid_domains.insert(domain.into()) + if let Some(domain) = email.split('@').nth(1) { + if valid_domains.insert(domain.into()) { self.get_principal_info(domain) .await .caused_by(trc::location!())? .filter(|v| v.typ == Type::Domain && v.has_tenant_access(tenant_id)) .ok_or_else(|| not_found(domain.to_string()))?; - } + }} principal_create.emails.push(email); } } @@ -1003,8 +1003,8 @@ if tenant_id.is_some() && !matches!(principal_type, Type::Tenant | Type::Domain) { - if let Some(domain) = new_name.split('@').nth(1) - && self + if let Some(domain) = new_name.split('@').nth(1) { + if self .get_principal_info(domain) .await .caused_by(trc::location!())? @@ -1014,7 +1014,7 @@ .is_some() { valid_domains.insert(domain.to_string()); - } + }} if valid_domains.is_empty() { return Err(error( @@ -1572,8 +1572,8 @@ for member_id in &members { if !new_members.contains(member_id) { // Update changed principal ids - if principal_type != Type::List - && let Some(member_info) = self + if principal_type != Type::List { + if let Some(member_info) = self .get_principal(*member_id) .await .caused_by(trc::location!())? @@ -1584,7 +1584,7 @@ principal_id, principal_type, ); - } + }} batch.clear(ValueClass::Directory(DirectoryClass::MemberOf { principal_id: *member_id, @@ -2328,15 +2328,15 @@ // Map tenant name #[cfg(feature = "enterprise")] - if let Some(tenant_id) = principal.tenant - && (fields.is_empty() || fields.contains(&PrincipalField::Tenant)) - && let Some(name) = self + if let Some(tenant_id) = principal.tenant { + if (fields.is_empty() || fields.contains(&PrincipalField::Tenant)) { + if let Some(name) = self .get_principal_name(tenant_id) .await .caused_by(trc::location!())? { result.set(PrincipalField::Tenant, name); - } + }}} // SPDX-SnippetEnd @@ -2345,11 +2345,11 @@ (PrincipalField::Name, Some(principal.name)), (PrincipalField::Description, principal.description), ] { - if let Some(value) = value - && (fields.is_empty() || fields.contains(&name)) + if let Some(value) = value { + if (fields.is_empty() || fields.contains(&name)) { result.set(name, value); - } + }} } for (name, value) in [ (PrincipalField::Secrets, principal.secrets), --- a/crates/directory/src/backend/ldap/lookup.rs +++ b/crates/directory/src/backend/ldap/lookup.rs @@ -230,13 +230,13 @@ .map_err(|err| err.into_error().caused_by(trc::location!()))?; for entry in rs { 'outer: for (attr, value) in SearchEntry::construct(entry).attrs { - if self.mappings.attr_name.contains(&attr) - && let Some(group) = value.into_iter().next() - && !group.is_empty() + if self.mappings.attr_name.contains(&attr) { + if let Some(group) = value.into_iter().next() { + if !group.is_empty() { name = group; break 'outer; - } + }}} } } } @@ -313,15 +313,15 @@ for entry in rs { let entry = SearchEntry::construct(entry); for attr in &self.mappings.attr_name { - if let Some(name) = entry.attrs.get(attr).and_then(|v| v.first()) - && !name.is_empty() + if let Some(name) = entry.attrs.get(attr).and_then(|v| v.first()) { + if !name.is_empty() { return self .data_store .get_or_create_principal_id(name, Type::Individual) .await .map(Some); - } + }} } } --- a/crates/directory/src/backend/sql/lookup.rs +++ b/crates/directory/src/backend/sql/lookup.rs @@ -293,11 +293,11 @@ if let Value::Text(text) = value { principal.emails.push(text.to_lowercase()); } - } else if name.eq_ignore_ascii_case(&self.column_quota) - && let Value::Integer(quota) = value + } else if name.eq_ignore_ascii_case(&self.column_quota) { + if let Value::Integer(quota) = value { principal.quota = (quota as u64).into(); - } + }} } } --- a/crates/directory/src/core/dispatch.rs +++ b/crates/directory/src/core/dispatch.rs @@ -40,11 +40,11 @@ pub async fn is_local_domain(&self, domain: &str) -> trc::Result<bool> { // Check cache - if let Some(cache) = &self.cache - && let Some(result) = cache.get_domain(domain) + if let Some(cache) = &self.cache { + if let Some(result) = cache.get_domain(domain) { return Ok(result); - } + }} let result = match &self.store { DirectoryInner::Internal(store) => store.is_local_domain(domain).await, @@ -67,11 +67,11 @@ pub async fn rcpt(&self, email: &str) -> trc::Result<RcptType> { // Check cache - if let Some(cache) = &self.cache - && let Some(result) = cache.get_rcpt(email) + if let Some(cache) = &self.cache { + if let Some(result) = cache.get_rcpt(email) { return Ok(result); - } + }} let result = match &self.store { DirectoryInner::Internal(store) => store.rcpt(email).await, --- a/crates/directory/src/core/principal.rs +++ b/crates/directory/src/core/principal.rs @@ -238,12 +238,12 @@ } else { None } - }) && let Some(idx) = permissions + }) { if let Some(idx) = permissions .iter_mut() .position(|p| p.permission == permission && p.grant == grant) { permissions.swap_remove(idx); - } + }} } pub fn remove_permissions(&mut self, grant: bool) { @@ -272,11 +272,11 @@ } // If the principal has no roles, take the ones from the external principal - if let Some(roles) = external.roles_mut().filter(|s| !s.is_empty()) - && self.roles().is_empty() + if let Some(roles) = external.roles_mut().filter(|s| !s.is_empty()) { + if self.roles().is_empty() { self.data.push(PrincipalData::Roles(std::mem::take(roles))); - } + }} if external.description.as_ref().is_some_and(|v| !v.is_empty()) && self.description != external.description --- a/crates/common/src/addresses.rs +++ b/crates/common/src/addresses.rs @@ -186,11 +186,11 @@ ) -> Cow<'x, str> { match self { AddressMapping::Enable => { - if let Some((local_part, domain_part)) = address.rsplit_once('@') - && let Some((local_part, _)) = local_part.split_once('+') + if let Some((local_part, domain_part)) = address.rsplit_once('@') { + if let Some((local_part, _)) = local_part.split_once('+') { return format!("{}@{}", local_part, domain_part).into(); - } + }} } AddressMapping::Custom(if_block) => { if let Some(result) = core --- a/crates/common/src/auth/access_token.rs +++ b/crates/common/src/auth/access_token.rs @@ -69,8 +69,8 @@ // SPDX-License-Identifier: LicenseRef-SEL #[cfg(feature = "enterprise")] - if self.is_enterprise_edition() - && let Some(tenant_id) = principal.tenant + if self.is_enterprise_edition() { + if let Some(tenant_id) = principal.tenant { // Limit tenant permissions @@ -95,7 +95,7 @@ .quota .unwrap_or_default(), }); - } + }} // SPDX-SnippetEnd @@ -111,11 +111,11 @@ .store() .query(QueryParams::id(group_id).with_return_member_of(false)) .await - .caused_by(trc::location!())? - && group.typ == Type::Group + .caused_by(trc::location!())? { + if group.typ == Type::Group { emails.extend(group.emails); - } + }} } // Build access token --- a/crates/common/src/auth/mod.rs +++ b/crates/common/src/auth/mod.rs @@ -167,15 +167,15 @@ } _ => { // Validate API credentials - if req.allow_api_access - && let Ok(Some(principal)) = self + if req.allow_api_access { + if let Ok(Some(principal)) = self .store() .query( QueryParams::credentials(&req.credentials) .with_return_member_of(req.return_member_of), ) - .await - && principal.typ == Type::ApiKey + .await { + if principal.typ == Type::ApiKey { trc::event!( Auth(trc::AuthEvent::Success), @@ -185,7 +185,7 @@ ); return Ok(principal); - } + }}} } } } --- a/crates/common/src/auth/rate_limit.rs +++ b/crates/common/src/auth/rate_limit.rs @@ -57,9 +57,9 @@ } pub async fn is_http_anonymous_request_allowed(&self, addr: &IpAddr) -> trc::Result<()> { - if let Some(rate) = &self.core.jmap.rate_anonymous - && !self.is_ip_allowed(addr) - && self + if let Some(rate) = &self.core.jmap.rate_anonymous { + if !self.is_ip_allowed(addr) { + if self .core .storage .lookup @@ -74,7 +74,7 @@ .is_some() { return Err(trc::LimitEvent::TooManyRequests.into_err()); - } + }}} Ok(()) } --- a/crates/common/src/config/spamfilter.rs +++ b/crates/common/src/config/spamfilter.rs @@ -330,14 +330,14 @@ ] { if config .property_or_default(("spam-filter.header", typ, "enable"), "true") - .unwrap_or(true) - && let Some(value) = config.value(("spam-filter.header", typ, "name")) + .unwrap_or(true) { + if let Some(value) = config.value(("spam-filter.header", typ, "name")) { let value = value.trim(); if !value.is_empty() { *var = value.to_string().into(); } - } + }} } header --- a/crates/common/src/config/telemetry.rs +++ b/crates/common/src/config/telemetry.rs @@ -170,12 +170,12 @@ .collect::<Vec<_>>() { if let Some(event_type) = - config.try_parse_value::<EventType>(("tracing.level", &event_name), &event_name) - && let Some(level) = + config.try_parse_value::<EventType>(("tracing.level", &event_name), &event_name) { + if let Some(level) = config.property_require::<Level>(("tracing.level", &event_name)) { custom_levels.insert(event_type, level); - } + }} } // Parse tracers @@ -528,8 +528,8 @@ { if config .property_or_default("tracing.history.enable", "false") - .unwrap_or(false) - && let Some(store_id) = config.value_require("tracing.history.store") + .unwrap_or(false) { + if let Some(store_id) = config.value_require("tracing.history.store") { if let Some(store) = stores.stores.get(store_id) { let mut tracer = TelemetrySubscriber { @@ -551,7 +551,7 @@ let err = format!("Store {store_id} not found"); config.new_build_error("tracing.history.store", err); } - } + }} } // SPDX-SnippetEnd @@ -609,18 +609,18 @@ if config .value(("tracer", tracer_id, "enable")) .unwrap_or("true") - == "true" - && config + == "true" { + if config .value(("tracer", tracer_id, "type")) .unwrap_or_default() - == "log" - && let Some(path) = config + == "log" { + if let Some(path) = config .value(("tracer", tracer_id, "path")) .map(|s| s.to_string()) { metrics.log_path = Some(path); break; - } + }}} } if config --- a/crates/common/src/core.rs +++ b/crates/common/src/core.rs @@ -412,8 +412,8 @@ // SPDX-License-Identifier: LicenseRef-SEL #[cfg(feature = "enterprise")] - if self.core.is_enterprise_edition() - && let Some(tenant) = quotas.tenant.filter(|tenant| tenant.quota != 0) + if self.core.is_enterprise_edition() { + if let Some(tenant) = quotas.tenant.filter(|tenant| tenant.quota != 0) { let used_quota = self.get_used_quota(tenant.id).await? as u64; @@ -423,7 +423,7 @@ .ctx(trc::Key::Limit, tenant.quota) .ctx(trc::Key::Size, used_quota)); } - } + }} // SPDX-SnippetEnd @@ -462,8 +462,8 @@ // SPDX-License-Identifier: LicenseRef-SEL #[cfg(feature = "enterprise")] - if self.core.is_enterprise_edition() - && let Some(tenant_id) = principal.tenant() + if self.core.is_enterprise_edition() { + if let Some(tenant_id) = principal.tenant() { quotas.tenant = TenantInfo { id: tenant_id, @@ -480,7 +480,7 @@ .unwrap_or_default(), } .into(); - } + }} // SPDX-SnippetEnd } @@ -804,15 +804,15 @@ } pub async fn cluster_broadcast(&self, event: BroadcastEvent) { - if let Some(broadcast_tx) = &self.inner.ipc.broadcast_tx.clone() - && broadcast_tx.send(event).await.is_err() + if let Some(broadcast_tx) = &self.inner.ipc.broadcast_tx.clone() { + if broadcast_tx.send(event).await.is_err() { trc::event!( Server(trc::ServerEvent::ThreadError), Details = "Error sending broadcast event.", CausedBy = trc::location!() ); - } + }} } #[allow(clippy::blocks_in_conditions)] --- a/crates/common/src/listener/listen.rs +++ b/crates/common/src/listener/listen.rs @@ -279,24 +279,24 @@ Details = "Failed to set TCP_NODELAY", ); } - if let Some(ttl) = self.ttl - && let Err(err) = stream.set_ttl(ttl) + if let Some(ttl) = self.ttl { + if let Err(err) = stream.set_ttl(ttl) { trc::event!( Network(trc::NetworkEvent::SetOptError), Reason = err.to_string(), Details = "Failed to set TTL", ); - } - if self.linger.is_some() - && let Err(err) = stream.set_linger(self.linger) + }} + if self.linger.is_some() { + if let Err(err) = stream.set_linger(self.linger) { trc::event!( Network(trc::NetworkEvent::SetOptError), Reason = err.to_string(), Details = "Failed to set LINGER", ); - } + }} } } --- a/crates/common/src/manager/boot.rs +++ b/crates/common/src/manager/boot.rs @@ -461,15 +461,15 @@ // Spam filter auto-update if config .property_or_default::<bool>("spam-filter.auto-update", "false") - .unwrap_or_default() - && let Err(err) = core.storage.config.update_spam_rules(false, false).await + .unwrap_or_default() { + if let Err(err) = core.storage.config.update_spam_rules(false, false).await { trc::event!( Resource(trc::ResourceEvent::Error), Details = "Failed to update spam-filter", CausedBy = err ); - } + }} // Build shared inner let has_remote_asn = matches!( --- a/crates/common/src/sharing/resources.rs +++ b/crates/common/src/sharing/resources.rs @@ -45,8 +45,8 @@ let check_acls = check_acls.into(); for resource in &self.resources { - if resource.document_id == document_id - && let Some(acls) = resource.acls() + if resource.document_id == document_id { + if let Some(acls) = resource.acls() { for acl in acls { if access_token.is_member(acl.account_id) { @@ -56,7 +56,7 @@ } } break; - } + }} } false @@ -66,8 +66,8 @@ let mut account_acls = Bitmap::<Acl>::new(); for resource in &self.resources { - if resource.document_id == document_id - && let Some(acls) = resource.acls() + if resource.document_id == document_id { + if let Some(acls) = resource.acls() { for acl in acls { if access_token.is_member(acl.account_id) { @@ -75,7 +75,7 @@ } } break; - } + }} } account_acls --- a/crates/common/src/telemetry/tracers/otel.rs +++ b/crates/common/src/telemetry/tracers/otel.rs @@ -57,8 +57,8 @@ pending_logs.push(otel.build_log_record(&event)); } - if otel.span_exporter_enable - && let Some(span) = event.inner.span.as_ref() + if otel.span_exporter_enable { + if let Some(span) = event.inner.span.as_ref() { let span_id = span.span_id().unwrap(); if !event.inner.typ.is_span_end() { @@ -74,7 +74,7 @@ &instrumentation, )); } - } + }} } } Ok(None) => { @@ -90,8 +90,8 @@ if !pending_spans.is_empty() || !pending_logs.is_empty() { next_delivery = now + otel.throttle; - if !pending_spans.is_empty() - && let Err(err) = otel + if !pending_spans.is_empty() { + if let Err(err) = otel .span_exporter .export(std::mem::take(&mut pending_spans)) .await @@ -101,7 +101,7 @@ Details = "Failed to export spans", Reason = err.to_string() ); - } + }} if !pending_logs.is_empty() { let logs = pending_logs --- a/crates/groupware/src/calendar/alarm.rs +++ b/crates/groupware/src/calendar/alarm.rs @@ -80,8 +80,8 @@ .single()? .timestamp(); - if let Some(alarm_time) = alarm.delta.to_timestamp(start, end, default_tz) - && alarm_time > start_time + if let Some(alarm_time) = alarm.delta.to_timestamp(start, end, default_tz) { + if alarm_time > start_time { if let Some(next) = next_alarm { if alarm_time < next.alarm_time { @@ -107,7 +107,7 @@ }); } continue 'outer; - } + }} } } else { // Single event @@ -126,8 +126,8 @@ .single()? .timestamp(); - if let Some(alarm_time) = alarm.delta.to_timestamp(start, end, default_tz) - && alarm_time > start_time + if let Some(alarm_time) = alarm.delta.to_timestamp(start, end, default_tz) { + if alarm_time > start_time { if let Some(next) = next_alarm { if alarm_time < next.alarm_time { @@ -152,7 +152,7 @@ event_end_tz: end_tz.as_id(), }); } - } + }} } } --- a/crates/spam-filter/src/analysis/bayes.rs +++ b/crates/spam-filter/src/analysis/bayes.rs @@ -24,9 +24,9 @@ impl SpamFilterAnalyzeBayes for Server { async fn spam_filter_analyze_bayes_classify(&self, ctx: &mut SpamFilterContext<'_>) { - if let Some(config) = &self.core.spam.bayes - && !ctx.result.has_tag("SPAM_TRAP") - && !ctx.result.has_tag("TRUSTED_REPLY") + if let Some(config) = &self.core.spam.bayes { + if !ctx.result.has_tag("SPAM_TRAP") { + if !ctx.result.has_tag("TRUSTED_REPLY") { match self.bayes_classify(ctx).await { Ok(Some(score)) => { @@ -41,7 +41,7 @@ trc::error!(err.span_id(ctx.input.span_id).caused_by(trc::location!())); } } - } + }}} } async fn spam_filter_analyze_spam_trap(&self, ctx: &mut SpamFilterContext<'_>) -> bool { --- a/crates/spam-filter/src/analysis/domain.rs +++ b/crates/spam-filter/src/analysis/domain.rs @@ -41,14 +41,14 @@ // Add DKIM domains for dkim in ctx.input.dkim_result { - if dkim.result() == &DkimResult::Pass - && let Some(domain) = dkim.signature().map(|s| &s.d) + if dkim.result() == &DkimResult::Pass { + if let Some(domain) = dkim.signature().map(|s| &s.d) { domains.insert(ElementLocation::new( CompactString::from_str_to_lowercase(domain), Location::HeaderDkimPass, )); - } + }} } // Add Received headers @@ -59,11 +59,11 @@ .into_iter() .flatten() { - if let Host::Name(name) = host - && let Some(name) = Hostname::new(name.as_ref()).sld + if let Host::Name(name) = host { + if let Some(name) = Hostname::new(name.as_ref()).sld { domains.insert(ElementLocation::new(name, Location::HeaderReceived)); - } + }} } } (HeaderName::MessageId, value) => { --- a/crates/spam-filter/src/analysis/from.rs +++ b/crates/spam-filter/src/analysis/from.rs @@ -86,8 +86,8 @@ ctx.result.add_tag("FROM_HAS_DN"); } - if from_name_trimmed.contains('@') - && let Some(from_name_addr) = TypesTokenizer::new(from_name_trimmed) + if from_name_trimmed.contains('@') { + if let Some(from_name_addr) = TypesTokenizer::new(from_name_trimmed) .tokenize_numbers(false) .tokenize_urls(false) .tokenize_urls_without_scheme(false) @@ -113,7 +113,7 @@ } else { ctx.result.add_tag("FROM_NEQ_DISPLAY_NAME"); } - } + }} } // Check sender @@ -187,11 +187,11 @@ } // Check whether read confirmation address is different to from address - if let Some(crt) = crt - && crt != from_addr.address + if let Some(crt) = crt { + if crt != from_addr.address { ctx.result.add_tag("HEADER_RCONFIRM_MISMATCH"); - } + }} } if !env_from_empty { @@ -215,11 +215,11 @@ } // Check whether disposition notification address is different to return path - if let Some(dnt) = dnt - && dnt != ctx.output.env_from_addr.address + if let Some(dnt) = dnt { + if dnt != ctx.output.env_from_addr.address { ctx.result.add_tag("HEADER_FORGED_MDN"); - } + }} } } } --- a/crates/spam-filter/src/analysis/ip.rs +++ b/crates/spam-filter/src/analysis/ip.rs @@ -38,22 +38,22 @@ if let (HeaderName::Received, HeaderValue::Received(received)) = (&header.name, &header.value) { - if let Some(ip) = received.from_ip() - && !ip.is_loopback() - && !self.is_ip_allowed(&ip) + if let Some(ip) = received.from_ip() { + if !ip.is_loopback() { + if !self.is_ip_allowed(&ip) { ips.insert(ElementLocation::new(ip, Location::HeaderReceived)); - } + }}} for host in [&received.from, &received.helo, &received.by] .into_iter() .flatten() { - if let Host::IpAddr(ip) = host - && !ip.is_loopback() - && !self.is_ip_allowed(ip) + if let Host::IpAddr(ip) = host { + if !ip.is_loopback() { + if !self.is_ip_allowed(ip) { ips.insert(ElementLocation::new(*ip, Location::HeaderReceived)); - } + }}} } } } --- a/crates/spam-filter/src/analysis/mime.rs +++ b/crates/spam-filter/src/analysis/mime.rs @@ -366,8 +366,8 @@ if is_attachment { // Has a MIME attachment ctx.result.add_tag("HAS_ATTACHMENT"); - if ct_full != "application/octet-stream" - && let Some(t) = infer::get(part.contents()) + if ct_full != "application/octet-stream" { + if let Some(t) = infer::get(part.contents()) { if t.mime_type() == ct_full { // Known content-type @@ -376,7 +376,7 @@ // Known bad content-type ctx.result.add_tag("MIME_BAD"); } - } + }} } // Analyze attachment name --- a/crates/spam-filter/src/analysis/received.rs +++ b/crates/spam-filter/src/analysis/received.rs @@ -47,22 +47,22 @@ // HELO domain is "user" ctx.result.add_tag("RCVD_HELO_USER"); } else if let (Some(Host::Name(helo_domain)), Some(ip_rev)) = - (helo_domain, ip_rev) - && helo_domain.to_lowercase() != ip_rev.to_lowercase() + (helo_domain, ip_rev) { + if helo_domain.to_lowercase() != ip_rev.to_lowercase() { // HELO domain does not match PTR record ctx.result.add_tag("FORGED_RCVD_TRAIL"); - } + }} - if let Some(delivered_for) = received.for_().map(|s| s.to_lowercase()) - && ctx + if let Some(delivered_for) = received.for_().map(|s| s.to_lowercase()) { + if ctx .output .all_recipients() .any(|r| r.email.address == delivered_for) { // Recipient appears on Received trail ctx.result.add_tag("PREVIOUSLY_DELIVERED"); - } + }} if matches!(received.from, Some(Host::IpAddr(_))) { // Received from an IP address rather than a FQDN --- a/crates/spam-filter/src/analysis/recipient.rs +++ b/crates/spam-filter/src/analysis/recipient.rs @@ -101,12 +101,12 @@ // Check for spaces in recipient addresses for token in raw_utf8.split('<') { - if let Some((addr, _)) = token.split_once('>') - && (addr.starts_with(' ') || addr.ends_with(' ')) + if let Some((addr, _)) = token.split_once('>') { + if (addr.starts_with(' ') || addr.ends_with(' ')) { ctx.result.add_tag("TO_WRAPPED_IN_SPACES"); break; - } + }} } } } --- a/crates/spam-filter/src/analysis/trusted_reply.rs +++ b/crates/spam-filter/src/analysis/trusted_reply.rs @@ -64,7 +64,8 @@ if let (Some(hold_time), Some(message_id)) = ( self.core.spam.expiry.trusted_reply, ctx.input.message.message_id(), - ) && let Err(err) = self + ) { + if let Err(err) = self .in_memory_store() .key_set( KeyValue::with_prefix(KV_TRUSTED_REPLY, message_id.as_bytes(), vec![]) @@ -73,7 +74,7 @@ .await { trc::error!(err.span_id(ctx.input.span_id).caused_by(trc::location!())); - } + }} if self .core --- a/crates/spam-filter/src/analysis/url.rs +++ b/crates/spam-filter/src/analysis/url.rs @@ -97,8 +97,8 @@ match token { TokenType::Url(url) | TokenType::UrlNoScheme(url) => { if is_body - && !ctx.result.has_tag("RCPT_DOMAIN_IN_BODY") - && let Some(url_parsed) = &url.url_parsed + && !ctx.result.has_tag("RCPT_DOMAIN_IN_BODY") { + if let Some(url_parsed) = &url.url_parsed { let host = url_parsed.host.sld_or_default(); for rcpt in ctx.output.all_recipients() { @@ -107,7 +107,7 @@ break; } } - } + }} urls.insert(ElementLocation::new( url.to_owned(), --- a/crates/spam-filter/src/modules/dnsbl.rs +++ b/crates/spam-filter/src/modules/dnsbl.rs @@ -52,8 +52,8 @@ for dnsbl in &server.core.spam.dnsbl.servers { if dnsbl.scope == scope - && checks < max_checks - && let Some(tag) = is_dnsbl( + && checks < max_checks { + if let Some(tag) = is_dnsbl( server, dnsbl, SpamFilterResolver::new(ctx, resolver, location), @@ -63,7 +63,7 @@ .await { ctx.result.add_tag(tag); - } + }} } match scope { --- a/crates/spam-filter/src/modules/pyzor.rs +++ b/crates/spam-filter/src/modules/pyzor.rs @@ -320,15 +320,15 @@ continue; } b'>' if in_tag => { - if tag_token_pos == 1 - && let Some(tag) = input.get(token_start..token_end + 1) + if tag_token_pos == 1 { + if let Some(tag) = input.get(token_start..token_end + 1) { if tag.eq_ignore_ascii_case(b"style") { in_style = !is_tag_close; } else if tag.eq_ignore_ascii_case(b"script") { in_script = !is_tag_close; } - } + }} in_tag = false; is_token_start = true; --- a/crates/email/src/cache/email.rs +++ b/crates/email/src/cache/email.rs @@ -33,8 +33,8 @@ }; for (document_id, is_update) in changed_ids { - if *is_update - && let Some(archive) = server + if *is_update { + if let Some(archive) = server .get_archive(account_id, Collection::Email, *document_id) .await .caused_by(trc::location!())? @@ -44,7 +44,7 @@ *document_id, archive.to_unarchived::<MessageData>()?, ); - } + }} } for item in &store_cache.emails.items { --- a/crates/email/src/cache/mailbox.rs +++ b/crates/email/src/cache/mailbox.rs @@ -28,8 +28,8 @@ }; for (document_id, is_update) in changed_ids { - if *is_update - && let Some(archive) = server + if *is_update { + if let Some(archive) = server .get_archive(account_id, Collection::Mailbox, *document_id) .await .caused_by(trc::location!())? @@ -39,7 +39,7 @@ *document_id, archive.unarchive::<Mailbox>()?, ); - } + }} } for item in store_cache.mailboxes.items.iter() { --- a/crates/email/src/message/delete.rs +++ b/crates/email/src/message/delete.rs @@ -136,24 +136,24 @@ } // Auto-expunge deleted and junk messages - if let Some(hold_period) = self.core.jmap.mail_autoexpunge_after - && let Err(err) = self.emails_auto_expunge(account_id, hold_period).await + if let Some(hold_period) = self.core.jmap.mail_autoexpunge_after { + if let Err(err) = self.emails_auto_expunge(account_id, hold_period).await { trc::error!( err.details("Failed to auto-expunge e-mail messages.") .account_id(account_id) ); - } + }} // Auto-expunge iMIP messages - if let Some(hold_period) = self.core.groupware.itip_inbox_auto_expunge - && let Err(err) = self.itip_auto_expunge(account_id, hold_period).await + if let Some(hold_period) = self.core.groupware.itip_inbox_auto_expunge { + if let Err(err) = self.itip_auto_expunge(account_id, hold_period).await { trc::error!( err.details("Failed to auto-expunge iTIP messages.") .account_id(account_id) ); - } + }} // Purge tombstoned messages if let Err(err) = self.emails_purge_tombstoned(account_id).await { @@ -164,14 +164,14 @@ } // Purge changelogs - if let Some(history) = self.core.jmap.changes_max_history - && let Err(err) = self.delete_changes(account_id, history).await + if let Some(history) = self.core.jmap.changes_max_history { + if let Err(err) = self.delete_changes(account_id, history).await { trc::error!( err.details("Failed to purge changes.") .account_id(account_id) ); - } + }} // Delete lock if let Err(err) = self --- a/crates/email/src/message/ingest.rs +++ b/crates/email/src/message/ingest.rs @@ -206,13 +206,13 @@ // If the message is classified as spam, check whether the sender address is present in the user's address book if is_spam - && self.core.spam.card_is_ham - && let Some(sender) = message + && self.core.spam.card_is_ham { + if let Some(sender) = message .from() .and_then(|s| s.first()) .and_then(|s| s.address()) - .and_then(sanitize_email) - && sender != deliver_to + .and_then(sanitize_email) { + if sender != deliver_to && is_sender_authenticated && !self .store() @@ -236,7 +236,7 @@ { train_spam = Some(false); } - } + }}} // Classify the message with user's model if let Some(bayes_config) = self.core.spam.bayes.as_ref().filter(|config| { @@ -313,7 +313,8 @@ .subtype() .is_some_and(|st| st.eq_ignore_ascii_case("calendar")) && ct.has_attribute("method") - }) && let Some(itip_message) = part.text_contents() + }) { + if let Some(itip_message) = part.text_contents() { if itip_message.len() < self.core.groupware.itip_inbound_max_ical_size { if let Some(sender) = sender.get_or_insert_with(|| { @@ -381,7 +382,7 @@ Size = itip_message.len(), ) } - } + }} } } } @@ -511,13 +512,13 @@ part.offset_end += offset_start as u32; part.offset_header += offset_start as u32; - if let PartType::Message(sub_message) = &mut part.body - && sub_message.root_part().offset_header != 0 + if let PartType::Message(sub_message) = &mut part.body { + if sub_message.root_part().offset_header != 0 { sub_message.raw_message = raw_message.as_ref().into(); part_iter_stack.push(part_iter); part_iter = sub_message.parts.iter_mut(); - } + }} } else if let Some(iter) = part_iter_stack.pop() { part_iter = iter; } else { @@ -541,8 +542,8 @@ IngestSource::Restore => false, }; if do_encrypt - && !message.is_encrypted() - && let Some(encrypt_params_) = self + && !message.is_encrypted() { + if let Some(encrypt_params_) = self .get_archive_by_property(account_id, Collection::Principal, 0, Property::Parameters) .await .caused_by(trc::location!())? @@ -591,7 +592,7 @@ } _ => unreachable!(), } - } + }} // Store blob let blob_id = self --- a/crates/email/src/sieve/ingest.rs +++ b/crates/email/src/sieve/ingest.rs @@ -186,11 +186,11 @@ TRASH_ID } else { let mut mailbox_id = u32::MAX; - if let Ok(role) = SpecialUse::parse_value(&role) - && let Some(m) = cache.mailbox_by_role(&role) + if let Ok(role) = SpecialUse::parse_value(&role) { + if let Some(m) = cache.mailbox_by_role(&role) { mailbox_id = m.document_id; - } + }} mailbox_id }); @@ -317,19 +317,19 @@ } // Find mailbox by role - if let Some(special_use) = special_use - && target_id == u32::MAX + if let Some(special_use) = special_use { + if target_id == u32::MAX { if special_use.eq_ignore_ascii_case("inbox") { target_id = INBOX_ID; } else if special_use.eq_ignore_ascii_case("trash") { target_id = TRASH_ID; - } else if let Ok(role) = SpecialUse::parse_value(&special_use) - && let Some(item) = cache.mailbox_by_role(&role) + } else if let Ok(role) = SpecialUse::parse_value(&special_use) { + if let Some(item) = cache.mailbox_by_role(&role) { target_id = item.document_id; - } - } + }} + }} // Find mailbox by name if target_id == u32::MAX { --- a/crates/dav/src/calendar/query.rs +++ b/crates/dav/src/calendar/query.rs @@ -275,12 +275,12 @@ let mut matched_any = false; for value in entry.values.iter() { - if let Some(text) = value.as_text() - && text_match.matches(text) + if let Some(text) = value.as_text() { + if text_match.matches(text) { matched_any = true; break; - } + }} } matched_any @@ -448,9 +448,9 @@ .unwrap(); // Limit recurrence override - if let Some(limit_recurrence) = &data.limit_recurrence - && component.is_recurrence_override() - && !self.expanded_times.iter().any(|event| { + if let Some(limit_recurrence) = &data.limit_recurrence { + if component.is_recurrence_override() { + if !self.expanded_times.iter().any(|event| { event.comp_id == component_id && limit_recurrence.is_in_range( component.component_type == ICalendarComponentType::VTodo, @@ -460,18 +460,18 @@ }) { continue; - } + }}} // Limit freebusy - if let Some(limit_recurrence) = &data.limit_freebusy - && component.component_type == ICalendarComponentType::VFreebusy - && !self.expanded_times.iter().any(|event| { + if let Some(limit_recurrence) = &data.limit_freebusy { + if component.component_type == ICalendarComponentType::VFreebusy { + if !self.expanded_times.iter().any(|event| { event.comp_id == component_id && limit_recurrence.is_in_range(false, event.start, event.end) }) { continue; - } + }}} // Filter entries let mut entries = component --- a/crates/dav/src/card/query.rs +++ b/crates/dav/src/card/query.rs @@ -124,12 +124,12 @@ let mut matched_any = false; for value in entry.values.iter() { - if let Some(text) = value.as_text() - && text_match.matches(text) + if let Some(text) = value.as_text() { + if text_match.matches(text) { matched_any = true; break; - } + }} } matched_any --- a/crates/dav/src/common/lock.rs +++ b/crates/dav/src/common/lock.rs @@ -525,8 +525,8 @@ } if let Some(document_id) = - resource_state.document_id.filter(|&id| id != u32::MAX) - && let Some(archive) = self + resource_state.document_id.filter(|&id| id != u32::MAX) { + if let Some(archive) = self .get_archive( resource_state.account_id, resource_state.collection, @@ -536,13 +536,13 @@ .caused_by(trc::location!())? { resource_state.etag = archive.etag().into(); - } + }} } // Fetch lock token if needs_lock_token - && resource_state.lock_tokens.is_empty() - && let Some(idx) = locks.find_cache_pos(self, resource_state).await? + && resource_state.lock_tokens.is_empty() { + if let Some(idx) = locks.find_cache_pos(self, resource_state).await? { let found_locks = locks .find_locks_by_pos(idx, resource_state, false)? @@ -550,7 +550,7 @@ .map(|(_, lock)| lock.urn().to_string()) .collect::<Vec<_>>(); resource_state.lock_tokens = found_locks; - } + }} // Fetch sync token if needs_sync_token && resource_state.sync_token.is_none() { --- a/crates/dav/src/common/propfind.rs +++ b/crates/dav/src/common/propfind.rs @@ -1037,12 +1037,12 @@ } // Add dead properties - if skip_not_found - && let Some(dead_properties) = + if skip_not_found { + if let Some(dead_properties) = dead_properties.filter(|dead_properties| !dead_properties.0.is_empty()) { dead_properties.to_dav_values(&mut fields); - } + }} // Add response let mut prop_stat = Vec::with_capacity(2); @@ -1253,8 +1253,8 @@ } } - if maybe_has_vanished - && let Some(vanished_collection) = sync_collection.vanished_collection() + if maybe_has_vanished { + if let Some(vanished_collection) = sync_collection.vanished_collection() { vanished = server .store() @@ -1262,7 +1262,7 @@ .await .caused_by(trc::location!())?; total_changes += vanished.len(); - } + }} // Truncate changes if total_changes > limit { --- a/crates/dav/src/file/copy_move.rs +++ b/crates/dav/src/file/copy_move.rs @@ -146,16 +146,16 @@ // Validate destination ACLs if let Some(document_id) = destination.document_id { - if let Some(delete_destination) = &delete_destination - && !access_token.is_member(to_account_id) - && !from_resources.has_access_to_container( + if let Some(delete_destination) = &delete_destination { + if !access_token.is_member(to_account_id) { + if !from_resources.has_access_to_container( access_token, delete_destination.document_id.unwrap(), Acl::Delete, ) { return Err(DavError::Code(StatusCode::FORBIDDEN)); - } + }}} if !access_token.is_member(to_account_id) && !from_resources.has_access_to_container(access_token, document_id, Acl::Modify) --- a/crates/email/src/sieve/activate.rs +++ b/crates/email/src/sieve/activate.rs @@ -78,8 +78,8 @@ } // Activate script - if let Some(document_id) = activate_id - && let Some(sieve_) = self + if let Some(document_id) = activate_id { + if let Some(sieve_) = self .get_archive(account_id, Collection::SieveScript, document_id) .await? { @@ -97,7 +97,7 @@ ) .caused_by(trc::location!())?; changed_ids.push((document_id, true)); - } + }} // Write changes if !changed_ids.is_empty() { --- a/crates/cli/src/modules/import.rs +++ b/crates/cli/src/modules/import.rs @@ -473,8 +473,8 @@ for (path, mailbox) in build_mailbox_tree(&mailboxes) { let id = mailbox.id().unwrap_result("obtain mailbox id"); // Find existing mailbox based on role - if !matches!(mailbox.role(), Role::None) - && let Some(existing_mailbox) = existing_mailboxes + if !matches!(mailbox.role(), Role::None) { + if let Some(existing_mailbox) = existing_mailboxes .iter() .find(|m| m.role() == mailbox.role()) { @@ -486,7 +486,7 @@ .to_string(), ); continue; - } + }} // Find existing mailbox by name if let Some(mailbox) = nested_existing_mailboxes.get(&path) { --- a/crates/imap/src/core/client.rs +++ b/crates/imap/src/core/client.rs @@ -260,14 +260,14 @@ } } - if let Some(needs_literal) = needs_literal - && let Err(err) = self + if let Some(needs_literal) = needs_literal { + if let Err(err) = self .write_bytes(format!("+ Ready for {} bytes.\r\n", needs_literal).into_bytes()) .await { self.write_error(err).await; return SessionResult::Close; - } + }} SessionResult::Continue } @@ -293,9 +293,9 @@ async fn is_allowed(&self, request: Request<Command>) -> trc::Result<Request<Command>> { let state = &self.state; // Rate limit request - if let State::Authenticated { data } | State::Selected { data, .. } = state - && let Some(rate) = &self.server.core.imap.rate_requests - && data + if let State::Authenticated { data } | State::Selected { data, .. } = state { + if let Some(rate) = &self.server.core.imap.rate_requests { + if data .server .core .storage @@ -310,7 +310,7 @@ .is_some() { return Err(trc::LimitEvent::TooManyRequests.into_err()); - } + }}} match &request.command { Command::Capability | Command::Noop | Command::Logout | Command::Id => Ok(request), --- a/crates/imap/src/core/mailbox.rs +++ b/crates/imap/src/core/mailbox.rs @@ -316,12 +316,12 @@ // Add new mailboxes for (mailbox_name, mailbox_id) in new_account.mailbox_names.iter() { if let Some(old_mailbox) = old_account.mailbox_state.get(mailbox_id) { - if let Some(mailbox) = new_account.mailbox_state.get(mailbox_id) - && (mailbox.total_messages != old_mailbox.total_messages + if let Some(mailbox) = new_account.mailbox_state.get(mailbox_id) { + if (mailbox.total_messages != old_mailbox.total_messages || mailbox.total_unseen != old_mailbox.total_unseen) { changes.changed.push(mailbox_name.clone()); - } + }} } else { changes.added.push(mailbox_name.clone()); } --- a/crates/imap/src/core/session.rs +++ b/crates/imap/src/core/session.rs @@ -28,13 +28,13 @@ session: SessionData<T>, ) -> impl std::future::Future<Output = ()> + Send { async move { - if let Ok(mut session) = Session::new(session, self).await - && session.handle_conn().await - && session.instance.acceptor.is_tls() - && let Ok(mut session) = session.into_tls().await + if let Ok(mut session) = Session::new(session, self).await { + if session.handle_conn().await { + if session.instance.acceptor.is_tls() { + if let Ok(mut session) = session.into_tls().await { session.handle_conn().await; - } + }}}} } } --- a/crates/imap/src/op/create.rs +++ b/crates/imap/src/op/create.rs @@ -85,11 +85,11 @@ for (pos, &path_item) in params.path.iter().enumerate() { let mut mailbox = email::mailbox::Mailbox::new(path_item).with_parent_id(parent_id); - if pos == params.path.len() - 1 - && let Some(mailbox_role) = arguments.mailbox_role.map(attr_to_role) + if pos == params.path.len() - 1 { + if let Some(mailbox_role) = arguments.mailbox_role.map(attr_to_role) { mailbox.role = mailbox_role; - } + }} let mailbox_id = next_document_id; next_document_id -= 1; batch --- a/crates/imap/src/op/fetch.rs +++ b/crates/imap/src/op/fetch.rs @@ -540,8 +540,8 @@ self.write_bytes(buf).await?; // Add to set flags - if set_seen_flag - && let Some(data_) = self + if set_seen_flag { + if let Some(data_) = self .server .get_archive(account_id, Collection::Email, id) .await @@ -566,7 +566,7 @@ ) .imap_ctx(&arguments.tag, trc::location!())? .commit_point(); - } + }} } // Set Seen ids @@ -940,8 +940,8 @@ None }?; - if let ArchivedMetadataPartType::Message(nested_message_id) = &part.body - && let Some(( + if let ArchivedMetadataPartType::Message(nested_message_id) = &part.body { + if let Some(( _, Section::Part { .. } | Section::Header @@ -952,7 +952,7 @@ message = self.message_id(*nested_message_id); part = message.root_part(); message_id = u16::from(nested_message_id) as usize; - } + }} } Section::Header => { return Some( --- a/crates/imap/src/op/subscribe.rs +++ b/crates/imap/src/op/subscribe.rs @@ -76,8 +76,8 @@ // Verify if mailbox is already subscribed/unsubscribed for account in self.mailboxes.lock().iter_mut() { if account.account_id == account_id { - if let Some(mailbox) = account.mailbox_state.get(&mailbox_id) - && mailbox.is_subscribed == subscribe + if let Some(mailbox) = account.mailbox_state.get(&mailbox_id) { + if mailbox.is_subscribed == subscribe { return Err(trc::ImapEvent::Error .into_err() @@ -87,7 +87,7 @@ "Mailbox is already unsubscribed." }) .id(tag)); - } + }} break; } } --- a/crates/imap/src/op/thread.rs +++ b/crates/imap/src/op/thread.rs @@ -89,11 +89,11 @@ let mut threads: AHashMap<u32, Vec<u32>> = AHashMap::new(); let state = mailbox.state.lock(); for item in &cache.emails.items { - if result_set.results.contains(item.document_id) - && let Some((imap_id, _)) = state.map_result_id(item.document_id, is_uid) + if result_set.results.contains(item.document_id) { + if let Some((imap_id, _)) = state.map_result_id(item.document_id, is_uid) { threads.entry(item.thread_id).or_default().push(imap_id); - } + }} } let mut threads = threads --- a/crates/smtp/src/inbound/data.rs +++ b/crates/smtp/src/inbound/data.rs @@ -388,8 +388,8 @@ } // Add Received-SPF header - if let Some(spf_output) = &self.data.spf_mail_from - && self + if let Some(spf_output) = &self.data.spf_mail_from { + if self .server .eval_if(&dc.add_received_spf, self, self.data.session_id) .await @@ -403,12 +403,12 @@ &self.hostname, ) .write_header(&mut headers); - } + }} // ARC Seal - if let (Some(arc_sealer), Some(arc_output)) = (arc_sealer, &arc_output) - && !dkim_output.is_empty() - && arc_output.can_be_sealed() + if let (Some(arc_sealer), Some(arc_output)) = (arc_sealer, &arc_output) { + if !dkim_output.is_empty() { + if arc_output.can_be_sealed() { match arc_sealer.seal(&auth_message, &auth_results, arc_output) { Ok(set) => { @@ -422,7 +422,7 @@ ); } } - } + }}} // Run SPAM filter if self.server.core.spam.enabled --- a/crates/smtp/src/inbound/ehlo.rs +++ b/crates/smtp/src/inbound/ehlo.rs @@ -97,8 +97,8 @@ self.server .get_trusted_sieve_script(&name, self.data.session_id) .map(|s| (s, name)) - }) - && let ScriptResult::Reject(message) = self + }) { + if let ScriptResult::Reject(message) = self .run_script( script_id, script.clone(), @@ -110,7 +110,7 @@ self.data.helo_domain = prev_helo_domain; self.data.spf_ehlo = None; return self.write(message.as_bytes()).await; - } + }} // Milter filtering if let Err(message) = self.run_milters(Stage::Ehlo, None).await { --- a/crates/smtp/src/inbound/spawn.rs +++ b/crates/smtp/src/inbound/spawn.rs @@ -46,11 +46,11 @@ if session.is_allowed().await && session.init_conn().await && session.handle_conn().await - && session.instance.acceptor.is_tls() - && let Ok(mut session) = session.into_tls().await + && session.instance.acceptor.is_tls() { + if let Ok(mut session) = session.into_tls().await { session.handle_conn().await; - } + }} } #[allow(clippy::manual_async_fn)] @@ -87,8 +87,8 @@ self.server .get_trusted_sieve_script(&name, self.data.session_id) .map(|s| (s, name)) - }) - && let ScriptResult::Reject(message) = self + }) { + if let ScriptResult::Reject(message) = self .run_script( script_id, script.clone(), @@ -98,7 +98,7 @@ { let _ = self.write(message.as_bytes()).await; return false; - } + }} // Milter filtering if let Err(message) = self.run_milters(Stage::Connect, None).await { --- a/crates/smtp/src/outbound/delivery.rs +++ b/crates/smtp/src/outbound/delivery.rs @@ -1030,8 +1030,8 @@ ); // Verify DANE - if let Some(dane_policy) = &dane_policy - && let Err(status) = dane_policy.verify( + if let Some(dane_policy) = &dane_policy { + if let Err(status) = dane_policy.verify( message.span_id, envelope.mx, smtp_client.tls_connection().peer_certificates(), @@ -1060,7 +1060,7 @@ last_status = status; continue 'next_host; - } + }} // Report TLS success if let Some(tls_report) = &tls_report { --- a/crates/smtp/src/outbound/mta_sts/lookup.rs +++ b/crates/smtp/src/outbound/mta_sts/lookup.rs @@ -59,11 +59,11 @@ }; // Check if the policy has been cached - if let Some(value) = self.inner.cache.dbs_mta_sts.get(domain) - && value.id == record.id + if let Some(value) = self.inner.cache.dbs_mta_sts.get(domain) { + if value.id == record.id { return Ok(value); - } + }} // Fetch policy #[cfg(not(feature = "test_mode"))] --- a/crates/smtp/src/outbound/mta_sts/verify.rs +++ b/crates/smtp/src/outbound/mta_sts/verify.rs @@ -22,11 +22,11 @@ } } MxPattern::StartsWith(domain) => { - if let Some((_, suffix)) = mx_host.split_once('.') - && suffix == domain + if let Some((_, suffix)) = mx_host.split_once('.') { + if suffix == domain { return true; - } + }} } } } --- a/crates/smtp/src/queue/dsn.rs +++ b/crates/smtp/src/queue/dsn.rs @@ -396,14 +396,14 @@ let now = now(); for rcpt in &mut self.message.recipients { - if !rcpt.has_flag(RCPT_DSN_SENT | RCPT_NOTIFY_NEVER) - && let Status::PermanentFailure(err) = &rcpt.status + if !rcpt.has_flag(RCPT_DSN_SENT | RCPT_NOTIFY_NEVER) { + if let Status::PermanentFailure(err) = &rcpt.status { rcpt.flags |= RCPT_DSN_SENT; let mut dsn = String::new(); err.write_dsn_text(&rcpt.address, &mut dsn); is_double_bounce.push(dsn); - } + }} if rcpt.notify.due <= now { rcpt.notify.due = rcpt @@ -529,13 +529,13 @@ } fn write_dsn_will_retry_until(&self, created: u64, dsn: &mut String) { - if let Some(expires) = self.expiration_time(created) - && expires > now() + if let Some(expires) = self.expiration_time(created) { + if expires > now() { dsn.push_str("Will-Retry-Until: "); dsn.push_str(&DateTime::from_timestamp(expires as i64).to_rfc822()); dsn.push_str("\r\n"); - } + }} } } @@ -624,11 +624,11 @@ } fn write_dsn_diagnostic(&self, dsn: &mut String) { - if let Status::PermanentFailure(err) | Status::TemporaryFailure(err) = self - && let Error::UnexpectedResponse(response) = &err.details + if let Status::PermanentFailure(err) | Status::TemporaryFailure(err) = self { + if let Error::UnexpectedResponse(response) = &err.details { response.response.write_dsn_diagnostic(dsn); - } + }} } } --- a/crates/smtp/src/reporting/tls.rs +++ b/crates/smtp/src/reporting/tls.rs @@ -303,11 +303,11 @@ continue; }; - if let Some(serialized_size) = serialized_size.as_deref_mut() - && serde::Serialize::serialize(&tls, serialized_size).is_err() + if let Some(serialized_size) = serialized_size.as_deref_mut() { + if serde::Serialize::serialize(&tls, serialized_size).is_err() { continue; - } + }} // Group duplicates let mut total_success = 0; --- a/crates/pop3/src/session.rs +++ b/crates/pop3/src/session.rs @@ -48,11 +48,11 @@ .await .is_ok() && session.handle_conn().await - && session.instance.acceptor.is_tls() - && let Ok(mut session) = session.into_tls().await + && session.instance.acceptor.is_tls() { + if let Ok(mut session) = session.into_tls().await { session.handle_conn().await; - } + }} } } @@ -189,10 +189,10 @@ trc::error!(err.span_id(self.session_id)); - if write_err && let Err(err) = self.write_bytes(response).await { + if write_err { if let Err(err) = self.write_bytes(response).await { trc::error!(err.span_id(self.session_id)); return false; - } + }} !disconnect } --- a/crates/managesieve/src/core/client.rs +++ b/crates/managesieve/src/core/client.rs @@ -132,14 +132,14 @@ } } - if let Some(needs_literal) = needs_literal - && let Err(err) = self + if let Some(needs_literal) = needs_literal { + if let Err(err) = self .write(format!("OK Ready for {} bytes.\r\n", needs_literal).as_bytes()) .await { trc::error!(err.span_id(self.session_id)); return SessionResult::Close; - } + }} SessionResult::Continue } --- a/crates/managesieve/src/core/session.rs +++ b/crates/managesieve/src/core/session.rs @@ -41,14 +41,14 @@ .await .is_ok() && session.handle_conn().await - && session.instance.acceptor.is_tls() - && let Ok(mut session) = session.into_tls().await + && session.instance.acceptor.is_tls() { + if let Ok(mut session) = session.into_tls().await { let _ = session .write(&session.handle_capability(SERVER_GREETING).await.unwrap()) .await; session.handle_conn().await; - } + }} } } --- a/crates/services/src/housekeeper/mod.rs +++ b/crates/services/src/housekeeper/mod.rs @@ -98,12 +98,12 @@ } // OTEL Push Metrics - if server.core.network.roles.push_metrics - && let Some(otel) = &server.core.metrics.otel + if server.core.network.roles.push_metrics { + if let Some(otel) = &server.core.metrics.otel { OtelMetrics::enable_errors(); queue.schedule(Instant::now() + otel.interval, ActionClass::OtelMetrics); - } + }} // Calculate expensive metrics queue.schedule(Instant::now(), ActionClass::CalculateMetrics); @@ -200,19 +200,19 @@ } if let Some(metrics_store) = enterprise.metrics_store.as_ref() - && !queue.has_action(&ActionClass::InternalMetrics) + { if !queue.has_action(&ActionClass::InternalMetrics) { queue.schedule( Instant::now() + metrics_store.interval.time_to_next(), ActionClass::InternalMetrics, ); - } + }} if !enterprise.metrics_alerts.is_empty() - && !queue.has_action(&ActionClass::AlertMetrics) + { if !queue.has_action(&ActionClass::AlertMetrics) { queue.schedule(Instant::now(), ActionClass::AlertMetrics); - } + }} } // SPDX-SnippetEnd @@ -720,17 +720,17 @@ // SPDX-License-Identifier: LicenseRef-SEL #[cfg(feature = "enterprise")] if let Some(trace_retention) = trace_retention - && let Err(err) = store.purge_spans(trace_retention).await + { if let Err(err) = store.purge_spans(trace_retention).await { trc::error!(err.details("Failed to purge tracing spans")); - } + }} #[cfg(feature = "enterprise")] if let Some(metrics_retention) = metrics_retention - && let Err(err) = store.purge_metrics(metrics_retention).await + { if let Err(err) = store.purge_metrics(metrics_retention).await { trc::error!(err.details("Failed to purge metrics")); - } + }} // SPDX-SnippetEnd } PurgeType::Blobs { store, blob_store } => { @@ -768,7 +768,7 @@ // Remove lock if let Some(lock_name) = &lock_name - && let Err(err) = self + { if let Err(err) = self .in_memory_store() .remove_lock(KV_LOCK_HOUSEKEEPER, lock_name) .await @@ -777,7 +777,7 @@ err.details("Failed to delete task lock.") .details(lock_type) ); - } + }} } } --- a/crates/services/src/state_manager/manager.rs +++ b/crates/services/src/state_manager/manager.rs @@ -75,14 +75,14 @@ .access_to .iter() .any(|(id, _)| *id == *shared_account_id) - && let Some(shared_list) = + { if let Some(shared_list) = shared_accounts_map.get_mut(shared_account_id) { shared_list.remove(&account_id); if shared_list.is_empty() { shared_accounts_map.remove(shared_account_id); } - } + }} } } @@ -139,8 +139,8 @@ } => { // Publish event to cluster if broadcast - && let Some(broadcast_tx) = &inner.ipc.broadcast_tx.clone() - && broadcast_tx + { if let Some(broadcast_tx) = &inner.ipc.broadcast_tx.clone() + { if broadcast_tx .send(BroadcastEvent::StateChange(state_change)) .await .is_err() @@ -150,7 +150,7 @@ Details = "Error sending broadcast event.", CausedBy = trc::location!() ); - } + }}} if let Some(shared_accounts) = shared_accounts_map.get(&state_change.account_id) { @@ -244,14 +244,14 @@ for subscriber_id in subscribers.keys() { if let SubscriberId::Push(push_id) = subscriber_id - && !subscriptions.iter().any(|s| { + { if !subscriptions.iter().any(|s| { matches!(s, UpdateSubscription::Verified( PushSubscription { id, .. } ) if id == push_id) }) { remove_ids.push(*subscriber_id); - } + }} } for remove_id in remove_ids { --- a/crates/migration/src/submission.rs +++ b/crates/migration/src/submission.rs @@ -237,7 +237,7 @@ fn convert_envelope_address(envelope: &Value) -> Option<Address> { if let Value::Object(envelope) = envelope - && let (Value::Text(email), Value::Object(params)) = ( + { if let (Value::Text(email), Value::Object(params)) = ( envelope.get(&Property::Email), envelope.get(&Property::Parameters), ) @@ -248,16 +248,16 @@ }; for (k, v) in params.0.iter() { if let Property::_T(k) = &k - && !k.is_empty() + { if !k.is_empty() { let k = k.to_string(); let v = v.as_string().map(|s| s.to_string()); addr.parameters.get_or_insert_default().append(k, v); - } + }} } return Some(addr); - } + }} None } --- a/crates/services/src/task_manager/imip.rs +++ b/crates/services/src/task_manager/imip.rs @@ -476,7 +476,7 @@ if let Some(guests) = fields .iter() .find(|e| e.name == ICalendarProperty::Attendee) - && let ArchivedItipValue::Participants(guests) = &guests.value + { if let ArchivedItipValue::Participants(guests) = &guests.value { variables.insert_single( CalendarTemplateVariable::AttendeesTitle, @@ -507,13 +507,13 @@ ] }), ); - } + }} // Add RSVP buttons if matches!( summary, ArchivedItipSummary::Invite(_) | ArchivedItipSummary::Update { .. } - ) && let Some(rsvp_url) = server + ) { if let Some(rsvp_url) = server .http_rsvp_url(task.account_id, task.document_id, to) .await { @@ -549,7 +549,7 @@ ] }), ); - } + }} // Add footer variables.insert_block( --- a/crates/jmap/src/changes/state.rs +++ b/crates/jmap/src/changes/state.rs @@ -49,10 +49,10 @@ ) -> trc::Result<State> { let old_state: State = self.get_state(account_id, collection).await?; if let Some(if_in_state) = if_in_state - && &old_state != if_in_state + { if &old_state != if_in_state { return Err(trc::JmapEvent::StateMismatch.into_err()); - } + }} Ok(old_state) } @@ -70,10 +70,10 @@ fn assert_state(&self, is_mailbox: bool, if_in_state: &Option<State>) -> trc::Result<State> { let old_state: State = self.get_state(is_mailbox); if let Some(if_in_state) = if_in_state - && &old_state != if_in_state + { if &old_state != if_in_state { return Err(trc::JmapEvent::StateMismatch.into_err()); - } + }} Ok(old_state) } } --- a/crates/jmap/src/mailbox/query.rs +++ b/crates/jmap/src/mailbox/query.rs @@ -183,10 +183,10 @@ response.total = Some(total); } if let Some(paginate) = &mut paginate - && paginate.limit > total + { if paginate.limit > total { paginate.limit = total; - } + }} result_set.results = filtered_ids; } } --- a/crates/jmap/src/sieve/set.rs +++ b/crates/jmap/src/sieve/set.rs @@ -391,7 +391,7 @@ } else if update .as_ref() .is_none_or(|(_, obj)| obj.inner.name != value) - && let Some(id) = self + { if let Some(id) = self .filter( ctx.resource_token.account_id, Collection::SieveScript, @@ -407,7 +407,7 @@ "A sieve script with name '{}' already exists.", value )))); - } + }} changes.name = value; } --- a/crates/jmap/src/submission/get.rs +++ b/crates/jmap/src/submission/get.rs @@ -104,7 +104,7 @@ .collect::<VecMap<_, _>>(); let mut is_pending = false; if let Some(queue_id) = submission.queue_id.as_ref().map(u64::from) - && let Some(queued_message_) = self + { if let Some(queued_message_) = self .read_message_archive(queue_id) .await .caused_by(trc::location!())? @@ -136,7 +136,7 @@ }; } is_pending = true; - } + }} let mut result = Object::with_capacity(properties.len()); for property in &properties { --- a/crates/jmap/src/submission/set.rs +++ b/crates/jmap/src/submission/set.rs @@ -512,7 +512,7 @@ if let ArchivedHeaderValue::Address(addr) = &header.value { for address in addr.iter() { if let Some(address) = address.address().and_then(sanitize_email) - && !rcpt_to.iter().any(|rcpt| rcpt.address == address) + { if !rcpt_to.iter().any(|rcpt| rcpt.address == address) { submission.envelope.rcpt_to.push(Address { email: address.to_string(), @@ -522,7 +522,7 @@ address, ..Default::default() }); - } + }} } } } @@ -697,7 +697,7 @@ for (k, v) in params.0 { if let Property::_T(k) = k - && !k.is_empty() + { if !k.is_empty() { if !params_text.is_empty() { params_text.push(' '); @@ -710,7 +710,7 @@ } else { params_list.append(k, None); } - } + }} } params_text.push('\n'); --- a/crates/jmap/src/vacation/set.rs +++ b/crates/jmap/src/vacation/set.rs @@ -316,13 +316,13 @@ } else if !will_destroy.is_empty() { for id in will_destroy { if id.is_singleton() - && let Some(document_id) = self.get_vacation_sieve_script_id(account_id).await? + { if let Some(document_id) = self.get_vacation_sieve_script_id(account_id).await? { self.sieve_script_delete(&resource_token, document_id, false, &mut batch) .await?; response.destroyed.push(id); continue; - } + }} response.not_destroyed.append(id, SetError::not_found()); } --- a/crates/http/src/auth/authenticate.rs +++ b/crates/http/src/auth/authenticate.rs @@ -160,10 +160,10 @@ } fn decode_bearer_token(token: &str, allow_api_access: bool) -> Option<Credentials<String>> { - if allow_api_access && let Some(token) = token.strip_prefix("api_").and_then(decode_plain_auth) + if allow_api_access { if let Some(token) = token.strip_prefix("api_").and_then(decode_plain_auth) { return Some(token); - } + }} Some(Credentials::OAuthBearer { token: token.to_string(), --- a/crates/http/src/autoconfig/mod.rs +++ b/crates/http/src/autoconfig/mod.rs @@ -203,19 +203,19 @@ .email_to_id(emailaddress) .await .caused_by(trc::location!())? - && let Ok(Some(principal)) = self + { if let Ok(Some(principal)) = self .core .storage .directory .query(QueryParams::id(id).with_return_member_of(false)) .await - && principal + { if principal .emails .first() .is_some_and(|email| email.eq_ignore_ascii_case(emailaddress)) { account_name = principal.name; - } + }}} Ok((account_name, self.core.network.server_name.clone(), domain)) } @@ -293,11 +293,11 @@ } if let Ok(Event::Text(text)) = reader.read_event_into(&mut buf) - && let Ok(text) = text.xml_content() - && text.contains('@') + { if let Ok(text) = text.xml_content() + { if text.contains('@') { return Ok(text.trim().to_lowercase()); - } + }}} Err(format!( "Expected email address, found unexpected value at position {}.", --- a/crates/http/src/form/mod.rs +++ b/crates/http/src/form/mod.rs @@ -51,8 +51,8 @@ ) -> trc::Result<HttpResponse> { // Validate rate if let Some(rate) = &form.rate - && !session.remote_ip.is_loopback() - && self + { if !session.remote_ip.is_loopback() + { if self .core .storage .lookup @@ -67,7 +67,7 @@ .is_some() { return Err(trc::LimitEvent::TooManyRequests.into_err()); - } + }}} // Validate honeypot if form --- a/crates/http/src/management/principal.rs +++ b/crates/http/src/management/principal.rs @@ -169,7 +169,7 @@ // Set report domain if let Some(report_domain) = report_domain - && let Err(err) = self + { if let Err(err) = self .core .storage .config @@ -177,7 +177,7 @@ .await { trc::error!(err.details("Failed to set report domain")); - } + }} // Increment revision self.invalidate_principal_caches(result.changed_principals) @@ -205,20 +205,20 @@ .split(',') { if let Some(typ) = Type::parse(typ) - && !types.contains(&typ) + { if !types.contains(&typ) { types.push(typ); - } + }} } // Parse fields let mut fields = Vec::new(); for field in params.get("fields").unwrap_or_default().split(',') { if let Some(field) = PrincipalField::try_parse(field) - && !fields.contains(&field) + { if !fields.contains(&field) { fields.push(field); - } + }} } // Validate the access token --- a/crates/http/src/management/queue.rs +++ b/crates/http/src/management/queue.rs @@ -145,7 +145,7 @@ // Limit to tenant domains #[cfg(feature = "enterprise")] if self.core.is_enterprise_edition() - && let Some(tenant) = access_token.tenant + { if let Some(tenant) = access_token.tenant { tenant_domains = self .core @@ -162,7 +162,7 @@ }) .caused_by(trc::location!())? .into(); - } + }} // SPDX-SnippetEnd --- a/crates/http/src/management/report.rs +++ b/crates/http/src/management/report.rs @@ -54,7 +54,7 @@ // Limit to tenant domains #[cfg(feature = "enterprise")] if self.core.is_enterprise_edition() - && let Some(tenant) = access_token.tenant + { if let Some(tenant) = access_token.tenant { tenant_domains = self .core @@ -71,7 +71,7 @@ }) .caused_by(trc::location!())? .into(); - } + }} // SPDX-SnippetEnd @@ -207,11 +207,11 @@ } if !batch.is_empty() - && let Err(err) = + { if let Err(err) = server.core.storage.data.write(batch.build_all()).await { trc::error!(err.caused_by(trc::location!())); - } + }} }); } --- a/crates/http/src/management/settings.rs +++ b/crates/http/src/management/settings.rs @@ -92,7 +92,7 @@ let mut ids = Vec::new(); for key in settings.keys() { if let Some(id) = key.strip_suffix(&suffix) - && !id.is_empty() + { if !id.is_empty() { if !has_filter { if offset == 0 { @@ -106,7 +106,7 @@ } else { ids.push(id); } - } + }} } // Group settings by record id @@ -319,10 +319,10 @@ return Err(trc::ManageEvent::AssertFailed.into_err()); } } else if let Some((key, _)) = values.first() - && self.core.storage.config.get(key).await?.is_some() + { if self.core.storage.config.get(key).await?.is_some() { return Err(trc::ManageEvent::AssertFailed.into_err()); - } + }} } self.core --- a/crates/http/src/request.rs +++ b/crates/http/src/request.rs @@ -558,7 +558,7 @@ "prometheus" => { if let Some(prometheus) = &self.core.metrics.prometheus { if let Some(auth) = &prometheus.auth - && req + { if req .authorization_basic() .is_none_or(|secret| secret != auth) { @@ -566,7 +566,7 @@ .into_err() .details("Invalid or missing credentials.") .caused_by(trc::location!())); - } + }} return Ok(Resource::new( "text/plain; version=0.0.4",

