# error[E0626]: borrow may still be in use when pattern guard evaluates

- **ID:** `rust/e0626-borrow-in-pattern-guard`
- **Domain:** rust
- **Category:** type_error
- **Error Code:** `E0626`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

A borrow in a `match` arm's guard condition may still be active when the guard evaluates, because the compiler cannot guarantee the borrow is released before the guard runs, leading to potential aliasing violations.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| rustc 1.73.0 | active | — | — |
| rustc 1.75.0 | active | — | — |
| rustc 1.78.0 | active | — | — |

## Workarounds

1. **Refactor the guard condition to use a separate `if let` or a function that takes ownership or a reference with a shorter lifetime.** (85% success)
   ```
   Refactor the guard condition to use a separate `if let` or a function that takes ownership or a reference with a shorter lifetime.
   ```
2. **Bind the value with a reference pattern and then use a separate condition outside the match, e.g., using `matches!` macro.** (80% success)
   ```
   Bind the value with a reference pattern and then use a separate condition outside the match, e.g., using `matches!` macro.
   ```
3. **Use a `match` with a guard that does not borrow, e.g., by copying a boolean flag or using a method that returns a value without borrowing.** (75% success)
   ```
   Use a `match` with a guard that does not borrow, e.g., by copying a boolean flag or using a method that returns a value without borrowing.
   ```

## Dead Ends

- **** — Cloning creates a new value but the borrow of the original may still be active in the guard's scope; the compiler still sees the borrow. (55% fail)
- **** — Unsafe code can bypass borrow checking but introduces memory safety risks; the compiler still emits the error in safe code. (65% fail)
