diff --git a/clippy.toml b/clippy.toml index 70096057..38037a01 100644 --- a/clippy.toml +++ b/clippy.toml @@ -49,6 +49,8 @@ disallowed-methods = [ { path = 'tokio::fs::write', reason = 'use fs_err::tokio::write for more helpful error messages' }, { path = 'axum::Router::nest', reason = 'specify full resource paths for searchability' }, + + { path = 'itertools::repeat_n', reason = 'use core::iter::repeat_n' }, ] disallowed-types = [ { path = 'std::fs::DirEntry', reason = 'use fs_err::DirEntry for more helpful error messages' }, diff --git a/fork_choice_store/src/store.rs b/fork_choice_store/src/store.rs index 65c3d139..0cc07dd5 100644 --- a/fork_choice_store/src/store.rs +++ b/fork_choice_store/src/store.rs @@ -248,7 +248,7 @@ impl Store

{ }; let validator_count = anchor_state.validators().len_usize(); - let latest_messages = itertools::repeat_n(None, validator_count).collect(); + let latest_messages = core::iter::repeat_n(None, validator_count).collect(); Self { chain_config, @@ -2446,7 +2446,7 @@ impl Store

{ fn extend_latest_messages_after_finalization(&mut self) { let old_length = self.latest_messages.len(); let new_length = self.last_finalized().state(self).validators().len_usize(); - let added_vacancies = itertools::repeat_n(None, new_length - old_length); + let added_vacancies = core::iter::repeat_n(None, new_length - old_length); self.latest_messages.extend(added_vacancies); } diff --git a/ssz/src/contiguous_vector.rs b/ssz/src/contiguous_vector.rs index eab27ae5..e626b4b9 100644 --- a/ssz/src/contiguous_vector.rs +++ b/ssz/src/contiguous_vector.rs @@ -159,7 +159,7 @@ impl> ContiguousVector { where T: Clone, { - Self::try_from_iter(itertools::repeat_n(element, N::USIZE)) + Self::try_from_iter(core::iter::repeat_n(element, N::USIZE)) .expect("length of iterator matches type parameter") } } diff --git a/ssz/src/merkle_tree.rs b/ssz/src/merkle_tree.rs index 6d6d8005..d6187884 100644 --- a/ssz/src/merkle_tree.rs +++ b/ssz/src/merkle_tree.rs @@ -393,12 +393,12 @@ mod tests { let ff_hash_1 = hashing::hash_256_256(ff_hash_0, ff_hash_0); let ff_hash_2 = hashing::hash_256_256(ff_hash_1, ff_hash_1); - let chunks = itertools::repeat_n(ff_hash_0, capacity); + let chunks = core::iter::repeat_n(ff_hash_0, capacity); let chunk_indices = 0..capacity; let proof_indices = chunk_indices.clone(); let expected_proof = [ff_hash_0, ff_hash_1, ff_hash_2, hash_of_length(capacity)].into(); - let expected_proofs = itertools::repeat_n(expected_proof, capacity); + let expected_proofs = core::iter::repeat_n(expected_proof, capacity); let actual_proofs = MerkleTree::::default().extend_and_construct_proofs( chunks, diff --git a/transition_functions/src/altair/epoch_intermediates.rs b/transition_functions/src/altair/epoch_intermediates.rs index 7f4a3294..cee7b58c 100644 --- a/transition_functions/src/altair/epoch_intermediates.rs +++ b/transition_functions/src/altair/epoch_intermediates.rs @@ -366,12 +366,12 @@ mod spec_tests { TestDeltas::assert_equal( epoch_deltas.iter().map(|deltas| deltas.head_reward), - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), case.ssz_default("head_deltas"), ); TestDeltas::assert_equal( - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty), case.ssz_default("inactivity_penalty_deltas"), ); diff --git a/transition_functions/src/bellatrix/epoch_intermediates.rs b/transition_functions/src/bellatrix/epoch_intermediates.rs index 790c80f1..1575a50a 100644 --- a/transition_functions/src/bellatrix/epoch_intermediates.rs +++ b/transition_functions/src/bellatrix/epoch_intermediates.rs @@ -148,12 +148,12 @@ mod spec_tests { TestDeltas::assert_equal( epoch_deltas.iter().map(|deltas| deltas.head_reward), - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), case.ssz_default("head_deltas"), ); TestDeltas::assert_equal( - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty), case.ssz_default("inactivity_penalty_deltas"), ); diff --git a/transition_functions/src/capella/epoch_intermediates.rs b/transition_functions/src/capella/epoch_intermediates.rs index b790e2a6..be56b3f1 100644 --- a/transition_functions/src/capella/epoch_intermediates.rs +++ b/transition_functions/src/capella/epoch_intermediates.rs @@ -148,12 +148,12 @@ mod spec_tests { TestDeltas::assert_equal( epoch_deltas.iter().map(|deltas| deltas.head_reward), - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), case.ssz_default("head_deltas"), ); TestDeltas::assert_equal( - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty), case.ssz_default("inactivity_penalty_deltas"), ); diff --git a/transition_functions/src/deneb/epoch_intermediates.rs b/transition_functions/src/deneb/epoch_intermediates.rs index 495a5fa5..199c8896 100644 --- a/transition_functions/src/deneb/epoch_intermediates.rs +++ b/transition_functions/src/deneb/epoch_intermediates.rs @@ -148,12 +148,12 @@ mod spec_tests { TestDeltas::assert_equal( epoch_deltas.iter().map(|deltas| deltas.head_reward), - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), case.ssz_default("head_deltas"), ); TestDeltas::assert_equal( - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty), case.ssz_default("inactivity_penalty_deltas"), ); diff --git a/transition_functions/src/electra/epoch_intermediates.rs b/transition_functions/src/electra/epoch_intermediates.rs index d98ea1d7..02b67a2b 100644 --- a/transition_functions/src/electra/epoch_intermediates.rs +++ b/transition_functions/src/electra/epoch_intermediates.rs @@ -148,12 +148,12 @@ mod spec_tests { TestDeltas::assert_equal( epoch_deltas.iter().map(|deltas| deltas.head_reward), - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), case.ssz_default("head_deltas"), ); TestDeltas::assert_equal( - itertools::repeat_n(0, epoch_deltas.len()), + core::iter::repeat_n(0, epoch_deltas.len()), epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty), case.ssz_default("inactivity_penalty_deltas"), ); diff --git a/transition_functions/src/phase0/epoch_intermediates.rs b/transition_functions/src/phase0/epoch_intermediates.rs index 8b9c712e..c7b419f3 100644 --- a/transition_functions/src/phase0/epoch_intermediates.rs +++ b/transition_functions/src/phase0/epoch_intermediates.rs @@ -818,12 +818,12 @@ mod spec_tests { deltas .iter() .map(|deltas| deltas.proposer_reward + deltas.inclusion_delay_reward), - itertools::repeat_n(0, deltas.len()), + core::iter::repeat_n(0, deltas.len()), case.ssz_default("inclusion_delay_deltas"), ); TestDeltas::assert_equal( - itertools::repeat_n(0, deltas.len()), + core::iter::repeat_n(0, deltas.len()), deltas .iter() .map(|deltas| deltas.canceling_penalty + deltas.inactivity_penalty),