ReviewOS

home-lang/home

feat(types): Send/Sync auto traits and thread-aware borrow checking

#806
Open chris opened this 9 days ago ·
9 days ago

Problem

Data-race freedom is not enforced anywhere, yet ROADMAP-WEB-COMPETITIVE.md marks "No data races (Send/Sync) – Done ✅". The built-in traits are Copy/Clone/Display/Debug/Default/Eq/Ord/Hash only; Send/Sync appear only in packages/safety/src/unsafe_blocks.zig, which isn't built. borrow_check_pass.zig tracks moves and borrows but knows nothing about threads or captures that cross them. Threads with shared objects are only safe with this. (New direction.)

Evidence (origin/main @ d4b219507)

Scope

  • Send / Sync auto traits derived structurally; raw pointers and non-atomic RC opt out.
  • spawn requires Send captures; shared references across threads require Sync.
  • Borrow checker: no &mut shared across threads; scoped threads may borrow.

Acceptance criteria

  • Sending a non-Send value into spawn is a compile error with a dedicated code and test.
  • Sharing &mut across threads is rejected; Arc<Mutex<T>> is accepted.

Depends on: #805 Part of #814.

Sign in to comment on this issue.