{
  "id": "rust/e0599-no-method-found-trait-object",
  "signature": "error[E0599]: no method named `method` found for struct `Box<dyn Trait>` in the current scope",
  "signature_zh": "错误[E0599]：在当前作用域中未找到结构体 `Box<dyn Trait>` 的方法 `method`",
  "regex": "error\\[E0599\\]: no method named `[^`]+` found for struct `Box<dyn [^`]+>`",
  "domain": "rust",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Trying to call a method on a trait object that is not part of the trait's interface, often due to missing trait bound or incorrect dispatch.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在 trait 对象上调用不属于该 trait 接口的方法，通常是由于缺少 trait 约束或错误的派发。",
  "versions": [
    {
      "version": "rustc 1.66.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.73.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": "The method must be part of the trait definition; blanket impls cannot add new methods.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Downcasting requires `std::any::Any` trait and is not directly available for arbitrary trait objects.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Transmute is highly unsafe and likely to cause undefined behavior due to type layout differences.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add the method to the trait definition: `trait Trait { fn method(&self); }` and implement it for all types.",
      "success_rate": 0.9,
      "how": "Add the method to the trait definition: `trait Trait { fn method(&self); }` and implement it for all types.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a separate trait for the method and require it as a bound: `fn foo<T: Trait + OtherTrait>(t: &T) { t.other_method(); }`.",
      "success_rate": 0.85,
      "how": "Use a separate trait for the method and require it as a bound: `fn foo<T: Trait + OtherTrait>(t: &T) { t.other_method(); }`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using `Box<dyn Trait>`, downcast to a concrete type using `Any`: `let concrete: &Concrete = (*boxed).downcast_ref::<Concrete>().unwrap();`",
      "success_rate": 0.75,
      "how": "If using `Box<dyn Trait>`, downcast to a concrete type using `Any`: `let concrete: &Concrete = (*boxed).downcast_ref::<Concrete>().unwrap();`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add the method to the trait definition: `trait Trait { fn method(&self); }` and implement it for all types.",
    "Use a separate trait for the method and require it as a bound: `fn foo<T: Trait + OtherTrait>(t: &T) { t.other_method(); }`.",
    "If using `Box<dyn Trait>`, downcast to a concrete type using `Any`: `let concrete: &Concrete = (*boxed).downcast_ref::<Concrete>().unwrap();`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0599.html",
  "official_doc_section": null,
  "error_code": "E0599",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}