{
  "id": "rust/e0308-match-arm-different-types-with-generic",
  "signature": "error[E0308]: `match` arms have incompatible types\n\nnote: expected `Result<(), MyError>`\n      found `Result<(), OtherError>`",
  "signature_zh": "错误[E0308]：`match` 分支的类型不兼容\n\n注意：期望 `Result<(), MyError>`\n      发现 `Result<(), OtherError>`",
  "regex": "`match` arms have incompatible types.*expected `Result<.+>`.*found `Result<.+>`",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Different match arms return `Result` types with different error types, even if both implement `From` or `Into`.",
  "root_cause_type": "generic",
  "root_cause_zh": "不同的 match 分支返回具有不同错误类型的 `Result` 类型，即使两者都实现了 `From` 或 `Into`。",
  "versions": [
    {
      "version": "rustc 1.74",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.75",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Only fixes one arm; compiler still sees mismatch if the other arm has a different error type.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Panics on error; not a proper fix for error handling.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use `.map_err()` on each arm to convert errors to a common type: `arm1.map_err(|e| MyError::from(e))`.",
      "success_rate": 0.9,
      "how": "Use `.map_err()` on each arm to convert errors to a common type: `arm1.map_err(|e| MyError::from(e))`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Define a unified error enum that wraps both error types and implement `From` for each.",
      "success_rate": 0.95,
      "how": "Define a unified error enum that wraps both error types and implement `From` for each.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在每个分支上使用 `.map_err()` 将错误转换为公共类型：`arm1.map_err(|e| MyError::from(e))`。",
    "定义一个统一的错误枚举，包装两种错误类型，并为每种类型实现 `From`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/stable/error_codes/E0308.html",
  "official_doc_section": null,
  "error_code": "E0308",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-10-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}