Skip to content

Commit 00df505

Browse files
authored
fix: add explicit lifetimes to fix mismatched_lifetime_syntaxes warnings (#564)
Add explicit '_ lifetime annotations to return types where &self implies a lifetime but the return type uses elision to hide it. This addresses the mismatched_lifetime_syntaxes lint enabled by default in recent Rust versions. Fixes 16 warnings across 11 files: - RclPrimitive::handle() trait and all implementations - Various lock() methods returning MutexGuard - NodeState::use_undeclared_parameters() returning Parameters - LogParams::get_logger_name() returning &LoggerName Closes #558
1 parent 7517fb7 commit 00df505

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

rclrs/src/action/action_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ impl<A: Action> RclPrimitive for ActionClientExecutable<A> {
847847
RclPrimitiveKind::ActionClient
848848
}
849849

850-
fn handle(&self) -> crate::RclPrimitiveHandle {
850+
fn handle(&self) -> crate::RclPrimitiveHandle<'_> {
851851
RclPrimitiveHandle::ActionClient(self.board.handle.lock())
852852
}
853853
}
@@ -863,7 +863,7 @@ pub struct ActionClientHandle {
863863
}
864864

865865
impl ActionClientHandle {
866-
fn lock(&self) -> MutexGuard<rcl_action_client_t> {
866+
fn lock(&self) -> MutexGuard<'_, rcl_action_client_t> {
867867
self.rcl_action_client.lock().unwrap()
868868
}
869869

rclrs/src/action/action_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<A: Action> RclPrimitive for ActionServerExecutable<A> {
662662
RclPrimitiveKind::ActionServer
663663
}
664664

665-
fn handle(&self) -> RclPrimitiveHandle {
665+
fn handle(&self) -> RclPrimitiveHandle<'_> {
666666
RclPrimitiveHandle::ActionServer(self.board.handle.lock())
667667
}
668668
}
@@ -687,7 +687,7 @@ pub(crate) struct ActionServerHandle<A: Action> {
687687
unsafe impl Send for rcl_action_server_t {}
688688

689689
impl<A: Action> ActionServerHandle<A> {
690-
pub(super) fn lock(&self) -> MutexGuard<rcl_action_server_t> {
690+
pub(super) fn lock(&self) -> MutexGuard<'_, rcl_action_server_t> {
691691
self.rcl_action_server.lock().unwrap()
692692
}
693693

rclrs/src/action/action_server/action_server_goal_handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<A: Action> ActionServerGoalHandle<A> {
3131
}
3232
}
3333

34-
pub(super) fn lock(&self) -> MutexGuard<rcl_action_goal_handle_t> {
34+
pub(super) fn lock(&self) -> MutexGuard<'_, rcl_action_goal_handle_t> {
3535
self.rcl_handle.lock().unwrap()
3636
}
3737

rclrs/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ where
420420
self.board.lock().unwrap().execute(&self.handle)
421421
}
422422

423-
fn handle(&self) -> RclPrimitiveHandle {
423+
fn handle(&self) -> RclPrimitiveHandle<'_> {
424424
RclPrimitiveHandle::Client(self.handle.lock())
425425
}
426426

@@ -543,7 +543,7 @@ struct ClientHandle {
543543
}
544544

545545
impl ClientHandle {
546-
fn lock(&self) -> MutexGuard<rcl_client_t> {
546+
fn lock(&self) -> MutexGuard<'_, rcl_client_t> {
547547
self.rcl_client.lock().unwrap()
548548
}
549549
}

rclrs/src/logging/log_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a> LogParams<'a> {
3636
}
3737

3838
/// Get the logger name
39-
pub fn get_logger_name(&self) -> &LoggerName {
39+
pub fn get_logger_name(&self) -> &LoggerName<'_> {
4040
&self.logger_name
4141
}
4242

rclrs/src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ impl NodeState {
14051405
/// Enables usage of undeclared parameters for this node.
14061406
///
14071407
/// Returns a [`Parameters`] struct that can be used to get and set all parameters.
1408-
pub fn use_undeclared_parameters(&self) -> Parameters {
1408+
pub fn use_undeclared_parameters(&self) -> Parameters<'_> {
14091409
self.parameter.allow_undeclared();
14101410
Parameters {
14111411
interface: &self.parameter,

rclrs/src/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ where
265265
RclPrimitiveKind::Service
266266
}
267267

268-
fn handle(&self) -> RclPrimitiveHandle {
268+
fn handle(&self) -> RclPrimitiveHandle<'_> {
269269
RclPrimitiveHandle::Service(self.handle.lock())
270270
}
271271
}
@@ -285,7 +285,7 @@ pub struct ServiceHandle {
285285
}
286286

287287
impl ServiceHandle {
288-
fn lock(&self) -> MutexGuard<rcl_service_t> {
288+
fn lock(&self) -> MutexGuard<'_, rcl_service_t> {
289289
self.rcl_service.lock().unwrap()
290290
}
291291

rclrs/src/subscription.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ where
291291
RclPrimitiveKind::Subscription
292292
}
293293

294-
fn handle(&self) -> RclPrimitiveHandle {
294+
fn handle(&self) -> RclPrimitiveHandle<'_> {
295295
RclPrimitiveHandle::Subscription(self.handle.lock())
296296
}
297297
}
@@ -311,7 +311,7 @@ pub(crate) struct SubscriptionHandle {
311311
}
312312

313313
impl SubscriptionHandle {
314-
pub(crate) fn lock(&self) -> MutexGuard<rcl_subscription_t> {
314+
pub(crate) fn lock(&self) -> MutexGuard<'_, rcl_subscription_t> {
315315
self.rcl_subscription.lock().unwrap()
316316
}
317317

rclrs/src/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl<Scope: WorkScope> RclPrimitive for TimerExecutable<Scope> {
506506
RclPrimitiveKind::Timer
507507
}
508508

509-
fn handle(&self) -> RclPrimitiveHandle {
509+
fn handle(&self) -> RclPrimitiveHandle<'_> {
510510
RclPrimitiveHandle::Timer(self.handle.rcl_timer.lock().unwrap())
511511
}
512512
}

rclrs/src/wait_set/guard_condition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl RclPrimitive for GuardConditionExecutable {
218218
RclPrimitiveKind::GuardCondition
219219
}
220220

221-
fn handle(&self) -> RclPrimitiveHandle {
221+
fn handle(&self) -> RclPrimitiveHandle<'_> {
222222
RclPrimitiveHandle::GuardCondition(self.handle.rcl_guard_condition.lock().unwrap())
223223
}
224224
}

0 commit comments

Comments
 (0)