From 3992efe9ade0853ba53db3ee34f410df936fe9db Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Tue, 30 Apr 2024 09:14:33 +0000 Subject: [PATCH 1/5] Use nightly for style check Signed-off-by: Michael X. Grey --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 02a142d66..c2f9b5fa4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -64,7 +64,7 @@ jobs: run: | for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do cd $path - cargo fmt -- --check + cargo +nightly fmt -- --check cd - done From 6974c3aeb6c2fe4518656fa2e6cff6cdb6cacd84 Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Tue, 30 Apr 2024 09:27:57 +0000 Subject: [PATCH 2/5] Install nightly for cargo +nightly fmt Signed-off-by: Michael X. Grey --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c2f9b5fa4..e6f015e6d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -64,6 +64,7 @@ jobs: run: | for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do cd $path + rustup toolchain install nightly cargo +nightly fmt -- --check cd - done From 53570022db309bcd3c34ea855fe70d04d167ff3c Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Tue, 30 Apr 2024 09:34:19 +0000 Subject: [PATCH 3/5] Fix style in examples Signed-off-by: Michael X. Grey --- examples/message_demo/src/message_demo.rs | 4 +--- examples/minimal_pub_sub/src/minimal_two_nodes.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/message_demo/src/message_demo.rs b/examples/message_demo/src/message_demo.rs index 8f3bb2a63..3e2bf53b2 100644 --- a/examples/message_demo/src/message_demo.rs +++ b/examples/message_demo/src/message_demo.rs @@ -1,6 +1,4 @@ -use std::convert::TryInto; -use std::env; -use std::sync::Arc; +use std::{convert::TryInto, env, sync::Arc}; use anyhow::{Error, Result}; use rosidl_runtime_rs::{seq, BoundedSequence, Message, Sequence}; diff --git a/examples/minimal_pub_sub/src/minimal_two_nodes.rs b/examples/minimal_pub_sub/src/minimal_two_nodes.rs index ddf685bd7..fb03574a2 100644 --- a/examples/minimal_pub_sub/src/minimal_two_nodes.rs +++ b/examples/minimal_pub_sub/src/minimal_two_nodes.rs @@ -1,6 +1,10 @@ -use std::env; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::sync::{Arc, Mutex}; +use std::{ + env, + sync::{ + atomic::{AtomicU32, Ordering}, + Arc, Mutex, + }, +}; use anyhow::{Error, Result}; From 35e8bb3ee524cf4d1535e78ff73e30192f9d3c85 Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Tue, 30 Apr 2024 16:07:04 +0000 Subject: [PATCH 4/5] Update style for rosidl_runtime_rs Signed-off-by: Michael X. Grey --- rosidl_runtime_rs/src/sequence.rs | 12 +++++++----- rosidl_runtime_rs/src/string.rs | 15 ++++++++------- rosidl_runtime_rs/src/traits.rs | 3 +-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/rosidl_runtime_rs/src/sequence.rs b/rosidl_runtime_rs/src/sequence.rs index 3ac2127b8..9cc79206e 100644 --- a/rosidl_runtime_rs/src/sequence.rs +++ b/rosidl_runtime_rs/src/sequence.rs @@ -1,8 +1,10 @@ -use std::cmp::Ordering; -use std::fmt::{self, Debug, Display}; -use std::hash::{Hash, Hasher}; -use std::iter::{Extend, FromIterator, FusedIterator}; -use std::ops::{Deref, DerefMut}; +use std::{ + cmp::Ordering, + fmt::{self, Debug, Display}, + hash::{Hash, Hasher}, + iter::{Extend, FromIterator, FusedIterator}, + ops::{Deref, DerefMut}, +}; #[cfg(feature = "serde")] mod serde; diff --git a/rosidl_runtime_rs/src/string.rs b/rosidl_runtime_rs/src/string.rs index ba15851fe..74286b034 100644 --- a/rosidl_runtime_rs/src/string.rs +++ b/rosidl_runtime_rs/src/string.rs @@ -1,14 +1,15 @@ -use std::cmp::Ordering; -use std::ffi::CStr; -use std::fmt::{self, Debug, Display}; -use std::hash::{Hash, Hasher}; -use std::ops::{Deref, DerefMut}; +use std::{ + cmp::Ordering, + ffi::CStr, + fmt::{self, Debug, Display}, + hash::{Hash, Hasher}, + ops::{Deref, DerefMut}, +}; #[cfg(feature = "serde")] mod serde; -use crate::sequence::Sequence; -use crate::traits::SequenceAlloc; +use crate::{sequence::Sequence, traits::SequenceAlloc}; /// A zero-terminated UTF-8 string. /// diff --git a/rosidl_runtime_rs/src/traits.rs b/rosidl_runtime_rs/src/traits.rs index d468a42d5..15f206108 100644 --- a/rosidl_runtime_rs/src/traits.rs +++ b/rosidl_runtime_rs/src/traits.rs @@ -15,8 +15,7 @@ // DISTRIBUTION A. Approved for public release; distribution unlimited. // OPSEC #4584. // -use std::borrow::Cow; -use std::fmt::Debug; +use std::{borrow::Cow, fmt::Debug}; /// Internal trait that connects a particular `Sequence` instance to generated C functions /// that allocate and deallocate memory. From 0aaf01d9a6d469f3d4083e15717a1a0c56783456 Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Thu, 2 May 2024 09:16:42 +0000 Subject: [PATCH 5/5] Add a comment indicating that nightly release is needed for formatting Signed-off-by: Michael X. Grey --- .rustfmt.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 230ec3333..d11c488e6 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,2 +1,3 @@ +# This requires the nightly release of Rust, so when formating the repo, use +# $ cargo +nightly fmt imports_granularity = "Crate" -