Skip to content

automatic clippy --fix --lib corrections #507

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions rclrs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ where
let commands = node.commands().async_worker_commands();
let handle = Arc::new(ClientHandle {
rcl_client: Mutex::new(rcl_client),
node: Arc::clone(&node),
node: Arc::clone(node),
});

let board = Arc::new(Mutex::new(ClientRequestBoard::new()));
Expand All @@ -359,7 +359,7 @@ where
handle: Arc::clone(&handle),
board: Arc::clone(&board),
}),
Some(Arc::clone(&commands.get_guard_condition())),
Some(Arc::clone(commands.get_guard_condition())),
);
commands.add_to_wait_set(waitable);

Expand Down Expand Up @@ -419,7 +419,7 @@ where
self.board.lock().unwrap().execute(&self.handle)
}

fn handle(&self) -> RclPrimitiveHandle {
fn handle(&self) -> RclPrimitiveHandle<'_> {
RclPrimitiveHandle::Client(self.handle.lock())
}

Expand Down Expand Up @@ -542,7 +542,7 @@ struct ClientHandle {
}

impl ClientHandle {
fn lock(&self) -> MutexGuard<rcl_client_t> {
fn lock(&self) -> MutexGuard<'_, rcl_client_t> {
self.rcl_client.lock().unwrap()
}
}
Expand Down
11 changes: 3 additions & 8 deletions rclrs/src/executor/basic_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use crate::{
Waitable, WeakActivityListener, WorkerChannel,
};

static FAILED_TO_SEND_WORKER: &'static str =
"Failed to send the new runner. This should never happen. \
static FAILED_TO_SEND_WORKER: &str = "Failed to send the new runner. This should never happen. \
Please report this to the rclrs maintainers with a minimal reproducible example.";

/// The implementation of this runtime is based off of the async Rust reference book:
Expand Down Expand Up @@ -76,11 +75,7 @@ impl AllGuardConditions {

fn push(&self, guard_condition: Weak<GuardCondition>) {
let mut inner = self.inner.lock().unwrap();
if inner
.iter()
.find(|other| guard_condition.ptr_eq(other))
.is_some()
{
if inner.iter().any(|other| guard_condition.ptr_eq(other)) {
// This guard condition is already known
return;
}
Expand Down Expand Up @@ -351,7 +346,7 @@ impl TaskSender {
task_sender: self.task_sender.clone(),
});

if let Err(_) = self.task_sender.send(task) {
if self.task_sender.send(task).is_err() {
// This is a debug log because it is normal for this to happen while
// an executor is winding down.
log_debug!(
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/logging/log_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> LogParams<'a> {
}

/// Get the logger name
pub fn get_logger_name(&self) -> &LoggerName {
pub fn get_logger_name(&self) -> &LoggerName<'_> {
&self.logger_name
}

Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ impl NodeState {
/// Enables usage of undeclared parameters for this node.
///
/// Returns a [`Parameters`] struct that can be used to get and set all parameters.
pub fn use_undeclared_parameters(&self) -> Parameters {
pub fn use_undeclared_parameters(&self) -> Parameters<'_> {
self.parameter.allow_undeclared();
Parameters {
interface: &self.parameter,
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/node/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ mod tests {

let check_rosout = |topics: HashMap<String, Vec<String>>| {
// rosout shows up in humble and iron, even if the graph is empty
#[cfg(any(ros_distro = "humble"))]
#[cfg(ros_distro = "humble")]
{
assert_eq!(topics.len(), 1);
assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/node/node_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,10 @@ impl<'a> NodeOptions<'a> {
)
};
commands.add_to_wait_set(graph_change_waitable);
let _ = commands.run(node_graph_task(
drop(commands.run(node_graph_task(
graph_change_receiver,
graph_change_guard_condition,
));
)));

let node = Arc::new(NodeState {
time_source: TimeSource::builder(self.clock_type)
Expand All @@ -396,7 +396,7 @@ impl<'a> NodeOptions<'a> {
parameter,
logger: Logger::new(logger_name)?,
graph_change_action,
commands: Arc::clone(&commands),
commands: Arc::clone(commands),
handle,
});
node.time_source.attach_node(&node);
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/parameter/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn list_parameters(req: ListParameters_Request, map: &ParameterMap) -> ListParam
.keys()
.filter_map(|name| {
let name: rosidl_runtime_rs::String = name.clone().into();
if req.prefixes.len() == 0 && check_parameter_name_depth(&name[..]) {
if req.prefixes.is_empty() && check_parameter_name_depth(&name[..]) {
return Some(name);
}
req.prefixes
Expand Down
8 changes: 4 additions & 4 deletions rclrs/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ where

let handle = Arc::new(ServiceHandle {
rcl_service: Mutex::new(rcl_service),
node_handle: Arc::clone(&node_handle),
node_handle: Arc::clone(node_handle),
});

let (waitable, lifecycle) = Waitable::new(
Box::new(ServiceExecutable::<T, Scope> {
handle: Arc::clone(&handle),
callback: Arc::clone(&callback),
commands: Arc::clone(&commands),
commands: Arc::clone(commands),
}),
Some(Arc::clone(commands.get_guard_condition())),
);
Expand Down Expand Up @@ -260,7 +260,7 @@ where
RclPrimitiveKind::Service
}

fn handle(&self) -> RclPrimitiveHandle {
fn handle(&self) -> RclPrimitiveHandle<'_> {
RclPrimitiveHandle::Service(self.handle.lock())
}
}
Expand All @@ -280,7 +280,7 @@ pub struct ServiceHandle {
}

impl ServiceHandle {
fn lock(&self) -> MutexGuard<rcl_service_t> {
fn lock(&self) -> MutexGuard<'_, rcl_service_t> {
self.rcl_service.lock().unwrap()
}

Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/service/any_service_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
commands: &Arc<WorkerCommands>,
) -> Result<(), RclrsError> {
match self {
Self::Node(node) => node.execute(Arc::clone(&handle), commands),
Self::Node(node) => node.execute(Arc::clone(handle), commands),
Self::Worker(worker) => worker.execute(handle, payload),
}
}
Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/service/node_service_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T: Service> NodeServiceCallback<T> {
if let Err(err) =
handle.send_response::<T>(&mut rmw_request_id, response.await)
{
log_service_send_error(&*handle, rmw_request_id, err);
log_service_send_error(&handle, rmw_request_id, err);
}
});
}
Expand All @@ -49,7 +49,7 @@ impl<T: Service> NodeServiceCallback<T> {
if let Err(err) =
handle.send_response::<T>(&mut rmw_request_id, response.await)
{
log_service_send_error(&*handle, rmw_request_id, err);
log_service_send_error(&handle, rmw_request_id, err);
}
});
}
Expand All @@ -62,7 +62,7 @@ impl<T: Service> NodeServiceCallback<T> {
if let Err(err) =
handle.send_response::<T>(&mut rmw_request_id, response.await)
{
log_service_send_error(&*handle, rmw_request_id, err);
log_service_send_error(&handle, rmw_request_id, err);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions rclrs/src/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ where
RclPrimitiveKind::Subscription
}

fn handle(&self) -> RclPrimitiveHandle {
fn handle(&self) -> RclPrimitiveHandle<'_> {
RclPrimitiveHandle::Subscription(self.handle.lock())
}
}
Expand All @@ -292,7 +292,7 @@ struct SubscriptionHandle {
}

impl SubscriptionHandle {
fn lock(&self) -> MutexGuard<rcl_subscription_t> {
fn lock(&self) -> MutexGuard<'_, rcl_subscription_t> {
self.rcl_subscription.lock().unwrap()
}

Expand Down
4 changes: 2 additions & 2 deletions rclrs/src/wait_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl WaitSet {

// For the remaining entities, check if they were activated and then run
// the callback for those that were.
for waiter in self.primitives.values_mut().flat_map(|v| v) {
for waiter in self.primitives.values_mut().flatten() {
if waiter.is_ready(&self.handle.rcl_wait_set) {
f(&mut *waiter.primitive)?;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ impl WaitSet {
///
/// [1]: crate::RclReturnCode
fn register_rcl_primitives(&mut self) -> Result<(), RclrsError> {
for entity in self.primitives.values_mut().flat_map(|c| c) {
for entity in self.primitives.values_mut().flatten() {
entity.add_to_wait_set(&mut self.handle.rcl_wait_set)?;
}
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/wait_set/guard_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl GuardCondition {

let handle = Arc::new(GuardConditionHandle {
rcl_guard_condition,
context_handle: Arc::clone(&context),
context_handle: Arc::clone(context),
});

let (waitable, lifecycle) = Waitable::new(
Expand Down Expand Up @@ -105,7 +105,7 @@ impl GuardCondition {

let handle = Arc::new(GuardConditionHandle {
rcl_guard_condition,
context_handle: Arc::clone(&context),
context_handle: Arc::clone(context),
});

let (waitable, lifecycle) = Waitable::new(
Expand Down Expand Up @@ -216,7 +216,7 @@ impl RclPrimitive for GuardConditionExecutable {
RclPrimitiveKind::GuardCondition
}

fn handle(&self) -> RclPrimitiveHandle {
fn handle(&self) -> RclPrimitiveHandle<'_> {
RclPrimitiveHandle::GuardCondition(self.handle.rcl_guard_condition.lock().unwrap())
}
}
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/wait_set/rcl_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait RclPrimitive: Send + Sync {
fn kind(&self) -> RclPrimitiveKind;

/// Provide the handle for this primitive
fn handle(&self) -> RclPrimitiveHandle;
fn handle(&self) -> RclPrimitiveHandle<'_>;
}

/// Enum to describe the kind of an executable.
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/wait_set/wait_set_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl WaitSetRunner {
let (sender, promise) = channel();
std::thread::spawn(move || {
let result = self.run_blocking(conditions);
if let Err(_) = sender.send((self, result)) {
if sender.send((self, result)).is_err() {
// This is a debug log because this is a normal thing to occur
// when an executor is winding down.
log_debug!(
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/wait_set/waitable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Waitable {
rcl_wait_set_add_subscription(wait_set, &*handle, &mut index)
}
RclPrimitiveHandle::GuardCondition(handle) => handle.use_handle(|handle| {
rcl_wait_set_add_guard_condition(wait_set, &*handle, &mut index)
rcl_wait_set_add_guard_condition(wait_set, handle, &mut index)
}),
RclPrimitiveHandle::Service(handle) => {
rcl_wait_set_add_service(wait_set, &*handle, &mut index)
Expand Down
Loading