{
  "id": "rust/e0277-async-fn-not-send",
  "signature": "error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely\n\n`Rc<()>` is not `Send` because `Rc` is not `Send`",
  "signature_zh": "错误[E0277]：`std::rc::Rc<()>` 无法在线程间安全发送\n\n`Rc<()>` 不是 `Send` 的，因为 `Rc` 不是 `Send` 的",
  "regex": "`std::rc::Rc<.+>` cannot be sent between threads safely",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Using `Rc` inside an async block or future that is expected to implement `Send`, typically when spawning a task with `tokio::spawn`.",
  "root_cause_type": "generic",
  "root_cause_zh": "在需要实现 `Send` 的异步块或 future 中使用了 `Rc`，通常在使用 `tokio::spawn` 生成任务时发生。",
  "versions": [
    {
      "version": "rustc 1.75",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tokio 1.35",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "`Mutex<Rc>` still doesn't make `Rc` `Send`; `Rc` is fundamentally not thread-safe. You need `Arc` instead.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Unsafe to implement `Send` for `Rc`; leads to data races and undefined behavior.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace `Rc` with `Arc` (atomic reference counting) and `RefCell` with `Mutex` or `RwLock`.",
      "success_rate": 0.95,
      "how": "Replace `Rc` with `Arc` (atomic reference counting) and `RefCell` with `Mutex` or `RwLock`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `tokio::task::LocalSet` to spawn non-Send futures on the current thread if you must keep `Rc`.",
      "success_rate": 0.85,
      "how": "Use `tokio::task::LocalSet` to spawn non-Send futures on the current thread if you must keep `Rc`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将 `Rc` 替换为 `Arc`（原子引用计数），并将 `RefCell` 替换为 `Mutex` 或 `RwLock`。",
    "使用 `tokio::task::LocalSet` 在当前线程上生成非 Send 的 future，如果你必须保留 `Rc`。"
  ],
  "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.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}