Skip to content

Commit

Permalink
v1.17: Uses stable u64::next_multiple_of() (backport of #33549) (#3…
Browse files Browse the repository at this point in the history
…3567)

Uses stable `u64::next_multiple_of()` (#33549)

(cherry picked from commit c8d545c)

Co-authored-by: Brooks <[email protected]>
  • Loading branch information
mergify[bot] and brooksprumo authored Oct 6, 2023
1 parent a330ffc commit 194903c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn test_background_services_request_handling_for_epoch_accounts_hash() {
// Based on the EAH start and snapshot interval, pick a slot to mass-root all the banks in
// this range such that an EAH request will be sent and also a snapshot request.
let eah_start_slot = epoch_accounts_hash_utils::calculation_start(&bank);
let set_root_slot = next_multiple_of(eah_start_slot, FULL_SNAPSHOT_INTERVAL);
let set_root_slot = eah_start_slot.next_multiple_of(FULL_SNAPSHOT_INTERVAL);

if bank.block_height() == set_root_slot {
info!("Calling set_root() on bank {}...", bank.slot());
Expand Down Expand Up @@ -661,16 +661,3 @@ fn test_epoch_accounts_hash_and_warping() {
.wait_get_epoch_accounts_hash();
info!("Waiting for epoch accounts hash... DONE");
}

// Copy the impl of `next_multiple_of` since it is nightly-only experimental.
// https://doc.rust-lang.org/std/primitive.u64.html#method.next_multiple_of
// https://github.com/rust-lang/rust/issues/88581
// https://github.com/rust-lang/rust/pull/88582
// https://github.com/jhpratt/rust/blob/727a4fc7e3f836938dfeb4a2ab237cfca612222d/library/core/src/num/uint_macros.rs#L1811-L1837
const fn next_multiple_of(lhs: u64, rhs: u64) -> u64 {
#![allow(clippy::arithmetic_side_effects)]
match lhs % rhs {
0 => lhs,
r => lhs + (rhs - r),
}
}

0 comments on commit 194903c

Please sign in to comment.