E0433
rust
module_error
ai_generated
true
错误[E0433]:解析失败:使用了未声明的 crate 或模块 `my_crate` --> src/main.rs:2:5 | 2 | use my_crate::some_module; | ^^^^^^^^ 使用了未声明的 crate 或模块 `my_crate`
error[E0433]: failed to resolve: use of undeclared crate or module `my_crate` --> src/main.rs:2:5 | 2 | use my_crate::some_module; | ^^^^^^^^ use of undeclared crate or module `my_crate`
ID: rust/e0433-module-not-found-workspace
93%修复率
88%置信度
1证据数
2023-07-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| rustc 1.73 | active | — | — | — |
| cargo 1.73 | active | — | — | — |
根因分析
尝试使用一个未在 `Cargo.toml` 中列为依赖的 crate,或未通过 `mod` 声明的模块。
English
Attempting to use a crate that is not listed as a dependency in `Cargo.toml`, or a module that is not declared via `mod`.
官方文档
https://doc.rust-lang.org/stable/error_codes/E0433.html解决方案
-
将缺失的 crate 添加到 `Cargo.toml`:`my_crate = "1.0"` 并运行 `cargo build`。
-
如果是本地模块,在 `main.rs` 或 `lib.rs` 中使用 `mod my_module;` 声明它。
无效尝试
常见但无效的做法:
-
60% 失败
Cargo cannot find the crate; no matching package available.
-
80% 失败
In Rust 2018+, `extern crate` is rarely needed and still requires the crate to be in dependencies.