From a003dd2f8d82a7efa345406ea24a16ff37bb6bd8 Mon Sep 17 00:00:00 2001 From: prabhaks Date: Fri, 10 Jul 2026 20:03:29 -0700 Subject: [PATCH] chore: fix clippy lints for rust 1.97 Rust/clippy 1.97 introduced new lints that now fail the CI clippy check (`cargo hack clippy --each-feature -- -D warnings`) against existing code: - for_kv_map: iterate `map.values()` instead of `map.iter()` with an unused key - useless_borrows_in_formatting: drop the redundant `&` in `format!` arguments - cloned_ref_to_slice_refs: use `std::slice::from_ref(x)` instead of `&[x.to_string()]` - collapse a `match` on a `Result` into the `?` operator These are mechanical, behavior-preserving fixes (mostly via `cargo clippy --fix`). No functional change. Co-Authored-By: Claude Opus 4.8 --- src/alerts/target.rs | 2 +- src/connectors/kafka/metrics.rs | 2 +- src/handlers/airplane.rs | 2 +- src/handlers/http/alerts.rs | 2 +- src/handlers/http/cluster/mod.rs | 2 +- src/metastore/metastores/object_store_metastore.rs | 6 +++--- src/metrics/prom_utils.rs | 4 ++-- src/parseable/streams.rs | 10 ++++------ src/query/listing_table_builder.rs | 2 +- src/rbac/mod.rs | 4 ++-- src/sse/mod.rs | 2 +- src/storage/gcs.rs | 4 ++-- src/storage/s3.rs | 4 ++-- src/users/filters.rs | 2 +- 14 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/alerts/target.rs b/src/alerts/target.rs index abe8792a5..edb28f453 100644 --- a/src/alerts/target.rs +++ b/src/alerts/target.rs @@ -142,7 +142,7 @@ impl TargetConfigs { return Err(AlertError::CustomError("No AlertManager set".into())); }; - for (_, alert) in alerts.get_all_alerts(tenant_id).await.iter() { + for alert in alerts.get_all_alerts(tenant_id).await.values() { if alert.get_targets().contains(target_id) { return Err(AlertError::TargetInUse); } diff --git a/src/connectors/kafka/metrics.rs b/src/connectors/kafka/metrics.rs index e37271b2f..4ea509908 100644 --- a/src/connectors/kafka/metrics.rs +++ b/src/connectors/kafka/metrics.rs @@ -820,7 +820,7 @@ impl Collector for KafkaMetricsCollector { mfs.extend(self.core_metrics.collect_metrics(&stats)); // Collect broker metrics - for (_broker_id, broker) in stats.brokers.iter() { + for broker in stats.brokers.values() { mfs.extend(self.broker_metrics.collect_metrics(broker)); } diff --git a/src/handlers/airplane.rs b/src/handlers/airplane.rs index 8352ea3f9..3414ffb85 100644 --- a/src/handlers/airplane.rs +++ b/src/handlers/airplane.rs @@ -156,7 +156,7 @@ impl FlightService for AirServiceImpl { query.time_range.start.timestamp_millis(), query.time_range.end.timestamp_millis(), ) { - let sql = format!("select * from \"{}\"", &stream_name); + let sql = format!("select * from \"{}\"", stream_name); let start_time = ticket.start_time.clone(); let end_time = ticket.end_time.clone(); let out_ticket = json!({ diff --git a/src/handlers/http/alerts.rs b/src/handlers/http/alerts.rs index db5ccc9aa..60e5ba698 100644 --- a/src/handlers/http/alerts.rs +++ b/src/handlers/http/alerts.rs @@ -419,7 +419,7 @@ pub async fn update_notification_state( } else { return Err(AlertError::InvalidStateChange(format!( "Invalid notification state change request. Expected `notify`, `indefinite` or human-time or UTC datetime. Got `{}`", - &new_notification_state.state + new_notification_state.state ))); }; NotificationState::Mute(till_time) diff --git a/src/handlers/http/cluster/mod.rs b/src/handlers/http/cluster/mod.rs index b5f4dab7a..493d8eb49 100644 --- a/src/handlers/http/cluster/mod.rs +++ b/src/handlers/http/cluster/mod.rs @@ -1984,7 +1984,7 @@ pub async fn send_query_request( let send_null = query_request.send_null; let uri = format!( "{}api/v1/query?fields={fields}&streaming={streaming}&send_null={send_null}", - &querier.domain_name, + querier.domain_name, ); let body = match serde_json::to_string(&query_request) { diff --git a/src/metastore/metastores/object_store_metastore.rs b/src/metastore/metastores/object_store_metastore.rs index 4a1ca703d..ef9622fd0 100644 --- a/src/metastore/metastores/object_store_metastore.rs +++ b/src/metastore/metastores/object_store_metastore.rs @@ -965,9 +965,9 @@ impl Metastore for ObjectStoreMetastore { async move { let t_start = std::time::Instant::now(); let date_path = if let Some(tenant) = tenant.as_ref() { - object_store::path::Path::from(format!("{}/{}/{}", tenant, &stream, &date)) + object_store::path::Path::from(format!("{}/{}/{}", tenant, stream, date)) } else { - object_store::path::Path::from(format!("{}/{}", &stream, &date)) + object_store::path::Path::from(format!("{}/{}", stream, date)) }; let t_list = std::time::Instant::now(); @@ -1420,7 +1420,7 @@ impl Metastore for ObjectStoreMetastore { STREAM_ROOT_DIRECTORY, ]) } else { - object_store::path::Path::from(format!("{}/{}", &stream, STREAM_ROOT_DIRECTORY)) + object_store::path::Path::from(format!("{}/{}", stream, STREAM_ROOT_DIRECTORY)) }; let resp = self.storage.list_with_delimiter(Some(stream_path)).await?; if resp diff --git a/src/metrics/prom_utils.rs b/src/metrics/prom_utils.rs index ab026b4df..3f04d89f6 100644 --- a/src/metrics/prom_utils.rs +++ b/src/metrics/prom_utils.rs @@ -228,7 +228,7 @@ impl Metrics { ) -> Result<(String, String), PostError> { let uri = Url::parse(&format!( "{}{}/about", - &metadata.domain_name(), + metadata.domain_name(), base_path_without_preceding_slash() )) .map_err(|err| { @@ -260,7 +260,7 @@ impl Metrics { ); Err(PostError::Invalid(anyhow::anyhow!( "Failed to fetch about API response from server: {}\n", - &metadata.domain_name() + metadata.domain_name() ))) } } diff --git a/src/parseable/streams.rs b/src/parseable/streams.rs index 8ebcdaea0..ce5d1587f 100644 --- a/src/parseable/streams.rs +++ b/src/parseable/streams.rs @@ -966,13 +966,11 @@ impl Stream { .collect(); for res in _schemas { - match res { - Ok(s) => { - if let Some(s) = s { - schemas.push(s) - } + { + let s = res?; + if let Some(s) = s { + schemas.push(s) } - Err(e) => return Err(e), } } if schemas.is_empty() { diff --git a/src/query/listing_table_builder.rs b/src/query/listing_table_builder.rs index 0b106e34f..55ff7065c 100644 --- a/src/query/listing_table_builder.rs +++ b/src/query/listing_table_builder.rs @@ -91,7 +91,7 @@ impl ListingTableBuilder { let prefixes: Vec<_> = prefixes .into_iter() .map(|prefix| { - relative_path::RelativePathBuf::from(format!("{}/{}", &self.stream, prefix)) + relative_path::RelativePathBuf::from(format!("{}/{}", self.stream, prefix)) }) .collect(); diff --git a/src/rbac/mod.rs b/src/rbac/mod.rs index 1d952bbab..7197c7583 100644 --- a/src/rbac/mod.rs +++ b/src/rbac/mod.rs @@ -336,8 +336,8 @@ impl Users { } pub fn get_user_tenant_from_basic(&self, username: &str, password: &str) -> Option { - for (_, usermap) in users().iter() { - for (_, user) in usermap.iter() { + for usermap in users().values() { + for user in usermap.values() { if let UserType::Native(basic) = &user.ty && basic.username.eq(username) && basic.verify_password(password) diff --git a/src/sse/mod.rs b/src/sse/mod.rs index 68244bd7a..3b8b36345 100644 --- a/src/sse/mod.rs +++ b/src/sse/mod.rs @@ -166,7 +166,7 @@ impl Broadcaster { } else { // broadcast let mut futures = vec![]; - for (_, clients) in tenant_clients.iter() { + for clients in tenant_clients.values() { clients .iter() .for_each(|client| futures.push(client.send(sse::Data::new(msg).into()))); diff --git a/src/storage/gcs.rs b/src/storage/gcs.rs index 2ef85568b..13d9e81cd 100644 --- a/src/storage/gcs.rs +++ b/src/storage/gcs.rs @@ -142,7 +142,7 @@ impl ObjectStorageProvider for GcsConfig { let object_store_registry = DefaultObjectStoreRegistry::new(); // Register GCS client under the "gs://" scheme so DataFusion can route // object store calls to our GoogleCloudStorage implementation - let url = ObjectStoreUrl::parse(format!("gs://{}", &self.bucket_name)).unwrap(); + let url = ObjectStoreUrl::parse(format!("gs://{}", self.bucket_name)).unwrap(); object_store_registry.register_store(url.as_ref(), Arc::new(gcs)); RuntimeEnvBuilder::new().with_object_store_registry(Arc::new(object_store_registry)) @@ -1028,7 +1028,7 @@ impl ObjectStorage for Gcs { prefixes .into_iter() .map(|prefix| { - let path = format!("gs://{}/{}", &self.bucket, prefix); + let path = format!("gs://{}/{}", self.bucket, prefix); ListingTableUrl::parse(path).unwrap() }) .collect() diff --git a/src/storage/s3.rs b/src/storage/s3.rs index 0a1d2f752..6d47c3da9 100644 --- a/src/storage/s3.rs +++ b/src/storage/s3.rs @@ -338,7 +338,7 @@ impl ObjectStorageProvider for S3Config { let s3 = MetricLayer::new(s3, "s3"); let object_store_registry = DefaultObjectStoreRegistry::new(); - let url = ObjectStoreUrl::parse(format!("s3://{}", &self.bucket_name)).unwrap(); + let url = ObjectStoreUrl::parse(format!("s3://{}", self.bucket_name)).unwrap(); object_store_registry.register_store(url.as_ref(), Arc::new(s3)); RuntimeEnvBuilder::new().with_object_store_registry(Arc::new(object_store_registry)) @@ -1291,7 +1291,7 @@ impl ObjectStorage for S3 { prefixes .into_iter() .map(|prefix| { - let path = format!("s3://{}/{}", &self.bucket, prefix); + let path = format!("s3://{}/{}", self.bucket, prefix); ListingTableUrl::parse(path).unwrap() }) .collect() diff --git a/src/users/filters.rs b/src/users/filters.rs index f2947a6b2..e1232e8bf 100644 --- a/src/users/filters.rs +++ b/src/users/filters.rs @@ -187,7 +187,7 @@ impl Filters { } } else if *filter_type == FilterType::Search || *filter_type == FilterType::Filter { let dataset_name = &f.stream_name; - if user_auth_for_datasets(&permissions, &[dataset_name.to_string()], &tenant_id) + if user_auth_for_datasets(&permissions, std::slice::from_ref(dataset_name), &tenant_id) .await .is_ok() {