{
  "id": "rust/e0080-constant-evaluation-error-divide-by-zero",
  "signature": "error[E0080]: constant evaluation error: division by zero",
  "signature_zh": "错误[E0080]：常量求值错误：除以零",
  "regex": "error\\[E0080\\]: constant evaluation error: division by zero",
  "domain": "rust",
  "category": "const-eval",
  "subcategory": null,
  "root_cause": "A constant expression performs division or modulo by zero at compile time.",
  "root_cause_type": "generic",
  "root_cause_zh": "常量表达式在编译时执行了除以零或取模零的操作。",
  "versions": [
    {
      "version": "1.63.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.66.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.70.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using `unsafe` to bypass the check in const context",
      "why_fails": "`unsafe` is not allowed in const contexts; compiler rejects it.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing the divisor to a variable to defer evaluation to runtime",
      "why_fails": "If the divisor is still zero at runtime, it causes a panic; compile-time check is bypassed but runtime error remains.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the divisor is non-zero by using a conditional: `const DIV: u32 = if DENOM != 0 { NUM / DENOM } else { 0 };`",
      "success_rate": 0.95,
      "how": "Ensure the divisor is non-zero by using a conditional: `const DIV: u32 = if DENOM != 0 { NUM / DENOM } else { 0 };`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use checked arithmetic: `const RESULT: Option<u32> = NUM.checked_div(DENOM);`",
      "success_rate": 0.9,
      "how": "Use checked arithmetic: `const RESULT: Option<u32> = NUM.checked_div(DENOM);`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过条件确保除数非零：`const DIV: u32 = if DENOM != 0 { NUM / DENOM } else { 0 };`",
    "使用检查算术：`const RESULT: Option<u32> = NUM.checked_div(DENOM);`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0080.html",
  "official_doc_section": null,
  "error_code": "E0080",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-06-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}