Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lifetime from Proxy::request() future #146

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions elfo-core/src/actor_status.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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::<u8, ActorStatusKind>(result) }
}
}
2 changes: 1 addition & 1 deletion elfo-core/src/address_book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion elfo-core/src/message/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
Expand Down
4 changes: 2 additions & 2 deletions elfo-core/src/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub struct Local<'t> {
demux: RefCell<Demux>,
}

impl<'t> Local<'t> {
impl Local<'_> {
#[doc(hidden)]
pub fn addr(&self) -> Addr {
self.entry.addr()
Expand Down Expand Up @@ -497,7 +497,7 @@ cfg_network!({
nodes: Option<Nodes>,
}

impl<'a> RegisterRemoteGroupGuard<'a> {
impl RegisterRemoteGroupGuard<'_> {
pub fn handle_addr(&self) -> Addr {
self.handle_addr
}
Expand Down
2 changes: 1 addition & 1 deletion elfo-dumper/src/dump_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dump> {
Expand Down
2 changes: 1 addition & 1 deletion elfo-dumper/src/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ struct CompactDump<'a> {
message: Option<Cow<'a, str>>,
}

impl<'a> serde::Serialize for CompactDump<'a> {
impl serde::Serialize for CompactDump<'_> {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let field_count = 12
+ !self.dump.meta.key.is_empty() as usize // "k"
Expand Down
12 changes: 6 additions & 6 deletions elfo-logger/src/line_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 6 additions & 4 deletions elfo-test/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ impl Proxy {

/// See [`Context::request()`] for details.
#[track_caller]
pub fn request<R: Request>(&self, request: R) -> impl Future<Output = R::Response> + '_ {
pub fn request<R: Request>(&self, request: R) -> impl Future<Output = R::Response> {
let location = Location::caller();
let context = self.context.pruned();
self.scope.clone().within(async move {
let name = request.name();
match self.context.request(request).resolve().await {
match context.request(request).resolve().await {
Ok(response) => response,
Err(err) => panic!("cannot send {} ({}) at {}", name, err, location),
}
Expand All @@ -115,11 +116,12 @@ impl Proxy {
&self,
recipient: Addr,
request: R,
) -> impl Future<Output = R::Response> + '_ {
) -> impl Future<Output = R::Response> {
let location = Location::caller();
let context = self.context.pruned();
self.scope.clone().within(async move {
let name = request.name();
match self.context.request_to(recipient, request).resolve().await {
match context.request_to(recipient, request).resolve().await {
Ok(response) => response,
Err(err) => panic!("cannot send {} ({}) at {}", name, err, location),
}
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/common.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/config_validation.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use elfo::{
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/gentle_outcome.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::panic::AssertUnwindSafe;
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/mailbox_capacity.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::time::Duration;
Expand Down
2 changes: 2 additions & 0 deletions elfo/tests/message_macro.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

use serde::Serialize;
use static_assertions::*;

Expand Down
1 change: 1 addition & 0 deletions elfo/tests/msg_macro.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use elfo::{config::AnyConfig, prelude::*};
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/protocol_evolution.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "network")]

use std::collections::HashMap;
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/remote_messaging.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "network")]
#![cfg(feature = "turmoil06")]

Expand Down
1 change: 1 addition & 0 deletions elfo/tests/request_routing.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/restarting.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]
#![allow(clippy::never_loop)]

Expand Down
1 change: 1 addition & 0 deletions elfo/tests/source_delay.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::{collections::HashMap, time::Duration};
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/source_interval.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/source_signal.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/source_stream.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::{collections::HashMap, sync::Arc, time::Duration};
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/start_info.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::{num::NonZeroU64, time::Duration};
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/subscription_to_statuses.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/termination.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]
#![allow(clippy::never_loop)]

Expand Down
2 changes: 2 additions & 0 deletions elfo/tests/ui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

#[test]
fn ui() {
let t = trybuild::TestCases::new();
Expand Down
1 change: 1 addition & 0 deletions elfo/tests/update_config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "test-util")]

use serde::Deserialize;
Expand Down
Loading