Repository navigation
fix(scoring): remove count_state's unsafe; run existence tests under Miri - #219
Merged
Merged
Conversation
dense_raw and key_from_raw reinterpreted a generic K as usize and back through raw pointers, sound only because callers reach them in the K == usize arm, which a debug_assert checked in debug builds only. They now use Any downcasts, which monomorphize to the identity in that arm and panic otherwise, so the scoring crate has no unsafe left and forbids it.
The existence tests are the ones that drive the dense, usize-keyed count state. A new Miri job runs them on a pinned nightly (nightly-2026-01-20), so a new nightly cannot fail CI on its own. Closes #218.
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.
Closes #218. Base
main@b2f02b55:f22f2bd1dense_raw/key_from_rawuseAnydowncasts instead of raw-pointer casts;solverforge-scoringnow#![forbid(unsafe_code)]. No productionunsaferemains in the workspace.afb879a7GitHub CIMirijob:cargo +nightly-2026-01-20 miri test -p solverforge-scoring --lib -- constraint::tests::exists.Coverage check: making either function panic fails exactly the existence tests (
exists,exists_descriptor_updates) plus two benches, so those tests are the dense path. Locally under Miri on nightly-2026-01-20: 5 passed, 0 failed, no UB reported.Gate (fmt, clippy, doc-names file-length facade-reachability public-api deps, rustdoc, examples, workspace all-feature tests, doctests): EXIT 0, 1592 passed, 0 failed, 71 result lines.