From 32249b802ca5da7eba7e0741313feaec6e536818 Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Mon, 2 Dec 2024 12:14:34 +0800 Subject: [PATCH 1/4] Update for clippy 1.83 Signed-off-by: Michael X. Grey --- rclrs/src/parameter.rs | 6 +++--- rclrs/src/publisher/loaned_message.rs | 12 ++++++------ rclrs/src/subscription/readonly_loaned_message.rs | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rclrs/src/parameter.rs b/rclrs/src/parameter.rs index 3c49993b3..2a0829eac 100644 --- a/rclrs/src/parameter.rs +++ b/rclrs/src/parameter.rs @@ -195,7 +195,7 @@ impl<'a, T: ParameterVariant> ParameterBuilder<'a, T> { } } -impl<'a, T> ParameterBuilder<'a, Arc<[T]>> +impl ParameterBuilder<'_, Arc<[T]>> where Arc<[T]>: ParameterVariant, { @@ -206,7 +206,7 @@ where } } -impl<'a> ParameterBuilder<'a, Arc<[Arc]>> { +impl ParameterBuilder<'_, Arc<[Arc]>> { /// Sets the default for the parameter from a string-like array. pub fn default_string_array(mut self, default_value: U) -> Self where @@ -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. diff --git a/rclrs/src/publisher/loaned_message.rs b/rclrs/src/publisher/loaned_message.rs index c03fc300f..7d29122dc 100644 --- a/rclrs/src/publisher/loaned_message.rs +++ b/rclrs/src/publisher/loaned_message.rs @@ -22,7 +22,7 @@ where pub(super) publisher: &'a Publisher, } -impl<'a, T> Deref for LoanedMessage<'a, T> +impl Deref for LoanedMessage<'_, T> where T: RmwMessage, { @@ -33,7 +33,7 @@ where } } -impl<'a, T> DerefMut for LoanedMessage<'a, T> +impl DerefMut for LoanedMessage<'_, T> where T: RmwMessage, { @@ -43,7 +43,7 @@ where } } -impl<'a, T> Drop for LoanedMessage<'a, T> +impl Drop for LoanedMessage<'_, T> where T: RmwMessage, { @@ -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 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 Sync for LoanedMessage<'_, T> where T: RmwMessage {} -impl<'a, T> LoanedMessage<'a, T> +impl LoanedMessage<'_, T> where T: RmwMessage, { diff --git a/rclrs/src/subscription/readonly_loaned_message.rs b/rclrs/src/subscription/readonly_loaned_message.rs index df4ad6a5b..c6f52e280 100644 --- a/rclrs/src/subscription/readonly_loaned_message.rs +++ b/rclrs/src/subscription/readonly_loaned_message.rs @@ -22,7 +22,7 @@ where pub(super) subscription: &'a Subscription, } -impl<'a, T> Deref for ReadOnlyLoanedMessage<'a, T> +impl Deref for ReadOnlyLoanedMessage<'_, T> where T: Message, { @@ -32,7 +32,7 @@ where } } -impl<'a, T> Drop for ReadOnlyLoanedMessage<'a, T> +impl Drop for ReadOnlyLoanedMessage<'_, T> where T: Message, { @@ -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 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 Sync for ReadOnlyLoanedMessage<'_, T> where T: Message {} #[cfg(test)] mod tests { From 70e86f7420b337ff9955114b133100c62436bbc0 Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Mon, 2 Dec 2024 12:28:32 +0800 Subject: [PATCH 2/4] Update clippy for cfg(test) as well Signed-off-by: Michael X. Grey --- rclrs/src/logging/logging_configuration.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rclrs/src/logging/logging_configuration.rs b/rclrs/src/logging/logging_configuration.rs index 1012608ec..7b57ad60f 100644 --- a/rclrs/src/logging/logging_configuration.rs +++ b/rclrs/src/logging/logging_configuration.rs @@ -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 { @@ -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()), From 110813aa3f34c60078071554ac1fa1c638bcde0e Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Mon, 2 Dec 2024 20:02:29 +0800 Subject: [PATCH 3/4] Exclude dependencies from clippy test Signed-off-by: Michael X. Grey --- .github/workflows/rust-minimal.yml | 4 ++-- .github/workflows/rust-stable.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust-minimal.yml b/.github/workflows/rust-minimal.yml index 9b1a5bb49..66fc3c038 100644 --- a/.github/workflows/rust-minimal.yml +++ b/.github/workflows/rust-minimal.yml @@ -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 diff --git a/.github/workflows/rust-stable.yml b/.github/workflows/rust-stable.yml index 6dc395496..944b9da27 100644 --- a/.github/workflows/rust-stable.yml +++ b/.github/workflows/rust-stable.yml @@ -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 From f91e77bc15d7453738d45b052312f52055674c9f Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Mon, 2 Dec 2024 20:42:38 +0800 Subject: [PATCH 4/4] Fix clippy for rosidl_runtime_rs Signed-off-by: Michael X. Grey --- rosidl_runtime_rs/src/string/serde.rs | 2 +- rosidl_runtime_rs/src/traits.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rosidl_runtime_rs/src/string/serde.rs b/rosidl_runtime_rs/src/string/serde.rs index fe68661b5..0ded3fd4a 100644 --- a/rosidl_runtime_rs/src/string/serde.rs +++ b/rosidl_runtime_rs/src/string/serde.rs @@ -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 { diff --git a/rosidl_runtime_rs/src/traits.rs b/rosidl_runtime_rs/src/traits.rs index 1e0908544..61d8c2392 100644 --- a/rosidl_runtime_rs/src/traits.rs +++ b/rosidl_runtime_rs/src/traits.rs @@ -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;