From b376cb6217c173694587175567bad0b81267071f Mon Sep 17 00:00:00 2001 From: Daniil Polyakov Date: Tue, 17 Dec 2024 15:09:01 +0300 Subject: [PATCH] fix: clippy & allow missing docs in integration tests --- elfo-core/src/actor_status.rs | 11 +++++++---- elfo-core/src/address_book.rs | 2 +- elfo-core/src/message/any.rs | 2 +- elfo-core/src/topology.rs | 4 ++-- elfo-dumper/src/dump_storage.rs | 2 +- elfo-dumper/src/serializer.rs | 2 +- elfo-logger/src/line_buffer.rs | 12 ++++++------ elfo/tests/common.rs | 1 + elfo/tests/config_validation.rs | 1 + elfo/tests/gentle_outcome.rs | 1 + elfo/tests/mailbox_capacity.rs | 1 + elfo/tests/message_macro.rs | 2 ++ elfo/tests/msg_macro.rs | 1 + elfo/tests/protocol_evolution.rs | 1 + elfo/tests/remote_messaging.rs | 1 + elfo/tests/request_routing.rs | 1 + elfo/tests/restarting.rs | 1 + elfo/tests/source_delay.rs | 1 + elfo/tests/source_interval.rs | 1 + elfo/tests/source_signal.rs | 1 + elfo/tests/source_stream.rs | 1 + elfo/tests/start_info.rs | 1 + elfo/tests/subscription_to_statuses.rs | 1 + elfo/tests/termination.rs | 1 + elfo/tests/ui.rs | 2 ++ elfo/tests/update_config.rs | 1 + 26 files changed, 40 insertions(+), 16 deletions(-) diff --git a/elfo-core/src/actor_status.rs b/elfo-core/src/actor_status.rs index 9264d0bc..6d62a08f 100644 --- a/elfo-core/src/actor_status.rs +++ b/elfo-core/src/actor_status.rs @@ -1,5 +1,7 @@ -use std::sync::atomic::{self, AtomicU8}; -use std::{fmt, mem}; +use std::{ + fmt, mem, + sync::atomic::{self, AtomicU8}, +}; use serde::{Deserialize, Serialize}; @@ -142,8 +144,9 @@ impl AtomicActorStatusKind { let result = self.0.load(ordering); // SAFETY: `ActorStatusKind` has `#[repr(u8)]` annotation. The only - // place where value may be changed is `Self::store`, which consumes `ActorStatusKind`, thus, - // guarantees that possibly invalid value cannot be stored + // place where value may be changed is `Self::store`, which consumes + // `ActorStatusKind`, thus, guarantees that possibly invalid value + // cannot be stored unsafe { mem::transmute::(result) } } } diff --git a/elfo-core/src/address_book.rs b/elfo-core/src/address_book.rs index 99b29584..b4f2a783 100644 --- a/elfo-core/src/address_book.rs +++ b/elfo-core/src/address_book.rs @@ -109,7 +109,7 @@ pub(crate) struct VacantEntry<'g> { group_no: GroupNo, } -impl<'g> VacantEntry<'g> { +impl VacantEntry<'_> { pub(crate) fn insert(self, object: Object) { self.entry.insert(object) } diff --git a/elfo-core/src/message/any.rs b/elfo-core/src/message/any.rs index e0991c7e..986a01ab 100644 --- a/elfo-core/src/message/any.rs +++ b/elfo-core/src/message/any.rs @@ -347,7 +347,7 @@ struct MessageTag<'a> { name: &'a str, } -impl<'de, 'tag> de::DeserializeSeed<'de> for MessageTag<'tag> { +impl<'de> de::DeserializeSeed<'de> for MessageTag<'_> { type Value = AnyMessage; fn deserialize(self, deserializer: D) -> Result diff --git a/elfo-core/src/topology.rs b/elfo-core/src/topology.rs index 3c70299d..072f6f8e 100644 --- a/elfo-core/src/topology.rs +++ b/elfo-core/src/topology.rs @@ -194,7 +194,7 @@ pub struct Local<'t> { demux: RefCell, } -impl<'t> Local<'t> { +impl Local<'_> { #[doc(hidden)] pub fn addr(&self) -> Addr { self.entry.addr() @@ -497,7 +497,7 @@ cfg_network!({ nodes: Option, } - impl<'a> RegisterRemoteGroupGuard<'a> { + impl RegisterRemoteGroupGuard<'_> { pub fn handle_addr(&self) -> Addr { self.handle_addr } diff --git a/elfo-dumper/src/dump_storage.rs b/elfo-dumper/src/dump_storage.rs index 62a51df0..0f1af44d 100644 --- a/elfo-dumper/src/dump_storage.rs +++ b/elfo-dumper/src/dump_storage.rs @@ -328,7 +328,7 @@ impl<'a> Drain<'a> { } } -impl<'a> Iterator for Drain<'a> { +impl Iterator for Drain<'_> { type Item = Dump; fn next(&mut self) -> Option { diff --git a/elfo-dumper/src/serializer.rs b/elfo-dumper/src/serializer.rs index 07acaa0a..21d8a2dc 100644 --- a/elfo-dumper/src/serializer.rs +++ b/elfo-dumper/src/serializer.rs @@ -181,7 +181,7 @@ struct CompactDump<'a> { message: Option>, } -impl<'a> serde::Serialize for CompactDump<'a> { +impl serde::Serialize for CompactDump<'_> { fn serialize(&self, serializer: S) -> Result { let field_count = 12 + !self.dump.meta.key.is_empty() as usize // "k" diff --git a/elfo-logger/src/line_buffer.rs b/elfo-logger/src/line_buffer.rs index 86a72351..d2a6ff9a 100644 --- a/elfo-logger/src/line_buffer.rs +++ b/elfo-logger/src/line_buffer.rs @@ -20,7 +20,7 @@ struct Repr<'a> { #[derive(Debug)] pub(crate) struct TruncatingWrite<'a>(Repr<'a>); -impl<'a> Line for TruncatingWrite<'a> { +impl Line for TruncatingWrite<'_> { fn try_commit(mut self) -> bool { let add_truncated_marker = self.probe_size_limit(); @@ -51,7 +51,7 @@ impl<'a> Line for TruncatingWrite<'a> { } } -impl<'a> TruncatingWrite<'a> { +impl TruncatingWrite<'_> { fn meta_len(&self) -> usize { self.0.buf.buffer.len() - self.0.pre_start_buffer_size } @@ -61,7 +61,7 @@ impl<'a> TruncatingWrite<'a> { } } -impl<'a> TruncatingWrite<'a> { +impl TruncatingWrite<'_> { fn probe_size_limit(&mut self) -> bool { let len = self.len(); let mut need_to_erase = if len > self.0.buf.max_line_size { @@ -96,7 +96,7 @@ impl<'a> TruncatingWrite<'a> { } } -impl<'a> Drop for TruncatingWrite<'a> { +impl Drop for TruncatingWrite<'_> { fn drop(&mut self) { self.0.buf.buffer.truncate(self.0.pre_start_buffer_size); } @@ -107,7 +107,7 @@ impl<'a> Drop for TruncatingWrite<'a> { #[derive(Debug)] pub(crate) struct DirectWrite<'a>(Repr<'a>); -impl<'a> DirectWrite<'a> { +impl DirectWrite<'_> { fn len(&self) -> usize { self.0.buf.buffer.len() - self.0.pre_start_buffer_size } @@ -144,7 +144,7 @@ impl Line for DirectWrite<'_> { } } -impl<'a> Drop for DirectWrite<'a> { +impl Drop for DirectWrite<'_> { fn drop(&mut self) { self.0.buf.buffer.truncate(self.0.pre_start_buffer_size); } diff --git a/elfo/tests/common.rs b/elfo/tests/common.rs index 1476acd1..2f74108f 100644 --- a/elfo/tests/common.rs +++ b/elfo/tests/common.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] // TODO: combine tests into "it/*" +#![allow(missing_docs)] // For tests without `elfo::test::proxy`. pub(crate) fn setup_logger() { diff --git a/elfo/tests/config_validation.rs b/elfo/tests/config_validation.rs index 3a2dbff4..2b86ce1c 100644 --- a/elfo/tests/config_validation.rs +++ b/elfo/tests/config_validation.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use elfo::{ diff --git a/elfo/tests/gentle_outcome.rs b/elfo/tests/gentle_outcome.rs index 74bb6a47..3eee9f5f 100644 --- a/elfo/tests/gentle_outcome.rs +++ b/elfo/tests/gentle_outcome.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::panic::AssertUnwindSafe; diff --git a/elfo/tests/mailbox_capacity.rs b/elfo/tests/mailbox_capacity.rs index 4fd5540d..18e14fb1 100644 --- a/elfo/tests/mailbox_capacity.rs +++ b/elfo/tests/mailbox_capacity.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::time::Duration; diff --git a/elfo/tests/message_macro.rs b/elfo/tests/message_macro.rs index 8712efb6..a95188b1 100644 --- a/elfo/tests/message_macro.rs +++ b/elfo/tests/message_macro.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + use serde::Serialize; use static_assertions::*; diff --git a/elfo/tests/msg_macro.rs b/elfo/tests/msg_macro.rs index 14067ba5..8ef15c7b 100644 --- a/elfo/tests/msg_macro.rs +++ b/elfo/tests/msg_macro.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use elfo::{config::AnyConfig, prelude::*}; diff --git a/elfo/tests/protocol_evolution.rs b/elfo/tests/protocol_evolution.rs index c235aff6..6a621c41 100644 --- a/elfo/tests/protocol_evolution.rs +++ b/elfo/tests/protocol_evolution.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "network")] use std::collections::HashMap; diff --git a/elfo/tests/remote_messaging.rs b/elfo/tests/remote_messaging.rs index 1acb6e65..495a9745 100644 --- a/elfo/tests/remote_messaging.rs +++ b/elfo/tests/remote_messaging.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "network")] #![cfg(feature = "turmoil06")] diff --git a/elfo/tests/request_routing.rs b/elfo/tests/request_routing.rs index 0bfa5ace..531df1db 100644 --- a/elfo/tests/request_routing.rs +++ b/elfo/tests/request_routing.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::time::Duration; diff --git a/elfo/tests/restarting.rs b/elfo/tests/restarting.rs index 1a3a784d..3e9008e5 100644 --- a/elfo/tests/restarting.rs +++ b/elfo/tests/restarting.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] #![allow(clippy::never_loop)] diff --git a/elfo/tests/source_delay.rs b/elfo/tests/source_delay.rs index b2c7d572..fc04e2bc 100644 --- a/elfo/tests/source_delay.rs +++ b/elfo/tests/source_delay.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::{collections::HashMap, time::Duration}; diff --git a/elfo/tests/source_interval.rs b/elfo/tests/source_interval.rs index 13d6177b..c8aca62b 100644 --- a/elfo/tests/source_interval.rs +++ b/elfo/tests/source_interval.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::time::Duration; diff --git a/elfo/tests/source_signal.rs b/elfo/tests/source_signal.rs index 0cde5d3f..0f535f6d 100644 --- a/elfo/tests/source_signal.rs +++ b/elfo/tests/source_signal.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] #![cfg_attr(windows, allow(unused_imports))] // TODO: test on windows #![allow(clippy::await_holding_lock)] diff --git a/elfo/tests/source_stream.rs b/elfo/tests/source_stream.rs index 566f3583..65a4f97c 100644 --- a/elfo/tests/source_stream.rs +++ b/elfo/tests/source_stream.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::{collections::HashMap, sync::Arc, time::Duration}; diff --git a/elfo/tests/start_info.rs b/elfo/tests/start_info.rs index f73a76b6..28b407fa 100644 --- a/elfo/tests/start_info.rs +++ b/elfo/tests/start_info.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::{num::NonZeroU64, time::Duration}; diff --git a/elfo/tests/subscription_to_statuses.rs b/elfo/tests/subscription_to_statuses.rs index cd154d98..a35be523 100644 --- a/elfo/tests/subscription_to_statuses.rs +++ b/elfo/tests/subscription_to_statuses.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use std::time::Duration; diff --git a/elfo/tests/termination.rs b/elfo/tests/termination.rs index 609274ac..678dc9f4 100644 --- a/elfo/tests/termination.rs +++ b/elfo/tests/termination.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] #![allow(clippy::never_loop)] diff --git a/elfo/tests/ui.rs b/elfo/tests/ui.rs index 870c2f95..2f3501dd 100644 --- a/elfo/tests/ui.rs +++ b/elfo/tests/ui.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + #[test] fn ui() { let t = trybuild::TestCases::new(); diff --git a/elfo/tests/update_config.rs b/elfo/tests/update_config.rs index 522eb869..16ba2c6a 100644 --- a/elfo/tests/update_config.rs +++ b/elfo/tests/update_config.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "test-util")] use serde::Deserialize;