{
  "id": "rust/e0277-send-not-implemented-for-arc-cell",
  "signature": "error[E0277]: `Cell<i32>` cannot be shared between threads safely",
  "signature_zh": "错误[E0277]：`Cell<i32>` 无法在线程间安全共享",
  "regex": "error\\[E0277\\]: `Cell<.*>` cannot be shared between threads safely",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Attempting to send a type containing Cell (which is !Send) across threads, typically via Arc<Cell<T>> or a struct with Cell field.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在线程间发送包含 `Cell`（它实现了 `!Send`）的类型，通常通过 `Arc<Cell<T>>` 或带有 `Cell` 字段的结构体。",
  "versions": [
    {
      "version": "rustc 1.68",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.75",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.82",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.90",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Arc<T> only implements Send if T: Send, and Cell is !Send, so Arc<Cell<i32>> remains !Send.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "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.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The compiler correctly rejects because the closure captures a !Send type, even with move.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.95,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `std::cell::RefCell` with `Mutex` outer: `Arc<Mutex<RefCell<T>>>` if interior mutability is needed but the outer type must be Send.",
      "success_rate": 0.8,
      "how": "Use `std::cell::RefCell` with `Mutex` outer: `Arc<Mutex<RefCell<T>>>` if interior mutability is needed but the outer type must be Send.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the value is only read, use `Arc<std::sync::RwLock<T>>` for better concurrency.",
      "success_rate": 0.85,
      "how": "If the value is only read, use `Arc<std::sync::RwLock<T>>` for better concurrency.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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.",
    "Use `std::cell::RefCell` with `Mutex` outer: `Arc<Mutex<RefCell<T>>>` if interior mutability is needed but the outer type must be Send.",
    "If the value is only read, use `Arc<std::sync::RwLock<T>>` for better concurrency."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/stable/error_codes/E0277.html",
  "official_doc_section": null,
  "error_code": "E0277",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-01-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}