diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24159075a1..9bc7d8b656 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: uses: taiki-e/install-action@cargo-semver-checks - name: Code format check - run: cargo fmt --check -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate" + run: rustfmt --check --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate,skip_children=true" $(git ls-files '*.rs') - name: Clippy zenoh no-default-features run: cargo +stable clippy -p zenoh --all-targets --no-default-features -- --deny warnings @@ -186,7 +186,7 @@ jobs: - name: Check spelling uses: crate-ci/typos@master - + markdown_lint: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 0a8588c038..8f1b70afc3 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -53,7 +53,7 @@ jobs: run: rustup component add rustfmt clippy - name: Code format check - run: cargo fmt --check -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate" + run: rustfmt --check --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate,skip_children=true" $(git ls-files '*.rs') env: CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86dc1703ed..33d70d72d2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,6 @@ repos: hooks: - id: fmt name: fmt - entry: cargo fmt -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate" + entry: rustfmt --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate,skip_children=true" $(git ls-files '*.rs') language: system types: [rust] diff --git a/commons/zenoh-buffers/src/slice.rs b/commons/zenoh-buffers/src/slice.rs index 6453c47bab..d422ac9b7c 100644 --- a/commons/zenoh-buffers/src/slice.rs +++ b/commons/zenoh-buffers/src/slice.rs @@ -43,7 +43,10 @@ impl Buffer for &mut [u8] { // SplitBuffer impl<'b> SplitBuffer for &'b [u8] { - type Slices<'a> = option::IntoIter<&'a [u8]> where 'b: 'a; + type Slices<'a> + = option::IntoIter<&'a [u8]> + where + 'b: 'a; fn slices(&self) -> Self::Slices<'_> { Some(*self).into_iter() diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs index a5a16e1d82..999966000b 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs @@ -87,9 +87,19 @@ impl + AsNodeMut + 'static, S: core::hash::BuildHashe } #[cfg(feature = "std")] - type Entry<'a, 'b> = Entry<'a, OwnedKeyExpr, T> where Self: 'a, 'a: 'b, T: 'b; + type Entry<'a, 'b> + = Entry<'a, OwnedKeyExpr, T> + where + Self: 'a, + 'a: 'b, + T: 'b; #[cfg(not(feature = "std"))] - type Entry<'a, 'b> = Entry<'a, OwnedKeyExpr, T, S> where Self: 'a, 'a: 'b, T: 'b; + type Entry<'a, 'b> + = Entry<'a, OwnedKeyExpr, T, S> + where + Self: 'a, + 'a: 'b, + T: 'b; fn entry<'a, 'b>(&'a mut self, chunk: &'b keyexpr) -> Self::Entry<'a, 'b> where Self: 'a, @@ -99,7 +109,10 @@ impl + AsNodeMut + 'static, S: core::hash::BuildHashe self.entry(chunk.into()) } - type Iter<'a> = Values<'a, OwnedKeyExpr, T> where Self: 'a; + type Iter<'a> + = Values<'a, OwnedKeyExpr, T> + where + Self: 'a; fn children<'a>(&'a self) -> Self::Iter<'a> where Self: 'a, @@ -107,9 +120,10 @@ impl + AsNodeMut + 'static, S: core::hash::BuildHashe self.values() } - type IterMut<'a> = ValuesMut<'a, OwnedKeyExpr, T> -where - Self: 'a; + type IterMut<'a> + = ValuesMut<'a, OwnedKeyExpr, T> + where + Self: 'a; fn children_mut<'a>(&'a mut self) -> Self::IterMut<'a> where @@ -122,28 +136,32 @@ where self.retain(|_, v| predicate(v)); } - type Intersection<'a> = super::FilterMap, super::Intersection<'a>> + type Intersection<'a> + = super::FilterMap, super::Intersection<'a>> where Self: 'a, Self::Node: 'a; fn intersection<'a>(&'a self, key: &'a keyexpr) -> Self::Intersection<'a> { super::FilterMap::new(self.iter(), super::Intersection(key)) } - type IntersectionMut<'a> = super::FilterMap, super::Intersection<'a>> + type IntersectionMut<'a> + = super::FilterMap, super::Intersection<'a>> where Self: 'a, Self::Node: 'a; fn intersection_mut<'a>(&'a mut self, key: &'a keyexpr) -> Self::IntersectionMut<'a> { super::FilterMap::new(self.iter_mut(), super::Intersection(key)) } - type Inclusion<'a> = super::FilterMap, super::Inclusion<'a>> + type Inclusion<'a> + = super::FilterMap, super::Inclusion<'a>> where Self: 'a, Self::Node: 'a; fn inclusion<'a>(&'a self, key: &'a keyexpr) -> Self::Inclusion<'a> { super::FilterMap::new(self.iter(), super::Inclusion(key)) } - type InclusionMut<'a> = super::FilterMap, super::Inclusion<'a>> + type InclusionMut<'a> + = super::FilterMap, super::Inclusion<'a>> where Self: 'a, Self::Node: 'a; diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs index f61e509ead..4adbbdb1f5 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs @@ -65,7 +65,12 @@ impl + AsNodeMut> IChildren for KeyedSet bool { self.is_empty() } - type Entry<'a, 'b> = keyed_set::Entry<'a, T, ChunkExtractor, &'b keyexpr> where Self: 'a, 'a: 'b, T: 'b; + type Entry<'a, 'b> + = keyed_set::Entry<'a, T, ChunkExtractor, &'b keyexpr> + where + Self: 'a, + 'a: 'b, + T: 'b; fn entry<'a, 'b>(&'a mut self, chunk: &'b keyexpr) -> Self::Entry<'a, 'b> where Self: 'a, @@ -75,7 +80,10 @@ impl + AsNodeMut> IChildren for KeyedSet = keyed_set::Iter<'a, T> where Self: 'a; + type Iter<'a> + = keyed_set::Iter<'a, T> + where + Self: 'a; fn children<'a>(&'a self) -> Self::Iter<'a> where Self: 'a, @@ -83,9 +91,10 @@ impl + AsNodeMut> IChildren for KeyedSet = keyed_set::IterMut<'a, T> -where - Self: 'a; + type IterMut<'a> + = keyed_set::IterMut<'a, T> + where + Self: 'a; fn children_mut<'a>(&'a mut self) -> Self::IterMut<'a> where @@ -98,28 +107,32 @@ where self.drain_where(predicate); } - type Intersection<'a> = super::FilterMap, super::Intersection<'a>> + type Intersection<'a> + = super::FilterMap, super::Intersection<'a>> where Self: 'a, Self::Node: 'a; fn intersection<'a>(&'a self, key: &'a keyexpr) -> Self::Intersection<'a> { super::FilterMap::new(self.iter(), super::Intersection(key)) } - type IntersectionMut<'a> = super::FilterMap, super::Intersection<'a>> + type IntersectionMut<'a> + = super::FilterMap, super::Intersection<'a>> where Self: 'a, Self::Node: 'a; fn intersection_mut<'a>(&'a mut self, key: &'a keyexpr) -> Self::IntersectionMut<'a> { super::FilterMap::new(self.iter_mut(), super::Intersection(key)) } - type Inclusion<'a> = super::FilterMap, super::Inclusion<'a>> + type Inclusion<'a> + = super::FilterMap, super::Inclusion<'a>> where Self: 'a, Self::Node: 'a; fn inclusion<'a>(&'a self, key: &'a keyexpr) -> Self::Inclusion<'a> { super::FilterMap::new(self.iter(), super::Inclusion(key)) } - type InclusionMut<'a> = super::FilterMap, super::Inclusion<'a>> + type InclusionMut<'a> + = super::FilterMap, super::Inclusion<'a>> where Self: 'a, Self::Node: 'a; diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/impls/vec_set_impl.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/impls/vec_set_impl.rs index 510755e3c4..a00e7c5687 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/impls/vec_set_impl.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/impls/vec_set_impl.rs @@ -61,7 +61,12 @@ impl + AsNodeMut + 'static> IChildren for Vec { fn is_empty(&self) -> bool { self.is_empty() } - type Entry<'a, 'b> = Entry<'a, 'b, T> where Self: 'a , 'a: 'b, T: 'b; + type Entry<'a, 'b> + = Entry<'a, 'b, T> + where + Self: 'a, + 'a: 'b, + T: 'b; fn entry<'a, 'b>(&'a mut self, chunk: &'b keyexpr) -> Self::Entry<'a, 'b> where Self: 'a, @@ -75,7 +80,10 @@ impl + AsNodeMut + 'static> IChildren for Vec { } } - type Iter<'a> = core::slice::Iter<'a, T> where Self: 'a; + type Iter<'a> + = core::slice::Iter<'a, T> + where + Self: 'a; fn children<'a>(&'a self) -> Self::Iter<'a> where Self: 'a, @@ -83,9 +91,10 @@ impl + AsNodeMut + 'static> IChildren for Vec { self.iter() } - type IterMut<'a> = core::slice::IterMut<'a, T> -where - Self: 'a; + type IterMut<'a> + = core::slice::IterMut<'a, T> + where + Self: 'a; fn children_mut<'a>(&'a mut self) -> Self::IterMut<'a> where @@ -102,28 +111,32 @@ where } } - type Intersection<'a> = super::FilterMap, super::Intersection<'a>> + type Intersection<'a> + = super::FilterMap, super::Intersection<'a>> where Self: 'a, Self::Node: 'a; fn intersection<'a>(&'a self, key: &'a keyexpr) -> Self::Intersection<'a> { super::FilterMap::new(self.iter(), super::Intersection(key)) } - type IntersectionMut<'a> = super::FilterMap, super::Intersection<'a>> + type IntersectionMut<'a> + = super::FilterMap, super::Intersection<'a>> where Self: 'a, Self::Node: 'a; fn intersection_mut<'a>(&'a mut self, key: &'a keyexpr) -> Self::IntersectionMut<'a> { super::FilterMap::new(self.iter_mut(), super::Intersection(key)) } - type Inclusion<'a> = super::FilterMap, super::Inclusion<'a>> + type Inclusion<'a> + = super::FilterMap, super::Inclusion<'a>> where Self: 'a, Self::Node: 'a; fn inclusion<'a>(&'a self, key: &'a keyexpr) -> Self::Inclusion<'a> { super::FilterMap::new(self.iter(), super::Inclusion(key)) } - type InclusionMut<'a> = super::FilterMap, super::Inclusion<'a>> + type InclusionMut<'a> + = super::FilterMap, super::Inclusion<'a>> where Self: 'a, Self::Node: 'a; diff --git a/commons/zenoh-shm/src/posix_shm/segment.rs b/commons/zenoh-shm/src/posix_shm/segment.rs index 09bdb448db..9eeff20dbd 100644 --- a/commons/zenoh-shm/src/posix_shm/segment.rs +++ b/commons/zenoh-shm/src/posix_shm/segment.rs @@ -18,10 +18,9 @@ use rand::Rng; use shared_memory::{Shmem, ShmemConf, ShmemError}; use zenoh_result::{bail, zerror, ZResult}; -use crate::cleanup::CLEANUP; - #[cfg(target_os = "linux")] use super::segment_lock::unix::{ExclusiveShmLock, ShmLock}; +use crate::cleanup::CLEANUP; const SEGMENT_DEDICATE_TRIES: usize = 100; const ECMA: crc::Crc = crc::Crc::::new(&crc::CRC_64_ECMA_182);