Skip to content

Commit 6f4571e

Browse files
authored
Merge pull request MaterializeInc#33472 from petrosagg/forbid-iterator-zip
*: disallow using `Iterator::zip`
2 parents 905e90a + bbcd9ca commit 6f4571e

File tree

94 files changed

+339
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+339
-209
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ await-holding-invalid-types = [
44
]
55

66
disallowed-methods = [
7+
{ path = "std::iter::Iterator::zip", reason = "use `Itertools::zip_eq` instead" },
78
{ path = "std::panic::catch_unwind", reason = "use `mz_ore::panic::catch_unwind` instead" },
89
{ path = "futures::FutureExt::catch_unwind", reason = "use `mz_ore::future::FutureExt::catch_unwind` instead" },
910

src/adapter/src/catalog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ mod tests {
28082808
let full_name = conn_catalog.resolve_full_name(item.name());
28092809
let actual_desc = item.desc(&full_name).expect("invalid item type");
28102810
for (index, ((actual_name, actual_typ), (expected_name, expected_typ))) in
2811-
actual_desc.iter().zip(expected_desc.iter()).enumerate()
2811+
actual_desc.iter().zip_eq(expected_desc.iter()).enumerate()
28122812
{
28132813
assert_eq!(
28142814
actual_name, expected_name,

src/adapter/src/catalog/open.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ fn add_new_remove_old_builtin_items_migration(
791791
let new_builtin_ids = txn.allocate_system_item_ids(usize_to_u64(new_builtins.len()))?;
792792
let new_builtins: Vec<_> = new_builtins
793793
.into_iter()
794-
.zip(new_builtin_ids.clone())
794+
.zip_eq(new_builtin_ids.clone())
795795
.collect();
796796

797797
// Look for migrated builtins.

src/adapter/src/coord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3229,7 +3229,7 @@ impl Coordinator {
32293229
);
32303230

32313231
let catalog = self.catalog_mut();
3232-
for (id, plan) in catalog_ids.into_iter().zip(dataflows) {
3232+
for (id, plan) in catalog_ids.into_iter().zip_eq(dataflows) {
32333233
catalog.set_physical_plan(id, plan);
32343234
}
32353235

src/adapter/src/coord/sequencer/inner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl Coordinator {
467467
.allocate_user_ids(u64::cast_from(subsource_stmts.len()), id_ts)
468468
.await?;
469469
for (subsource_stmt, (item_id, global_id)) in
470-
subsource_stmts.into_iter().zip(ids.into_iter())
470+
subsource_stmts.into_iter().zip_eq(ids.into_iter())
471471
{
472472
let s = self.plan_subsource(session, &params, subsource_stmt, item_id, global_id)?;
473473
subsource_plans.push(s);
@@ -622,7 +622,7 @@ impl Coordinator {
622622
.catalog_mut()
623623
.allocate_user_ids(u64::cast_from(subsource_stmts.len()), id_ts)
624624
.await?;
625-
for (stmt, (item_id, global_id)) in subsource_stmts.into_iter().zip(ids.into_iter()) {
625+
for (stmt, (item_id, global_id)) in subsource_stmts.into_iter().zip_eq(ids.into_iter()) {
626626
let plan = self.plan_subsource(ctx.session(), &params, stmt, item_id, global_id)?;
627627
create_source_plans.push(plan);
628628
}

src/adapter/src/coord/sql.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//! Various utility methods used by the [`Coordinator`]. Ideally these are all
1111
//! put in more meaningfully named modules.
1212
13+
use itertools::Itertools;
1314
use mz_adapter_types::connection::ConnectionId;
1415
use mz_ore::now::EpochMillis;
1516
use mz_repr::{Diff, GlobalId, ScalarType};
@@ -76,7 +77,7 @@ impl Coordinator {
7677
let params = params
7778
.datums
7879
.into_iter()
79-
.zip(params.execute_types)
80+
.zip_eq(params.execute_types)
8081
.collect();
8182
let result_formats = vec![mz_pgwire_common::Format::Text; desc.arity()];
8283
let logging = session.mint_logging(sql, Some(&stmt), now);

src/adapter/src/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use std::fmt::Debug;
1111

12+
use itertools::Itertools;
1213
use mz_catalog::durable::{DurableCatalogError, FenceError};
1314
use mz_compute_client::controller::error::{
1415
CollectionUpdateError, DataflowCreationError, InstanceMissing, PeekError, ReadPolicyError,
@@ -463,7 +464,7 @@ pub fn verify_datum_desc(
463464
return Err(AdapterError::Internal(msg));
464465
}
465466

466-
for (i, (d, t)) in datums.iter().zip(col_types).enumerate() {
467+
for (i, (d, t)) in datums.iter().zip_eq(col_types).enumerate() {
467468
if !d.is_instance_of(t) {
468469
let msg = format!(
469470
"internal error: column {} is not of expected type {:?}: {:?}",

src/arrow-util/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ arrow = { version = "55.2.0", default-features = false }
1515
chrono = { version = "0.4.39", default-features = false, features = ["std"] }
1616
dec = { version = "0.4.9", features = ["num-traits"] }
1717
half = "2"
18+
itertools = "0.14.0"
1819
mz-repr = { path = "../repr" }
1920
mz-ore = { path = "../ore" }
2021
num-traits = "0.2"

src/arrow-util/src/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use arrow::datatypes::{
2222
use arrow::error::ArrowError;
2323
use arrow::record_batch::RecordBatch;
2424
use chrono::Timelike;
25+
use itertools::Itertools;
2526
use mz_ore::cast::CastFrom;
2627
use mz_repr::adt::jsonb::JsonbRef;
2728
use mz_repr::{Datum, RelationDesc, Row, ScalarType};
@@ -123,7 +124,7 @@ impl ArrowBuilder {
123124
/// Appends a row to the builder.
124125
/// Errors if the row contains an unimplemented or out-of-range value.
125126
pub fn add_row(&mut self, row: &Row) -> Result<(), anyhow::Error> {
126-
for (col, datum) in self.columns.iter_mut().zip(row.iter()) {
127+
for (col, datum) in self.columns.iter_mut().zip_eq(row.iter()) {
127128
col.append_datum(datum)?;
128129
}
129130
self.row_size_bytes += row.byte_len();

0 commit comments

Comments
 (0)