Skip to content

lint: add # Safety docs to FFI exports, clean up clippy warnings#10

Merged
membphis merged 2 commits into
mainfrom
worktree-ffi-safety-docs
May 15, 2026
Merged

lint: add # Safety docs to FFI exports, clean up clippy warnings#10
membphis merged 2 commits into
mainfrom
worktree-ffi-safety-docs

Conversation

@membphis
Copy link
Copy Markdown
Collaborator

Summary

  • Add # Safety sections to all 20 public qjd_* FFI exports plus the test-panic export; a module-level shared-contract block keeps per-function docs short. Also fixes adjacent clippy warnings (transmute annotations, collapsible_if, approx_constant, same_item_push, hidden lifetime).
  • Drop cargo fmt --check from make lint: the codebase uses intentional manual column alignment that default rustfmt would reflow. Tracked as a deferred decision in README rather than reformatted.
  • README "Roadmap / Deferred" updated: remove the now-done safety-docs item; refine the AVX-512 estimate to 1.5–1.8× (L3-bandwidth-bound per a profile run, not a clean 2×); add validate_brackets fusion as a new deferred item (profile showed it's 65% of parse on dense workloads, 0.3% on the current string-heavy bench).

Test plan

  • make lint (clippy -D warnings, all-targets) — green
  • cargo clippy --release --all-targets --no-default-features -- -D warnings — green
  • cargo clippy --release --all-targets --features test-panic -- -D warnings — green
  • cargo test --release — all integration + unit tests pass
  • Lua busted suite — verified locally is environment-dependent (busted not installed on this dev box); CI runs it

membphis added 2 commits May 15, 2026 17:03
Make `make lint` (cargo clippy -D warnings, all-targets) green:

- Add `# Safety` sections to all 20 public `qjd_*` extern "C" functions
  plus the test-panic export. A module-level shared-contract block in
  ffi.rs documents the common obligations (live doc, valid path slice,
  scratch-buffer lifetime, panic barrier) so per-function docs stay short.
- Annotate the two `std::mem::transmute` calls with explicit types.
- Collapse bracket-mismatch arms in validate_brackets into match guards.
- Stop approximating PI in two tests; switch to arbitrary decimals.
- Use Vec::resize instead of per-byte push loops in scanner test fixtures.
- Make path::tests::parse's elided lifetime explicit.

Drop `cargo fmt --check` from `make lint`: the codebase uses manual
column alignment in struct definitions and compact single-line literals
that default rustfmt would reflow. Recorded as a deferred item rather
than reformatted, since style was an intentional choice.

README "Roadmap / Deferred" updated:
- Remove the safety-docs entry (done).
- Refine AVX-512 estimate to 1.5-1.8x on the bench (L3-bandwidth bound
  per profile session, not a clean 2x).
- Add `validate_brackets` fusion as a new deferred item: profiling
  showed it's 65% of parse time on structurally-dense JSON (0.3% on the
  current string-heavy bench), so it's a win for config/JSONL workloads
  but not for the current bench scenario.
Local review caught that swapping 3.14 → 2.5 (to silence
clippy::approx_constant) accidentally removed the only f64 test
exercising the decimal-to-binary rounding path: 2.5 is exactly
representable in IEEE-754, as are the rest of the suite's values.

Switch to 1.7, which is inexact like the original 3.14 was, and
rename `f64_decimal` to `f64_inexact_decimal` so the intent is
visible in the test name.
@membphis membphis merged commit 9b2b5d7 into main May 15, 2026
1 check passed
@membphis membphis deleted the worktree-ffi-safety-docs branch May 15, 2026 17:16
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.

1 participant