← ClaudeAtlas

rust-send-synclisted

Use when you decide whether a type is Send, Sync, both, or neither, and when the compiler rejects a value at a thread boundary. Covers the one rule that generates the rest, that &T is Send exactly when T is Sync. Covers the Send error whose help line names Sync, and the auto trait table for &T, &mut T, Box, Arc, Rc and raw pointers. Covers why Mutex<T> Sync needs only T Send while RwLock<T> Sync needs T Send + Sync, so the swap is not drop-in. Covers why MutexGuard is not Send but is Sync, so a scoped thread reads through a reference to the guard. Covers the four PhantomData markers and their variance side effect, auto trait leakage out of impl Trait and async fn, and E0321 on an unsafe impl for a reference type. Triggers on "Send", "Sync", "auto trait", "cannot be sent between threads safely", "cannot be shared between threads safely", "future cannot be sent between threads safely", "E0321", "PhantomData", "thread::scope", "Arc vs Rc", "MutexGuard is not Send", or "is not Send".
po4yka/rust-skills · ★ 2 · AI & Automation · score 76
Install: claude install-skill po4yka/rust-skills
# Rust Send and Sync ## Purpose Decide whether a type crosses a thread boundary, and read the diagnostic when it does not. One sentence generates almost every rule below: **`&T` is `Send` exactly when `T` is `Sync`**. `Sync` states that one fact at the type level. A `Send` error whose `help:` line names `Sync` therefore does not ask for a `Send` impl. It reports a shared reference to a non-shareable value. This skill is safe-code type reasoning. It stops where a manual `unsafe impl` starts: the proof obligation, the field audit, and the `SAFETY` comment belong to `rust-unsafe`. Atomics belong to `memory-model`. Cancel safety belongs to `rust-async-internals`. Every error text below comes from rustc 1.97.0, edition 2024, on aarch64-apple-darwin. ## Route the symptom to a section | Symptom or task | Section | | --- | --- | | `error[E0277]: X cannot be sent between threads safely` with `help: the trait Sync is not implemented` | [The one rule](#the-one-rule-t-is-send-exactly-when-t-is-sync) | | `error[E0277]: X cannot be shared between threads safely` | [The auto trait table](#the-auto-trait-table) | | `error[E0321]: cross-crate traits with a default impl, like Send` | [E0321](#unsafe-impl-send-cannot-target-a-reference-e0321) | | A `Mutex` was changed to an `RwLock` and the build broke | [Lock payload bounds](#lock-payload-bounds-mutex-and-rwlock-are-not-interchangeable) | | `MutexGuard<'_, T> cannot be sent between threads safely` | [Guards](#guards-mutexguard-is-not-sen