Skip to content

fix(scoring): remove count_state's unsafe; run existence tests under Miri - #219

Merged
blackopsrepl merged 2 commits into
mainfrom
feature/218-miri
Nov 5, 2026
Merged

blackopsrepl merged 2 commits into
mainfrom
feature/218-miri

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Closes #218. Base main @ b2f02b55:

  • f22f2bd1 dense_raw/key_from_raw use Any downcasts instead of raw-pointer casts; solverforge-scoring now #![forbid(unsafe_code)]. No production unsafe remains in the workspace.
  • afb879a7 GitHub CI Miri job: 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.

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.
@blackopsrepl
blackopsrepl merged commit afb879a into main Nov 5, 2026
14 checks passed
@blackopsrepl
blackopsrepl deleted the feature/218-miri branch November 5, 2026 13:20
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.

count_state.rs uses unsafe for a usize identity and nothing runs Miri

1 participant