# error[E0193]: cannot destructure a type that implements `Drop`; use `std::mem::ManuallyDrop`

- **ID:** `rust/e0193-cannot-destruct-type-with-drop`
- **Domain:** rust
- **Category:** type_error
- **Error Code:** `E0193`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| rustc 1.79.0 | active | — | — |
| rustc 1.80.0 | active | — | — |
| rustc 1.82.0 | active | — | — |

## Workarounds

1. **Wrap the field in `std::mem::ManuallyDrop` to prevent automatic drop, allowing destructuring.** (85% success)
   ```
   Wrap the field in `std::mem::ManuallyDrop` to prevent automatic drop, allowing destructuring.
   ```
2. **Refactor the type to not implement `Drop`, e.g., by moving cleanup logic to a separate method that users call explicitly.** (80% success)
   ```
   Refactor the type to not implement `Drop`, e.g., by moving cleanup logic to a separate method that users call explicitly.
   ```
3. **Use `std::mem::take` or `std::mem::replace` to extract values without destructuring, then handle cleanup manually.** (75% success)
   ```
   Use `std::mem::take` or `std::mem::replace` to extract values without destructuring, then handle cleanup manually.
   ```

## Dead Ends

- **** — The error is about the language restriction on destructuring `Drop` types; implementing `Drop` again doesn't remove the restriction. (75% fail)
- **** — Unsafe code can bypass the check but risks double drops or memory corruption; the compiler still prevents safe destructuring. (60% fail)
