Skip to content

Commit e2ef1c8

Browse files
[Issue-1961]: Handle clippy::explicit_iter_loop (tensorzero#2813)
* [Issue-1961]: Handle clippy::explicit_iter_loop * Remove cfg of e2e test field
1 parent 831a476 commit e2ef1c8

26 files changed

Lines changed: 40 additions & 39 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ unsafe_code = "forbid"
7474
allow_attributes = "deny"
7575
dbg_macro = "deny"
7676
expect_used = "deny"
77+
explicit_iter_loop = "deny"
7778
if_not_else = "deny"
7879
ignored_unit_patterns = "deny"
7980
manual_string_new = "deny"

evaluations/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub async fn get_tool_params_args(
2727
FunctionConfig::Chat(function_config) => {
2828
let mut additional_tools = Vec::new();
2929
let mut allowed_tools = Vec::new();
30-
for tool in tool_params.tools_available.iter() {
30+
for tool in &tool_params.tools_available {
3131
if function_config.tools.contains(&tool.name) {
3232
allowed_tools.push(tool.name.clone());
3333
} else {

evaluations/src/stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ impl EvaluationStats {
7777
debug!(evaluators = ?evaluators.keys().collect::<Vec<_>>(), "Initialized data collectors for evaluators");
7878
// Collect evaluation inference data into vectors by evaluation (all as floats)
7979
debug!("Processing evaluation results into statistics");
80-
for evaluation_info in self.evaluation_infos.iter() {
81-
for (evaluation_name, evaluation_result) in evaluation_info.evaluations.iter() {
80+
for evaluation_info in &self.evaluation_infos {
81+
for (evaluation_name, evaluation_result) in &evaluation_info.evaluations {
8282
match evaluation_result {
8383
Some(Value::Number(n)) => {
8484
if let Some(data_vec) = data.get_mut(evaluation_name) {

examples/integrations/cursor/feedback/src/ted/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'tree, L: Eq> Tree<'tree, L> {
202202
) -> Self {
203203
let key_roots = Self::compute_key_roots(left_most_leaf_descendant_root, parent_offset);
204204
debug_assert!(!key_roots.is_empty(), "key_roots must have ≥1 node");
205-
for root in key_roots.iter() {
205+
for root in &key_roots {
206206
debug_assert!(*root < post.len(), "key_root must be within bounds");
207207
}
208208
debug_assert_eq!(

internal/tensorzero-derive/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ pub fn tensorzero_derive(input: TokenStream) -> TokenStream {
119119
// other derive macros (e.g. `#[strum]`0. We're not applying any derive macros
120120
// to our new enum, so we need to avoid copying over other attributes to prevent errors.
121121
let mut stripped_variants = data.variants.clone();
122-
for variant in stripped_variants.iter_mut() {
122+
for variant in &mut stripped_variants {
123123
variant.attrs.retain(|attr| attr.path().is_ident("serde"));
124-
for field in variant.fields.iter_mut() {
124+
for field in &mut variant.fields {
125125
field.attrs.retain(|attr| attr.path().is_ident("serde"));
126126
}
127127
}

tensorzero-core/src/clickhouse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn set_clickhouse_format_settings(database_url: &mut Url) {
659659
}
660660
}
661661

662-
for setting in OVERRIDDEN_SETTINGS.iter() {
662+
for setting in &OVERRIDDEN_SETTINGS {
663663
database_url.query_pairs_mut().append_pair(setting, "0");
664664
}
665665
database_url.query_pairs_mut().finish();

tensorzero-core/src/config_parser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ impl UninitializedFunctionConfig {
977977
.into_iter()
978978
.map(|(name, variant)| variant.load().map(|v| (name, Arc::new(v))))
979979
.collect::<Result<HashMap<_, _>, Error>>()?;
980-
for (name, variant) in variants.iter() {
980+
for (name, variant) in &variants {
981981
if let VariantConfig::ChatCompletion(chat_config) = &variant.inner {
982982
if chat_config.json_mode.is_some() {
983983
return Err(ErrorDetails::Config {
@@ -1025,7 +1025,7 @@ impl UninitializedFunctionConfig {
10251025
.map(|(name, variant)| variant.load().map(|v| (name, Arc::new(v))))
10261026
.collect::<Result<HashMap<_, _>, Error>>()?;
10271027

1028-
for (name, variant) in variants.iter() {
1028+
for (name, variant) in &variants {
10291029
let mut warn_variant = None;
10301030
match &variant.inner {
10311031
VariantConfig::ChatCompletion(chat_config) => {

tensorzero-core/src/endpoints/dynamic_evaluation_run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub fn validate_variant_pins(
141141
variant_pins: &HashMap<String, String>,
142142
config: &Config,
143143
) -> Result<(), Error> {
144-
for (function_name, variant_name) in variant_pins.iter() {
144+
for (function_name, variant_name) in variant_pins {
145145
let function_config = config.get_function(function_name)?;
146146
function_config
147147
.variants()

tensorzero-core/src/function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ impl FunctionConfig {
477477
}
478478
match self {
479479
FunctionConfig::Chat(params) => {
480-
for tool in params.tools.iter() {
480+
for tool in &params.tools {
481481
static_tools.get(tool).ok_or_else(|| Error::new(ErrorDetails::Config {
482482
message: format!("`functions.{function_name}.tools`: tool `{tool}` is not present in the config"),
483483
}))?;
@@ -546,7 +546,7 @@ fn validate_all_text_input(
546546
}?;
547547
for (index, message) in input.messages.iter().enumerate() {
548548
// Only for Text blocks, not RawText blocks since we don't validate those
549-
for block in message.content.iter() {
549+
for block in &message.content {
550550
if let InputMessageContent::Text(kind) = block {
551551
let content = match kind {
552552
TextKind::Arguments { arguments } => {

tensorzero-core/src/providers/aws_http_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl HttpConnector for ReqwestConnector {
153153
);
154154
// Copy the header, body, and timeout.
155155
let parts = request.into_parts();
156-
for (name, value) in parts.headers.iter() {
156+
for (name, value) in &parts.headers {
157157
let name = name.to_owned();
158158
let value = value.as_bytes().to_owned();
159159
req_builder = req_builder.header(name, value);

0 commit comments

Comments
 (0)