umem: narrow unsafe blocks for the rustc lint #101

Manually merged
github merged 1 commit from github-bot/gh-101 into gh-pr/101/base 2026-12-01 14:03:01 +00:00 AGit
Owner

@⁠TheRifai on GitHub · 2026-12-01 13:39 UTC · original
TheRifai:umem-unsafe-narrow → main · +176 −42 · 5 files · 1 commits · merged 2026-12-01 14:00 UTC

What

Reworks the rejected #95 shape for umem (docs/TASKS.md “The root workspace's rustc lints everywhere”, issue #41). unsafe_op_in_unsafe_fn is denied for umem only. Every unsafe operation inside an unsafe fn now has its own narrow unsafe { … } block with a // SAFETY: note about that operation, and each unsafe fn carries a /// # Safety section stating the caller's contract. No whole-function wraps remain. Where a precondition could not be verified from the code, the note says so instead of asserting it.

The workspace-lint table and xtask check are deliberately left out of this PR, per the review: they come after the other crates' unsafe sites are narrow.

The reference

The root Cargo.toml's rustc lint table is the policy source; this brings umem partway there.

Evidence

  • cargo check -p umem --all-targets --locked, tools/build.sh, CI's native tests (11 + 16 + 151) and policy (6) pass with the deny in place.
  • The separate umem/tests/bench.rs test fails locally with ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS on this RADV setup; it is not in CI's test set and is unrelated to these edits.

Checklist (docs/AGENTS.md)

  • One topic; docs/TASKS.md not edited (rule 29/31)
  • No fallback added (rule 33)
  • No constants or switches added (rules 2/9b)
  • No queues changed (rule 35)
  • Every unsafe block has a specific // SAFETY: note; unsafe fns have a /// # Safety contract (rule 36)
  • Check, build and CI tests pass; no translator output change (rule 27)
  • Comments say what is true now (rule 3)
  • Nothing from the title, no non-free data pointers (hard constraints)
**@⁠TheRifai** on GitHub · 2026-12-01 13:39 UTC · [original](https://github.com/vktory6/VKtory/pull/101) `TheRifai:umem-unsafe-narrow` → `main` · +176 −42 · 5 files · 1 commits · merged 2026-12-01 14:00 UTC ## What Reworks the rejected `#95` shape for umem (docs/TASKS.md “The root workspace's rustc lints everywhere”, issue #41). `unsafe_op_in_unsafe_fn` is denied for umem only. Every unsafe operation inside an `unsafe fn` now has its own narrow `unsafe { … }` block with a `// SAFETY:` note about **that** operation, and each `unsafe fn` carries a `/// # Safety` section stating the caller's contract. No whole-function wraps remain. Where a precondition could not be verified from the code, the note says so instead of asserting it. The workspace-lint table and xtask check are deliberately left out of this PR, per the review: they come after the other crates' unsafe sites are narrow. ## The reference The root Cargo.toml's rustc lint table is the policy source; this brings umem partway there. ## Evidence - `cargo check -p umem --all-targets --locked`, `tools/build.sh`, CI's native tests (11 + 16 + 151) and policy (6) pass with the deny in place. - The separate `umem/tests/bench.rs` test fails locally with `ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS` on this RADV setup; it is not in CI's test set and is unrelated to these edits. ## Checklist (docs/AGENTS.md) - [x] One topic; `docs/TASKS.md` not edited (rule 29/31) - [x] No fallback added (rule 33) - [x] No constants or switches added (rules 2/9b) - [x] No queues changed (rule 35) - [x] Every unsafe block has a specific `// SAFETY:` note; unsafe fns have a `/// # Safety` contract (rule 36) - [x] Check, build and CI tests pass; no translator output change (rule 27) - [x] Comments say what is true now (rule 3) - [x] Nothing from the title, no non-free data pointers (hard constraints)
Rework of the rejected cargo-fix version: instead of wrapping whole function
bodies, every unsafe operation inside an unsafe fn now has its own narrow
unsafe block with a SAFETY note about that operation, and each unsafe fn has a
`/// # Safety` section naming the caller's contract. Claims that were not
verified are left as "not proven" rather than asserted. The lint is enabled
for umem only; the workspace table switch comes after the other crates.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 13:41:52 +00:00
github-bot changed target branch from main to gh-pr/101/base 2026-12-01 14:03:00 +00:00
github manually merged commit 58a3e8b721 into gh-pr/101/base 2026-12-01 14:03:01 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 14:01 UTC · original

Merged as f104060, thank you! This is exactly the shape that was meant: narrow blocks, a reason per operation, the callers' contracts in # Safety, and "not proven" where it isn't. #102 (with one fix, see there) and #104 are in the queue.

**@⁠vktory6** on GitHub · 2026-12-01 14:01 UTC · [original](https://github.com/vktory6/VKtory/pull/101#issuecomment-7313562467) Merged as f104060, thank you! This is exactly the shape that was meant: narrow blocks, a reason per operation, the callers' contracts in `# Safety`, and "not proven" where it isn't. #102 (with one fix, see there) and #104 are in the queue.
This discussion has been locked. Commenting is limited to contributors.
No description provided.