{
  "id": "rust/e0594-cannot-assign-to-data-in-an-arc",
  "signature": "error[E0594]: cannot assign to data in an `Arc`",
  "signature_zh": "错误[E0594]：无法赋值给 `Arc` 中的数据",
  "regex": "error\\[E0594\\]: cannot assign to data in an `Arc`",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Attempting to mutate data behind an `Arc<T>` without interior mutability (e.g., `Mutex`, `RwLock`, or `Cell`).",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在没有内部可变性（例如 `Mutex`、`RwLock` 或 `Cell`）的情况下修改 `Arc<T>` 背后的数据。",
  "versions": [
    {
      "version": "1.65.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.68.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.72.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using `unsafe` to cast `Arc<T>` to a mutable reference via raw pointer",
      "why_fails": "Undefined behavior due to data races; violates Rust's safety guarantees.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping the entire `Arc` in a `RefCell` without thread safety",
      "why_fails": "`RefCell` is not `Sync`, so the `Arc<RefCell<T>>` cannot be shared across threads.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use `Arc<Mutex<T>>` and lock before mutation: `*arc.lock().unwrap() = new_value;`",
      "success_rate": 0.92,
      "how": "Use `Arc<Mutex<T>>` and lock before mutation: `*arc.lock().unwrap() = new_value;`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `Arc<AtomicU32>` for simple numeric types and `store` method.",
      "success_rate": 0.95,
      "how": "Use `Arc<AtomicU32>` for simple numeric types and `store` method.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 `Arc<Mutex<T>>` 并在修改前加锁：`*arc.lock().unwrap() = new_value;`",
    "对于简单的数值类型使用 `Arc<AtomicU32>` 和 `store` 方法。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0594.html",
  "official_doc_section": null,
  "error_code": "E0594",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}