From 5bbf6ed5c4eb520db615ad05942c10e642b2e4a9 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 15:34:46 +0200 Subject: [PATCH 01/10] Resolve `clippy::doc-lazy-continuation` errors --- commons/zenoh-keyexpr/src/keyexpr_tree/mod.rs | 2 +- commons/zenoh-keyexpr/src/lib.rs | 2 +- zenoh/src/api/session.rs | 4 ++-- zenoh/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/mod.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/mod.rs index 5bd0f7dae3..fd36e6fdcc 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/mod.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/mod.rs @@ -36,7 +36,7 @@ //! KeTrees come in two flavours: //! - [`KeBoxTree`] is the easier flavour. Much like a HashMap, it uniquely owns all of its nodes and data. //! - [`KeArcTree`] allows the shared ownership of nodes, allowing you to store subsections of the tree elsewhere -//! without worrying about lifetimes. +//! without worrying about lifetimes. //! //! # Usage //! KeTrees were designed to maximize code reuse. As such, their core properties are reflected through the [`IKeyExprTree`] and [`IKeyExprTreeMut`] traits. diff --git a/commons/zenoh-keyexpr/src/lib.rs b/commons/zenoh-keyexpr/src/lib.rs index 5142076b6d..03565fe63a 100644 --- a/commons/zenoh-keyexpr/src/lib.rs +++ b/commons/zenoh-keyexpr/src/lib.rs @@ -24,7 +24,7 @@ //! - [`keyexpr`] is the equivalent of a [`str`], //! - [`OwnedKeyExpr`] works like an [`Arc`](std::sync::Arc), //! - [`KeyExpr`](https://docs.rs/zenoh/latest/zenoh/key_expr/struct.KeyExpr.html) works like a [`Cow`](std::borrow::Cow), but also stores some additional context internal to Zenoh to optimize -//! routing and network usage. +//! routing and network usage. //! //! All of these types [`Deref`](core::ops::Deref) to [`keyexpr`], which notably has methods to check whether a given [`keyexpr::intersects`] with another, //! or even if a [`keyexpr::includes`] another. diff --git a/zenoh/src/api/session.rs b/zenoh/src/api/session.rs index 8a5d9e746e..a2745ecd96 100644 --- a/zenoh/src/api/session.rs +++ b/zenoh/src/api/session.rs @@ -2033,7 +2033,7 @@ impl<'s> SessionDeclarations<'s, 'static> for Arc { /// # Arguments /// /// * `key_expr` - The key expression matching the queries the - /// [`Queryable`](crate::query::Queryable) will reply to + /// [`Queryable`](crate::query::Queryable) will reply to /// /// # Examples /// ```no_run @@ -2692,7 +2692,7 @@ pub trait SessionDeclarations<'s, 'a> { /// # Arguments /// /// * `key_expr` - The key expression matching the queries the - /// [`Queryable`](crate::query::Queryable) will reply to + /// [`Queryable`](crate::query::Queryable) will reply to /// /// # Examples /// ```no_run diff --git a/zenoh/src/lib.rs b/zenoh/src/lib.rs index 86fb9e918f..02c90ce0ec 100644 --- a/zenoh/src/lib.rs +++ b/zenoh/src/lib.rs @@ -142,7 +142,7 @@ pub mod prelude; /// - [`keyexpr`](crate::key_expr::keyexpr) is the equivalent of a [`str`], /// - [`OwnedKeyExpr`](crate::key_expr::OwnedKeyExpr) works like an [`std::sync::Arc`], /// - [`KeyExpr`](crate::key_expr::KeyExpr) works like a [`std::borrow::Cow`], but also stores some additional context internal to Zenoh to optimize -/// routing and network usage. +/// routing and network usage. /// /// All of these types [`Deref`](std::ops::Deref) to [`keyexpr`](crate::key_expr::keyexpr), which notably has methods to check whether a given [`intersects`](crate::key_expr::keyexpr::includes) with another, /// or even if a [`includes`](crate::key_expr::keyexpr::includes) another. From 358fc2444ce2a1fd44058d30cc18d33131c66a78 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 15:51:22 +0200 Subject: [PATCH 02/10] Keep never-constructed logger interceptor --- zenoh/src/net/routing/interceptor/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zenoh/src/net/routing/interceptor/mod.rs b/zenoh/src/net/routing/interceptor/mod.rs index 3be30e9205..054982c736 100644 --- a/zenoh/src/net/routing/interceptor/mod.rs +++ b/zenoh/src/net/routing/interceptor/mod.rs @@ -159,6 +159,8 @@ impl InterceptorTrait for ComputeOnMiss { } } +#[allow(dead_code)] + pub(crate) struct IngressMsgLogger {} impl InterceptorTrait for IngressMsgLogger { @@ -186,6 +188,8 @@ impl InterceptorTrait for IngressMsgLogger { Some(ctx) } } + +#[allow(dead_code)] pub(crate) struct EgressMsgLogger {} impl InterceptorTrait for EgressMsgLogger { @@ -213,6 +217,7 @@ impl InterceptorTrait for EgressMsgLogger { } } +#[allow(dead_code)] pub(crate) struct LoggerInterceptor {} impl InterceptorFactoryTrait for LoggerInterceptor { From 10acad88eaa87a1a92ab349cd970be76f0dd95d1 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 15:55:18 +0200 Subject: [PATCH 03/10] Fix `target_pointer_width` usage --- zenoh/src/api/encoding.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zenoh/src/api/encoding.rs b/zenoh/src/api/encoding.rs index 7e86e9091a..bc335a5fc2 100644 --- a/zenoh/src/api/encoding.rs +++ b/zenoh/src/api/encoding.rs @@ -901,16 +901,12 @@ impl EncodingMapping for u128 { } impl EncodingMapping for usize { - #[cfg(target_pointer_width = "8")] - const ENCODING: Encoding = Encoding::ZENOH_UINT8; #[cfg(target_pointer_width = "16")] const ENCODING: Encoding = Encoding::ZENOH_UINT16; #[cfg(target_pointer_width = "32")] const ENCODING: Encoding = Encoding::ZENOH_UINT32; #[cfg(target_pointer_width = "64")] const ENCODING: Encoding = Encoding::ZENOH_UINT64; - #[cfg(target_pointer_width = "128")] - const ENCODING: Encoding = Encoding::ZENOH_UINT128; } // Zenoh signed integers From b32da8236d90ea841fb782cdeb6b878dcdfe7e6b Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 16:09:20 +0200 Subject: [PATCH 04/10] Allow unexpected `doc_auto_cfg` flag --- zenoh/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zenoh/Cargo.toml b/zenoh/Cargo.toml index 605efd16a0..968acac805 100644 --- a/zenoh/Cargo.toml +++ b/zenoh/Cargo.toml @@ -141,3 +141,6 @@ license-file = ["../LICENSE", "0"] depends = "zenohd (=0.11.0-dev-1), zenoh-plugin-rest (=0.11.0-dev-1), zenoh-plugin-storage-manager (=0.11.0-dev-1)" maintainer-scripts = ".deb" assets = [["../README.md", "README.md", "644"]] + +[lints.rust] +unexpected_cfgs = { level = "allow", check-cfg = ['cfg(doc_auto_cfg)'] } From c4d50f65d6e523a04a53cd32bcc009885b1bd7f4 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 16:09:42 +0200 Subject: [PATCH 05/10] Ignore interior mutability of `Resource` --- clippy.toml | 6 ++++++ zenoh/src/net/routing/dispatcher/resource.rs | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000000..4f0db10e79 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,6 @@ +# NOTE: Resources are hashed using their `.suffix` field without using any interior mutable fields. +# See https://github.com/eclipse-zenoh/zenoh/blob/b55c781220d7ea9f7f117570990f6e4e063e58fe/zenoh/src/net/routing/dispatcher/resource.rs#L193 +# A corresponding comment is present in the `Hash` implementation of `Ressource` as a reminder that this configuration is set. +ignore-interior-mutability = [ + "zenoh::net::routing::dispatcher::resource::Resource", +] diff --git a/zenoh/src/net/routing/dispatcher/resource.rs b/zenoh/src/net/routing/dispatcher/resource.rs index b829709bf2..f864c39049 100644 --- a/zenoh/src/net/routing/dispatcher/resource.rs +++ b/zenoh/src/net/routing/dispatcher/resource.rs @@ -188,6 +188,10 @@ impl PartialEq for Resource { } impl Eq for Resource {} +// NOTE: The `clippy::mutable_key_type` lint takes issue with the fact that `Resource` contains +// interior mutable data. A configuration option is used to assert that the accessed fields are +// not interior mutable in clippy.toml. Thus care should be taken to ensure soundness of this impl +// as Clippy will not warn about its usage in sets/maps. impl Hash for Resource { fn hash(&self, state: &mut H) { self.expr().hash(state); From 00e3eb5e95ba94742e2f168b7ba5811af6daf7b0 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 16:13:35 +0200 Subject: [PATCH 06/10] Fix typo --- clippy.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy.toml b/clippy.toml index 4f0db10e79..49436d7ba9 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,6 +1,6 @@ # NOTE: Resources are hashed using their `.suffix` field without using any interior mutable fields. # See https://github.com/eclipse-zenoh/zenoh/blob/b55c781220d7ea9f7f117570990f6e4e063e58fe/zenoh/src/net/routing/dispatcher/resource.rs#L193 -# A corresponding comment is present in the `Hash` implementation of `Ressource` as a reminder that this configuration is set. +# A corresponding comment is present in the `Hash` implementation of `Resource` as a reminder that this configuration is set. ignore-interior-mutability = [ "zenoh::net::routing::dispatcher::resource::Resource", ] From 1f167fb1dea5e5c903ffd64732234367485c45b3 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 16:22:32 +0200 Subject: [PATCH 07/10] Upgrade `time@0.3.28` to `time@0.3.36` See https://github.com/time-rs/time/issues/693 --- Cargo.lock | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04348c0dde..24a39b3d63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,7 +248,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.28", + "time 0.3.36", ] [[package]] @@ -1081,9 +1081,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] [[package]] name = "derive-new" @@ -2093,7 +2096,7 @@ dependencies = [ "regex", "serde", "serde_json", - "time 0.3.28", + "time 0.3.36", "url", "uuid", ] @@ -2476,6 +2479,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.46" @@ -2944,6 +2953,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3197,7 +3212,7 @@ dependencies = [ "pem", "ring", "rustls-pki-types", - "time 0.3.28", + "time 0.3.36", "yasna", ] @@ -4338,22 +4353,24 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", - "time-macros 0.2.14", + "time-macros 0.2.18", ] [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" @@ -4367,10 +4384,11 @@ dependencies = [ [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -5335,7 +5353,7 @@ dependencies = [ "oid-registry", "rusticata-macros", "thiserror", - "time 0.3.28", + "time 0.3.36", ] [[package]] @@ -5344,7 +5362,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.28", + "time 0.3.36", ] [[package]] From db643f9f86cada3447e5d9e9548573eb1894b9ea Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 17:38:56 +0200 Subject: [PATCH 08/10] Fix `unused_variables` and `unused_imports` errors for `shared-memory` --- zenoh/src/net/runtime/mod.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/zenoh/src/net/runtime/mod.rs b/zenoh/src/net/runtime/mod.rs index b7ba0d11da..9abb01b94e 100644 --- a/zenoh/src/net/runtime/mod.rs +++ b/zenoh/src/net/runtime/mod.rs @@ -146,22 +146,17 @@ impl RuntimeBuilder { runtime: std::sync::RwLock::new(WeakRuntime { state: Weak::new() }), }); - let transport_manager = TransportManager::builder() + let transport_manager_builder = TransportManager::builder() .from_config(&config) .await? .whatami(whatami) .zid(zid); - #[cfg(feature = "unstable")] - let transport_manager = zcondfeat!( - "shared-memory", - transport_manager.shm_reader(shm_clients.map(ShmReader::new)), - transport_manager - ) - .build(handler.clone())?; + #[cfg(feature = "shared-memory")] + let transport_manager_builder = + transport_manager_builder.shm_reader(shm_clients.map(ShmReader::new)); - #[cfg(not(feature = "unstable"))] - let transport_manager = transport_manager.build(handler.clone())?; + let transport_manager = transport_manager_builder.build(handler.clone())?; // Plugins manager #[cfg(feature = "plugins")] From bbfd9a9048fa5f91a8e0044e92e87eae00cf3457 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 25 Jul 2024 17:45:42 +0200 Subject: [PATCH 09/10] Resolve more `clippy::doc-lazy-continuation` errors --- zenoh/src/api/plugins.rs | 10 +++++----- zenohd/src/main.rs | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/zenoh/src/api/plugins.rs b/zenoh/src/api/plugins.rs index 2f51f78a85..2623ce2c6f 100644 --- a/zenoh/src/api/plugins.rs +++ b/zenoh/src/api/plugins.rs @@ -94,13 +94,13 @@ pub trait RunningPluginTrait: Send + Sync + PluginControl { /// Thus the plugin can reply its contribution to the global admin space of this zenohd. /// Parameters: /// * `key_expr`: the key_expr selector of the query. This key_expr is - /// exactly the same as it was requested by user, for example "@/ROUTER_ID/router/plugins/PLUGIN_NAME/some/plugin/info" or "@/*/router/plugins/*/foo/bar". - /// But the plugin's [RunningPluginTrait::adminspace_getter] is called only if the key_expr matches the `plugin_status_key` + /// exactly the same as it was requested by user, for example "@/ROUTER_ID/router/plugins/PLUGIN_NAME/some/plugin/info" or "@/*/router/plugins/*/foo/bar". + /// But the plugin's [RunningPluginTrait::adminspace_getter] is called only if the key_expr matches the `plugin_status_key` /// * `plugin_status_key`: the actual path to plugin's status in the admin space. For example "@/ROUTER_ID/router/plugins/PLUGIN_NAME" - /// Returns value: + /// Returns value: /// * `Ok(Vec)`: the list of responses to the query. For example if plugins can return information on subleys "foo", "bar", "foo/buzz" and "bar/buzz" - /// and it's requested with the query "@/ROUTER_ID/router/plugins/PLUGIN_NAME/*", it should return only information on "foo" and "bar" subkeys, but not on "foo/buzz" and "bar/buzz" - /// as they doesn't match the query. + /// and it's requested with the query "@/ROUTER_ID/router/plugins/PLUGIN_NAME/*", it should return only information on "foo" and "bar" subkeys, but not on "foo/buzz" and "bar/buzz" + /// as they doesn't match the query. /// * `Err(ZError)`: Problem occurred when processing the query. /// /// If plugin implements subplugins (as the storage plugin), then it should also reply with information about its subplugins with the same rules. diff --git a/zenohd/src/main.rs b/zenohd/src/main.rs index 71fa0bce34..60d898d84f 100644 --- a/zenohd/src/main.rs +++ b/zenohd/src/main.rs @@ -77,9 +77,10 @@ struct Args { /// Allows arbitrary configuration changes as column-separated KEY:VALUE pairs, where: /// - KEY must be a valid config path. /// - VALUE must be a valid JSON5 string that can be deserialized to the expected type for the KEY field. + /// /// Examples: - /// --cfg='startup/subscribe:["demo/**"]' - /// --cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}' + /// - `--cfg='startup/subscribe:["demo/**"]'` + /// - `--cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}'` #[arg(long)] cfg: Vec, /// Configure the read and/or write permissions on the admin space. Default is read only. From 68cc5fdf75f71f69af62ad3ccf3c2dba6ea7cc15 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 25 Jul 2024 18:01:54 +0200 Subject: [PATCH 10/10] Update zenoh/src/net/routing/interceptor/mod.rs --- zenoh/src/net/routing/interceptor/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/zenoh/src/net/routing/interceptor/mod.rs b/zenoh/src/net/routing/interceptor/mod.rs index 054982c736..ba0209de2d 100644 --- a/zenoh/src/net/routing/interceptor/mod.rs +++ b/zenoh/src/net/routing/interceptor/mod.rs @@ -160,7 +160,6 @@ impl InterceptorTrait for ComputeOnMiss { } #[allow(dead_code)] - pub(crate) struct IngressMsgLogger {} impl InterceptorTrait for IngressMsgLogger {