{
  "id": "rust/e0784-type-alias-bounds-on-associated-type",
  "signature": "error[E0784]: type alias bounds are not allowed on associated type `X`",
  "signature_zh": "错误[E0784]：关联类型 `X` 上不允许类型别名约束",
  "regex": "error\\[E0784\\]: type alias bounds are not allowed on associated type `[a-zA-Z_][a-zA-Z0-9_]*`",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Using a type alias with bounds (e.g., `type Foo = Bar + Bound`) on an associated type in a trait definition, which is syntactically ambiguous and not supported; associated types should use `trait` bounds instead.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 trait 定义中对关联类型使用带有约束的类型别名（例如 `type Foo = Bar + Bound`），这在语法上存在歧义且不被支持；关联类型应使用 trait 约束。",
  "versions": [
    {
      "version": "rustc 1.77.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.79.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.81.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Parentheses create a tuple type, not a bounded type alias; the compiler will then complain about wrong types.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing to a generic parameter changes the trait's design and may require propagating the generic to all implementors, which is not always desirable.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace the type alias with an associated type that has a trait bound in the where clause, e.g., `type Foo: Bound;`.",
      "success_rate": 0.9,
      "how": "Replace the type alias with an associated type that has a trait bound in the where clause, e.g., `type Foo: Bound;`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Remove the bound from the type alias and apply it to the trait or method where the associated type is used.",
      "success_rate": 0.85,
      "how": "Remove the bound from the type alias and apply it to the trait or method where the associated type is used.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a separate trait to express the bound, e.g., `trait MyTrait: BoundProvider { type Foo; }` where `BoundProvider` specifies the bound.",
      "success_rate": 0.8,
      "how": "Use a separate trait to express the bound, e.g., `trait MyTrait: BoundProvider { type Foo; }` where `BoundProvider` specifies the bound.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Replace the type alias with an associated type that has a trait bound in the where clause, e.g., `type Foo: Bound;`.",
    "Remove the bound from the type alias and apply it to the trait or method where the associated type is used.",
    "Use a separate trait to express the bound, e.g., `trait MyTrait: BoundProvider { type Foo; }` where `BoundProvider` specifies the bound."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0784.html",
  "official_doc_section": null,
  "error_code": "E0784",
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2024-02-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}