{
  "id": "rust/e0626-borrow-in-pattern-guard",
  "signature": "error[E0626]: borrow may still be in use when pattern guard evaluates",
  "signature_zh": "错误[E0626]：模式守卫求值时，借用可能仍在使用中",
  "regex": "error\\[E0626\\]: borrow may still be in use when pattern guard evaluates",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "`match` 分支的守卫条件中的借用可能在守卫求值时仍处于活动状态，因为编译器无法保证借用能在守卫运行前释放，可能导致别名冲突。",
  "versions": [
    {
      "version": "rustc 1.73.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.75.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.78.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "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.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Unsafe code can bypass borrow checking but introduces memory safety risks; the compiler still emits the error in safe code.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Refactor the guard condition to use a separate `if let` or a function that takes ownership or a reference with a shorter lifetime.",
      "success_rate": 0.85,
      "how": "Refactor the guard condition to use a separate `if let` or a function that takes ownership or a reference with a shorter lifetime.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Bind the value with a reference pattern and then use a separate condition outside the match, e.g., using `matches!` macro.",
      "success_rate": 0.8,
      "how": "Bind the value with a reference pattern and then use a separate condition outside the match, e.g., using `matches!` macro.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.75,
      "how": "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.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Refactor the guard condition to use a separate `if let` or a function that takes ownership or a reference with a shorter lifetime.",
    "Bind the value with a reference pattern and then use a separate condition outside the match, e.g., using `matches!` macro.",
    "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."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0626.html",
  "official_doc_section": null,
  "error_code": "E0626",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-11-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}