E0432 rust module_error ai_generated true

错误[E0432]:未解析的导入 `crate::module::Item`

error[E0432]: unresolved import `crate::module::Item`

ID: rust/e0432-unresolved-import-crate

其他格式: JSON · Markdown 中文 · English
90%修复率
85%置信度
1证据数
2023-08-20首次发现

版本兼容性

版本状态引入弃用备注
rustc 1.65.0 active
rustc 1.72.0 active
rustc 1.80.0 active

根因分析

指定的模块或项在 crate 的模块树中不存在,通常是由于缺少 `mod` 声明或路径错误。

English

The specified module or item does not exist in the crate's module tree, often due to missing `mod` declaration or incorrect path.

generic

官方文档

https://doc.rust-lang.org/error_codes/E0432.html

解决方案

  1. Ensure the module is declared in the crate root: add `mod module;` to `lib.rs` or `main.rs`, and create the corresponding file `src/module.rs` or directory `src/module/`.
  2. If the item is in a submodule, use the correct relative path: `use self::submodule::Item;` or `use super::Item;`.
  3. Check for typos in the module or item name and ensure the file exists with the correct casing (case-sensitive on most platforms).

无效尝试

常见但无效的做法:

  1. 70% 失败

    The module must be declared with `mod` before re-exporting; otherwise the compiler cannot find it.

  2. 50% 失败

    The `crate` keyword already refers to the root; `::crate` is redundant and may be invalid.

  3. 80% 失败

    Rust requires explicit `mod` declarations in `lib.rs` or `main.rs` to include modules.