Email me

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 -d

2. 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

Up next

Find the right pagePaste any Rust errorCompiler codes and build errors in one finder.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ