Skip to content

Commit e587aa9

Browse files
authored
Fix Clippy errors from Rust 1.80 (#1273)
* Allow unexpected `doc_auto_cfg` flag * Keep never-constructed logger interceptor * Ignore interior mutability of `Resource` * Fix typo * Resolve `clippy::doc-lazy-continuation` errors * Upgrade `[email protected]` to `[email protected]` See time-rs/time#693
1 parent 021f7c6 commit e587aa9

File tree

9 files changed

+59
-21
lines changed

9 files changed

+59
-21
lines changed

Cargo.lock

Lines changed: 30 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clippy.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# NOTE: Resources are hashed using their `.suffix` field without using any interior mutable fields.
2+
# See https://github.com/eclipse-zenoh/zenoh/blob/b55c781220d7ea9f7f117570990f6e4e063e58fe/zenoh/src/net/routing/dispatcher/resource.rs#L193
3+
# A corresponding comment is present in the `Hash` implementation of `Resource` as a reminder that this configuration is set.
4+
ignore-interior-mutability = [
5+
"zenoh::net::routing::dispatcher::resource::Resource",
6+
]

zenoh/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ license-file = ["../LICENSE", "0"]
130130
depends = "zenohd (=0.11.0-dev-1), zenoh-plugin-rest (=0.11.0-dev-1), zenoh-plugin-storage-manager (=0.11.0-dev-1)"
131131
maintainer-scripts = ".deb"
132132
assets = [["../README.md", "README.md", "644"]]
133+
134+
[lints.rust]
135+
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(doc_auto_cfg)'] }

zenoh/src/key_expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! - [`keyexpr`] is the equivalent of a [`str`],
2525
//! - [`OwnedKeyExpr`] works like an [`std::sync::Arc<str>`],
2626
//! - [`KeyExpr`] works like a [`std::borrow::Cow<str>`], but also stores some additional context internal to Zenoh to optimize
27-
//! routing and network usage.
27+
//! routing and network usage.
2828
//!
2929
//! All of these types [`Deref`](core::ops::Deref) to [`keyexpr`], which notably has methods to check whether a given [`keyexpr::intersects`] with another,
3030
//! or even if a [`keyexpr::includes`] another.

zenoh/src/net/routing/dispatcher/resource.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ impl PartialEq for Resource {
185185
}
186186
impl Eq for Resource {}
187187

188+
// NOTE: The `clippy::mutable_key_type` lint takes issue with the fact that `Resource` contains
189+
// interior mutable data. A configuration option is used to assert that the accessed fields are
190+
// not interior mutable in clippy.toml. Thus care should be taken to ensure soundness of this impl
191+
// as Clippy will not warn about its usage in sets/maps.
188192
impl Hash for Resource {
189193
fn hash<H: Hasher>(&self, state: &mut H) {
190194
self.expr().hash(state);

zenoh/src/net/routing/interceptor/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ impl<T: InterceptorTrait> InterceptorTrait for ComputeOnMiss<T> {
158158
}
159159
}
160160

161+
#[allow(dead_code)]
162+
161163
pub(crate) struct IngressMsgLogger {}
162164

163165
impl InterceptorTrait for IngressMsgLogger {
@@ -185,6 +187,8 @@ impl InterceptorTrait for IngressMsgLogger {
185187
Some(ctx)
186188
}
187189
}
190+
191+
#[allow(dead_code)]
188192
pub(crate) struct EgressMsgLogger {}
189193

190194
impl InterceptorTrait for EgressMsgLogger {
@@ -212,6 +216,7 @@ impl InterceptorTrait for EgressMsgLogger {
212216
}
213217
}
214218

219+
#[allow(dead_code)]
215220
pub(crate) struct LoggerInterceptor {}
216221

217222
impl InterceptorFactoryTrait for LoggerInterceptor {

zenoh/src/plugins/sealed.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ pub trait RunningPluginTrait: Send + Sync + PluginControl {
9393
/// Thus the plugin can reply its contribution to the global admin space of this zenohd.
9494
/// Parameters:
9595
/// * `selector`: the full selector of the query (usually only key_expr part is used). This selector is
96-
/// exactly the same as it was requested by user, for example "@/router/ROUTER_ID/plugins/PLUGIN_NAME/some/plugin/info" or "@/router/*/plugins/*/foo/bar".
97-
/// But the plugin's [RunningPluginTrait::adminspace_getter] is called only if the selector matches the `plugin_status_key`
96+
/// exactly the same as it was requested by user, for example "@/router/ROUTER_ID/plugins/PLUGIN_NAME/some/plugin/info" or "@/router/*/plugins/*/foo/bar".
97+
/// But the plugin's [RunningPluginTrait::adminspace_getter] is called only if the selector matches the `plugin_status_key`
9898
/// * `plugin_status_key`: the actual path to plugin's status in the admin space. For example "@/router/ROUTER_ID/plugins/PLUGIN_NAME"
99+
///
99100
/// Returns value:
100101
/// * `Ok(Vec<Response>)`: the list of responses to the query. For example if plugins can return information on subleys "foo", "bar", "foo/buzz" and "bar/buzz"
101-
/// and it's requested with the query "@/router/ROUTER_ID/plugins/PLUGIN_NAME/*", it should return only information on "foo" and "bar" subkeys, but not on "foo/buzz" and "bar/buzz"
102-
/// as they doesn't match the query.
102+
/// and it's requested with the query "@/router/ROUTER_ID/plugins/PLUGIN_NAME/*", it should return only information on "foo" and "bar" subkeys, but not on "foo/buzz" and "bar/buzz"
103+
/// as they doesn't match the query.
103104
/// * `Err(ZError)`: Problem occurred when processing the query.
104105
///
105106
/// If plugin implements subplugins (as the storage plugin), then it should also reply with information about its subplugins with the same rules.

zenoh/src/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ impl<'s> SessionDeclarations<'s, 'static> for Arc<Session> {
20032003
/// # Arguments
20042004
///
20052005
/// * `key_expr` - The key expression matching the queries the
2006-
/// [`Queryable`](Queryable) will reply to
2006+
/// [`Queryable`](Queryable) will reply to
20072007
///
20082008
/// # Examples
20092009
/// ```no_run
@@ -2602,7 +2602,7 @@ pub trait SessionDeclarations<'s, 'a> {
26022602
/// # Arguments
26032603
///
26042604
/// * `key_expr` - The key expression matching the queries the
2605-
/// [`Queryable`](crate::queryable::Queryable) will reply to
2605+
/// [`Queryable`](crate::queryable::Queryable) will reply to
26062606
///
26072607
/// # Examples
26082608
/// ```no_run

zenohd/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ struct Args {
8181
/// Allows arbitrary configuration changes as column-separated KEY:VALUE pairs, where:
8282
/// - KEY must be a valid config path.
8383
/// - VALUE must be a valid JSON5 string that can be deserialized to the expected type for the KEY field.
84+
///
8485
/// Examples:
85-
/// --cfg='startup/subscribe:["demo/**"]'
86-
/// --cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}'
86+
/// - `--cfg='startup/subscribe:["demo/**"]'`
87+
/// - `--cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}'`
8788
#[arg(long)]
8889
cfg: Vec<String>,
8990
/// Configure the read and/or write permissions on the admin space. Default is read only.

0 commit comments

Comments
 (0)