{
  "id": "rust/e0308-mismatched-types-async",
  "signature": "error[E0308]: mismatched types -- expected `impl Future<Output = ()>`, found `()`",
  "signature_zh": "错误[E0308]: 类型不匹配 —— 期望 `impl Future<Output = ()>`，找到 `()`",
  "regex": "error\\[E0308\\]: mismatched types -- expected `impl Future<Output = .*>`, found `.*`",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "An async function or block is returning a value directly instead of returning a Future, often due to missing 'async' keyword or incorrect return type.",
  "root_cause_type": "generic",
  "root_cause_zh": "异步函数或块直接返回了一个值，而不是返回一个 Future，通常是由于缺少 'async' 关键字或返回类型不正确。",
  "versions": [
    {
      "version": "1.65.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.72.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.80.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding '.await' at the call site without making the calling function async — this causes a different error about 'await' outside async context.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Returning a 'Box::pin(future)' without adjusting the return type — still mismatched type.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add 'async' keyword to the function definition: 'async fn my_func() -> () { /* ... */ }'. This wraps the return value in a Future.",
      "success_rate": 0.95,
      "how": "Add 'async' keyword to the function definition: 'async fn my_func() -> () { /* ... */ }'. This wraps the return value in a Future.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the function must return a Future manually, change return type to 'Pin<Box<dyn Future<Output = ()>>>' and return 'Box::pin(async move { ... })'.",
      "success_rate": 0.85,
      "how": "If the function must return a Future manually, change return type to 'Pin<Box<dyn Future<Output = ()>>>' and return 'Box::pin(async move { ... })'.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add 'async' keyword to the function definition: 'async fn my_func() -> () { /* ... */ }'. This wraps the return value in a Future.",
    "If the function must return a Future manually, change return type to 'Pin<Box<dyn Future<Output = ()>>>' and return 'Box::pin(async move { ... })'."
  ],
  "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.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-08-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}