{
  "id": "rust/e0432-unresolved-import-crate-name-hyphen",
  "signature": "error[E0432]: unresolved import `my-crate` -- could not find `my-crate` in the crate root",
  "signature_zh": "错误[E0432]：无法解析导入 `my-crate` -- 在 crate 根中找不到 `my-crate`",
  "regex": "error\\[E0432\\]: unresolved import `.*-.*` -- could not find `.*` in the crate root",
  "domain": "rust",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Rust crate names with hyphens are automatically converted to underscores in code; use `my_crate` instead of `my-crate` in use statements.",
  "root_cause_type": "generic",
  "root_cause_zh": "Rust 中带连字符的 crate 名称在代码中会自动转换为下划线；在 use 语句中应使用 `my_crate` 而不是 `my-crate`。",
  "versions": [
    {
      "version": "rustc 1.56.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.63.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rustc 1.70.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "extern crate also uses the underscore convention. The hyphen is only valid in Cargo.toml dependency names, not in code.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Cargo.toml dependency names can have hyphens, but the crate name in Rust source is always underscores. Renaming in Cargo.toml is unnecessary.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hyphens are not valid in Rust identifiers. Use underscores instead.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace hyphens with underscores in all use statements: `use my_crate::SomeType;`",
      "success_rate": 0.98,
      "how": "Replace hyphens with underscores in all use statements: `use my_crate::SomeType;`",
      "condition": "",
      "sources": []
    },
    {
      "action": "In Cargo.toml, use the `package` key to rename: `my_crate = { package = \"my-crate\", version = \"1.0\" }` then import as `my_crate`.",
      "success_rate": 0.95,
      "how": "In Cargo.toml, use the `package` key to rename: `my_crate = { package = \"my-crate\", version = \"1.0\" }` then import as `my_crate`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `extern crate my_crate as my_crate;` if needed for legacy code.",
      "success_rate": 0.85,
      "how": "Use `extern crate my_crate as my_crate;` if needed for legacy code.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在所有 use 语句中将连字符替换为下划线：`use my_crate::SomeType;`",
    "在 Cargo.toml 中使用 `package` 键重命名：`my_crate = { package = \"my-crate\", version = \"1.0\" }`，然后以 `my_crate` 导入。",
    "如果需要，使用 `extern crate my_crate as my_crate;` 用于遗留代码。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://doc.rust-lang.org/error_codes/E0432.html",
  "official_doc_section": null,
  "error_code": "E0432",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.98,
  "resolvable": "true",
  "first_seen": "2023-02-14",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}