Skip to content

Add debug assertion documenting the bucket_mask overflow invariant - #745

Merged
clarfonthey merged 1 commit into
rust-lang:mainfrom
ChrisJr404:document-bucket-mask-invariant
Aug 27, 2026
Merged

Add debug assertion documenting the bucket_mask overflow invariant#745
clarfonthey merged 1 commit into
rust-lang:mainfrom
ChrisJr404:document-bucket-mask-invariant

Conversation

@ChrisJr404

@ChrisJr404 ChrisJr404 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Follows up #734. You said a debug assertion would be a good way to document that bucket_mask can never be usize::MAX, so this adds one where the +1 happens.

Fixes #734.

@clarfonthey

Copy link
Copy Markdown
Contributor

Longer-term I think it would be good to use a niche type for the mask to more explicitly encode the valid values for this type, but for now, this should be fine.

@clarfonthey
clarfonthey added this pull request to the merge queue Aug 27, 2026
Merged via the queue into rust-lang:main with commit cf57b89 Aug 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bucket_mask_to_capacity() integer overflow when bucket_mask == usize::MAX

2 participants