Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: rustfmt all files #1716

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:

- name: Check spelling
uses: crate-ci/typos@master

markdown_lint:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 4 additions & 1 deletion commons/zenoh-buffers/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
38 changes: 28 additions & 10 deletions commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,19 @@ impl<T: HasChunk + AsNode<T> + AsNodeMut<T> + '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,
Expand All @@ -99,17 +109,21 @@ impl<T: HasChunk + AsNode<T> + AsNodeMut<T> + '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,
{
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
Expand All @@ -122,28 +136,32 @@ where
self.retain(|_, v| predicate(v));
}

type Intersection<'a> = super::FilterMap<Iter<'a, OwnedKeyExpr, T>, super::Intersection<'a>>
type Intersection<'a>
= super::FilterMap<Iter<'a, OwnedKeyExpr, T>, 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<IterMut<'a, OwnedKeyExpr, T>, super::Intersection<'a>>
type IntersectionMut<'a>
= super::FilterMap<IterMut<'a, OwnedKeyExpr, T>, 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<Iter<'a, OwnedKeyExpr, T>, super::Inclusion<'a>>
type Inclusion<'a>
= super::FilterMap<Iter<'a, OwnedKeyExpr, T>, 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<IterMut<'a, OwnedKeyExpr, T>, super::Inclusion<'a>>
type InclusionMut<'a>
= super::FilterMap<IterMut<'a, OwnedKeyExpr, T>, super::Inclusion<'a>>
where
Self: 'a,
Self::Node: 'a;
Expand Down
31 changes: 22 additions & 9 deletions commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ impl<T: HasChunk + AsNode<T> + AsNodeMut<T>> IChildren<T> for KeyedSet<T, ChunkE
fn is_empty(&self) -> 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,
Expand All @@ -75,17 +80,21 @@ impl<T: HasChunk + AsNode<T> + AsNodeMut<T>> IChildren<T> for KeyedSet<T, ChunkE
self.entry(chunk)
}

type Iter<'a> = 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,
{
self.iter()
}

type IterMut<'a> = 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
Expand All @@ -98,28 +107,32 @@ where
self.drain_where(predicate);
}

type Intersection<'a> = super::FilterMap<keyed_set::Iter<'a, T>, super::Intersection<'a>>
type Intersection<'a>
= super::FilterMap<keyed_set::Iter<'a, T>, 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<keyed_set::IterMut<'a, T>, super::Intersection<'a>>
type IntersectionMut<'a>
= super::FilterMap<keyed_set::IterMut<'a, T>, 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<keyed_set::Iter<'a, T>, super::Inclusion<'a>>
type Inclusion<'a>
= super::FilterMap<keyed_set::Iter<'a, T>, 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<keyed_set::IterMut<'a, T>, super::Inclusion<'a>>
type InclusionMut<'a>
= super::FilterMap<keyed_set::IterMut<'a, T>, super::Inclusion<'a>>
where
Self: 'a,
Self::Node: 'a;
Expand Down
31 changes: 22 additions & 9 deletions commons/zenoh-keyexpr/src/keyexpr_tree/impls/vec_set_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ impl<T: HasChunk + AsNode<T> + AsNodeMut<T> + 'static> IChildren<T> for Vec<T> {
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,
Expand All @@ -75,17 +80,21 @@ impl<T: HasChunk + AsNode<T> + AsNodeMut<T> + 'static> IChildren<T> for Vec<T> {
}
}

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,
{
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
Expand All @@ -102,28 +111,32 @@ where
}
}

type Intersection<'a> = super::FilterMap<core::slice::Iter<'a, T>, super::Intersection<'a>>
type Intersection<'a>
= super::FilterMap<core::slice::Iter<'a, T>, 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<core::slice::IterMut<'a, T>, super::Intersection<'a>>
type IntersectionMut<'a>
= super::FilterMap<core::slice::IterMut<'a, T>, 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<core::slice::Iter<'a, T>, super::Inclusion<'a>>
type Inclusion<'a>
= super::FilterMap<core::slice::Iter<'a, T>, 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<core::slice::IterMut<'a, T>, super::Inclusion<'a>>
type InclusionMut<'a>
= super::FilterMap<core::slice::IterMut<'a, T>, super::Inclusion<'a>>
where
Self: 'a,
Self::Node: 'a;
Expand Down
3 changes: 1 addition & 2 deletions commons/zenoh-shm/src/posix_shm/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64> = crc::Crc::<u64>::new(&crc::CRC_64_ECMA_182);
Expand Down
Loading