{
  "id": "rust/e0271-expected-bound-lifetime-parameter",
  "signature": "error[E0271]: type mismatch resolving `<X as Y>::Z` -- expected bound lifetime parameter `'a`, found concrete lifetime",
  "signature_zh": "错误[E0271]：类型不匹配，解析 `<X as Y>::Z` 时——期望绑定生命周期参数 `'a`，但找到具体生命周期",
  "regex": "error\\[E0271\\]: type mismatch resolving.*expected bound lifetime parameter.*found concrete lifetime",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A trait bound or associated type expects a generic lifetime parameter, but the implementation provides a concrete lifetime, causing a mismatch in higher-ranked trait bounds.",
  "root_cause_type": "generic",
  "root_cause_zh": "trait 约束或关联类型期望一个泛型生命周期参数，但实现提供了具体生命周期，导致高阶 trait 约束不匹配。",
  "versions": [
    {
      "version": "rustc 1.72.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.80.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Forces all references to be 'static, which is often too strict and may cause new borrow-checker errors.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Lifetime elision often defaults to '_, which may still not match the expected bound, and the error may shift to a different location.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Explicitly annotate the higher-ranked lifetime using `for<'a>` syntax in the trait bound, e.g., `T: for<'a> MyTrait<'a>`.",
      "success_rate": 0.85,
      "how": "Explicitly annotate the higher-ranked lifetime using `for<'a>` syntax in the trait bound, e.g., `T: for<'a> MyTrait<'a>`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Refactor the associated type to use a generic lifetime parameter instead of a concrete one, e.g., change `type Output = &i32` to `type Output<'a> = &'a i32`.",
      "success_rate": 0.8,
      "how": "Refactor the associated type to use a generic lifetime parameter instead of a concrete one, e.g., change `type Output = &i32` to `type Output<'a> = &'a i32`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a boxed trait object with dynamic dispatch to avoid lifetime parameter mismatches.",
      "success_rate": 0.75,
      "how": "Use a boxed trait object with dynamic dispatch to avoid lifetime parameter mismatches.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Explicitly annotate the higher-ranked lifetime using `for<'a>` syntax in the trait bound, e.g., `T: for<'a> MyTrait<'a>`.",
    "Refactor the associated type to use a generic lifetime parameter instead of a concrete one, e.g., change `type Output = &i32` to `type Output<'a> = &'a i32`.",
    "Use a boxed trait object with dynamic dispatch to avoid lifetime parameter mismatches."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0271.html",
  "official_doc_section": null,
  "error_code": "E0271",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}