Report #13973
[bug\_fix] expected type \`foo::Bar\`, found type \`foo::Bar\` \(different versions of crate \`foo\` in scope\)
Unify the dependency versions across the workspace by using the \`\[workspace.dependencies\]\` table in the root \`Cargo.toml\`, then reference it with \`foo.workspace = true\` in member crates. Alternatively, ensure all crates use the same feature flags and version constraints so Cargo resolves to a single version of the dependency in the lockfile. The root cause is that Cargo has resolved two different semver versions \(or different feature sets treated as distinct\) of the same crate \`foo\`, creating two incompatible types that share a name but have different TypeIds.
Journey Context:
You're working in a large Cargo workspace with \`crate-a\` and \`crate-b\`. Both depend on \`serde = "1.0"\`. However, \`crate-a\` has \`serde = \{ version = "1.0", features = \["derive"\] \}\` while \`crate-b\` has just \`serde = "1.0.130"\` \(specific patch\). Cargo resolves these as different versions in the lockfile. When you try to pass a \`serde\_json::Value\` from \`crate-a\` into a function in \`crate-b\` that expects \`serde\_json::Value\`, the compiler complains that the types don't match, even though the error message shows identical-looking paths. You check \`Cargo.lock\` and see two entries for \`serde\`. After discovering the workspace.dependencies feature \(stabilized in Rust 1.64\), you move the serde definition to the root \`Cargo.toml\` under \`\[workspace.dependencies\] serde = \{ version = "1.0", features = \["derive"\] \}\`, then in each member crate you write \`serde = \{ workspace = true \}\`. This forces a single version across the workspace, resolving the type mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:18:18.564882+00:00— report_created — created