# 错误[E0277]：`Cell<i32>` 无法在线程间安全共享

- **ID:** `rust/e0277-send-not-implemented-for-arc-cell`
- **领域:** rust
- **类别:** type_error
- **错误码:** `E0277`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

尝试在线程间发送包含 `Cell`（它实现了 `!Send`）的类型，通常通过 `Arc<Cell<T>>` 或带有 `Cell` 字段的结构体。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| rustc 1.68 | active | — | — |
| rustc 1.75 | active | — | — |
| rustc 1.82 | active | — | — |
| rustc 1.90 | active | — | — |

## 解决方案

1. ```
   Replace Cell with Mutex: `let shared = Arc::new(Mutex::new(42));` then use `shared.lock().unwrap()` to access the value. This makes the type Send because Mutex<T> is Send if T: Send.
   ```
2. ```
   Use `std::cell::RefCell` with `Mutex` outer: `Arc<Mutex<RefCell<T>>>` if interior mutability is needed but the outer type must be Send.
   ```
3. ```
   If the value is only read, use `Arc<std::sync::RwLock<T>>` for better concurrency.
   ```

## 无效尝试

- **** — Arc<T> only implements Send if T: Send, and Cell is !Send, so Arc<Cell<i32>> remains !Send. (95% 失败率)
- **** — Unsafe impl of Send for a type containing Cell is unsound; the compiler will still reject it unless you also disable the lint, and it may cause data races at runtime. (85% 失败率)
- **** — The compiler correctly rejects because the closure captures a !Send type, even with move. (90% 失败率)
