greenfield: apply the root workspace's rustc lints everywhere #95

Closed
github-bot wants to merge 1 commit from github-bot/gh-95 into main AGit
Owner

@⁠TheRifai on GitHub · 2026-12-01 13:19 UTC · original
TheRifai:rustc-lints-all → main · +104 −59 · 14 files · 1 commits · closed without merging

What

The root workspace denies unsafe_op_in_unsafe_fn and unused_must_use, but greenfield and greenfield/wine never inherited them (docs/TASKS.md “The root workspace's rustc lints everywhere”, issue #41). Both workspaces now carry the same [workspace.lints.rust] table, and xtask's lint_tables_match test checks the rustc table as well as clippy. The unsafe operations that were implicitly allowed in unsafe fn bodies are wrapped in explicit unsafe {} blocks, each with a // SAFETY: note naming the caller contract. cargo fix produced scope-correct wraps; every block was reviewed. No caller or rendering behaviour changed.

The reference

The root Cargo.toml is the policy source; the two copies and the xtask check keep the fork's workspaces in sync with it, as they already do for clippy.

Evidence

  • cargo check --workspace --all-targets --locked clean in both greenfield/ and greenfield/wine/, with the deny in place.
  • Root tests (240 + xtask 6) and greenfield library tests (11 + 16 + 151) plus policy (6) pass; tools/build.sh succeeds.

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 new unsafe block has a // SAFETY: comment (rule 36)
  • Check, build and 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:19 UTC · [original](https://github.com/vktory6/VKtory/pull/95) `TheRifai:rustc-lints-all` → `main` · +104 −59 · 14 files · 1 commits · closed without merging ## What The root workspace denies `unsafe_op_in_unsafe_fn` and `unused_must_use`, but greenfield and greenfield/wine never inherited them (docs/TASKS.md “The root workspace's rustc lints everywhere”, issue #41). Both workspaces now carry the same `[workspace.lints.rust]` table, and xtask's `lint_tables_match` test checks the rustc table as well as clippy. The unsafe operations that were implicitly allowed in `unsafe fn` bodies are wrapped in explicit `unsafe {}` blocks, each with a `// SAFETY:` note naming the caller contract. `cargo fix` produced scope-correct wraps; every block was reviewed. No caller or rendering behaviour changed. ## The reference The root `Cargo.toml` is the policy source; the two copies and the xtask check keep the fork's workspaces in sync with it, as they already do for clippy. ## Evidence - `cargo check --workspace --all-targets --locked` clean in both `greenfield/` and `greenfield/wine/`, with the deny in place. - Root tests (240 + xtask 6) and greenfield library tests (11 + 16 + 151) plus policy (6) pass; `tools/build.sh` succeeds. ## 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 new `unsafe` block has a `// SAFETY:` comment (rule 36) - [x] Check, build and 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)
Add [workspace.lints.rust] (unsafe_op_in_unsafe_fn, unused_must_use) to both
greenfield workspaces and teach xtask's lint_tables_match to check the rustc
table as well as clippy (docs/TASKS.md, issue #41). cargo fix wrapped the
remaining unsafe operations in explicit blocks; each new block carries a
SAFETY note naming the caller contract. No behaviour changes.

Root, greenfield and wine checks/tests and tools/build.sh pass.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 13:20:04 +00:00
Author
Owner

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

Thanks for widening it. Our comments crossed: you closed #94 a minute before my review there (#94), and this PR has the same shape, so the same points apply. In short:

  • 23 of the 28 new blocks wrap a whole function body ({ unsafe { … }}). That is the same as before the lint; it should be one narrow unsafe { } per unsafe operation.
  • Each block gets a // SAFETY: saying why that operation is sound there; the caller's contract goes in a /// # Safety doc section on the unsafe fn.
  • Only claims you've checked: "caller holds the lock" and similar need the thing that guarantees it named, or "not proven: …".

The lint-table part (both workspaces carry the root table, xtask checks it) is good as it is. If it helps, split it: one PR per crate for the unsafe sites (umem first) and the table switch last, once the sites are narrow. Holding this one until then.

**@⁠vktory6** on GitHub · 2026-12-01 13:23 UTC · [original](https://github.com/vktory6/VKtory/pull/95#issuecomment-7312546347) Thanks for widening it. Our comments crossed: you closed #94 a minute before my review there (https://git.gtahub.st/github/vktory6--VKtory/pulls/94), and this PR has the same shape, so the same points apply. In short: - 23 of the 28 new blocks wrap a whole function body (`{ unsafe { … }}`). That is the same as before the lint; it should be one narrow `unsafe { }` per unsafe operation. - Each block gets a `// SAFETY:` saying why *that* operation is sound there; the caller's contract goes in a `/// # Safety` doc section on the `unsafe fn`. - Only claims you've checked: "caller holds the lock" and similar need the thing that guarantees it named, or "not proven: …". The lint-table part (both workspaces carry the root table, xtask checks it) is good as it is. If it helps, split it: one PR per crate for the unsafe sites (umem first) and the table switch last, once the sites are narrow. Holding this one until then.
github-bot closed this pull request 2026-12-01 13:36:35 +00:00
Author
Owner

@⁠TheRifai on GitHub · 2026-12-01 13:33 UTC · original

Closing per review: reworking umem's unsafe sites with narrow blocks and specific SAFETY notes before re-enabling the lint.

**@⁠TheRifai** on GitHub · 2026-12-01 13:33 UTC · [original](https://github.com/vktory6/VKtory/pull/95#issuecomment-7312821143) Closing per review: reworking umem's unsafe sites with narrow blocks and specific SAFETY notes before re-enabling the lint.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.