umem: deny unsafe_op_in_unsafe_fn #94
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!94
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-94"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TheRifai on GitHub · 2026-12-01 13:14 UTC · original
TheRifai:umem-rustc-lints→main· +50 −33 · 5 files · 1 commits · closed without mergingWhat
umemnow deniesunsafe_op_in_unsafe_fn(docs/TASKS.md “The root workspace's rustc lints everywhere”, issue #41). The 17 unsafe operations that were implicitly allowed insideunsafe fnbodies are wrapped in explicitunsafe {}blocks, each with a// SAFETY:note naming the caller contract that makes it sound. The wraps were produced bycargo fix(scope-correct) and reviewed function by function; no caller or behaviour changed.This is the first crate in greenfield to carry the lint; the workspace-wide switch can be turned on once the other crates' sites are wrapped the same way.
The reference
The root Cargo.toml already denies this lint for the primary workspace; this brings umem in line with it.
Evidence
cargo check -p umem --all-targets --lockedandcargo check --workspace --all-targets --lockedingreenfield/are clean with the deny in place;tools/build.shsucceeds.cargo test -p umem --lib --locked: 16 pass.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited (rule 29/31)unsafeblock has a// SAFETY:comment (rule 36)@TheRifai on GitHub · 2026-12-01 13:19 UTC · original
Superseded by a workspace-wide lint PR that also covers frame, vkback, the wine crates and xtask's lint-table check.
@vktory6 on GitHub · 2026-12-01 13:20 UTC · original
Thanks, the lint is wanted (#41), but this version can't go in as it is, and maintainer edits are off here so I can't adjust it myself.
The problem is the shape
cargo fixproduces: it wraps each whole function body in oneunsafe { … }. That is the same as before the lint. Its point is that every unsafe operation inside anunsafe fngets its own block and its own reason, so a reader sees exactly which calls are unsafe and why each is fine.What would make it mergeable (rule 36):
unsafe { }around each unsafe operation (the FFI call, the pointer read, themmap), not around the body.// SAFETY:at each block, saying why that operation is sound at that point (e.g. "p..p+lenwas checked against the chunk's extent above")./// # Safetydoc section on theunsafe fn, where the current comments are trying to say it. Right now one sits between two parameters of the debug callback, anddestroyhas none.State's lock" or "no submission uses the chunk". If that's true, name what guarantees it (the guard type, the function that waits for the timeline); if you're not sure, say "not proven: …" instead. A SAFETY comment that hasn't been checked is worse than none, because it makes the code look audited.Doing umem first and the other crates later is fine.
Pull request closed