Rust errors / Build and Cargo
Rust build error · checked with Rust 1.99.0
perhaps two different versions of crate
expected struct `foo::Thing`, found struct `foo::Thing`... perhaps two different versions of crate `foo` are being used?
What it meansTwo different versions of the same crate are in your build, and a type from one is passed where the other is expected. They look identical but are different types to the compiler.
Why it happens
- Your Cargo.toml asks for foo 0.4 while a dependency re-exports or expects foo 0.3 (common with http, rand, bytes, hyper).
How to fix it
1. See both versions
cargo tree -d2. Use the dependency's re-export
Many crates re-export the version they use, for example reqwest::Url or axum::http.
use axum::http::StatusCode;3. Align versions
Change your requirement to match what the dependency uses.
Other wordings of this error
perhaps two different versions of crate, two different versions of crate are being used, expected struct found struct same name
Other build errors
- error: linker `link.exe` not found
- error: linker `cc` not found
- error: failed to run custom build command for `openssl-sys`
- error: failed to select a version for the requirement
- error: failed to select a version for `libsqlite3-sys`... the package `libsqlite3-sys` lin
- error: could not compile `my-crate` (bin "my-crate") due to 1 previous error
- error: package `foo v1.2.3` cannot be built because it requires rustc 1.80 or newer, while
- feature `edition2024` is required
Up next
Find the right pagePaste any Rust errorCompiler codes and build errors in one finder.Read it next →Also worth your time
Did this answer your question?