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 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()), 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 { 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;