Skip to content

Commit

Permalink
Update for clippy 1.83 (#441)
Browse files Browse the repository at this point in the history
* Update for clippy 1.83

Signed-off-by: Michael X. Grey <[email protected]>

* Update clippy for cfg(test) as well

Signed-off-by: Michael X. Grey <[email protected]>

* Exclude dependencies from clippy test

Signed-off-by: Michael X. Grey <[email protected]>

* Fix clippy for rosidl_runtime_rs

Signed-off-by: Michael X. Grey <[email protected]>

---------

Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey authored Dec 2, 2024
1 parent a604ad7 commit 3eba2b0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ jobs:
echo "Running clippy in $path"
# Run clippy for all features except generate_docs (needed for docs.rs)
if [ "$(basename $path)" = "rclrs" ]; then
cargo clippy --all-targets -F default,dyn_msg -- -D warnings
cargo clippy --no-deps --all-targets -F default,dyn_msg -- -D warnings
else
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --no-deps --all-targets --all-features -- -D warnings
fi
cd -
done
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ jobs:
echo "Running clippy in $path"
# Run clippy for all features except generate_docs (needed for docs.rs)
if [ "$(basename $path)" = "rclrs" ]; then
cargo clippy --all-targets -F default,dyn_msg -- -D warnings
cargo clippy --no-deps --all-targets -F default,dyn_msg -- -D warnings
else
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --no-deps --all-targets --all-features -- -D warnings
fi
cd -
done
Expand Down
4 changes: 2 additions & 2 deletions rclrs/src/logging/logging_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub(crate) mod log_handler {
pub(crate) message: Cow<'a, str>,
}

impl<'a> LogEntry<'a> {
impl LogEntry<'_> {
/// Change the entry from something borrowed into something owned
pub(crate) fn into_owned(self) -> LogEntry<'static> {
LogEntry {
Expand All @@ -124,7 +124,7 @@ pub(crate) mod log_handler {
pub line_number: usize,
}

impl<'a> LogLocation<'a> {
impl LogLocation<'_> {
pub(crate) fn into_owned(self) -> LogLocation<'static> {
LogLocation {
function_name: Cow::Owned(self.function_name.into_owned()),
Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'a, T: ParameterVariant> ParameterBuilder<'a, T> {
}
}

impl<'a, T> ParameterBuilder<'a, Arc<[T]>>
impl<T> ParameterBuilder<'_, Arc<[T]>>
where
Arc<[T]>: ParameterVariant,
{
Expand All @@ -206,7 +206,7 @@ where
}
}

impl<'a> ParameterBuilder<'a, Arc<[Arc<str>]>> {
impl ParameterBuilder<'_, Arc<[Arc<str>]>> {
/// Sets the default for the parameter from a string-like array.
pub fn default_string_array<U>(mut self, default_value: U) -> Self
where
Expand Down Expand Up @@ -679,7 +679,7 @@ impl std::fmt::Display for DeclarationError {

impl std::error::Error for DeclarationError {}

impl<'a> Parameters<'a> {
impl Parameters<'_> {
/// Tries to read a parameter of the requested type.
///
/// Returns `Some(T)` if a parameter of the requested type exists, `None` otherwise.
Expand Down
12 changes: 6 additions & 6 deletions rclrs/src/publisher/loaned_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where
pub(super) publisher: &'a Publisher<T>,
}

impl<'a, T> Deref for LoanedMessage<'a, T>
impl<T> Deref for LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand All @@ -33,7 +33,7 @@ where
}
}

impl<'a, T> DerefMut for LoanedMessage<'a, T>
impl<T> DerefMut for LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand All @@ -43,7 +43,7 @@ where
}
}

impl<'a, T> Drop for LoanedMessage<'a, T>
impl<T> Drop for LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand All @@ -66,11 +66,11 @@ where

// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
// they are running in. Therefore, this type can be safely sent to another thread.
unsafe impl<'a, T> Send for LoanedMessage<'a, T> where T: RmwMessage {}
unsafe impl<T> Send for LoanedMessage<'_, T> where T: RmwMessage {}
// SAFETY: There is no interior mutability in this type. All mutation happens through &mut references.
unsafe impl<'a, T> Sync for LoanedMessage<'a, T> where T: RmwMessage {}
unsafe impl<T> Sync for LoanedMessage<'_, T> where T: RmwMessage {}

impl<'a, T> LoanedMessage<'a, T>
impl<T> LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand Down
8 changes: 4 additions & 4 deletions rclrs/src/subscription/readonly_loaned_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where
pub(super) subscription: &'a Subscription<T>,
}

impl<'a, T> Deref for ReadOnlyLoanedMessage<'a, T>
impl<T> Deref for ReadOnlyLoanedMessage<'_, T>
where
T: Message,
{
Expand All @@ -32,7 +32,7 @@ where
}
}

impl<'a, T> Drop for ReadOnlyLoanedMessage<'a, T>
impl<T> Drop for ReadOnlyLoanedMessage<'_, T>
where
T: Message,
{
Expand All @@ -50,9 +50,9 @@ where

// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
// they are running in. Therefore, this type can be safely sent to another thread.
unsafe impl<'a, T> Send for ReadOnlyLoanedMessage<'a, T> where T: Message {}
unsafe impl<T> Send for ReadOnlyLoanedMessage<'_, T> where T: Message {}
// SAFETY: This type has no interior mutability, in fact it has no mutability at all.
unsafe impl<'a, T> Sync for ReadOnlyLoanedMessage<'a, T> where T: Message {}
unsafe impl<T> Sync for ReadOnlyLoanedMessage<'_, T> where T: Message {}

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion rosidl_runtime_rs/src/string/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
struct StringVisitor;
struct WStringVisitor;

impl<'de> Visitor<'de> for StringVisitor {
impl Visitor<'_> for StringVisitor {
type Value = String;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
5 changes: 3 additions & 2 deletions rosidl_runtime_rs/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ pub trait RmwMessage: Clone + Debug + Default + Send + Sync + Message {
///
/// Memory ownership by C is achieved by calling `init()` when any string or sequence is created,
/// as well as in the `Default` impl for messages.
///
/// User code can still create messages explicitly, which will not call `init()`, but this is not a
/// problem, since nothing is allocated this way.
/// problem, since nothing is allocated this way.
///
/// The `Drop` impl for any sequence or string will call `fini()`.
pub trait Message: Clone + Debug + Default + 'static + Send + Sync {
/// The corresponding RMW-native message type.
type RmwMsg: RmwMessage;
Expand Down

0 comments on commit 3eba2b0

Please sign in to comment.