From 0da4c5ac10b5a780caae06be68ab644cdd1b5c1d Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Fri, 27 Jan 2023 13:02:23 +0100 Subject: [PATCH] Fix new Clippy 1.67.0 warns and bump Zenoh --- Cargo.lock | 52 +++++++++++++++--------------- zenoh-bridge-dds/src/main.rs | 2 +- zplugin-dds/src/config.rs | 9 +++--- zplugin-dds/src/dds_mgt.rs | 4 +-- zplugin-dds/src/lib.rs | 8 ++--- zplugin-dds/src/qos.rs | 2 +- zplugin-dds/src/ros_discovery.rs | 10 +++--- zplugin-dds/src/route_dds_zenoh.rs | 10 ++---- zplugin-dds/src/route_zenoh_dds.rs | 6 ++-- 9 files changed, 47 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af67232f..cecfb7d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3402,7 +3402,7 @@ checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "zenoh" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-global-executor", "async-std", @@ -3466,7 +3466,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "zenoh-collections", ] @@ -3474,7 +3474,7 @@ dependencies = [ [[package]] name = "zenoh-cfg-properties" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "zenoh-macros", "zenoh-result", @@ -3483,7 +3483,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "uhlc", "zenoh-buffers", @@ -3494,12 +3494,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" [[package]] name = "zenoh-config" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "flume", "json5", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "lazy_static", @@ -3529,7 +3529,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "aes 0.8.2", "hmac 0.12.1", @@ -3542,7 +3542,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "bincode", @@ -3561,7 +3561,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3581,7 +3581,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3598,7 +3598,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3622,7 +3622,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3638,7 +3638,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-rustls", "async-std", @@ -3661,7 +3661,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3680,7 +3680,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3698,7 +3698,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", @@ -3718,7 +3718,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "proc-macro2", "quote", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-rest" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "anyhow", "async-std", @@ -3757,7 +3757,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "libloading", "log", @@ -3770,7 +3770,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "hex", "rand 0.8.5", @@ -3784,7 +3784,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "anyhow", ] @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "zenoh-shm" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "bincode", "log", @@ -3805,7 +3805,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "event-listener", @@ -3820,7 +3820,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-executor", "async-global-executor", @@ -3851,7 +3851,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "0.7.0-rc" -source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#d118a2d79bb26965cb2e5c5f6c21f47f055555d2" +source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#a322f6bb055ba9cbbe7b1f95e3452eeb05847426" dependencies = [ "async-std", "async-trait", diff --git a/zenoh-bridge-dds/src/main.rs b/zenoh-bridge-dds/src/main.rs index fc486481..eb981e31 100644 --- a/zenoh-bridge-dds/src/main.rs +++ b/zenoh-bridge-dds/src/main.rs @@ -178,7 +178,7 @@ r#"--watchdog=[PERIOD] 'Experimental!! Run a watchdog thread that monitors the } if let Some(port) = args.value_of("rest-http-port") { config - .insert_json5("plugins/rest/http_port", &format!(r#""{}""#, port)) + .insert_json5("plugins/rest/http_port", &format!(r#""{port}""#)) .unwrap(); } // Always add timestamps to publications (required for PublicationCache used in case of TRANSIENT_LOCAL topics) diff --git a/zplugin-dds/src/config.rs b/zplugin-dds/src/config.rs index 904c8d55..bd291d20 100644 --- a/zplugin-dds/src/config.rs +++ b/zplugin-dds/src/config.rs @@ -120,7 +120,7 @@ where let s: String = Deserialize::deserialize(deserializer)?; Regex::new(&s) .map(Some) - .map_err(|e| de::Error::custom(format!("Invalid regex 'allow={}': {}", s, e))) + .map_err(|e| de::Error::custom(format!("Invalid regex 'allow={s}': {e}"))) } fn deserialize_max_frequencies<'de, D>(deserializer: D) -> Result, D::Error> @@ -132,14 +132,13 @@ where for s in strs { let i = s .find('=') - .ok_or_else(|| de::Error::custom(format!("Invalid 'max_frequency': {}", s)))?; + .ok_or_else(|| de::Error::custom(format!("Invalid 'max_frequency': {s}")))?; let regex = Regex::new(&s[0..i]).map_err(|e| { - de::Error::custom(format!("Invalid regex for 'max_frequency': '{}': {}", s, e)) + de::Error::custom(format!("Invalid regex for 'max_frequency': '{s}': {e}")) })?; let frequency: f32 = s[i + 1..].parse().map_err(|e| { de::Error::custom(format!( - "Invalid float value for 'max_frequency': '{}': {}", - s, e + "Invalid float value for 'max_frequency': '{s}': {e}" )) })?; result.push((regex, frequency)); diff --git a/zplugin-dds/src/dds_mgt.rs b/zplugin-dds/src/dds_mgt.rs index 2e184de1..70766059 100644 --- a/zplugin-dds/src/dds_mgt.rs +++ b/zplugin-dds/src/dds_mgt.rs @@ -374,7 +374,7 @@ pub fn delete_dds_entity(entity: dds_entity_t) -> Result<(), String> { let r = dds_delete(entity); match r { 0 | DDS_RETCODE_ALREADY_DELETED => Ok(()), - e => Err(format!("Error deleting DDS entity - retcode={}", e)), + e => Err(format!("Error deleting DDS entity - retcode={e}")), } } } @@ -386,7 +386,7 @@ pub fn get_guid(entity: &dds_entity_t) -> Result { if r == 0 { Ok(hex::encode(guid.v)) } else { - Err(format!("Error getting GUID of DDS entity - retcode={}", r)) + Err(format!("Error getting GUID of DDS entity - retcode={r}")) } } } diff --git a/zplugin-dds/src/lib.rs b/zplugin-dds/src/lib.rs index 8a489ed2..36638191 100644 --- a/zplugin-dds/src/lib.rs +++ b/zplugin-dds/src/lib.rs @@ -270,7 +270,7 @@ impl Serialize for DdsPluginRuntime<'_> { .config .max_frequencies .iter() - .map(|(re, freq)| format!("{}={}", re, freq)) + .map(|(re, freq)| format!("{re}={freq}")) .collect::>(), )?; s.serialize_field("forward_discovery", &self.config.forward_discovery)?; @@ -646,9 +646,9 @@ impl<'a> DdsPluginRuntime<'a> { ) -> ZResult { // key_expr for a topic is: "//" with and being optional match (scope, partition) { - (Some(scope), Some(part)) => scope.join(&format!("{}/{}", part, topic_name)), + (Some(scope), Some(part)) => scope.join(&format!("{part}/{topic_name}")), (Some(scope), None) => scope.join(topic_name), - (None, Some(part)) => format!("{}/{}", part, topic_name).try_into(), + (None, Some(part)) => format!("{part}/{topic_name}").try_into(), (None, None) => topic_name.try_into(), } } @@ -1272,7 +1272,7 @@ impl<'a> DdsPluginRuntime<'a> { // remove all the references to the plugin's enities, removing no longer used routes // and updating/re-publishing ParticipantEntitiesInfo let admin_space = &mut self.admin_space; - let admin_subke = format!("@/service/{}/dds/", mid); + let admin_subke = format!("@/service/{mid}/dds/"); let mut participant_info_changed = false; self.routes_to_dds.retain(|zkey, route| { route.remove_remote_routed_writers_containing(&admin_subke); diff --git a/zplugin-dds/src/qos.rs b/zplugin-dds/src/qos.rs index 6eb0a8b0..760b358d 100644 --- a/zplugin-dds/src/qos.rs +++ b/zplugin-dds/src/qos.rs @@ -535,7 +535,7 @@ fn test_qos_serialization() { let qos = Qos::from_writer_qos_native(native); let json = serde_json::to_string(&qos).unwrap(); - println!("{}", json); + println!("{json}"); let qos2 = serde_json::from_str::(&json).unwrap(); assert!(qos == qos2); diff --git a/zplugin-dds/src/ros_discovery.rs b/zplugin-dds/src/ros_discovery.rs index 12b238da..a6805fa9 100644 --- a/zplugin-dds/src/ros_discovery.rs +++ b/zplugin-dds/src/ros_discovery.rs @@ -167,7 +167,7 @@ impl RosDiscoveryInfoMgr { pub(crate) fn write(&self, info: &ParticipantEntitiesInfo) -> Result<(), String> { unsafe { let buf = cdr::serialize::<_, _, CdrLe>(info, Infinite) - .map_err(|e| format!("Error serializing ParticipantEntitiesInfo: {}", e))?; + .map_err(|e| format!("Error serializing ParticipantEntitiesInfo: {e}"))?; // create sertype (Unfortunatelly cdds_ddsi_payload_create() takes *mut ddsi_sertype. And keeping it in Self would make it not Send) let ctyn = CString::new(ROS_DISCOVERY_INFO_TOPIC_TYPE) @@ -188,7 +188,7 @@ impl RosDiscoveryInfoMgr { ddsi_serdata_kind_SDK_DATA, ptr, len.try_into().map_err(|e| { - format!("Error creating payload for ParticipantEntitiesInfo: {}", e) + format!("Error creating payload for ParticipantEntitiesInfo: {e}") })?, ); dds_writecdr(self.writer, fwdp as *mut ddsi_serdata); @@ -253,7 +253,7 @@ impl std::fmt::Display for ParticipantEntitiesInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "participant {} : [", self.gid)?; for i in self.node_entities_info_seq.values() { - write!(f, "({}), ", i)?; + write!(f, "({i}), ")?; } write!(f, "]")?; Ok(()) @@ -291,7 +291,7 @@ where S: Serializer, { let mut buf = hex::decode(gid).map_err(|e| { - serde::ser::Error::custom(format!("Failed to decode gid {} as hex: {}", gid, e)) + serde::ser::Error::custom(format!("Failed to decode gid {gid} as hex: {e}")) })?; // Gid size in ROS messages in 24 bytes (The DDS gid is usually 16 bytes). Resize the buffer buf.resize(24, 0); @@ -317,7 +317,7 @@ where let mut seq = serializer.serialize_seq(Some(gids.len()))?; for s in gids { let mut buf = hex::decode(s).map_err(|e| { - serde::ser::Error::custom(format!("Failed to decode gid {} as hex: {}", s, e)) + serde::ser::Error::custom(format!("Failed to decode gid {s} as hex: {e}")) })?; // Gid size in ROS messages in 24 bytes (The DDS gid is usually 16 bytes). Resize the buffer buf.resize(24, 0); diff --git a/zplugin-dds/src/route_dds_zenoh.rs b/zplugin-dds/src/route_dds_zenoh.rs index 11755062..5663e893 100644 --- a/zplugin-dds/src/route_dds_zenoh.rs +++ b/zplugin-dds/src/route_dds_zenoh.rs @@ -104,10 +104,7 @@ impl RouteDDSZenoh<'_> { .res() .await .map_err(|e| { - format!( - "Route Zenoh->DDS ({} -> {}): failed to declare KeyExpr: {}", - topic_name, ke, e - ) + format!("Route Zenoh->DDS ({topic_name} -> {ke}): failed to declare KeyExpr: {e}") })?; // declare the zenoh Publisher @@ -152,10 +149,7 @@ impl RouteDDSZenoh<'_> { .res() .await .map_err(|e| { - format!( - "Failed create PublicationCache for key {} (rid={}): {}", - ke, declared_ke, e - ) + format!("Failed create PublicationCache for key {ke} (rid={declared_ke}): {e}") })?; ZPublisher::PublicationCache(pub_cache) } else { diff --git a/zplugin-dds/src/route_zenoh_dds.rs b/zplugin-dds/src/route_zenoh_dds.rs index 40099d2f..7345946b 100644 --- a/zplugin-dds/src/route_zenoh_dds.rs +++ b/zplugin-dds/src/route_zenoh_dds.rs @@ -184,8 +184,7 @@ impl RouteZenohDDS<'_> { .await .map_err(|e| { format!( - "Route Zenoh->DDS ({} -> {}): failed to create QueryingSubscriber: {}", - ke, topic_name, e + "Route Zenoh->DDS ({ke} -> {topic_name}): failed to create QueryingSubscriber: {e}" ) })?; ZSubscriber::QueryingSubscriber(sub) @@ -200,8 +199,7 @@ impl RouteZenohDDS<'_> { .await .map_err(|e| { format!( - "Route Zenoh->DDS ({} -> {}): failed to create Subscriber: {}", - ke, topic_name, e + "Route Zenoh->DDS ({ke} -> {topic_name}): failed to create Subscriber: {e}" ) })?; ZSubscriber::Subscriber(sub)