{
  "id": "rust/e0193-cannot-destruct-type-with-drop",
  "signature": "error[E0193]: cannot destructure a type that implements `Drop`; use `std::mem::ManuallyDrop`",
  "signature_zh": "错误[E0193]：无法解构实现了 `Drop` 的类型；请使用 `std::mem::ManuallyDrop`",
  "regex": "error\\[E0193\\]: cannot destructure a type that implements `Drop`",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Trying to pattern match or destructure a value of a type that implements the `Drop` trait, which would cause a double drop or undefined behavior if the destructor runs after partial moves.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试对实现了 `Drop` trait 的类型进行模式匹配或解构，这会导致部分移动后析构函数运行，可能造成双重释放或未定义行为。",
  "versions": [
    {
      "version": "rustc 1.79.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.80.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.82.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is about the language restriction on destructuring `Drop` types; implementing `Drop` again doesn't remove the restriction.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Unsafe code can bypass the check but risks double drops or memory corruption; the compiler still prevents safe destructuring.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Wrap the field in `std::mem::ManuallyDrop` to prevent automatic drop, allowing destructuring.",
      "success_rate": 0.85,
      "how": "Wrap the field in `std::mem::ManuallyDrop` to prevent automatic drop, allowing destructuring.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Refactor the type to not implement `Drop`, e.g., by moving cleanup logic to a separate method that users call explicitly.",
      "success_rate": 0.8,
      "how": "Refactor the type to not implement `Drop`, e.g., by moving cleanup logic to a separate method that users call explicitly.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `std::mem::take` or `std::mem::replace` to extract values without destructuring, then handle cleanup manually.",
      "success_rate": 0.75,
      "how": "Use `std::mem::take` or `std::mem::replace` to extract values without destructuring, then handle cleanup manually.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Wrap the field in `std::mem::ManuallyDrop` to prevent automatic drop, allowing destructuring.",
    "Refactor the type to not implement `Drop`, e.g., by moving cleanup logic to a separate method that users call explicitly.",
    "Use `std::mem::take` or `std::mem::replace` to extract values without destructuring, then handle cleanup manually."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0193.html",
  "official_doc_section": null,
  "error_code": "E0193",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}