rust
import_error
ai_generated
true
error[E0433]: failed to resolve: use of undeclared crate or module
ID: rust/e0433-unresolved-import
95%Fix Rate
95%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
Crate or module not found. Missing dependency in Cargo.toml or wrong use path.
genericWorkarounds
-
95% success Add the dependency to Cargo.toml: [dependencies] section
cargo add <crate-name>
Sources: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
-
90% success Check use path: crate:: for local, module_name:: for deps
use crate::module::MyType; // local use serde::Serialize; // external
Sources: https://doc.rust-lang.org/reference/items/use-declarations.html
-
82% success For feature-gated items, enable the feature in Cargo.toml
serde = { version = "1", features = ["derive"] }Sources: https://doc.rust-lang.org/cargo/reference/features.html
Dead Ends
Common approaches that don't work:
-
Add the path to src/lib.rs manually
75% fail
If the crate isn't in Cargo.toml, it's not available
-
Use extern crate (pre-2018 edition syntax)
70% fail
Unnecessary since Rust 2018 — just add to Cargo.toml
Error Chain
Frequently confused with: