{
  "id": "rust/e0759-has-an-anonymous-lifetime",
  "signature": "error[E0759]: `X` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement",
  "signature_zh": "错误[E0759]：`X` 具有匿名生命周期 `'_`，但需要满足 `'static` 生命周期要求",
  "regex": "error\\[E0759\\]: `[^`]+` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A reference with an elided lifetime (anonymous `'_`) is passed where a `'static` lifetime is required, often in async or thread spawning contexts.",
  "root_cause_type": "generic",
  "root_cause_zh": "具有省略生命周期（匿名 `'_`）的引用被传递到需要 `'static` 生命周期的上下文中，常见于异步或线程生成场景。",
  "versions": [
    {
      "version": "1.74.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.76.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.78.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding `'static` lifetime bound to the generic parameter without ensuring the data lives long enough",
      "why_fails": "Causes borrow checker errors or requires `unsafe`; often the data is not actually static.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using `Box::leak` to create a `&'static mut` reference",
      "why_fails": "Memory leak; only works if the data is truly intended to live forever, rare in practice.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use `Arc<T>` and move the `Arc` into the closure/task: `let shared = Arc::new(data); tokio::spawn(async move { /* use shared */ });`",
      "success_rate": 0.85,
      "how": "Use `Arc<T>` and move the `Arc` into the closure/task: `let shared = Arc::new(data); tokio::spawn(async move { /* use shared */ });`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Annotate the lifetime explicitly: `fn foo<'a>(x: &'a str) -> impl 'a + Future { ... }` and ensure the caller owns the data.",
      "success_rate": 0.78,
      "how": "Annotate the lifetime explicitly: `fn foo<'a>(x: &'a str) -> impl 'a + Future { ... }` and ensure the caller owns the data.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 `Arc<T>` 并将 `Arc` 移入闭包/任务：`let shared = Arc::new(data); tokio::spawn(async move { /* 使用 shared */ });`",
    "显式标注生命周期：`fn foo<'a>(x: &'a str) -> impl 'a + Future { ... }` 并确保调用者拥有数据。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0759.html",
  "official_doc_section": null,
  "error_code": "E0759",
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}