After figuring out cargo build of the same code: spurious compile time errors?, I want to know how to prevent such a problem:
$ cargo new feature_merge
$ cargo add nmea
$ cargo check > /dev/null 2>&1 && echo "success"
success
$ cargo add cexpr
$ cargo check > /dev/null 2>&1 || echo "failed"
failed
$ cargo rm cexpr && cargo check > /dev/null 2>&1 && echo "success"
success
I remove/add the dependency without any code modification and this influences the build result.
The source of problem, as I described, is that cexpr depends on nom like this:
nom = {version = "^3", features = ["verbose-errors"] }
while nmea describes the dependency like this:
nom = "3.1.0"
With only nmea as a dependency, Cargo builds nom with one set of features, while Cargo builds cexpr and nmea against nom with another set of features.
I want a way to prevent such wrong usage of the nmea crate which I maintain.
I'd like a compile time error like "`nom` compiled with wrong features"
, or force Cargo to build two variants of nom.
I tried such thing in nmea/Cargo.toml
:
nom = { version = "3.1.0", default-features = false }
This changed nothing; there's still a compile time error when cexpr and nmea are combined.