Skip to content

Commit

Permalink
Fix Clippy errors from Rust 1.80 (#1273)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fuzzypixelz authored Jul 26, 2024
1 parent 021f7c6 commit e587aa9
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 21 deletions.
42 changes: 30 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -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 `Resource` as a reminder that this configuration is set.
ignore-interior-mutability = [
"zenoh::net::routing::dispatcher::resource::Resource",
]
3 changes: 3 additions & 0 deletions zenoh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,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)'] }
2 changes: 1 addition & 1 deletion zenoh/src/key_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! - [`keyexpr`] is the equivalent of a [`str`],
//! - [`OwnedKeyExpr`] works like an [`std::sync::Arc<str>`],
//! - [`KeyExpr`] works like a [`std::borrow::Cow<str>`], 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.
Expand Down
4 changes: 4 additions & 0 deletions zenoh/src/net/routing/dispatcher/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,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<H: Hasher>(&self, state: &mut H) {
self.expr().hash(state);
Expand Down
5 changes: 5 additions & 0 deletions zenoh/src/net/routing/interceptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ impl<T: InterceptorTrait> InterceptorTrait for ComputeOnMiss<T> {
}
}

#[allow(dead_code)]

pub(crate) struct IngressMsgLogger {}

impl InterceptorTrait for IngressMsgLogger {
Expand Down Expand Up @@ -185,6 +187,8 @@ impl InterceptorTrait for IngressMsgLogger {
Some(ctx)
}
}

#[allow(dead_code)]
pub(crate) struct EgressMsgLogger {}

impl InterceptorTrait for EgressMsgLogger {
Expand Down Expand Up @@ -212,6 +216,7 @@ impl InterceptorTrait for EgressMsgLogger {
}
}

#[allow(dead_code)]
pub(crate) struct LoggerInterceptor {}

impl InterceptorFactoryTrait for LoggerInterceptor {
Expand Down
9 changes: 5 additions & 4 deletions zenoh/src/plugins/sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ pub trait RunningPluginTrait: Send + Sync + PluginControl {
/// Thus the plugin can reply its contribution to the global admin space of this zenohd.
/// Parameters:
/// * `selector`: the full selector of the query (usually only key_expr part is used). This selector is
/// 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".
/// But the plugin's [RunningPluginTrait::adminspace_getter] is called only if the selector matches the `plugin_status_key`
/// 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".
/// But the plugin's [RunningPluginTrait::adminspace_getter] is called only if the selector matches the `plugin_status_key`
/// * `plugin_status_key`: the actual path to plugin's status in the admin space. For example "@/router/ROUTER_ID/plugins/PLUGIN_NAME"
///
/// Returns value:
/// * `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"
/// 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"
/// as they doesn't match the query.
/// 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"
/// 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.
Expand Down
4 changes: 2 additions & 2 deletions zenoh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ impl<'s> SessionDeclarations<'s, 'static> for Arc<Session> {
/// # Arguments
///
/// * `key_expr` - The key expression matching the queries the
/// [`Queryable`](Queryable) will reply to
/// [`Queryable`](Queryable) will reply to
///
/// # Examples
/// ```no_run
Expand Down Expand Up @@ -2602,7 +2602,7 @@ pub trait SessionDeclarations<'s, 'a> {
/// # Arguments
///
/// * `key_expr` - The key expression matching the queries the
/// [`Queryable`](crate::queryable::Queryable) will reply to
/// [`Queryable`](crate::queryable::Queryable) will reply to
///
/// # Examples
/// ```no_run
Expand Down
5 changes: 3 additions & 2 deletions zenohd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,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<String>,
/// Configure the read and/or write permissions on the admin space. Default is read only.
Expand Down

0 comments on commit e587aa9

Please sign in to comment.