Skip to content

chore: enable clippy::iter_over_hash_type lints to check where non-determinstic iteration is happening #15567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kevaundray
Copy link
Contributor

@kevaundray kevaundray commented Apr 5, 2025

Not intended to fix the lint warnings.

Rationale: Iterating over a HashMap/HashSet is non-deterministic and can cause bugs where one expects determinism. This PR enables the lint to just double check where this non-determinism is happening. Likely okay in all of the places it is happening.

EDIT: CI exits early so would need to run it locally to see all of the errors

@kevaundray
Copy link
Contributor Author

Sidenote: one nice reason to have as much determinsm as possible is mainly testing -- in particular, one can benefit from snapshot testing the determinstic parts in a "convenient" way using something like insta.rs https://insta.rs

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we enable this on workspace level in cargo.toml instead?

@kevaundray
Copy link
Contributor Author

should we enable this on workspace level in cargo.toml instead?

Yep, we could do that -- I think there are likely quite a lot of false positives, ie places where it might be fine to have non-determinism, so I'll need to go through each crate individually and check that we should have determinism and that switching to something like BTreeMap doesn't hurt performance

@github-actions github-actions bot added S-stale This issue/PR is stale and will close with no further activity and removed S-stale This issue/PR is stale and will close with no further activity labels May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants