Skip to content

Commit d6a3b5a

Browse files
prabhaksclaude
andauthored
chore: fix clippy lints for rust 1.97 (#1721)
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 <noreply@anthropic.com>
1 parent 47cff47 commit d6a3b5a

14 files changed

Lines changed: 23 additions & 25 deletions

File tree

src/alerts/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl TargetConfigs {
142142
return Err(AlertError::CustomError("No AlertManager set".into()));
143143
};
144144

145-
for (_, alert) in alerts.get_all_alerts(tenant_id).await.iter() {
145+
for alert in alerts.get_all_alerts(tenant_id).await.values() {
146146
if alert.get_targets().contains(target_id) {
147147
return Err(AlertError::TargetInUse);
148148
}

src/connectors/kafka/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ impl Collector for KafkaMetricsCollector {
820820
mfs.extend(self.core_metrics.collect_metrics(&stats));
821821

822822
// Collect broker metrics
823-
for (_broker_id, broker) in stats.brokers.iter() {
823+
for broker in stats.brokers.values() {
824824
mfs.extend(self.broker_metrics.collect_metrics(broker));
825825
}
826826

src/handlers/airplane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl FlightService for AirServiceImpl {
156156
query.time_range.start.timestamp_millis(),
157157
query.time_range.end.timestamp_millis(),
158158
) {
159-
let sql = format!("select * from \"{}\"", &stream_name);
159+
let sql = format!("select * from \"{}\"", stream_name);
160160
let start_time = ticket.start_time.clone();
161161
let end_time = ticket.end_time.clone();
162162
let out_ticket = json!({

src/handlers/http/alerts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ pub async fn update_notification_state(
419419
} else {
420420
return Err(AlertError::InvalidStateChange(format!(
421421
"Invalid notification state change request. Expected `notify`, `indefinite` or human-time or UTC datetime. Got `{}`",
422-
&new_notification_state.state
422+
new_notification_state.state
423423
)));
424424
};
425425
NotificationState::Mute(till_time)

src/handlers/http/cluster/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ pub async fn send_query_request(
19841984
let send_null = query_request.send_null;
19851985
let uri = format!(
19861986
"{}api/v1/query?fields={fields}&streaming={streaming}&send_null={send_null}",
1987-
&querier.domain_name,
1987+
querier.domain_name,
19881988
);
19891989

19901990
let body = match serde_json::to_string(&query_request) {

src/metastore/metastores/object_store_metastore.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,9 @@ impl Metastore for ObjectStoreMetastore {
965965
async move {
966966
let t_start = std::time::Instant::now();
967967
let date_path = if let Some(tenant) = tenant.as_ref() {
968-
object_store::path::Path::from(format!("{}/{}/{}", tenant, &stream, &date))
968+
object_store::path::Path::from(format!("{}/{}/{}", tenant, stream, date))
969969
} else {
970-
object_store::path::Path::from(format!("{}/{}", &stream, &date))
970+
object_store::path::Path::from(format!("{}/{}", stream, date))
971971
};
972972

973973
let t_list = std::time::Instant::now();
@@ -1420,7 +1420,7 @@ impl Metastore for ObjectStoreMetastore {
14201420
STREAM_ROOT_DIRECTORY,
14211421
])
14221422
} else {
1423-
object_store::path::Path::from(format!("{}/{}", &stream, STREAM_ROOT_DIRECTORY))
1423+
object_store::path::Path::from(format!("{}/{}", stream, STREAM_ROOT_DIRECTORY))
14241424
};
14251425
let resp = self.storage.list_with_delimiter(Some(stream_path)).await?;
14261426
if resp

src/metrics/prom_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl Metrics {
228228
) -> Result<(String, String), PostError> {
229229
let uri = Url::parse(&format!(
230230
"{}{}/about",
231-
&metadata.domain_name(),
231+
metadata.domain_name(),
232232
base_path_without_preceding_slash()
233233
))
234234
.map_err(|err| {
@@ -260,7 +260,7 @@ impl Metrics {
260260
);
261261
Err(PostError::Invalid(anyhow::anyhow!(
262262
"Failed to fetch about API response from server: {}\n",
263-
&metadata.domain_name()
263+
metadata.domain_name()
264264
)))
265265
}
266266
}

src/parseable/streams.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,13 +966,11 @@ impl Stream {
966966
.collect();
967967

968968
for res in _schemas {
969-
match res {
970-
Ok(s) => {
971-
if let Some(s) = s {
972-
schemas.push(s)
973-
}
969+
{
970+
let s = res?;
971+
if let Some(s) = s {
972+
schemas.push(s)
974973
}
975-
Err(e) => return Err(e),
976974
}
977975
}
978976
if schemas.is_empty() {

src/query/listing_table_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl ListingTableBuilder {
9191
let prefixes: Vec<_> = prefixes
9292
.into_iter()
9393
.map(|prefix| {
94-
relative_path::RelativePathBuf::from(format!("{}/{}", &self.stream, prefix))
94+
relative_path::RelativePathBuf::from(format!("{}/{}", self.stream, prefix))
9595
})
9696
.collect();
9797

src/rbac/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ impl Users {
336336
}
337337

338338
pub fn get_user_tenant_from_basic(&self, username: &str, password: &str) -> Option<String> {
339-
for (_, usermap) in users().iter() {
340-
for (_, user) in usermap.iter() {
339+
for usermap in users().values() {
340+
for user in usermap.values() {
341341
if let UserType::Native(basic) = &user.ty
342342
&& basic.username.eq(username)
343343
&& basic.verify_password(password)

0 commit comments

Comments
 (0)