E0583
rust
build_error
ai_generated
true
错误[E0583]:未找到模块 `module_name` 的文件
error[E0583]: file not found for module `module_name`
ID: rust/e0583-file-not-found-for-module
95%修复率
90%置信度
1证据数
2023-03-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| rustc 1.68.0 | active | — | — | — |
| rustc 1.70.0 | active | — | — | — |
| rustc 1.74.0 | active | — | — | — |
根因分析
Rust 找不到声明的模块的源文件,可能是因为文件路径错误、文件扩展名错误,或者模块未在 `mod.rs` 或 `lib.rs` 中正确声明。
English
Rust cannot find the source file for a declared module, either because the file path is incorrect, the file extension is wrong, or the module is not properly declared in `mod.rs` or `lib.rs`.
官方文档
https://doc.rust-lang.org/error_codes/E0583.html解决方案
-
Ensure the module file is created with the correct name and path: for `mod module_name;` in `src/lib.rs`, create `src/module_name.rs`.
-
If the module has submodules, create a directory `src/module_name/` with a `mod.rs` file inside.
-
Check for typos in the `mod` declaration and the file name, ensuring they match exactly (case-sensitive).
无效尝试
常见但无效的做法:
-
50% 失败
Rust expects module files to follow a specific naming convention based on the `mod` declaration; wrong placement won't be recognized.
-
40% 失败
Rustc only recognizes `.rs` files for module declarations; other extensions are ignored.