From 03e3fdfc310ca836f390dc1e030d035fca5b2dae Mon Sep 17 00:00:00 2001 From: Derek Cofausper <256792747+decofe@users.noreply.github.com> Date: Mon, 13 Apr 2026 11:54:14 +0000 Subject: [PATCH] clippy: warn on iter_on_single_items Co-Authored-By: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- Cargo.toml | 1 + crates/anvil/tests/it/tempo.rs | 18 ++++++------------ crates/config/src/lib.rs | 7 +++---- .../doc/src/preprocessor/infer_hyperlinks.rs | 8 ++++---- crates/forge/src/cmd/cache.rs | 2 +- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d84d5efac7505..2d954897b9dc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,6 +61,7 @@ implicit_clone = "warn" if_not_else = "warn" imprecise_flops = "warn" iter_on_empty_collections = "warn" +iter_on_single_items = "warn" iter_with_drain = "warn" iter_without_into_iter = "warn" manual_assert = "warn" diff --git a/crates/anvil/tests/it/tempo.rs b/crates/anvil/tests/it/tempo.rs index 08c48aaee7716..27906ce72d1bc 100644 --- a/crates/anvil/tests/it/tempo.rs +++ b/crates/anvil/tests/it/tempo.rs @@ -2189,8 +2189,7 @@ async fn test_gas_estimation_tempo_aa_transaction() { let tx: WithOtherFields = WithOtherFields { inner: TransactionRequest::default().from(accounts[0]).to(PATH_USD).with_input(calldata), - other: [("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))] - .into_iter() + other: std::iter::once(("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))) .collect(), }; @@ -2224,8 +2223,7 @@ async fn test_gas_estimation_tempo_aa_with_2d_nonce() { .from(accounts[0]) .to(PATH_USD) .with_input(calldata.clone()), - other: [("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))] - .into_iter() + other: std::iter::once(("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))) .collect(), }; let baseline_gas = provider.estimate_gas(baseline_tx).await.unwrap(); @@ -2278,8 +2276,7 @@ async fn test_gas_estimation_tempo_aa_expiring_nonce() { .from(accounts[0]) .to(PATH_USD) .with_input(calldata.clone()), - other: [("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))] - .into_iter() + other: std::iter::once(("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))) .collect(), }; let baseline_gas = provider.estimate_gas(baseline_tx).await.unwrap(); @@ -2337,8 +2334,7 @@ async fn test_gas_estimation_t1_nonce_costs() { .from(accounts[0]) .to(PATH_USD) .with_input(calldata.clone()), - other: [("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))] - .into_iter() + other: std::iter::once(("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))) .collect(), }; let baseline_gas = provider.estimate_gas(baseline_tx).await.unwrap(); @@ -2371,8 +2367,7 @@ async fn test_gas_estimation_t1_nonce_costs() { .to(PATH_USD) .with_input(calldata.clone()) .with_nonce(1), - other: [("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))] - .into_iter() + other: std::iter::once(("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))) .collect(), }; let baseline_nonce1_gas = provider.estimate_gas(baseline_nonce1_tx).await.unwrap(); @@ -2521,8 +2516,7 @@ async fn test_gas_estimation_converges_for_tempo_intrinsic_gas() { .from(accounts[0]) .to(PATH_USD) .with_input(calldata.clone()), - other: [("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))] - .into_iter() + other: std::iter::once(("feeToken".to_string(), serde_json::json!(PATH_USD.to_string()))) .collect(), }; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 1ac58f309f33e..0cad08b773808 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1982,11 +1982,10 @@ impl Config { }) .collect::>(); // wrap inner table in [profile.] - let mut wrapping_table = [( + let mut wrapping_table = std::iter::once(( Self::PROFILE_SECTION.into(), - toml::Value::Table([(self.profile.to_string(), value)].into_iter().collect()), - )] - .into_iter() + toml::Value::Table(std::iter::once((self.profile.to_string(), value)).collect()), + )) .collect::>(); // insert standalone sections for (section, value) in standalone_sections { diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index cb8d9d1bcf5f4..b361490a7b94d 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -169,9 +169,9 @@ impl InferInlineHyperlinks { Self::find_match( &link, doc.relative_output_path(), - doc.content.iter_items().flat_map(|item| { - Some(item).into_iter().chain(item.children.iter()) - }), + doc.content + .iter_items() + .flat_map(|item| std::iter::once(item).chain(item.children.iter())), ) }) } else { @@ -182,7 +182,7 @@ impl InferInlineHyperlinks { parent .content .iter_items() - .flat_map(|item| Some(item).into_iter().chain(item.children.iter())), + .flat_map(|item| std::iter::once(item).chain(item.children.iter())), ) }; if let Some(target) = target { diff --git a/crates/forge/src/cmd/cache.rs b/crates/forge/src/cmd/cache.rs index 432d7c11c19dd..0cb32ceba3f88 100644 --- a/crates/forge/src/cmd/cache.rs +++ b/crates/forge/src/cmd/cache.rs @@ -173,7 +173,7 @@ impl TypedValueParser for ChainOrAllValueParser { } fn possible_chains() -> PossibleValuesParser { - Some(&"all").into_iter().chain(NamedChain::VARIANTS).into() + std::iter::once(&"all").chain(NamedChain::VARIANTS).into() } #[cfg(test)]