fix: update rand sample_iter usage for rand 0.10 API - #1080
Open
ayushsingh82 wants to merge 2 commits into
Open
Conversation
rand 0.10 moved sample_iter from the Rng trait onto Distribution, so it's now called as `distribution.sample_iter(rng)` instead of `rng.sample_iter(&distribution)`. Fixes the CI compile failures on the rand 0.10.0 dependency bump (graphprotocol#1070) in indexer-tap-agent and indexer-dips test code.
Author
|
cc @MoonBoi9001 — saw you're active on tap-agent/dips lately. Quick heads up: rand 0.10 moved |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
randcrate v0.10 movedsample_iteroff theRngtrait and ontoDistribution— it's now called asdistribution.sample_iter(rng)instead ofrng.sample_iter(&distribution). This currently breakscargo clippyandcargo teston the pendingrand0.10.0 security-update PR (#1070), inindexer-tap-agent'stest.rs(confirmed via CI logs on #1070) andindexer-dips'slib.rstest module (same broken pattern, not exercised by that CI job but would break onmainonce #1070 merges).This PR applies the same fix pattern used in
rand's own docs (callingsample_iteron theDistributioninstance) in both places, and drops the now-unusedRngimport.Changes
crates/tap-agent/src/test.rs:generate_random_prefix()fixedcrates/dips/src/lib.rs:VoucherContext::random()(test-only) fixedTest plan
cargo check -p indexer-tap-agent --tests— compiles cleancargo check -p indexer-dips --tests— compiles cleancargo fmt --check -p indexer-tap-agent -p indexer-dips— no diffcargo clippy -p indexer-tap-agent -p indexer-dips --all-features --all-targets -- -A dead-code -D warnings— clean, matching CI's exact invocationThis should unblock #1070 (
rand0.10.0 [security]) once rebased on top of, or merged alongside, this fix.