From 19c22876c43808a06577895e41bb807f31107b82 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 10 May 2024 17:11:24 -0400 Subject: [PATCH] Use Associated method syntax in macros to avoid infinite recursion lint --- omniqueue/src/macros.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/omniqueue/src/macros.rs b/omniqueue/src/macros.rs index bfb580c..6f25d2b 100644 --- a/omniqueue/src/macros.rs +++ b/omniqueue/src/macros.rs @@ -3,12 +3,11 @@ macro_rules! impl_queue_consumer { $ident:ident $( <$ty:ident: $tr:path> )?, $payload:ty ) => { - #[deny(unconditional_recursion)] // method calls must defer to inherent methods impl<$($ty: $tr)?> crate::QueueConsumer for $ident<$($ty)?> { type Payload = $payload; fn receive(&mut self) -> impl std::future::Future> + Send { - self.receive() + $ident::receive(self) } fn receive_all( @@ -16,7 +15,7 @@ macro_rules! impl_queue_consumer { max_messages: usize, deadline: Duration, ) -> impl std::future::Future>> + Send { - self.receive_all(max_messages, deadline) + $ident::receive_all(self, max_messages, deadline) } } }; @@ -27,7 +26,6 @@ macro_rules! impl_queue_producer { $ident:ident $( <$ty:ident: $tr:path> )?, $payload:ty ) => { - #[deny(unconditional_recursion)] // method calls must defer to inherent methods impl<$($ty: $tr)?> crate::QueueProducer for $ident<$($ty)?> { type Payload = $payload; @@ -35,14 +33,14 @@ macro_rules! impl_queue_producer { &self, payload: &Self::Payload, ) -> impl std::future::Future> + Send { - self.send_raw(payload) + $ident::send_raw(self, payload) } fn send_serde_json( &self, payload: &P, ) -> impl std::future::Future> + Send { - self.send_serde_json(payload) + $ident::send_serde_json(self, payload) } } }; @@ -53,14 +51,13 @@ macro_rules! impl_scheduled_queue_producer { $ident:ident $( <$ty:ident: $tr:path> )?, $payload:ty ) => { - #[deny(unconditional_recursion)] // method calls must defer to inherent methods impl<$($ty: $tr)?> crate::ScheduledQueueProducer for $ident<$($ty)?> { fn send_raw_scheduled( &self, payload: &Self::Payload, delay: Duration, ) -> impl std::future::Future> + Send { - self.send_raw_scheduled(payload, delay) + $ident::send_raw_scheduled(self, payload, delay) } fn send_serde_json_scheduled( @@ -68,7 +65,7 @@ macro_rules! impl_scheduled_queue_producer { payload: &P, delay: Duration, ) -> impl std::future::Future> + Send { - self.send_serde_json_scheduled(payload, delay) + $ident::send_serde_json_scheduled(self, payload, delay) } } };